diff --git a/digitalglarus/templates/digitalglarus/base.html b/digitalglarus/templates/digitalglarus/base.html index 43256d2f..3aa2482d 100644 --- a/digitalglarus/templates/digitalglarus/base.html +++ b/digitalglarus/templates/digitalglarus/base.html @@ -72,11 +72,14 @@
  • Home
  • +
  • + Contact +
  • About
  • - Contact + Blog
  • @@ -94,7 +97,7 @@
    -

    Copyright © ungleich GmbH 2015

    +

    Copyright © ungleich GmbH 2015

    diff --git a/digitalglarus/templates/glarus_blog/base.html b/digitalglarus/templates/glarus_blog/base.html new file mode 100644 index 00000000..40ad0c65 --- /dev/null +++ b/digitalglarus/templates/glarus_blog/base.html @@ -0,0 +1,19 @@ +{% 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..4565a4e7 --- /dev/null +++ b/digitalglarus/templates/glarus_blog/includes/blog_item.html @@ -0,0 +1,32 @@ +{% load i18n thumbnail %} + +
    + {% if image and post.main_image %} +
    + {% 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 %} +
    + {% block blog_meta %} + {# include "glarus_blog/includes/blog_meta.html" #} + {% endblock %} +

    + + {{ post.title }} + +
    + + {{ post.date_created }} + +

    +
    +
    +

    + {{ post.abstract| safe }} +

    +
    + +
    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..b9e78570 --- /dev/null +++ b/digitalglarus/templates/glarus_blog/includes/blog_meta.html @@ -0,0 +1,23 @@ +{% load i18n thumbnail %} + + + diff --git a/digitalglarus/templates/glarus_blog/post_detail.html b/digitalglarus/templates/glarus_blog/post_detail.html new file mode 100644 index 00000000..ae69dc5b --- /dev/null +++ b/digitalglarus/templates/glarus_blog/post_detail.html @@ -0,0 +1,34 @@ +{% 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 %} +
    + {% 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 %} +
    +

    + + {{ post.title }} + +
    + + {{ post.date_created }} + +

    + {% block blog_meta %} + {% include "glarus_blog/includes/blog_meta.html" %} + {% endblock %} +
    + {% 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..a55a82a5 --- /dev/null +++ b/digitalglarus/templates/glarus_blog/post_list.html @@ -0,0 +1,40 @@ +{% extends "glarus_blog/base.html" %} +{% load i18n thumbnail %}{% spaceless %} + +{% block canonical_url %}{% endblock canonical_url %} + +{% block content_blog %} +
    + {% block blog_title %} +
    +
    +

    + Digital Glarus Blog +

    +
    +
    + {% 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 %} diff --git a/digitalglarus/urls.py b/digitalglarus/urls.py index 585c6554..c3a14372 100644 --- a/digitalglarus/urls.py +++ b/digitalglarus/urls.py @@ -8,4 +8,6 @@ urlpatterns = [ url(r'contact$', views.contact, name='contact'), url(r'letscowork$', views.letscowork, name='letscowork'), url(r'home$', views.home, name='home'), + 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 071fe6b3..9818060c 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 @@ -55,3 +57,21 @@ def contact(request): } return render(request, 'digitalglarus/contact.html', context) + + +def blog(request): + tags = ["digitalglarus, 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)