diff --git a/cms/models.py b/cms/models.py index 67baf23..a4e6734 100644 --- a/cms/models.py +++ b/cms/models.py @@ -58,7 +58,13 @@ class WebsiteSettings(BaseSetting): null=True, blank=True, help_text = _('public description of the website; used for referencing'), ) - + list_page = models.ForeignKey( + 'cms.GenericPage', + verbose_name = _('page for lists'), + help_text=_('page used to display the results of a search and other ' + 'lists'), + related_name= 'list_page' + ) # comments accept_comments = models.BooleanField( default = True, @@ -108,12 +114,12 @@ class WebsiteSettings(BaseSetting): }, ) - panels = [ MultiFieldPanel([ FieldPanel('favicon'), FieldPanel('tags'), FieldPanel('description'), + FieldPanel('list_page'), ], heading=_('promotion')), MultiFieldPanel([ FieldPanel('allow_comments'), @@ -250,13 +256,16 @@ class Publication(Page): verbose_name = _('Publication') verbose_name_plural = _('Publication') - content_panels = Page.content_panels + [ - FieldPanel('body', classname="full") + content_panels = [ + MultiFieldPanel([ + FieldPanel('title'), + FieldPanel('body', classname='full'), + FieldPanel('summary'), + ], heading=_('Content')) ] promote_panels = [ MultiFieldPanel([ ImageChooserPanel('cover'), - FieldPanel('summary'), FieldPanel('tags'), FieldPanel('focus'), ], heading=_('Content')), @@ -273,6 +282,12 @@ class Publication(Page): index.FilterField('show_in_menus'), ] + @property + def url(self): + if not self.live: + parent = self.get_parent().specific + return parent and parent.url + return super().url @property def icon(self): @@ -482,6 +497,7 @@ class DiffusionPage(Publication): item.live = True item.info = [] + # Translators: informations about a diffusion if diff.initial: item.info.append(_('Rerun of %(date)s') % { 'date': diff.initial.start.strftime('%A %d') @@ -541,62 +557,10 @@ class DiffusionPage(Publication): super().save(*args, **kwargs) -class EventPageQuerySet(PageQuerySet): - def upcoming(self): - now = tz.now().date() - return self.filter(start_date__gte=now) - - -class EventPage(Publication): - order_field = 'start' - - start = models.DateTimeField( - _('start'), - help_text = _('when it happens'), - ) - end = models.DateTimeField( - _('end'), - blank = True, null = True, - ) - place = models.TextField( - _('place'), - help_text = _('address where the event takes place'), - ) - price = models.CharField( - _('price'), - max_length=64, - blank = True, null = True, - help_text = _('price of the event'), - ) - info = models.TextField( - _('info'), - blank = True, null = True, - help_text = _('additional information'), - ) - - objects = PageManager.from_queryset(EventPageQuerySet) - - class Meta: - verbose_name = _('Event') - verbose_name_plural = _('Events') - - content_panels = Publication.content_panels + [ - FieldRowPanel([ - FieldPanel('start'), - FieldPanel('end'), - ]), - FieldPanel('place'), - ] - - def save(self, *args, **kwargs): - self.date = self.start - super().save(*args, **kwargs) - - # -# Lists +# Other type of pages # -class ListPage(Page): +class GenericPage(Page): """ Page for simple lists, query is done though request' GET fields. Look at get_queryset for more information. @@ -606,15 +570,34 @@ class ListPage(Page): blank = True, null = True, help_text = _('add an extra description for this list') ) + list_from_request = models.BooleanField( + _('list from the request'), + default = False, + help_text = _( + 'if set, the page print a list based on the request made by ' + 'the website visitor, and its title will be adapted to this ' + 'request. Can be usefull for search pages, etc. and should ' + 'only be set on one page.' + ) + ) + + content_panels = [ + MultiFieldPanel([ + FieldPanel('title'), + FieldPanel('body'), + FieldPanel('list_from_request'), + ], heading=_('Content')) + ] class Meta: - verbose_name = _('List') - verbose_name_plural = _('List') + verbose_name = _('Generic Page') + verbose_name_plural = _('Generic Page') def get_context(self, request, *args, **kwargs): context = super().get_context(request, *args, **kwargs) - qs = ListBase.from_request(request, context=context) - context['object_list'] = qs + if self.list_from_request: + qs = ListBase.from_request(request, context=context) + context['object_list'] = qs return context diff --git a/cms/sections.py b/cms/sections.py index 8c3b270..46c2ca8 100644 --- a/cms/sections.py +++ b/cms/sections.py @@ -163,13 +163,15 @@ class ListBase(models.Model): ContentType, verbose_name = _('filter by type'), blank = True, null = True, + on_delete=models.SET_NULL, help_text = _('if set, select only elements that are of this type'), limit_choices_to = related_pages_filter, ) related = models.ForeignKey( Page, - verbose_name = _('filter by a related publication'), + verbose_name = _('filter by a related page'), blank = True, null = True, + on_delete=models.SET_NULL, help_text = _('if set, select children or siblings related to this page'), ) siblings = models.BooleanField( @@ -184,6 +186,9 @@ class ListBase(models.Model): help_text = _('if selected sort list in the ascending order by date') ) + class Meta: + abstract = True + panels = [ MultiFieldPanel([ FieldPanel('model'), @@ -196,8 +201,6 @@ class ListBase(models.Model): ], heading=_('sorting')) ] - class Meta: - abstract = True def get_queryset(self): """ @@ -245,7 +248,7 @@ class ListBase(models.Model): to override values of self or add some to the parameters. If there is related field use it to get the page, otherwise use the - given list_page or the first ListPage it finds. + given list_page or the first GenericPage it finds. """ import aircox.cms.models as models @@ -259,7 +262,7 @@ class ListBase(models.Model): params.update(kwargs) page = params.get('related') or list_page or \ - models.ListPage.objects.all().first() + models.GenericPage.objects.all().first() if params.get('related'): params['related'] = True @@ -465,6 +468,12 @@ class Section(ClusterableModel): 'page or publication is of this type'), limit_choices_to = related_pages_filter, ) + page = models.ForeignKey( + Page, + verbose_name = _('page'), + blank = True, null = True, + help_text=_('this section is displayed only on this page'), + ) panels = [ MultiFieldPanel([ @@ -494,9 +503,9 @@ class Section(ClusterableModel): ) return qs - def render(self, request, page = None, *args, **kwargs): + def render(self, request, page = None, context = None, *args, **kwargs): return ''.join([ - place.item.specific.render(request, page, *args, **kwargs) + place.item.specific.render(request, page, context, *args, **kwargs) for place in self.places.all() ]) @@ -596,6 +605,7 @@ class SectionItem(models.Model,metaclass=SectionItemMeta): Other context attributes usable in the default template: * content: **safe string** set as content of the section + * hide: DO NOT render the section, render only an empty string """ return { 'self': self, @@ -603,7 +613,7 @@ class SectionItem(models.Model,metaclass=SectionItemMeta): 'request': request, } - def render(self, request, page, *args, **kwargs): + def render(self, request, page, context, *args, **kwargs): """ Render the section. Page is the current publication being rendered. @@ -614,10 +624,13 @@ class SectionItem(models.Model,metaclass=SectionItemMeta): that can have a context attribute 'content' that is used to render content. """ - return render_to_string( - self.template, - self.get_context(request, *args, page=page, **kwargs) - ) + context_ = self.get_context(request, *args, page=page, **kwargs) + if context: + context_.update(context) + + if context.get('hide'): + return '' + return render_to_string(self.template, context_) def __str__(self): return '{}: {}'.format( @@ -824,6 +837,10 @@ class SectionList(ListBase, SectionRelativeItem): qs = qs.exclude(pk = focus.pk) else: focus = None + + if not qs.count(): + return { 'hide': True } + pages = qs[:self.count - (focus != None)] context['focus'] = focus @@ -920,12 +937,6 @@ class SectionPublicationInfo(SectionItem): @register_snippet class SectionSearchField(SectionItem): - page = models.ForeignKey( - 'cms.ListPage', - verbose_name = _('search page'), - blank = True, null = True, - help_text=_('page used to display the results'), - ) default_text = models.CharField( _('default text'), max_length=32, @@ -938,15 +949,12 @@ class SectionSearchField(SectionItem): verbose_name_plural = _('Sections: search field') panels = SectionItem.panels + [ - PageChooserPanel('page'), FieldPanel('default_text'), ] def get_context(self, request, page): - from aircox.cms.models import ListPage + from aircox.cms.models import GenericPage context = super().get_context(request, page) - list_page = self.page or ListPage.objects.live().first() - context['list_page'] = list_page return context diff --git a/cms/static/cms/css/layout.css b/cms/static/cms/css/layout.css index 394fd44..d7335c1 100644 --- a/cms/static/cms/css/layout.css +++ b/cms/static/cms/css/layout.css @@ -336,4 +336,12 @@ main .body ~ section:not(.comments) { display: inline-block; } +.meta > .share { + margin-top: 0.8em; +} + +.meta .author .summary { + display: none; +} + diff --git a/cms/static/cms/css/theme.css b/cms/static/cms/css/theme.css index eb8c8f2..5ea1e0e 100644 --- a/cms/static/cms/css/theme.css +++ b/cms/static/cms/css/theme.css @@ -43,7 +43,7 @@ h2 * { vertical-align: middle; } /** info **/ -time { +time, .tags { font-size: 0.9em; color: #616161; } @@ -54,6 +54,7 @@ time { color: #007EDF; } + a { cursor: pointer; text-decoration: none; @@ -64,6 +65,10 @@ a:hover { color: #007EDF; } +a:hover > .small_icon { + box-shadow: 0em 0em 0.1em #007EDF; +} + .error { color: red; } .warning { color: orange; } @@ -79,29 +84,52 @@ a:hover { main { background-color: rgba(255,255,255,0.9); padding: 1em; + margin: 0em 2em; box-shadow: 0em 0em 0.2em black; + width: 60%; } - main h1:not(.detail_title) { + + main:not(.detail) h1 { margin: 0em 0em 0.4em 0em; } +main.detail { + padding: 0em; +} - main h1.detail_title { + main.detail > .content { + padding: 1em; + } + + main.detail > header { + padding: 0em; margin: 0em; - padding: 0.2em; + } + + main.detail > header h1.title { position: relative; - left: -0.7em; - width: 80%; + width: calc(70% - 0.8em); + margin: 0em; + margin-bottom: -2em; + padding: 0.4em; background-color: rgba(255,255,255,0.8); } - main img.detail_cover { - width: calc(100% + 2em); - margin-top: -3.3em; - margin-left: -1em; + main.detail > header img.cover { + width: 70%; + display: inline-block; } + main.detail header .summary { + display: inline-block; + padding: 1em; + width: calc(20% - 2em); + vertical-align: top; + font-size: 1.2em; + font-weight: bold; + background-color: white; + } /** player **/ diff --git a/cms/static/cms/images/ic_action_feed.png b/cms/static/cms/images/ic_action_feed.png deleted file mode 100644 index 0f1c1e5..0000000 Binary files a/cms/static/cms/images/ic_action_feed.png and /dev/null differ diff --git a/cms/static/cms/js/player.js b/cms/static/cms/js/player.js index eae96cd..76d0df4 100644 --- a/cms/static/cms/js/player.js +++ b/cms/static/cms/js/player.js @@ -220,7 +220,6 @@ function Player(id, on_air_url, show_cover) { bar: this.player.querySelector('.controls .progress progress'), duration: this.player.querySelector('.controls .progress .duration') } - console.log(this.progress) this.controls = { single: this.player.querySelector('input.single'), @@ -361,6 +360,11 @@ Player.prototype = { this.audio.pause(); }, + stop: function() { + this.audio.pause(); + this.player.removeAttribute('state'); + }, + __mime_type: function(path) { ext = path.substr(path.lastIndexOf('.')+1); return 'audio/' + ext; diff --git a/cms/templates/cms/base_site.html b/cms/templates/cms/base_site.html index 3d7fa5a..f22cf5b 100644 --- a/cms/templates/cms/base_site.html +++ b/cms/templates/cms/base_site.html @@ -44,7 +44,7 @@ {% render_sections position="page_left" %} -
+
{% if messages %} {% endif %} +
{% block title %}

