From de2a013a16315e257f10cbca29b294bbe6b6fdf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sun, 7 Jun 2020 20:58:33 +0200 Subject: [PATCH] BDS: user search on the home page --- bds/static/bds/css/bds.css | 70 +++++++++++++++++++++++++++++++++++++ bds/templates/bds/base.html | 23 ++++++++++++ bds/templates/bds/home.html | 7 ++++ bds/templates/bds/nav.html | 29 +++++++++++++++ bds/urls.py | 1 + bds/views.py | 8 ++++- 6 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 bds/static/bds/css/bds.css create mode 100644 bds/templates/bds/base.html create mode 100644 bds/templates/bds/home.html create mode 100644 bds/templates/bds/nav.html diff --git a/bds/static/bds/css/bds.css b/bds/static/bds/css/bds.css new file mode 100644 index 00000000..9bce2d92 --- /dev/null +++ b/bds/static/bds/css/bds.css @@ -0,0 +1,70 @@ +html, body { + padding: 0; + margin: 0; + background: #ddcecc; + font-size: 18px; +} + +a { + text-decoration: none; + color: inherit; +} + +/* header */ + +nav { + background: #3d2464; + width: 100%; + text-align: center; + padding: 0.4em 0; +} + +input[type="text"] { + font-size: 18px; +} + +#search_autocomplete { + width: 480px; + margin: 0; + border: 0; + padding: 10px 10px; +} + +.highlight { + text-decoration: underline; + font-weight: bold; +} + +.yourlabs-autocomplete ul { + width: 500px; + list-style: none; + padding: 0; + margin: 0; +} + +.yourlabs-autocomplete ul li { + height: 2em; + line-height: 2em; + width: 500px; + padding: 0; +} + +.yourlabs-autocomplete ul li.hilight { + background: #e8554e; +} + +.autocomplete-item { + display: block; + width: 480px; + height: 100%; + padding: 2px 10px; + margin: 0; +} + +.autocomplete-header { + background: #b497e1; +} + +.autocomplete-value, .autocomplete-new, .autocomplete-more { + background: white; +} diff --git a/bds/templates/bds/base.html b/bds/templates/bds/base.html new file mode 100644 index 00000000..0bf34287 --- /dev/null +++ b/bds/templates/bds/base.html @@ -0,0 +1,23 @@ +{% load staticfiles %} + + + + + {{ site.name }} + + + + + {# CSS #} + + + {# Javascript #} + + + + + {% include "bds/nav.html" %} + + {% block content %}{% endblock %} + + diff --git a/bds/templates/bds/home.html b/bds/templates/bds/home.html new file mode 100644 index 00000000..2cf20e4a --- /dev/null +++ b/bds/templates/bds/home.html @@ -0,0 +1,7 @@ +{% extends "bds/base.html" %} + +{% block content %} +
+ Bienvenue sur le site du BDS! +
+{% endblock %} diff --git a/bds/templates/bds/nav.html b/bds/templates/bds/nav.html new file mode 100644 index 00000000..c7dbc70a --- /dev/null +++ b/bds/templates/bds/nav.html @@ -0,0 +1,29 @@ +{% load i18n %} + + + + diff --git a/bds/urls.py b/bds/urls.py index 8e72a1c1..fbddccc6 100644 --- a/bds/urls.py +++ b/bds/urls.py @@ -4,5 +4,6 @@ from bds import views app_name = "bds" urlpatterns = [ + path("", views.Home.as_view(), name="home"), path("autocomplete", views.AutocompleteView.as_view(), name="autocomplete"), ] diff --git a/bds/views.py b/bds/views.py index 40670a56..a8d78c42 100644 --- a/bds/views.py +++ b/bds/views.py @@ -13,5 +13,11 @@ class AutocompleteView(TemplateView): raise Http404 q = self.request.GET["q"] ctx["q"] = q - ctx.update(bds_search.search(q.split())) + results = bds_search.search(q.split()) + ctx.update(results) + ctx["total"] = sum((len(r) for r in results.values())) return ctx + + +class Home(TemplateView): + template_name = "bds/home.html"