]> git.parisson.com Git - mezzo.git/commitdiff
Search results first implementation
authorJérémy Fabre <Jeremy@iMac-de-Jeremy.local>
Tue, 18 Oct 2016 15:16:24 +0000 (17:16 +0200)
committerJérémy Fabre <Jeremy@iMac-de-Jeremy.local>
Tue, 18 Oct 2016 15:16:24 +0000 (17:16 +0200)
app/static/src/sass/modules/_all.scss
app/static/src/sass/modules/_search.scss
app/static/src/sass/modules/boxes/_search-box.scss [new file with mode: 0644]
app/templates/agenda/includes/event_search.html
app/templates/core/inc/generic_card_variable_height.html [deleted file]
app/templates/core/inc/search_card.html [new file with mode: 0644]
app/templates/includes/search_form.html
app/templates/media/inc/playlist_search.html
app/templates/pages/includes/page_search.html
app/templates/search_results.html

index 1b8917a752388a3735ae1b148d0562aed06a93af..e5aee2ab8a6df1dc7016214b2ca12d1de386bea5 100755 (executable)
@@ -16,6 +16,7 @@
 @import 'boxes/event-line-box';
 @import 'boxes/job-line-box';
 @import 'boxes/product-box';
+@import 'boxes/search-box';
 
 // Sliders
 @import 'sliders/slider-page';
index ac838e7daadc5f2e91bf7211e84be6e149e5ee18..eed67beb121861ad646ffeaae64935fffe703bcc 100644 (file)
@@ -55,6 +55,10 @@ $module: ".search";
 
     }
 
+}
+
+.search-form {
+
     input[type="text"] {
 
         border: 0;
diff --git a/app/static/src/sass/modules/boxes/_search-box.scss b/app/static/src/sass/modules/boxes/_search-box.scss
new file mode 100644 (file)
index 0000000..2b99788
--- /dev/null
@@ -0,0 +1,42 @@
+$module: ".search-box";
+
+#{$module} {
+
+    position: relative;
+    @include margin-bottom(2);
+
+    &__title {
+        @include margin(0 0 1 0);
+        font-weight: weight(bold);
+        text-transform: uppercase;
+
+        i {
+            display: inline-block;
+            @include margin-left(.5);
+            font-size: 0.75em;
+            position: relative;
+            top: -5px;
+        }
+    }
+
+    &__subtitle {
+
+        @include font-size(m);
+        @include line-height(1);
+        @include typeface(sans-serif);
+
+        @include margin-top(-.5);
+        @include margin-bottom(1);
+
+    }
+
+    &__content {
+
+        @include font-size(s);
+        @include line-height(1);
+        @include typeface(serif);
+        font-weight: weight(light);
+
+    }
+
+}
index e8199f67ce54c3e2f8e8d84e4b600d07a6568d58..0acf5357ecdfe4e2d7b37eb65106cbbdee83a1e8 100644 (file)
@@ -1,67 +1,35 @@
+{% extends "core/inc/search_card.html" %}
 {% load i18n future mezzanine_tags event_tags keyword_tags disqus_tags organization_tags %}
 
-<div class="row event-line-box">
+{% block title %}
+    {{ event.title }}
+{% endblock %}
 
-    <div class="col-sm-2 col-md-3 col-lg-3 event-line-box__month">
-
-        {% ifchanged event.start.month %}
-            {{ event.start|date:'F' }}
-        {% endifchanged %}
+{% block icon %}calendar-o{% endblock %}
 
+{% block subtitle %}
+    <div class="search-box__subtitle">
+        {% include 'agenda/includes/event_date_line.html' %}
     </div>
-
-    <div class="col-sm-10 col-md-9 col-lg-9 event-line-box__content">
-
-        <div class="row">
-
-            <div class="col-xs-3">
-                {% with True as unit_booking %}
-                    {% include 'agenda/includes/event_metainfo_line.html' %}
-                {% endwith %}
-            </div>
-            <div class="col-xs-3">
-                {% with event.images.all|get_type:'card' as images %}
-                    {% if images %}
-                        <a href="{{ event.get_absolute_url }}">
-                            <img class="event-line-box__image" src="{{ MEDIA_URL }}{% thumbnail images.0.file 203 140 %}" width="203" height="140">
-                        </a>
-                    {% else %}
-                        {% with event.parent.images.all|get_type:'card' as images %}
-                            {% if images %}
-                                <a href="{{ event.get_absolute_url }}">
-                                    <img class="event-line-box__image" src="{{ MEDIA_URL }}{% thumbnail images.0.file 203 140 %}" width="203" height="140">
-                                </a>
-                            {% endif %}
-                        {% endwith %}
-                    {% endif %}
-                {% endwith %}
-            </div>
-            <div class="col-xs-6">
-                {% keywords_for event as tags %}
-                {% if event.departments.all.0 or tags %}
-                    <div class="event-line-box__tags">
-                        {% if event.departments.all.0 %}
-                            <div class="tag tag--small dashed">
-                              {{ event.departments.all.0.department.name }}
-                            </div>
-                        {% endif %}
-                        {% if event.category %}
-                            <div class="tag tag--small tag--category">
-                                {{ event.category }}
-                            </div>
-                        {% endif %}
-                    </div>
-                {% endif %}
-                <h2 class="event-line-box__title">
-                    <a href="{{ event.get_absolute_url }}">{{ event.title }}</a>
-                </h2>
-                <div class="event-line-box__desc">
-                    {{ event.description|slice:":100" }}
+{% endblock %}
+
+{% block tags %}
+    {% keywords_for event as tags %}
+    {% if event.departments.all.0 or tags %}
+        {% if event.departments.all.0 %}
+            <div class="event-line-box__tags">
+                <div class="tag tag--small dashed">
+                  {{ event.departments.all.0.department.name }}
                 </div>
             </div>
+        {% endif %}
+    {% endif %}
+{% endblock %}
 
-        </div>
-
-    </div>
+{% block url %}
+    {{ event.get_absolute_url }}
+{% endblock %}
 
-</div>
+{% block content %}
+    {{ event.description|slice:":100" }}
+{% endblock %}
diff --git a/app/templates/core/inc/generic_card_variable_height.html b/app/templates/core/inc/generic_card_variable_height.html
deleted file mode 100644 (file)
index e925331..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-{% extends "core/inc/generic_card.html" %}
-{% load i18n pages_tags mezzanine_tags media_tags organization_tags %}
-
-{% block image %}
-    <img src="{{ MEDIA_URL }}{% thumbnail images.first.file 427 0 %}" data-src="{{ MEDIA_URL }}{% thumbnail images.0.file 427 286 %}" class="lazyload" alt="" />
-{% endblock %}
diff --git a/app/templates/core/inc/search_card.html b/app/templates/core/inc/search_card.html
new file mode 100644 (file)
index 0000000..4ff100a
--- /dev/null
@@ -0,0 +1,23 @@
+<div class="search-box">
+
+    {% block tags %}
+    {% endblock %}
+
+    <a href="{% block url %}{% endblock %}">
+        <h2 class="search-box__title dotted">
+            {% block title %}
+            {% endblock %}
+            <i class="fa fa-{% block icon %}{% endblock %}"></i>
+        </h2>
+    </a>
+
+    {% block subtitle %}
+    {% endblock %}
+
+    <div class="search-box__content">
+
+        {% block content %}
+        {% endblock %}
+    </div>
+
+</div>
index 47d109ee8da3c487201f4deb3264673587c4f7e5..8dceb004198c8f5c987ea4ad09223a91d4038a0c 100644 (file)
@@ -8,8 +8,8 @@
             <div class="container">
                 <div class="row">
                     <div class="col-md-10">
-                        <form action="{% url "search" %}" role="search">
-                            <input class="form-control" placeholder="{% trans "Type something" %}" type="text" name="q" value="{{ request.GET.q }}">
+                        <form action="{% url "search" %}" role="search" class="search-form">
+                            <input class="form-control" placeholder="{% trans "Type something" %}" type="text" name="q" value="">
                             <button type="submit">
                                 <i class="fa fa-search" aria-hidden="true"></i>
                             </button>
index 0ab4d8f3de6c49f3f6db1540bda2e2c8d2793242..5720973e912fbf3f50654566b7fab2a4aab52daf 100644 (file)
@@ -1,4 +1,30 @@
+{% extends "core/inc/search_card.html" %}
 {% load i18n mezzanine_tags organization_tags %}
+
+{% block title %}
+    {{ result }}
+{% endblock %}
+
+{% block icon %}file-{{playlist.type}}-o{% endblock %}
+
+{% block tags %}
+    <div class="event-line-box__tags">
+        <div class="tag tag--small dashed dashed--gray">
+            {{playlist.type}}
+        </div>
+    </div>
+{% endblock %}
+
+{% block url %}
+    {{ playlist.get_absolute_url }}
+{% endblock %}
+
+{% block content %}
+    {% if playlist.description != playlist|stringformat:"s" %}
+        {{ playlist.description|truncatewords_html:200|safe }}
+    {% endif %}
+{% endblock %}
+
 {% with playlist.get_absolute_url as playlist_url %}
     {% if playlist.medias.first.media.poster_url %}
         <!-- url of the media is distant. We can't generate back side thumbnail. Do it with css pliz -->
index 38e03f14b470c551096460f2cd1a2083d85f11f2..e578d78755d2dea102ebb1c8d66bee7193959d36 100644 (file)
@@ -1,16 +1,42 @@
+{% extends "core/inc/search_card.html" %}
 {% load i18n mezzanine_tags organization_tags %}
-{% with page.get_absolute_url as page_url %}
-    <h5>
-        {% if page_url %}
-            <a href="{{ page_url }}">{{ result }}</a>
+
+{% block title %}
+    {{ result }}
+{% endblock %}
+
+{% block icon %}files-o{% endblock %}
+
+{% block tags %}
+    {% with page.get_ascendants|last as top_level_parent %}
+        {% if top_level_parent.get_content_model.title %}
+            <div class="event-line-box__tags">
+                <div class="tag tag--small dashed">
+                    {{ top_level_parent.get_content_model.title }}
+                </div>
+            </div>
+        {% elif page.departmentpage %}
+            <div class="event-line-box__tags">
+                <div class="tag tag--small dashed">
+                    {{ page.departmentpage.title }}
+                </div>
+            </div>
         {% else %}
-            {{ result }}
+            <div class="event-line-box__tags">
+                <div class="tag tag--small dashed dashed--gray">
+                    {% trans "Link" %}
+                </div>
+            </div>
         {% endif %}
-    </h5>
+    {% endwith %}
+{% endblock %}
+
+{% block url %}
+    {{ page.get_absolute_url }}
+{% endblock %}
+
+{% block content %}
     {% if result.description != result|stringformat:"s" %}
-        <p>{{ result.description|truncatewords_html:200|safe }}</p>
+        {{ result.description|truncatewords_html:200|safe }}
     {% endif %}
-    {% if page_url %}
-        <a href="{{ page_url }}">{% trans "read more" %}</a>
-    {% endif %}
-{% endwith %}
+{% endblock %}
index 8603cf683a048bc075bd2a1c74e20a26359da6df..7e8a0e75255eaeb684c685bdabe31fa0ce63fe43 100644 (file)
@@ -9,62 +9,94 @@
 {% endblock %}
 
 {% block breadcrumb_menu %}
-<li class="breadcrumb__item">
-    <a href="{% url "home" %}">{% trans "Home" %}</a>
-</li>
-<li class="breadcrumb__item active">{% trans "Search Results" %}</li>
+    <li class="breadcrumb__item">
+        <a href="{% url "home" %}">{% trans "Home" %}</a>
+    </li>
+    <li class="breadcrumb__item active">{% trans "Search Results" %}</li>
 {% endblock %}
 
 {% block main %}
 
-<div class="row">
-    <div class="col-lg-8 col-md-push-2">
-        <h1 class="dotted">{% trans "Search Results" %}</h1>
-    </div>
-</div>
-
-<div class="row">
-    <div class="col-lg-8 col-lg-push-2">
-        <p>
-            {% if results.paginator.count == 0 %}
-            {% blocktrans %}
-            No results were found in {{ search_type }} matching your query: {{ query }}
-            {% endblocktrans %}
-            {% else %}
-            {% blocktrans with start=results.start_index end=results.end_index total=results.paginator.count %}
-            Showing {{ start }} to {{ end }} of {{ total }} results in {{ search_type }} matching your query: {{ query }}
-            {% endblocktrans %}
-            {% endif %}
-        </p>
-
-        <p>
-            <h4>Filter:</h4>
-            {% for key,value in filter_dict.items %}
-                <a href="{{ value.url }}" title="{{ value.verbose_name }}">{{ value.verbose_name }} {{ value.count }}</a><br>
-            {% endfor %}
-            {% if cancel_filter_url %}
-                <a href="{{ cancel_filter_url }}" title="">Cancel filter</a>
-            {% endif %}
-        </p>
-        {% for result in results.object_list %}
-            {{ result|classname }}
-            {% if result|classname == 'Event' %}
-                {% with result as event %}
-                    {% include 'agenda/includes/event_search.html' %}
-                {% endwith %}
-            {% elif result|classname == 'Playlist' %}
-                {% with result as playlist %}
-                    {% include 'media/inc/playlist_search.html' %}
-                {% endwith %}
-            {% else %}
-                {% with result as page %}
-                    {% include 'pages/includes/page_search.html' %}
-                {% endwith %}
-            {% endif %}
-        {% endfor %}
+    <div class="page">
+        <div class="container">
+
+            <div class="row">
+                <div class="col-sm-9 col-sm-push-3 col-lg-9 col-lg-push-2 white-bg">
+
+                    <form action="{% url "search" %}" role="search" class="search-form">
+                        <input class="form-control" placeholder="{% trans "Type something" %}" type="text" name="q" value="{{ request.GET.q }}">
+                        <button type="submit">
+                            <i class="fa fa-search" aria-hidden="true"></i>
+                        </button>
+                    </form>
+
+                    <div class="mt2 mb2">
+                        <p>
+                            {% if results.paginator.count == 0 %}
+                            {% blocktrans %}
+                            No results were found in {{ search_type }} matching your query: {{ query }}
+                            {% endblocktrans %}
+                            {% else %}
+                            {% blocktrans with start=results.start_index end=results.end_index total=results.paginator.count %}
+                            Showing {{ start }} to {{ end }} of {{ total }} results in {{ search_type }} matching your query: {{ query }}
+                            {% endblocktrans %}
+                            {% endif %}
+                        </p>
+                    </div>
+
+                </div>
+            </div>
+
+            <div class="row">
+
+                <div class="col-sm-3 col-lg-2 page__sidebar">
+
+                    <div style="position: relative;">
+                        <ul class="nav-tree nav-tree--level-0" data-sticky data-sticky-parent="row" data-sticky-offset="100" data-sticky-detach-at="971">
+                            {% for key,value in filter_dict.items %}
+                                <li class="nav-tree__item">
+                                    <a class="nav-tree__link nav-tree__link--filter" href="{{ value.url }}">
+                                        {{ value.verbose_name }} ({{ value.count }})
+                                    </a>
+                                </li>
+                            {% endfor %}
+                            {% if cancel_filter_url %}
+                                <li class="nav-tree__item">
+                                    <a class="nav-tree__link nav-tree__link--filter active" href="{{ cancel_filter_url }}" title="">Cancel filter</a>
+                                </li>
+                            {% endif %}
+                        </ul>
+                    </div>
+
+
+                </div>
+
+                <div class="mb2 col-sm-9 col-lg-8 white-bg page__content">
+
+                    {% for result in results.object_list %}
+                        {# result|classname #}
+                        {% if result|classname == 'Event' %}
+                            {% with result as event %}
+                                {% include 'agenda/includes/event_search.html' %}
+                            {% endwith %}
+                        {% elif result|classname == 'Playlist' %}
+                            {% with result as playlist %}
+                                {% include 'media/inc/playlist_search.html' %}
+                            {% endwith %}
+                        {% else %}
+                            {% with result as page %}
+                                {% include 'pages/includes/page_search.html' %}
+                            {% endwith %}
+                        {% endif %}
+                    {% endfor %}
+
+                </div>
+            </div>
+
+        </div>
 
         {% pagination_for results %}
+
     </div>
-</div>
 
 {% endblock %}