{{ page.title }}

{% endblock %} +
+ {% block content %} {% endblock %}
@@ -70,7 +73,7 @@ {% block footer %} diff --git a/cms/templates/cms/generic_page.html b/cms/templates/cms/generic_page.html new file mode 100644 index 0000000..6cf9f8c --- /dev/null +++ b/cms/templates/cms/generic_page.html @@ -0,0 +1,61 @@ +{% extends "cms/base_site.html" %} +{# generic page to display list of articles #} + +{% load i18n %} +{% load wagtailcore_tags %} +{% load wagtailimages_tags %} + + +{% block title %} +

+{# Translators: titles for the page that shows a list of elements. #} +{# Translators: terms are search terms, or tag tarms. url: url to the page #} +{% if page.list_from_request %} + {% with terms=list_selector.terms %} + {% if terms %} + {% blocktrans %}Search in publications for {{ terms }}{% endblocktrans %} + {% elif list_selector.filter_related %} + {# should never happen #} + {% with title=list_selector.filter_related.title url=list_selector.filter_related.url %} + {% blocktrans %} + Related to {{ title }}{% endblocktrans %} + {% endwith %} + {% else %} + {% blocktrans %}All the publications{% endblocktrans %} + {% endif %} + {% endwith %} +{% else %} +{{ page.title }} +{% endif %} +

+{% endblock %} + + +{% block content %} +{% if page.list_from_request %} + {% with related=list_selector.filter_related %} + {% if related %} +
+ {% image related.cover fill-128x128 class="cover item_cover" %} + {{ related.summary }} + {% trans "More about it" %} +
+ {% elif page.body %} +
+ {{ page.body|richtext }} +
+ {% endif %} + {% endwith %} + + {% with list_paginator=paginator %} + {% include "cms/snippets/list.html" %} + {% endwith %} +{% else %} +
+ {{ page.body|richtext }} +
+{% endif %} +{% endblock %} + + + diff --git a/cms/templates/cms/list_page.html b/cms/templates/cms/list_page.html deleted file mode 100644 index 2d7f6fb..0000000 --- a/cms/templates/cms/list_page.html +++ /dev/null @@ -1,49 +0,0 @@ -{% extends "cms/base_site.html" %} -{# generic page to display list of articles #} - -{% load i18n %} -{% load wagtailcore_tags %} -{% load wagtailimages_tags %} - - -{% block title %} -

-{% with terms=list_selector.terms %} -{% if terms %} -{% blocktrans %}Search in publications for {{ terms }}{% endblocktrans %} -{% elif list_selector.filter_related %} -{# should never happen #} -{% with title=list_selector.filter_related.title url=list_selector.filter_related.url %} -{% blocktrans %} - Related to {{ title }}{% endblocktrans %} -{% endwith %} -{% else %} -{% blocktrans %}All the publications{% endblocktrans %} -{% endif %} -{% endwith %} -

-{% endblock %} - - -{% block content %} -{% with related=list_selector.filter_related %} -{% if related %} -
- {% image related.cover fill-128x128 class="cover item_cover" %} - {{ related.summary }} - {% trans "More about it" %} -
-{% elif page.body %} -
-{{ page.body|richtext }} -
-{% endif %} -{% endwith %} - -{% with list_paginator=paginator %} -{% include "cms/snippets/list.html" %} -{% endwith %} -{% endblock %} - - - diff --git a/cms/templates/cms/publication.html b/cms/templates/cms/publication.html index 4555849..78e0388 100644 --- a/cms/templates/cms/publication.html +++ b/cms/templates/cms/publication.html @@ -8,10 +8,23 @@ {% if not object_list %} {% block title %} -

{{ page.title }}

+

{{ page.title }}

+ +{% if page.cover %} +{% image page.cover max-600x480 class="cover" height="" width="" %} +{% endif %} + +
+ {% if page.summary %} + {{ page.summary }} + {% else %} + {{ page.body|richtext|truncatewords:32 }} + {% endif %} +
{% endblock %} {% endif %} + {% block content %} {% if object_list %} {# list view #} @@ -25,25 +38,21 @@ {% endwith %} {% else %} {# detail view #} - {% if page.cover %} - {% image page.cover max-600x480 class="detail_cover cover" height="" width="" %} - {% endif %} +
+
+ {{ page.body|richtext}} +
-
-
- {{ page.body|richtext}} -
+ {% block content_extras %}{% endblock %} - {% block content_extras %}{% endblock %} - -
- {% render_sections position="post_content" %} -
- -
- {% include "cms/snippets/comments.html" %} -
+
+ {% render_sections position="post_content" %}
+ +
+ {% include "cms/snippets/comments.html" %} +
+
{% endif %} {% endblock %} diff --git a/cms/templates/cms/sections/section_publication_info.html b/cms/templates/cms/sections/section_publication_info.html index 123aac4..2be6dd5 100644 --- a/cms/templates/cms/sections/section_publication_info.html +++ b/cms/templates/cms/sections/section_publication_info.html @@ -1,11 +1,13 @@ {% extends "cms/sections/section_item.html" %} {% load i18n %} +{% load static %} + +{% load wagtailsettings_tags %} {% block content %}
{% if page.publish_as %} - {% trans "Published by" %} {% with item=page.publish_as item_date_format='' %} {% include "cms/snippets/list_item.html" %} {% endwith %} @@ -14,15 +16,44 @@ {{ page.owner }} {% endif %}
-