Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

Commit

Permalink
Merge pull request #362 from aldryn/feature/templates
Browse files Browse the repository at this point in the history
Simplify templates
  • Loading branch information
FinalAngel committed Mar 8, 2016
2 parents c0e1f4b + 60a5a51 commit 38ff766
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 103 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
CHANGELOG
=========


1.2.0 (UNRELEASED)
-------------------

* Remove unused render_placeholder configs
* Add static_placeholders where necessary
* Simplify templates


1.1.1 (2016-02-12)
-------------------

Expand Down
6 changes: 3 additions & 3 deletions aldryn_newsblog/boilerplates/bootstrap3/templates/aldryn_newsblog/article_detail.html
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
{% load i18n cms_tags apphooks_config_tags %}

{% block title %}{{ article.title }} - {{ block.super }}{% endblock %}
{% block breadcrumb %}{% endblock %}

{% block newsblog_content %}
{% render_placeholder view.config.placeholder_detail_top %}
<div class="aldryn-newsblog-detail">
{% include "aldryn_newsblog/includes/article.html" with detail_view="true" %}
</div>
{% render_placeholder view.config.placeholder_detail_bottom %}
{% static_placeholder "newsblog_social" %}
{% endblock %}

{% block newsblog_footer %}
Expand All @@ -27,5 +27,5 @@
{% endif %}
</ul>
</div>
{% render_placeholder view.config.placeholder_detail_footer %}
{% static_placeholder "newsblog_comments" %}
{% endblock %}
1 change: 0 additions & 1 deletion aldryn_newsblog/boilerplates/bootstrap3/templates/aldryn_newsblog/article_list.html
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{% load i18n cms_tags %}

{% block newsblog_content %}
{% render_placeholder view.config.list_view_placeholder language placeholder_language %}
<div class="aldryn-newsblog-list">
{% for article in article_list %}
{% include "aldryn_newsblog/includes/article.html" %}
Expand Down
5 changes: 0 additions & 5 deletions aldryn_newsblog/boilerplates/bootstrap3/templates/aldryn_newsblog/base.html
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
{% extends CMS_TEMPLATE %}

{% block extend_breadcrumb %}
{{ block.super }}
{% block newsblog_breadcrumb %}{% endblock newsblog_breadcrumb %}
{% endblock extend_breadcrumb %}

{% block content %}{% endblock content %}
4 changes: 0 additions & 4 deletions aldryn_newsblog/boilerplates/bootstrap3/templates/aldryn_newsblog/fullwidth.html
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
<div class="container">
<div class="row">
<div class="col-md-16 col-md-push-4">
{% if view.show_header %}
{% render_placeholder view.config.placeholder_base_top %}
{% endif %}
<div class="aldryn aldryn-newsblog">
{% block newsblog_title %}{% endblock %}
{% block newsblog_content %}{% endblock %}
</div>
</div>
Expand Down
112 changes: 51 additions & 61 deletions aldryn_newsblog/boilerplates/bootstrap3/templates/aldryn_newsblog/includes/article.html
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,71 +1,61 @@
{% load i18n apphooks_config_tags cms_tags sekizai_tags staticfiles thumbnail %}

<article class="aldryn-newsblog-article{% if article.is_featured %} aldryn-newsblog-featured{% endif %}{% if not article.published %} unpublished{% endif %}{% if article.future %} future{% endif %}">
{% block newsblog_visual %}
{% if article.featured_image_id %}
<p class="visual">
{% if not detail_view %}
<a href="{{ article.get_absolute_url }}">
{% endif %}
<img src="{% thumbnail article.featured_image.image 800x450 crop subject_location=article.featured_image.subject_location %}" alt="{{ article.featured_image.alt }}" class="img-responsive">
{% if not detail_view %}
</a>
{% endif %}
</p>
{% endif %}
{% endblock newsblog_visual %}

{% block newsblog_categories %}
{% if article.categories %}
<p class="category">
{% for category in article.categories.all %}
<a href="{% namespace_url 'article-list-by-category' category.slug namespace=namespace default='' %}">{{ category.name }}</a>{% if not forloop.last %}, {% endif %}
{% endfor %}
</p>
{% endif %}
{% endblock newsblog_categories %}

{% block newsblock_title %}
<h2>
{% if article.featured_image_id %}
<p class="visual">
{% if not detail_view %}
<a href="{% namespace_url 'article-detail' article.slug namespace=namespace default='' %}">{% render_model article "title" %}</a>
{% else %}
{% render_model article "title" %}
<a href="{{ article.get_absolute_url }}">
{% endif %}
</h2>
{% endblock newsblock_title %}

{% block newsblog_meta %}
<img src="{% thumbnail article.featured_image.image 800x450 crop subject_location=article.featured_image.subject_location %}" alt="{{ article.featured_image.alt }}" class="img-responsive">
{% if not detail_view %}
</a>
{% endif %}
</p>
{% endif %}

{% if article.categories %}
<p class="category">
{% for category in article.categories.all %}
<a href="{% namespace_url 'article-list-by-category' category.slug namespace=namespace default='' %}">{{ category.name }}</a>{% if not forloop.last %}, {% endif %}
{% endfor %}
</p>
{% endif %}

<h2>
{% if not detail_view %}
<div class="lead">
{% render_model article "lead_in" "" "" "truncatewords:'20'" %}
</div>
{% endif %}

{% include "aldryn_newsblog/includes/author.html" with author=article.author %}

{% if article.tags and detail_view %}
<p class="tags">
{% for tag in article.tags.all %}
<a href="{% namespace_url 'article-list-by-tag' tag=tag.slug namespace=namespace default='' %}">{{ tag.name }}</a>
{% endfor %}
</p>
{% endif %}

{% if detail_view %}
<div class="lead">
{% render_model article "lead_in" %}
</div>
{% endif %}
{% endblock newsblog_meta %}

{% block newsblog_content %}
{% if detail_view %}
<div class="content">
{% render_placeholder article.content language placeholder_language %}
</div>
<a href="{% namespace_url 'article-detail' article.slug namespace=namespace default='' %}">{% render_model article "title" %}</a>
{% else %}
{% render_model article "title" %}
{% endif %}
{% endblock newsblog_content %}
</h2>

{% if not detail_view %}
<div class="lead">
{% render_model article "lead_in" "" "" "truncatewords:'20'" %}
</div>
{% endif %}

{% include "aldryn_newsblog/includes/author.html" with author=article.author %}

{% if article.tags and detail_view %}
<p class="tags">
{% for tag in article.tags.all %}
<a href="{% namespace_url 'article-list-by-tag' tag=tag.slug namespace=namespace default='' %}">{{ tag.name }}</a>
{% endfor %}
</p>
{% endif %}

{% if detail_view %}
<div class="lead">
{% render_model article "lead_in" %}
</div>
{% endif %}

{% if detail_view %}
<div class="content">
{% render_placeholder article.content language placeholder_language %}
</div>
{% endif %}
</article>

{% addtoblock "css" %}<link rel="stylesheet" href="{% static 'css/aldryn-newsblog/article.css' %}">{% endaddtoblock %}
6 changes: 2 additions & 4 deletions aldryn_newsblog/boilerplates/bootstrap3/templates/aldryn_newsblog/two_column.html
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
<div class="row">
<div class="col-md-17">
{% if view.show_header %}
{% render_placeholder view.config.placeholder_base_top %}
{% static_placeholder "newsblog_feature" %}
{% endif %}
<div class="aldryn aldryn-newsblog">
{% block newsblog_title %}{% endblock %}
{% block newsblog_content %}{% endblock %}
{% block newsblog_footer %}{% endblock %}
</div>
</div>
<div class="col-md-7 aldryn-newsblog aldryn-newsblog-sidebar">
{% render_placeholder view.config.placeholder_base_sidebar %}
{% static_placeholder "newsblog_sidebar" %}
{% block newsblog_sidebar %}{% endblock %}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "aldryn_newsblog/base.html" %}
{% load i18n apphooks_config_tags %}
{% load i18n cms_tags apphooks_config_tags %}

{% block title %}
{{ article.title }} - {{ block.super }}
Expand All @@ -8,6 +8,8 @@
{% block newsblog_content %}
{% include "aldryn_newsblog/includes/article.html" with detail_view="true" %}

{% static_placeholder "newsblog_social" %}

<ul>
{% if prev_article %}
<li><a href="{{ prev_article.get_absolute_url }}">{% trans "Previous Article" %}</a></li>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{% load i18n %}

<ul>
{% for article in article_list %}
<li>
<h3><a href="{{ article.get_absolute_url }}">{{ article.title }}</a></h3>
<p>{% trans "by" %} <a href="#">{{ article.author }}</a> {{ article.publishing_date|date }}</p>
</li>
{% empty %}
<li>{% trans "No items available" %}</li>
{% endfor %}
</ul>
{% if article %}
<ul>
{% for article in article_list %}
<li>
<h3><a href="{{ article.get_absolute_url }}">{{ article.title }}</a></h3>
<p>{% trans "by" %} <a href="#">{{ article.author }}</a> {{ article.publishing_date|date }}</p>
</li>
{% empty %}
<li>{% trans "No items available" %}</li>
{% endfor %}
</ul>
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ var page = {
'.cms-toolbar-item-navigation a[href="/en/admin/"]')),
sideMenuIframe: element(by.css('.cms-sideframe-frame iframe')),
pagesLink: element(by.css('.model-page > th > a')),
addPageLink: element(by.css('.sitemap-noentry .addlink')),
addPageLink: element(by.css('.object-tools .addlink')),
titleInput: element(by.id('id_title')),
slugErrorNotification: element(by.css('.errors.slug')),
saveButton: element(by.css('.submit-row [name="_save"]')),
editPageLink: element(by.css('.col-preview [href*="preview/"]')),
editPageLink: element(by.css('.cms-tree-item-preview [href*="preview/"]')),
testLink: element(by.cssContainingText('a', 'Test')),
sideFrameClose: element(by.css('.cms-sideframe-close')),

Expand All @@ -56,15 +56,15 @@ var page = {
'.results th > [href*="/aldryn_newsblog/article/"]')),

// adding article to the page
aldrynNewsBlogBlock: element(by.css('.aldryn-newsblog-list')),
aldrynNewsBlogBlock: element(by.css('article')),
advancedSettingsOption: element(by.css(
'.cms-toolbar-item-navigation [href*="advanced-settings"]')),
modalIframe: element(by.css('.cms-modal-frame iframe')),
applicationSelect: element(by.id('application_urls')),
newsBlogOption: element(by.css('option[value="NewsBlogApp"]')),
saveModalButton: element(by.css('.cms-modal-buttons .cms-btn-action')),
newsBlogMetaBlock: element(by.css('.aldryn-newsblog-meta')),
articleLink: element(by.css('.aldryn-newsblog-list h2 > a')),
newsBlogMetaBlock: element(by.css('p')),
articleLink: element(by.css('article h2 > a')),

// deleting article
deleteButton: element(by.css('.deletelink-box a')),
Expand Down
23 changes: 16 additions & 7 deletions aldryn_newsblog/tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from aldryn_newsblog.models import NewsBlogConfig
from cms import api
from cms.models import StaticPlaceholder

from . import NewsBlogTestCase

Expand Down Expand Up @@ -112,8 +113,8 @@ def test_authors_plugin(self):

response = self.client.get(self.plugin_page.get_absolute_url())
response_content = force_text(response.content)
pattern = '<p class="author"><a href="{url}"></a>'
pattern += '</p>\s*<p[^>]*></p>\s*<p class="badge">{num}</p>'
pattern = '<p>\s*<a href="{url}">\s*</a>\s*</p>'
pattern += '\s*<p>{num}</p>'
author1_pattern = pattern.format(
num=3,
url=reverse(
Expand Down Expand Up @@ -167,7 +168,7 @@ def test_categories_plugin(self):

response = self.client.get(self.plugin_page.get_absolute_url())
response_content = force_text(response.content)
pattern = '<span[^>]*>{num}</span>\s*<a href=[^>]*>{name}</a>'
pattern = '<a href=[^>]*>{name}</a>\s*<span[^>]*>{num}</span>'
needle1 = pattern.format(num=3, name=self.category1.name)
needle2 = pattern.format(num=5, name=self.category2.name)
self.assertRegexpMatches(response_content, needle1)
Expand Down Expand Up @@ -243,10 +244,18 @@ class TestRelatedArticlesPlugin(NewsBlogTestCase):

def test_related_articles_plugin(self):
main_article = self.create_article(app_config=self.app_config)
self.placeholder = self.app_config.placeholder_detail_top
api.add_plugin(self.placeholder, 'NewsBlogRelatedPlugin', self.language)
self.plugin = self.placeholder.get_plugins()[0].get_plugin_instance()[0]
self.plugin.save()
static_placeholder = StaticPlaceholder.objects.get_or_create(
code='newsblog_social',
site__isnull=True,
)[0]
placeholder = static_placeholder.draft
api.add_plugin(placeholder, 'NewsBlogRelatedPlugin', self.language)

static_placeholder.publish(None, language=self.language, force=True)

plugin = placeholder.get_plugins()[0].get_plugin_instance()[0]
plugin.save()

self.plugin_page.publish(self.language)

main_article.save()
Expand Down
3 changes: 1 addition & 2 deletions test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
'aldryn_newsblog', 'tests', 'templates'),
),
'ALDRYN_NEWSBLOG_TEMPLATE_PREFIXES': [('dummy', 'dummy'), ],
'ALDRYN_BOILERPLATE_NAME': 'bootstrap3',
'CMS_PERMISSION': True,
'SITE_ID': 1,
'LANGUAGES': (
Expand Down Expand Up @@ -167,7 +166,7 @@ def run():
from djangocms_helper import runner
# --boilerplate option will ensure correct boilerplate settings are
# added to settings
runner.cms('aldryn_newsblog', extra_args=['--boilerplate'])
runner.cms('aldryn_newsblog', extra_args=[])

if __name__ == "__main__":
run()

0 comments on commit 38ff766

Please sign in to comment.