Search styling
This commit is contained in:
parent
8d777f545d
commit
6fdae0efd8
5 changed files with 32 additions and 6 deletions
3
Makefile
3
Makefile
|
@ -48,6 +48,9 @@ release:
|
||||||
reindex:
|
reindex:
|
||||||
docker-compose exec web ./manage.py update_index
|
docker-compose exec web ./manage.py update_index
|
||||||
|
|
||||||
|
clear_index:
|
||||||
|
docker-compose exec elasticsearch curl -XDELETE localhost:9200/_all
|
||||||
|
|
||||||
django-exec-bash:
|
django-exec-bash:
|
||||||
# execute bash in the currently running container
|
# execute bash in the currently running container
|
||||||
docker-compose exec web bash
|
docker-compose exec web bash
|
||||||
|
|
|
@ -11,6 +11,7 @@ from wagtail.wagtailcore.fields import StreamField, RichTextField
|
||||||
from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel, InlinePanel, MultiFieldPanel
|
from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel, InlinePanel, MultiFieldPanel
|
||||||
from wagtail.wagtailimages.blocks import ImageChooserBlock
|
from wagtail.wagtailimages.blocks import ImageChooserBlock
|
||||||
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
|
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
|
||||||
|
from wagtail.wagtailsearch import index
|
||||||
|
|
||||||
from puput.models import EntryPage
|
from puput.models import EntryPage
|
||||||
|
|
||||||
|
@ -110,6 +111,14 @@ class ArticlePage(Page):
|
||||||
related_name='+'
|
related_name='+'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
search_fields = Page.search_fields + [
|
||||||
|
index.SearchField('title', partial_match=True, boost=10),
|
||||||
|
index.SearchField('title_fr', partial_match=True, boost=10),
|
||||||
|
index.SearchField('body_de', partial_match=True),
|
||||||
|
index.SearchField('body_fr', partial_match=True),
|
||||||
|
index.SearchField('intro_de', partial_match=True),
|
||||||
|
index.SearchField('intro_fr', partial_match=True),
|
||||||
|
]
|
||||||
content_panels = [
|
content_panels = [
|
||||||
MultiFieldPanel([
|
MultiFieldPanel([
|
||||||
FieldPanel('title'),
|
FieldPanel('title'),
|
||||||
|
|
|
@ -7,10 +7,12 @@ register = template.Library()
|
||||||
# Language switcher
|
# Language switcher
|
||||||
@register.inclusion_tag('tags/language.html', takes_context=True)
|
@register.inclusion_tag('tags/language.html', takes_context=True)
|
||||||
def language_switcher(context):
|
def language_switcher(context):
|
||||||
url = context['page'].url.split('/')
|
url = '/$lang$'
|
||||||
if len(url) > 2 and len(url[1]) >= 2:
|
if 'page' in context:
|
||||||
url[1] = '$lang$'
|
url = context['page'].url.split('/')
|
||||||
url = '/'.join(url)
|
if len(url) > 2 and len(url[1]) >= 2:
|
||||||
|
url[1] = '$lang$'
|
||||||
|
url = '/'.join(url)
|
||||||
return {
|
return {
|
||||||
'languages': [
|
'languages': [
|
||||||
{ 'code': 'de', 'title': 'De', 'url': url.replace('$lang$','de') },
|
{ 'code': 'de', 'title': 'De', 'url': url.replace('$lang$','de') },
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<center>
|
<center>
|
||||||
<form action="{% url 'search' %}" method="get">
|
<form action="{% url 'search' %}" method="get">
|
||||||
<input type="text" name="query"{% if search_query %} value="{{ search_query }}{% endif %}">
|
<input type="text" name="query"{% if search_query %} value="{{ search_query }}"{% endif %}>
|
||||||
<button type="submit" title="Search">
|
<button type="submit" title="Search">
|
||||||
<span class="glyphicon glyphicon-search" aria-hidden="false"></span>
|
<span class="glyphicon glyphicon-search" aria-hidden="false"></span>
|
||||||
</button>
|
</button>
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
{{ search_results.next_page_number }}</a>
|
{{ search_results.next_page_number }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elif search_query %}
|
{% elif search_query %}
|
||||||
<b>Leider keine Ergebnisse / Désolé, aucun résultat n'a été trouvé</b>
|
<center><h5><i>Leider keine Ergebnisse gefunden<br><br>Désolé, aucun résultat n'a été trouvé</i></h5></center>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -46,3 +46,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#search-page {
|
||||||
|
input[type='text'] {
|
||||||
|
font-size: 110%;
|
||||||
|
}
|
||||||
|
h4 {
|
||||||
|
margin-bottom: 0px;
|
||||||
|
}
|
||||||
|
.container > center {
|
||||||
|
margin-bottom: 3em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue