PoC integration
This commit is contained in:
parent
874fdf85a2
commit
06ade77fce
7 changed files with 150 additions and 0 deletions
13
digitalglarus/templates/glarus_blog/base.html
Normal file
13
digitalglarus/templates/glarus_blog/base.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
{% extends "digitalglarus/base.html" %}
|
||||
|
||||
{% block meta %}
|
||||
{% if meta %}
|
||||
{% include "meta_mixin/meta.html" %}
|
||||
{% endif %}
|
||||
{% endblock meta %}
|
||||
|
||||
{% block content %}
|
||||
<div class="app app-blog span8">
|
||||
{% block content_blog %}{% endblock %}
|
||||
</div>
|
||||
{% endblock content %}
|
22
digitalglarus/templates/glarus_blog/includes/blog_item.html
Normal file
22
digitalglarus/templates/glarus_blog/includes/blog_item.html
Normal file
|
@ -0,0 +1,22 @@
|
|||
{% load i18n thumbnail %}
|
||||
|
||||
<article id="post-{{ post.slug }}" class="post-item">
|
||||
<header>
|
||||
<h3><a href="{% url 'digitalglarus:blog-detail' post.slug %}">{{ post.title }}</a></h3>
|
||||
{% block blog_meta %}
|
||||
{% include "glarus_blog/includes/blog_meta.html" %}
|
||||
{% endblock %}
|
||||
</header>
|
||||
{% if image and post.main_image %}
|
||||
<div class="blog-visual">
|
||||
{% 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 %}
|
||||
<img src="{{ thumb.url }}" alt="{{ post.main_image.default_alt_text }}" width="{{ thumb.width }}" height="{{ thumb.height }}" />
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="blog-lead">
|
||||
{{ post.abstract| safe }}
|
||||
</div>
|
||||
<footer class="read-more">
|
||||
<a href="{% url 'digitalglarus:blog-detail' post.slug %}">{% trans "read more" %} »</a>
|
||||
</footer>
|
||||
</article>
|
26
digitalglarus/templates/glarus_blog/includes/blog_meta.html
Normal file
26
digitalglarus/templates/glarus_blog/includes/blog_meta.html
Normal file
|
@ -0,0 +1,26 @@
|
|||
{% load i18n thumbnail %}
|
||||
|
||||
<ul class="post-detail">
|
||||
{% 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 %}
|
||||
<li>
|
||||
{{ post.date_published|date:"DATE_FORMAT" }}
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="post-detail tags">
|
||||
{% 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>
|
26
digitalglarus/templates/glarus_blog/post_detail.html
Normal file
26
digitalglarus/templates/glarus_blog/post_detail.html
Normal file
|
@ -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 %}<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">
|
||||
<header>
|
||||
<h2>{{ post.title }}</h2>
|
||||
{% block blog_meta %}
|
||||
{% include "glarus_blog/includes/blog_meta.html" %}
|
||||
{% endblock %}
|
||||
</header>
|
||||
{% 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="{{ thumb.url }}" alt="{{ post.main_image.default_alt_text }}" width="{{ thumb.width }}" height="{{ thumb.height }}" />
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endspaceless %}
|
||||
<div class="blog-content">{% render_placeholder post.content %}</div>
|
||||
</article>
|
||||
{% endblock content_blog %}
|
41
digitalglarus/templates/glarus_blog/post_list.html
Normal file
41
digitalglarus/templates/glarus_blog/post_list.html
Normal file
|
@ -0,0 +1,41 @@
|
|||
{% 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>
|
||||
<h2>
|
||||
{% 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 %}
|
||||
</h2>
|
||||
</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">{% 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 %}
|
|
@ -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<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
|
||||
|
||||
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue