diff --git a/digitalglarus/templates/glarus_blog/base.html b/digitalglarus/templates/glarus_blog/base.html new file mode 100644 index 00000000..69f50d5b --- /dev/null +++ b/digitalglarus/templates/glarus_blog/base.html @@ -0,0 +1,13 @@ +{% extends "digitalglarus/base.html" %} + +{% block meta %} + {% if meta %} + {% include "meta_mixin/meta.html" %} + {% endif %} +{% endblock meta %} + +{% block content %} +
+ {% block content_blog %}{% endblock %} +
+{% endblock content %} diff --git a/digitalglarus/templates/glarus_blog/includes/blog_item.html b/digitalglarus/templates/glarus_blog/includes/blog_item.html new file mode 100644 index 00000000..7340962f --- /dev/null +++ b/digitalglarus/templates/glarus_blog/includes/blog_item.html @@ -0,0 +1,22 @@ +{% load i18n thumbnail %} + +
+
+

{{ post.title }}

+ {% block blog_meta %} + {% include "glarus_blog/includes/blog_meta.html" %} + {% endblock %} +
+ {% if image and post.main_image %} +
+ {% thumbnail post.main_image post.thumbnail_options.size crop=post.thumbnail_options.crop upscale=post.thumbnail_options.upscale subject_location=post.main_image.subject_location as thumb %} + {{ post.main_image.default_alt_text }} +
+ {% endif %} +
+ {{ post.abstract| safe }} +
+ +
\ No newline at end of file diff --git a/digitalglarus/templates/glarus_blog/includes/blog_meta.html b/digitalglarus/templates/glarus_blog/includes/blog_meta.html new file mode 100644 index 00000000..24ca606a --- /dev/null +++ b/digitalglarus/templates/glarus_blog/includes/blog_meta.html @@ -0,0 +1,26 @@ +{% load i18n thumbnail %} + + + \ No newline at end of file diff --git a/digitalglarus/templates/glarus_blog/post_detail.html b/digitalglarus/templates/glarus_blog/post_detail.html new file mode 100644 index 00000000..ed71df5e --- /dev/null +++ b/digitalglarus/templates/glarus_blog/post_detail.html @@ -0,0 +1,26 @@ +{% extends "glarus_blog/base.html" %} +{% load i18n thumbnail cms_tags %} + +{% block meta_description %}{{ post.meta_description }}{% endblock meta_description %} +{% block meta_keywords %}{{ post.meta_keywords }}{% endblock meta_keywords %} +{% block canonical_url %}{% endblock canonical_url %} +{% block title %}{{ post.get_title }}{% endblock %} + +{% block content_blog %}{% spaceless %} +
+
+

{{ post.title }}

+ {% block blog_meta %} + {% include "glarus_blog/includes/blog_meta.html" %} + {% endblock %} +
+ {% if post.main_image_id %} +
+ {% thumbnail post.main_image post.full_image_options.size crop=post.full_image_options.crop upscale=post.full_image_options.upscale subject_location=post.main_image.subject_location as thumb %} + {{ post.main_image.default_alt_text }} +
+ {% endif %} + {% endspaceless %} +
{% render_placeholder post.content %}
+
+{% endblock content_blog %} diff --git a/digitalglarus/templates/glarus_blog/post_list.html b/digitalglarus/templates/glarus_blog/post_list.html new file mode 100644 index 00000000..d640f30e --- /dev/null +++ b/digitalglarus/templates/glarus_blog/post_list.html @@ -0,0 +1,41 @@ +{% extends "glarus_blog/base.html" %} +{% load i18n thumbnail %}{% spaceless %} + +{% block canonical_url %}{% endblock canonical_url %} + +{% block content_blog %} +
+ {% block blog_title %} +
+

+ {% if author %}{% trans "Articles by" %} {{ author.get_full_name }} + {% elif archive_date %}{% trans "Archive" %} – {% if month %}{{ archive_date|date:'F' }} {% endif %}{{ year }} + {% elif tagged_entries %}{% trans "Tag" %} – {{ tagged_entries|capfirst }} + {% elif category %}{% trans "Category" %} – {{ category }}{% endif %} +

+
+ {% endblock %} + {% for post in post_list %} + {% include "glarus_blog/includes/blog_item.html" with post=post image="true" TRUNCWORDS_COUNT=TRUNCWORDS_COUNT %} + {% empty %} +

{% trans "No article found." %}

+ {% endfor %} + {% if author or archive_date or tagged_entries %} +

{% trans "Back" %}

+ {% endif %} + {% if is_paginated %} + + {% endif %} +
+{% endblock %} +{% endspaceless %} \ No newline at end of file diff --git a/digitalglarus/urls.py b/digitalglarus/urls.py index c1ef0c5e..d08b5085 100644 --- a/digitalglarus/urls.py +++ b/digitalglarus/urls.py @@ -6,4 +6,6 @@ urlpatterns = [ url(r'^$', views.index, name='index'), url(r'about$', views.about, name='about'), url(r'contact$', views.contact, name='contact'), + url(r'blog/$', views.blog, name='blog'), + url(r'^blog/(?P\w[-\w]*)/$', views.blog_detail, name='blog-detail'), ] diff --git a/digitalglarus/views.py b/digitalglarus/views.py index c9d3feec..debfb528 100644 --- a/digitalglarus/views.py +++ b/digitalglarus/views.py @@ -4,6 +4,8 @@ from django.shortcuts import get_object_or_404, render from django.forms import ModelForm from django.http import HttpResponseRedirect from django.core.urlresolvers import reverse +from django.utils.translation import get_language +from djangocms_blog.models import Post from .models import Message @@ -43,3 +45,21 @@ def contact(request): } return render(request, 'digitalglarus/contact.html', context) + + +def blog(request): + tags = ["glarus"] + posts = Post.objects.filter(tags__name__in=tags) + context = { + 'post_list': posts, + } + return render(request, 'glarus_blog/post_list.html', context) + + +def blog_detail(request, slug): + language = get_language() + post = Post.objects.translated(language, slug=slug).language(language).get() + context = { + 'post': post, + } + return render(request, 'glarus_blog/post_detail.html', context)