Merge branch 'feature/digital-glarus-blog' into develop
This commit is contained in:
commit
16051bbf2e
8 changed files with 175 additions and 2 deletions
|
@ -72,11 +72,14 @@
|
|||
<li>
|
||||
<a href="{% url 'digitalglarus:home' %}">Home</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'digitalglarus:contact' %}">Contact</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'digitalglarus:about' %}">About</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'digitalglarus:contact' %}">Contact</a>
|
||||
<a href="{% url 'digitalglarus:blog' %}">Blog</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -94,7 +97,7 @@
|
|||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-12 text-center">
|
||||
<p>Copyright © <a href="http://www.ungleich.ch">ungleich GmbH 2015</a></p>
|
||||
<p class="text-center">Copyright © <a href="http://www.ungleich.ch">ungleich GmbH 2015</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
19
digitalglarus/templates/glarus_blog/base.html
Normal file
19
digitalglarus/templates/glarus_blog/base.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
{% extends "digitalglarus/base.html" %}
|
||||
|
||||
{% block meta %}
|
||||
{% if meta %}
|
||||
{% include "meta_mixin/meta.html" %}
|
||||
{% endif %}
|
||||
{% endblock meta %}
|
||||
|
||||
<div class="container">
|
||||
{% block content %}
|
||||
<div class="app app-blog span8">
|
||||
<div class="row">
|
||||
<div class="box">
|
||||
{% block content_blog %}{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
</div>
|
32
digitalglarus/templates/glarus_blog/includes/blog_item.html
Normal file
32
digitalglarus/templates/glarus_blog/includes/blog_item.html
Normal file
|
@ -0,0 +1,32 @@
|
|||
{% load i18n thumbnail %}
|
||||
|
||||
<article id="post-{{ post.slug }}" class="post-item col-lg-12 text-center">
|
||||
{% if image and post.main_image %}
|
||||
<div class="blog-visual">
|
||||
{% 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 %}
|
||||
<img src="{{ post.main_image.url }}" alt="{{ post.main_image.default_alt_text }}" class="img-responsive img-border img-full" />
|
||||
</div>
|
||||
{% endif %}
|
||||
<header>
|
||||
{% block blog_meta %}
|
||||
{# include "glarus_blog/includes/blog_meta.html" #}
|
||||
{% endblock %}
|
||||
<h2>
|
||||
<a href="{% url 'digitalglarus:blog-detail' post.slug %}">
|
||||
{{ post.title }}
|
||||
</a>
|
||||
<br>
|
||||
<small>
|
||||
{{ post.date_created }}
|
||||
</small>
|
||||
</h2>
|
||||
</header>
|
||||
<div class="blog-lead text-center">
|
||||
<p>
|
||||
{{ post.abstract| safe }}
|
||||
</p>
|
||||
</div>
|
||||
<footer class="read-more">
|
||||
<a class="lead" href="{% url 'digitalglarus:blog-detail' post.slug %}">{% trans "read more" %} »</a>
|
||||
</footer>
|
||||
</article>
|
23
digitalglarus/templates/glarus_blog/includes/blog_meta.html
Normal file
23
digitalglarus/templates/glarus_blog/includes/blog_meta.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
{% load i18n thumbnail %}
|
||||
|
||||
<ul class="post-detail list-inline">
|
||||
{% if post.author %}
|
||||
<li>
|
||||
{% trans "by" %} <a href="{% url 'djangocms_blog:posts-author' post.author.get_username %}">{% if post.author.get_full_name %}{{ post.author.get_full_name }}{% else %}{{ post.author }}{% endif %}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
<ul class="post-detail tags list-inline">
|
||||
{% if post.categories.exists %}
|
||||
{% for category in post.categories.all %}
|
||||
{% if category.slug %}
|
||||
<li class="category_{{ forloop.counter }}"><a href="{% url 'djangocms_blog:posts-category' category=category.slug %}" class="blog-categories-{{ category.count }}">{{ category.name }}</a>{% if not forloop.last %}, {% endif %}</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if post.tags.exists %}
|
||||
{% for tag in post.tags.all %}
|
||||
<li class="tag_{{ forloop.counter }}"><a href="{% url 'djangocms_blog:posts-tagged' tag=tag.slug %}" class="blog-tag blog-tag-{{ tag.count }}">{{ tag.name }}</a>{% if not forloop.last %}, {% endif %}</li>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</ul>
|
34
digitalglarus/templates/glarus_blog/post_detail.html
Normal file
34
digitalglarus/templates/glarus_blog/post_detail.html
Normal file
|
@ -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 %}<link rel="canonical" href="{{ SITE.domain }}{{ view.get_view_url }}"/>{% endblock canonical_url %}
|
||||
{% block title %}{{ post.get_title }}{% endblock %}
|
||||
|
||||
{% block content_blog %}{% spaceless %}
|
||||
<article id="post-{{ post.slug }}" class="post-item post-detail">
|
||||
{% if post.main_image_id %}
|
||||
<div class="blog-visual">
|
||||
{% 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 %}
|
||||
<img src="{{ post.main_image.url }}" alt="{{ post.main_image.default_alt_text }}" class="img-responsive img-border img-full" />
|
||||
</div>
|
||||
{% endif %}
|
||||
<header class="text-center">
|
||||
<h2>
|
||||
<a href="{% url 'digitalglarus:blog-detail' post.slug %}">
|
||||
{{ post.title }}
|
||||
</a>
|
||||
<br>
|
||||
<small>
|
||||
{{ post.date_created }}
|
||||
</small>
|
||||
</h2>
|
||||
{% block blog_meta %}
|
||||
{% include "glarus_blog/includes/blog_meta.html" %}
|
||||
{% endblock %}
|
||||
</header>
|
||||
{% endspaceless %}
|
||||
<div class="blog-content">{% render_placeholder post.content %}</div>
|
||||
</article>
|
||||
{% endblock content_blog %}
|
40
digitalglarus/templates/glarus_blog/post_list.html
Normal file
40
digitalglarus/templates/glarus_blog/post_list.html
Normal file
|
@ -0,0 +1,40 @@
|
|||
{% extends "glarus_blog/base.html" %}
|
||||
{% load i18n thumbnail %}{% spaceless %}
|
||||
|
||||
{% block canonical_url %}<link rel="canonical" href="{{ SITE.domain }}{{ view.get_view_url }}"/>{% endblock canonical_url %}
|
||||
|
||||
{% block content_blog %}
|
||||
<section class="blog-list">
|
||||
{% block blog_title %}
|
||||
<header>
|
||||
<hr></hr>
|
||||
<h2 class="intro-text text-center">
|
||||
Digital Glarus <b>Blog</b>
|
||||
</h2>
|
||||
<hr></hr>
|
||||
</header>
|
||||
{% endblock %}
|
||||
{% for post in post_list %}
|
||||
{% include "glarus_blog/includes/blog_item.html" with post=post image="true" TRUNCWORDS_COUNT=TRUNCWORDS_COUNT %}
|
||||
{% empty %}
|
||||
<p class="blog-empty text-center lead">{% trans "No article found." %}</p>
|
||||
{% endfor %}
|
||||
{% if author or archive_date or tagged_entries %}
|
||||
<p class="blog-back"><a href="{% url 'djangocms_blog:posts-latest' %}">{% trans "Back" %}</a></p>
|
||||
{% endif %}
|
||||
{% if is_paginated %}
|
||||
<nav class="{% firstof css_grid instance.css_grid %} pagination">
|
||||
{% if page_obj.has_previous %}
|
||||
<a href="?{{ view.page_kwarg }}={{ page_obj.previous_page_number }}">« {% trans "previous" %}</a>
|
||||
{% endif %}
|
||||
<span class="current">
|
||||
{% trans "Page" %} {{ page_obj.number }} {% trans "of" %} {{ paginator.num_pages }}
|
||||
</span>
|
||||
{% if page_obj.has_next %}
|
||||
<a href="?{{ view.page_kwarg }}={{ page_obj.next_page_number }}">{% trans "next" %} »</a>
|
||||
{% endif %}
|
||||
</nav>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endblock %}
|
||||
{% endspaceless %}
|
|
@ -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<slug>\w[-\w]*)/$', views.blog_detail, name='blog-detail'),
|
||||
]
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue