commit
725a1d1e3d
15 changed files with 258 additions and 14 deletions
|
@ -62,7 +62,7 @@ def contact(request):
|
||||||
|
|
||||||
def blog(request):
|
def blog(request):
|
||||||
tags = ["digitalglarus"]
|
tags = ["digitalglarus"]
|
||||||
posts = Post.objects.filter_by_language(get_language()).filter(tags__name__in=tags)
|
posts = Post.objects.filter_by_language(get_language()).filter(tags__name__in=tags).filter(slug=slug)
|
||||||
context = {
|
context = {
|
||||||
'post_list': posts,
|
'post_list': posts,
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,12 @@ TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
'DIRS': [os.path.join(PROJECT_DIR,'cms_templates/'),
|
'DIRS': [os.path.join(PROJECT_DIR,'cms_templates/'),
|
||||||
os.path.join(PROJECT_DIR,'cms_templates/djangocms_blog/')
|
os.path.join(PROJECT_DIR,'cms_templates/djangocms_blog/'),
|
||||||
|
os.path.join(PROJECT_DIR,'membership'),
|
||||||
|
os.path.join(PROJECT_DIR,'ungleich/templates/djangocms_blog/'),
|
||||||
|
os.path.join(PROJECT_DIR,'ungleich/templates/cms/ungleichch'),
|
||||||
|
os.path.join(PROJECT_DIR,'ungleich/templates/ungleich')
|
||||||
|
|
||||||
],
|
],
|
||||||
'APP_DIRS': True,
|
'APP_DIRS': True,
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
|
@ -162,8 +167,11 @@ CMS_TEMPLATES = (
|
||||||
('contact.html', gettext('DG.Contact')),
|
('contact.html', gettext('DG.Contact')),
|
||||||
('index.html', gettext('DG.Home')),
|
('index.html', gettext('DG.Home')),
|
||||||
('letscowork.html', gettext('DG.CoWork')),
|
('letscowork.html', gettext('DG.CoWork')),
|
||||||
('detail.html', gettext('DG.Detail')),
|
# ('detail.html', gettext('DG.Detail')),
|
||||||
('one_column.html', gettext('DG.OneColumn'))
|
('one_column.html', gettext('DG.OneColumn')),
|
||||||
|
#ungleich
|
||||||
|
('blog_ungleich.html', gettext('Blog')),
|
||||||
|
('page.html', gettext('Page')),
|
||||||
)
|
)
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
|
|
|
@ -18,6 +18,8 @@ urlpatterns = [
|
||||||
|
|
||||||
# note the django CMS URLs included via i18n_patterns
|
# note the django CMS URLs included via i18n_patterns
|
||||||
urlpatterns += i18n_patterns('',
|
urlpatterns += i18n_patterns('',
|
||||||
|
url(r'^$',include('ungleich.urls')),
|
||||||
|
url(r'^blog/',include('ungleich.urls',namespace='ungleich')),
|
||||||
url(r'^login/',include(membership_urls)),
|
url(r'^login/',include(membership_urls)),
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
url(r'^digitalglarus/', include('digitalglarus.urls',
|
url(r'^digitalglarus/', include('digitalglarus.urls',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
TEMPLATES = {
|
# TEMPLATES = {
|
||||||
'blog.html': _('Blog'),
|
# 'blog_u.html': _('Blog'),
|
||||||
'page.html': _('Page'),
|
# 'page.html': _('Page'),
|
||||||
}
|
# }
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
<!-- Page Header -->
|
<!-- Page Header -->
|
||||||
<!-- Set your background image for this header on the line below. -->
|
<!-- Set your background image for this header on the line below. -->
|
||||||
<header class="intro-header"
|
<header class="intro-header"
|
||||||
{% if request.current_page.ungleichpage %}
|
{% if request.current_page.pagemeta.image.url %}
|
||||||
style="background-image: url('{{ request.current_page.ungleichpage.image.url }}');"
|
style="background-image: url('{{ request.current_page.pagemeta.image.url }}');"
|
||||||
{% else %}
|
{% else %}
|
||||||
style="background-image: url('{% static 'blog.ungleich.ch/img/home-bg.jpg' %}');"
|
style="background-image: url('{% static 'blog.ungleich.ch/img/home-bg.jpg' %}');"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "ungleichch/base.html" %}
|
{% extends "base_ungleich.html" %}
|
||||||
{% block base_content %}
|
{% block base_content %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -1,3 +1,3 @@
|
||||||
{% extends "cms/ungleichch/base.html" %}
|
{% extends "base_ungleich.html" %}
|
||||||
{% block base_content %}
|
{% block base_content %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "ungleichch/base.html" %}
|
{% extends "base_ungleich.html" %}
|
||||||
{% load cms_tags %}
|
{% load cms_tags %}
|
||||||
{% block base_content %}
|
{% block base_content %}
|
||||||
{% placeholder "page_content" %}
|
{% placeholder "page_content" %}
|
||||||
|
|
12
ungleich/templates/ungleich/djangocms_blog/base.html
Normal file
12
ungleich/templates/ungleich/djangocms_blog/base.html
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{% extends 'cms/ungleichch/blog_ungleich.html' %}
|
||||||
|
{#{% extends CMS_TEMPLATE %}#}
|
||||||
|
{% 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 %}
|
|
@ -0,0 +1,31 @@
|
||||||
|
{% load i18n thumbnail cms_tags %}
|
||||||
|
|
||||||
|
<div class="post-preview">
|
||||||
|
<a href=" {{ post.get_absolute_url }} ">
|
||||||
|
<h2 class="post-title">
|
||||||
|
{{ post.title }}
|
||||||
|
</h2>
|
||||||
|
<h3 class="post-subtitle">
|
||||||
|
{% if not TRUNCWORDS_COUNT %}
|
||||||
|
{% render_model post "abstract" %}
|
||||||
|
{% else %}
|
||||||
|
{% render_model post "abstract" "" "" 'truncatewords_html:TRUNCWORDS_COUNT' %}
|
||||||
|
{% endif %}
|
||||||
|
</h3>
|
||||||
|
</a>
|
||||||
|
<p class="post-meta">
|
||||||
|
Posted
|
||||||
|
{% if post.author %}
|
||||||
|
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>
|
||||||
|
{% endif %}
|
||||||
|
on {{ post.date_published|date:"DATE_FORMAT" }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<hr>
|
49
ungleich/templates/ungleich/djangocms_blog/post_detail.html
Normal file
49
ungleich/templates/ungleich/djangocms_blog/post_detail.html
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
{% extends "ungleich/djangocms_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 %}{% page_attribute "page_title" %} - {{ post.get_title }}{% endblock %}
|
||||||
|
<!-- page header -->
|
||||||
|
{% block base_header %}
|
||||||
|
{% include "_header_post_detail.html" %}
|
||||||
|
{% endblock %}
|
||||||
|
<!-- page header -->
|
||||||
|
{% block content_blog %}
|
||||||
|
<article>
|
||||||
|
{% if post.app_config.use_placeholder %}
|
||||||
|
<div class="blog-content">{% render_placeholder post.content %}</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="blog-content">{% render_model post "post_text" "post_text" %}</div>
|
||||||
|
{% endif %}
|
||||||
|
</article>
|
||||||
|
{% endblock content_blog %}
|
||||||
|
{#{% 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="{{ meta.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>{% render_model post "title" %}</h2>#}
|
||||||
|
{# {% block blog_meta %}#}
|
||||||
|
{# {% include "djangocms_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 %}#}
|
||||||
|
{# {% if post.app_config.use_placeholder %}#}
|
||||||
|
{# <div class="blog-content">{% render_placeholder post.content %}</div>#}
|
||||||
|
{# {% else %}#}
|
||||||
|
{# <div class="blog-content">{% render_model post "post_text" "post_text" %}</div>#}
|
||||||
|
{# {% endif %}#}
|
||||||
|
{#</article>#}
|
||||||
|
{#{% endblock content_blog %}#}
|
|
@ -0,0 +1,90 @@
|
||||||
|
{% extends "ungleich/djangocms_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 "ungleich/djangocms_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 %}
|
||||||
|
<!-- Pager -->
|
||||||
|
<ul class="pager">
|
||||||
|
{% if page_obj.has_previous %}
|
||||||
|
<li class="previous">
|
||||||
|
<a href="?{{ view.page_kwarg }}={{ page_obj.previous_page_number }}">
|
||||||
|
« {% trans "Newer Posts" %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% if page_obj.has_next %}
|
||||||
|
<li class="next">
|
||||||
|
<a href="?{{ view.page_kwarg }}={{ page_obj.next_page_number }}">
|
||||||
|
{% trans "Older Posts" %} →
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
</section>
|
||||||
|
{% endblock %}
|
||||||
|
{% endspaceless %}
|
||||||
|
|
||||||
|
|
||||||
|
{#{% load i18n thumbnail %}{% spaceless %}#}
|
||||||
|
{##}
|
||||||
|
{#{% block canonical_url %}<link rel="canonical" href="{{ 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 "djangocms_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 %}#}
|
8
ungleich/urls.py
Normal file
8
ungleich/urls.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
from django.conf.urls import url
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
url(r'^$',views.PostListViewUngleich.as_view()),
|
||||||
|
# url(r'^$',views.PostListView.as_view()),
|
||||||
|
url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<slug>\w[-\w]*)/$',views.details)
|
||||||
|
]
|
|
@ -1,3 +1,47 @@
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
from django.utils.translation import get_language
|
||||||
|
from djangocms_blog.models import Post
|
||||||
|
from django.views.generic import ListView
|
||||||
|
from djangocms_blog.views import PostListView,BaseBlogView
|
||||||
|
from django.core.paginator import Paginator
|
||||||
|
from django.core.paginator import PageNotAnInteger
|
||||||
|
from django.core.paginator import EmptyPage
|
||||||
|
from djangocms_blog.settings import get_setting
|
||||||
|
|
||||||
# Create your views here.
|
|
||||||
|
def blog(request):
|
||||||
|
posts = Post.objects.all()
|
||||||
|
print(posts)
|
||||||
|
context = {
|
||||||
|
'post_list': posts
|
||||||
|
}
|
||||||
|
|
||||||
|
# PostListView.base_template_name='post_list.html'
|
||||||
|
return render(request, 'ungleich/djangocms_blog/post_list_ungleich.html', context=context)
|
||||||
|
|
||||||
|
|
||||||
|
class PostListViewUngleich(PostListView):
|
||||||
|
model = Post
|
||||||
|
context_object_name = 'post_list'
|
||||||
|
base_template_name = 'post_list_ungleich.html'
|
||||||
|
paginate_by = 5
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super(PostListView, self).get_context_data(**kwargs)
|
||||||
|
context['TRUNCWORDS_COUNT'] = get_setting('POSTS_LIST_TRUNCWORDS_COUNT')
|
||||||
|
return context
|
||||||
|
|
||||||
|
def get_paginate_by(self, queryset):
|
||||||
|
return get_setting('PAGINATION')
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
language = get_language()
|
||||||
|
queryset = self.model.objects.translated(language)
|
||||||
|
setattr(self.request, get_setting('CURRENT_NAMESPACE'), self.config)
|
||||||
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
|
def details(request, year, month, day, slug):
|
||||||
|
post = Post.objects.translated(get_language(), slug=slug).first()
|
||||||
|
context = {'post': post}
|
||||||
|
return render(request, 'ungleich/djangocms_blog/post_detail.html', context=context)
|
||||||
|
|
Loading…
Reference in a new issue