From 40fcc652cc94706194ee3c0c8acaa91994f7cd54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt?= <b.charpentier@webu.coop> Date: Fri, 13 Jan 2017 11:27:04 +0100 Subject: [PATCH] refactoring list-item --- newsbox/templates/newsbox/inc/list-item.html | 34 ++++++++++++++----- .../templates/newsbox_cms/inc/list-item.html | 28 +++++++++++++++ 2 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 newsbox_cms/templates/newsbox_cms/inc/list-item.html diff --git a/newsbox/templates/newsbox/inc/list-item.html b/newsbox/templates/newsbox/inc/list-item.html index c781534..b9021ec 100644 --- a/newsbox/templates/newsbox/inc/list-item.html +++ b/newsbox/templates/newsbox/inc/list-item.html @@ -2,28 +2,44 @@ <article class="comp__content-item {{ object.is_published|yesno:',draft' }}"> <header> {% block newsbox_list_item_header %} - <h2> + <h1> <a href="{{ object.get_absolute_url }}"> {{ object.newsbox_title }} </a> {% if object.newsbox_date and object.newsbox_date != object.newsbox_publication_start_date %} <time datetime="{{ object.newsbox_date }}">{{ object.newsbox_date|date:'SHORT_DATE_FORMAT' }}</time> {% endif %} - </h2> - <time datetime="{{ object.newsbox_publication_start_date }}" pubdate="pubdate">{% blocktrans with date=object.newsbox_publication_start_date|date:'SHORT_DATE_FORMAT' %}published on {{ date }}{% endblocktrans %}</time> + </h1> {% endblock %} </header> <div> {% block newsbox_list_item_content %} - {% if object.newsbox_summary %} - {{ object.newsbox_summary|linebreaks }} - - {% if object.newsbox_body %} - <a class="readmore" href="{{ object.get_absolute_url }}">{% trans "Read more" %}</a> + <div class="summary"> + {% if object.newsbox_summary %} + {{ object.newsbox_summary|linebreaks }} + {% else %} + {{ object.newsbox_body|truncatewords:50 }} {% endif %} - {% endif %} + </div> + + {% block newsbox_list_item_content_extra %} + {% with readmore=readmore|default:object.newsbox_body %} + {% if object.newsbox_publication_start_date or readmore %} + <div class="extra"> + {% if object.newsbox_publication_start_date %} + <time datetime="{{ object.newsbox_publication_start_date }}" pubdate="pubdate">{% blocktrans with date=object.newsbox_publication_start_date|date:'SHORT_DATE_FORMAT' %}published on {{ date }}{% endblocktrans %}</time> + {% endif %} + {% if readmore %} + <a class="readmore" href="{{ object.get_absolute_url }}">{% trans "Read more" %}</a> + {% endif %} + </div> + {% endif %} + {% endwith %} + {% endblock newsbox_list_item_content_extra %} {% endblock %} </div> + {% block newsbox_list_item_footer %}{% endblock newsbox_list_item_footer %} + </article> diff --git a/newsbox_cms/templates/newsbox_cms/inc/list-item.html b/newsbox_cms/templates/newsbox_cms/inc/list-item.html new file mode 100644 index 0000000..bcfe705 --- /dev/null +++ b/newsbox_cms/templates/newsbox_cms/inc/list-item.html @@ -0,0 +1,28 @@ +{% extends "newsbox/inc/list-item.html" %} +{% load i18n cms_tags %} + +{% block newsbox_list_item_header %} + {% render_model_icon object %} + {{ block.super }} +{% endblock %} + +{% block newsbox_list_item_content %} + <div class="summary"> + {% if object.newsbox_summary %} + {{ object.newsbox_summary }} + {% render_placeholder object.newsbox_body as body %} + {% else %} + {{ body|truncatewords_html:50 }} + {% endif %} + </div> + + {% block newsbox_list_item_content_extra %} + {% with readmore=body %} + {% if not instance.placeholder %} + {{ block.super }} + {% elif readmore %} + <div class="extra"><a class="readmore" href="{{ object.get_absolute_url }}">{% trans "Read more" %}</a></div> + {% endif %} + {% endwith %} + {% endblock newsbox_list_item_content_extra %} +{% endblock %} -- GitLab