Merge pull request #9 from nephila/feature/parler_upds

Feature/parler upds
This commit is contained in:
Iacopo Spalletti 2014-03-29 23:10:55 +01:00
commit 0428a29fc8
22 changed files with 244 additions and 175 deletions

8
.tx/config Normal file
View file

@ -0,0 +1,8 @@
[main]
host = https://www.transifex.com
[djangocms-blog.master]
file_filter = djangocms_blog/locale/<lang>/LC_MESSAGES/django.po
source_file = djangocms_blog/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

View file

@ -3,6 +3,17 @@
History
-------
0.2.0 (in development)
++++++++++++++++++
* **INCOMPATIBLE CHANGE**: view names changed!
* Synced with latest django-parler development branch
* Toolbar items contextual to the current page
* Add support for canonical URLs
* Add transifex support
0.1.0 (2014-03-06)
++++++++++++++++++

View file

@ -1 +1 @@
__version__ = '0.1.0'
__version__ = '0.2b1.dev1'

View file

@ -5,13 +5,23 @@ from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from .models import BLOG_CURRENT_POST_IDENTIFIER
@toolbar_pool.register
class BlogToolbar(CMSToolbar):
def populate(self):
if not (self.is_current_app and self.request.user.has_perm('djangocms_blog.add_post')):
return
admin_menu = self.toolbar.get_or_create_menu("djangocms_blog", _('Blog'))
url = reverse('admin:djangocms_blog_post_changelist')
admin_menu.add_modal_item(_('Post list'), url=url)
url = reverse('admin:djangocms_blog_post_add')
admin_menu.add_modal_item(_('Add post'), url=url)
admin_menu.add_modal_item(_('Add post'), url=url)
current_post = getattr(self.request, BLOG_CURRENT_POST_IDENTIFIER, None)
if current_post and self.request.user.has_perm('djangocms_blog.change_post'):
admin_menu.add_modal_item(_('Edit Post'),reverse(
'admin:djangocms_blog_post_change', args=(current_post.pk,)),
active=True)

View file

@ -10,7 +10,7 @@ from .models import Post
class LatestEntriesFeed(Feed):
def link(self):
return reverse('djangocms_blog:latest-posts')
return reverse('djangocms_blog:posts-latest')
def title(self):
return _('Blog articles on %(site_name)s') % {'site_name': Site.objects.get_current().name}

View file

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-03-05 18:08+0100\n"
"POT-Creation-Date: 2014-03-29 16:31+0100\n"
"PO-Revision-Date: 2014-03-05 18:09+0100\n"
"Last-Translator: Iacopo Spalletti\n"
"Language-Team: Italian <i.spalletti@nephila.it>\n"
@ -18,7 +18,7 @@ msgstr ""
"X-Generator: Lokalize 1.5\n"
#: cms_app.py:8 cms_plugins.py:32 cms_plugins.py:45 cms_plugins.py:56
#: cms_plugins.py:67 cms_toolbar.py:13
#: cms_plugins.py:67 cms_toolbar.py:17
msgid "Blog"
msgstr "Blog"
@ -38,146 +38,155 @@ msgstr "Tags"
msgid "Categories"
msgstr "Categories"
#: cms_plugins.py:68 templates/djangocms_blog/post_list.html:10
#: cms_plugins.py:68 templates/djangocms_blog/post_list.html:12
#: templates/djangocms_blog/plugins/archive.html:4
msgid "Archive"
msgstr "Archive"
#: cms_toolbar.py:15
#: cms_toolbar.py:19
msgid "Post list"
msgstr "Post list"
#: cms_toolbar.py:17
#: cms_toolbar.py:21
msgid "Add post"
msgstr "Add post"
#: cms_toolbar.py:25
msgid "Edit Post"
msgstr ""
#: feeds.py:16
#, python-format
msgid "Blog articles on %(site_name)s"
msgstr "Blog articles on %(site_name)s"
#: models.py:27
#: models.py:28
msgid "parent"
msgstr "parent"
#: models.py:29
#: models.py:30
msgid "created at"
msgstr "created at"
#: models.py:30
#: models.py:31
msgid "modified at"
msgstr "modified at"
#: models.py:33
#: models.py:34
msgid "name"
msgstr "name"
#: models.py:34 models.py:87
#: models.py:35 models.py:88
msgid "slug"
msgstr "slug"
#: models.py:41
#: models.py:42
msgid "blog category"
msgstr "blog category"
#: models.py:42
#: models.py:43
msgid "blog categories"
msgstr "blog categories"
#: models.py:64
#: models.py:65
msgid "Author"
msgstr "Author"
#: models.py:68
#: models.py:69
msgid "Published Since"
msgstr "Published Since"
#: models.py:70
#: models.py:71
msgid "Published Until"
msgstr "Published Until"
#: models.py:72
#: models.py:73
msgid "Publish"
msgstr "Publish"
#: models.py:73
#: models.py:74
msgid "category"
msgstr "category"
#: models.py:75
#: models.py:76
msgid "Main image"
msgstr "Main image"
#: models.py:77
#: models.py:78
msgid "Main image thumbnail"
msgstr "Main image thumbnail"
#: models.py:81
#: models.py:82
msgid "Main image full"
msgstr "Main image full"
#: models.py:86
#: models.py:87
msgid "Title"
msgstr "Title"
#: models.py:88
#: models.py:89
msgid "Text"
msgstr "Text"
#: models.py:89
#: models.py:90
msgid "Post meta description"
msgstr "Post meta description"
#: models.py:99
#: models.py:92
#, fuzzy
msgid "Post meta keywords"
msgstr "Post meta description"
#: models.py:102
msgid "blog article"
msgstr "blog article"
#: models.py:100
#: models.py:103
msgid "blog articles"
msgstr "blog articles"
#: models.py:143 models.py:168
#: models.py:147 models.py:172
msgid "Articles"
msgstr "Articles"
#: models.py:144
#: models.py:148
msgid "The number of latests articles to be displayed."
msgstr "The number of latests articles to be displayed."
#: models.py:146
#: models.py:150
msgid "Show only the blog articles tagged with chosen tags."
msgstr "Show only the blog articles tagged with chosen tags."
#: models.py:148
#: models.py:152
msgid "Show only the blog articles tagged with chosen categories."
msgstr "Show only the blog articles tagged with chosen categories."
#: models.py:165 templates/djangocms_blog/plugins/authors.html:3
#: models.py:169 templates/djangocms_blog/plugins/authors.html:3
msgid "Authors"
msgstr "Authors"
#: models.py:169
#: models.py:173
msgid "The number of author articles to be displayed."
msgstr "The number of author articles to be displayed."
#: templates/djangocms_blog/post_detail.html:14
#: templates/djangocms_blog/post_detail.html:16
#: templates/djangocms_blog/includes/blog_item.html:10
msgid "by"
msgstr "by"
#: templates/djangocms_blog/post_list.html:9
#: templates/djangocms_blog/post_list.html:11
msgid "Articles by"
msgstr "Articles by"
#: templates/djangocms_blog/post_list.html:11
#: templates/djangocms_blog/post_list.html:13
msgid "Tag"
msgstr "Tag"
#: templates/djangocms_blog/post_list.html:12
#: templates/djangocms_blog/post_list.html:14
msgid "Category"
msgstr "Category"
#: templates/djangocms_blog/post_list.html:19
#: templates/djangocms_blog/post_list.html:21
#: templates/djangocms_blog/plugins/archive.html:27
#: templates/djangocms_blog/plugins/authors.html:15
#: templates/djangocms_blog/plugins/categories.html:16
@ -186,23 +195,23 @@ msgstr "Category"
msgid "No article found."
msgstr "No article found."
#: templates/djangocms_blog/post_list.html:22
#: templates/djangocms_blog/post_list.html:24
msgid "Back"
msgstr "Back"
#: templates/djangocms_blog/post_list.html:28
#: templates/djangocms_blog/post_list.html:30
msgid "previous"
msgstr "previous"
#: templates/djangocms_blog/post_list.html:31
#: templates/djangocms_blog/post_list.html:33
msgid "Page"
msgstr "Page"
#: templates/djangocms_blog/post_list.html:31
#: templates/djangocms_blog/post_list.html:33
msgid "of"
msgstr "of"
#: templates/djangocms_blog/post_list.html:34
#: templates/djangocms_blog/post_list.html:36
msgid "next"
msgstr "next"

View file

@ -1,24 +1,26 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
# Iacopo Spalletti, 2014.
#
# Translators:
# Iacopo Spalletti, 2014
# yakky <i.spalletti@nephila.it>, 2014
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Project-Id-Version: djangocms-blog\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-03-05 18:08+0100\n"
"PO-Revision-Date: 2014-03-05 18:11+0100\n"
"Last-Translator: Iacopo Spalletti\n"
"Language-Team: Italian <i.spalletti@nephila.it>\n"
"Language: it\n"
"POT-Creation-Date: 2014-03-29 16:31+0100\n"
"PO-Revision-Date: 2014-03-29 15:34+0000\n"
"Last-Translator: yakky <i.spalletti@nephila.it>\n"
"Language-Team: Italian (http://www.transifex.com/projects/p/djangocms-blog/language/it/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: it\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Lokalize 1.5\n"
#: cms_app.py:8 cms_plugins.py:32 cms_plugins.py:45 cms_plugins.py:56
#: cms_plugins.py:67 cms_toolbar.py:13
#: cms_plugins.py:67 cms_toolbar.py:17
msgid "Blog"
msgstr "Blog"
@ -38,146 +40,154 @@ msgstr "Tag"
msgid "Categories"
msgstr "Categorie"
#: cms_plugins.py:68 templates/djangocms_blog/post_list.html:10
#: cms_plugins.py:68 templates/djangocms_blog/post_list.html:12
#: templates/djangocms_blog/plugins/archive.html:4
msgid "Archive"
msgstr "Archivio"
#: cms_toolbar.py:15
#: cms_toolbar.py:19
msgid "Post list"
msgstr "Lista degli articoli"
#: cms_toolbar.py:17
#: cms_toolbar.py:21
msgid "Add post"
msgstr "Aggiungi articolo"
#: cms_toolbar.py:25
msgid "Edit Post"
msgstr "Modifica articolo"
#: feeds.py:16
#, python-format
msgid "Blog articles on %(site_name)s"
msgstr "Articoli del blog su %(site_name)s"
#: models.py:27
#: models.py:28
msgid "parent"
msgstr "superiore"
#: models.py:29
#: models.py:30
msgid "created at"
msgstr "creato il"
#: models.py:30
#: models.py:31
msgid "modified at"
msgstr "modificato il"
#: models.py:33
#: models.py:34
msgid "name"
msgstr "nome"
#: models.py:34 models.py:87
#: models.py:35 models.py:88
msgid "slug"
msgstr "slug"
#: models.py:41
#: models.py:42
msgid "blog category"
msgstr "categoria del blog"
#: models.py:42
#: models.py:43
msgid "blog categories"
msgstr "categorie del blog"
#: models.py:64
#: models.py:65
msgid "Author"
msgstr "Autore"
#: models.py:68
#: models.py:69
msgid "Published Since"
msgstr "Pubblicato il"
#: models.py:70
#: models.py:71
msgid "Published Until"
msgstr "fino al"
#: models.py:72
#: models.py:73
msgid "Publish"
msgstr "Pubblicato"
#: models.py:73
#: models.py:74
msgid "category"
msgstr "categoria"
#: models.py:75
#: models.py:76
msgid "Main image"
msgstr "Immagine"
#: models.py:77
#: models.py:78
msgid "Main image thumbnail"
msgstr "Dimensione miniatura"
#: models.py:81
#: models.py:82
msgid "Main image full"
msgstr "Dimensione piena"
#: models.py:86
#: models.py:87
msgid "Title"
msgstr "Titolo"
#: models.py:88
#: models.py:89
msgid "Text"
msgstr "Testo"
#: models.py:89
#: models.py:90
msgid "Post meta description"
msgstr "Meta Descrizione dell'articolo"
msgstr "Meta descrizione dell'articolo"
#: models.py:99
#: models.py:92
msgid "Post meta keywords"
msgstr "Meta keyword dell'articolo"
#: models.py:102
msgid "blog article"
msgstr "articolo del blog"
#: models.py:100
#: models.py:103
msgid "blog articles"
msgstr "articoli del blog"
#: models.py:143 models.py:168
#: models.py:147 models.py:172
msgid "Articles"
msgstr "Articoli"
#: models.py:144
#: models.py:148
msgid "The number of latests articles to be displayed."
msgstr "Il numero di articoli da mostrare."
#: models.py:146
#: models.py:150
msgid "Show only the blog articles tagged with chosen tags."
msgstr "Mostra solo gli articoli marcati con i tag selezionati."
#: models.py:148
#: models.py:152
msgid "Show only the blog articles tagged with chosen categories."
msgstr "Mostra solo gli articoli marcati con i categorie selezionati."
#: models.py:165 templates/djangocms_blog/plugins/authors.html:3
#: models.py:169 templates/djangocms_blog/plugins/authors.html:3
msgid "Authors"
msgstr "Autori"
#: models.py:169
#: models.py:173
msgid "The number of author articles to be displayed."
msgstr "Numero di elementi per autore da mostrare."
#: templates/djangocms_blog/post_detail.html:14
#: templates/djangocms_blog/post_detail.html:16
#: templates/djangocms_blog/includes/blog_item.html:10
msgid "by"
msgstr "di"
#: templates/djangocms_blog/post_list.html:9
#: templates/djangocms_blog/post_list.html:11
msgid "Articles by"
msgstr "Articoli di"
#: templates/djangocms_blog/post_list.html:11
#: templates/djangocms_blog/post_list.html:13
msgid "Tag"
msgstr "Tag"
#: templates/djangocms_blog/post_list.html:12
#: templates/djangocms_blog/post_list.html:14
msgid "Category"
msgstr "Categoria"
#: templates/djangocms_blog/post_list.html:19
#: templates/djangocms_blog/post_list.html:21
#: templates/djangocms_blog/plugins/archive.html:27
#: templates/djangocms_blog/plugins/authors.html:15
#: templates/djangocms_blog/plugins/categories.html:16
@ -186,23 +196,23 @@ msgstr "Categoria"
msgid "No article found."
msgstr "Nessun articolo trovato."
#: templates/djangocms_blog/post_list.html:22
#: templates/djangocms_blog/post_list.html:24
msgid "Back"
msgstr "Indietro"
#: templates/djangocms_blog/post_list.html:28
#: templates/djangocms_blog/post_list.html:30
msgid "previous"
msgstr "precedente"
#: templates/djangocms_blog/post_list.html:31
#: templates/djangocms_blog/post_list.html:33
msgid "Page"
msgstr "Pagina"
#: templates/djangocms_blog/post_list.html:31
#: templates/djangocms_blog/post_list.html:33
msgid "of"
msgstr "di"
#: templates/djangocms_blog/post_list.html:34
#: templates/djangocms_blog/post_list.html:36
msgid "next"
msgstr "successivo"
@ -228,13 +238,13 @@ msgid "0 articles"
msgstr "0 articoli"
#~ msgid "blog post"
#~ msgstr "articolo"
#~ msgstr "blog post"
#~ msgid "Posts"
#~ msgstr "Articolo"
#~ msgstr "Posts"
#~ msgid "Entries by"
#~ msgstr "Articoli di"
#~ msgstr "Entries by"
#~ msgid "No entry found."
#~ msgstr "Nessun articolo trovato."
#~ msgstr "No entry found."

View file

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-03-05 18:08+0100\n"
"POT-Creation-Date: 2014-03-29 16:31+0100\n"
"PO-Revision-Date: 2014-02-27 16:45+0300\n"
"Last-Translator: Max Vyaznikov <maxvyaznikov@gmail.com>\n"
"Language-Team: \n"
@ -19,7 +19,7 @@ msgstr ""
"X-Generator: Poedit 1.5.4\n"
#: cms_app.py:8 cms_plugins.py:32 cms_plugins.py:45 cms_plugins.py:56
#: cms_plugins.py:67 cms_toolbar.py:13
#: cms_plugins.py:67 cms_toolbar.py:17
msgid "Blog"
msgstr "Блог"
@ -39,146 +39,154 @@ msgstr "Тэги"
msgid "Categories"
msgstr "Categories"
#: cms_plugins.py:68 templates/djangocms_blog/post_list.html:10
#: cms_plugins.py:68 templates/djangocms_blog/post_list.html:12
#: templates/djangocms_blog/plugins/archive.html:4
msgid "Archive"
msgstr "Архив"
#: cms_toolbar.py:15
#: cms_toolbar.py:19
msgid "Post list"
msgstr "Список статей"
#: cms_toolbar.py:17
#: cms_toolbar.py:21
msgid "Add post"
msgstr "Добавить статью"
#: cms_toolbar.py:25
msgid "Edit Post"
msgstr ""
#: feeds.py:16
#, python-format
msgid "Blog articles on %(site_name)s"
msgstr "Статьи из блог на %(site_name)s"
#: models.py:27
#: models.py:28
msgid "parent"
msgstr "предок"
#: models.py:29
#: models.py:30
msgid "created at"
msgstr "время создания"
#: models.py:30
#: models.py:31
msgid "modified at"
msgstr "время изменения"
#: models.py:33
#: models.py:34
msgid "name"
msgstr "название"
#: models.py:34 models.py:87
#: models.py:35 models.py:88
msgid "slug"
msgstr "URL"
#: models.py:41
#: models.py:42
msgid "blog category"
msgstr "категория блога"
#: models.py:42
#: models.py:43
msgid "blog categories"
msgstr "категории блога"
#: models.py:64
#: models.py:65
msgid "Author"
msgstr "Автор"
#: models.py:68
#: models.py:69
msgid "Published Since"
msgstr "Опубликована с"
#: models.py:70
#: models.py:71
msgid "Published Until"
msgstr "Опубликована до"
#: models.py:72
#: models.py:73
msgid "Publish"
msgstr "Показывать на сайте"
#: models.py:73
#: models.py:74
msgid "category"
msgstr "категория"
#: models.py:75
#: models.py:76
msgid "Main image"
msgstr "Картинка для статьи"
#: models.py:77
#: models.py:78
msgid "Main image thumbnail"
msgstr "Уменьшенная копия"
#: models.py:81
#: models.py:82
msgid "Main image full"
msgstr "Полный размер"
#: models.py:86
#: models.py:87
msgid "Title"
msgstr "Заголовок"
#: models.py:88
#: models.py:89
msgid "Text"
msgstr "Текст"
#: models.py:89
#: models.py:90
msgid "Post meta description"
msgstr ""
#: models.py:99
#: models.py:92
msgid "Post meta keywords"
msgstr ""
#: models.py:102
msgid "blog article"
msgstr "статья блога"
#: models.py:100
#: models.py:103
msgid "blog articles"
msgstr "статьи блога"
#: models.py:143 models.py:168
#: models.py:147 models.py:172
msgid "Articles"
msgstr "Статьи"
#: models.py:144
#: models.py:148
msgid "The number of latests articles to be displayed."
msgstr "Количество показываемых последних статей."
#: models.py:146
#: models.py:150
msgid "Show only the blog articles tagged with chosen tags."
msgstr "Показывать только статьи с выбранными тэгами."
#: models.py:148
#: models.py:152
msgid "Show only the blog articles tagged with chosen categories."
msgstr "Показывать только статьи из выбранныех категорий."
#: models.py:165 templates/djangocms_blog/plugins/authors.html:3
#: models.py:169 templates/djangocms_blog/plugins/authors.html:3
msgid "Authors"
msgstr "Авторы"
#: models.py:169
#: models.py:173
msgid "The number of author articles to be displayed."
msgstr "Количество статей автора, которые будут показаны."
#: templates/djangocms_blog/post_detail.html:14
#: templates/djangocms_blog/post_detail.html:16
#: templates/djangocms_blog/includes/blog_item.html:10
msgid "by"
msgstr "создана"
#: templates/djangocms_blog/post_list.html:9
#: templates/djangocms_blog/post_list.html:11
msgid "Articles by"
msgstr "Статьи созданы"
#: templates/djangocms_blog/post_list.html:11
#: templates/djangocms_blog/post_list.html:13
msgid "Tag"
msgstr "Тэг"
#: templates/djangocms_blog/post_list.html:12
#: templates/djangocms_blog/post_list.html:14
msgid "Category"
msgstr "Категория"
#: templates/djangocms_blog/post_list.html:19
#: templates/djangocms_blog/post_list.html:21
#: templates/djangocms_blog/plugins/archive.html:27
#: templates/djangocms_blog/plugins/authors.html:15
#: templates/djangocms_blog/plugins/categories.html:16
@ -187,23 +195,23 @@ msgstr "Категория"
msgid "No article found."
msgstr "Не найдено ни одной статьи."
#: templates/djangocms_blog/post_list.html:22
#: templates/djangocms_blog/post_list.html:24
msgid "Back"
msgstr "Назад"
#: templates/djangocms_blog/post_list.html:28
#: templates/djangocms_blog/post_list.html:30
msgid "previous"
msgstr "предыдущая"
#: templates/djangocms_blog/post_list.html:31
#: templates/djangocms_blog/post_list.html:33
msgid "Page"
msgstr "Страница"
#: templates/djangocms_blog/post_list.html:31
#: templates/djangocms_blog/post_list.html:33
msgid "of"
msgstr "из"
#: templates/djangocms_blog/post_list.html:34
#: templates/djangocms_blog/post_list.html:36
msgid "next"
msgstr "следующая"

View file

@ -17,6 +17,7 @@ from taggit_autosuggest.managers import TaggableManager
from . import settings
from .managers import GenericDateTaggedManager
BLOG_CURRENT_POST_IDENTIFIER = 'djangocms_post_current'
class BlogCategory(TranslatableModel):
"""
@ -101,6 +102,7 @@ class Post(TranslatableModel):
verbose_name = _('blog article')
verbose_name_plural = _('blog articles')
ordering = ("-date_published", "-date_created")
get_latest_by = 'date_published'
def __unicode__(self):
return self.safe_translation_getter('title')

View file

@ -7,7 +7,7 @@
{% block blog_meta %}
<ul class="post-detail">
<li>
{% trans "by" %} <a href="{% url 'djangocms_blog:author-posts' post.author.username %}">{{ post.author.get_full_name }}</a>
{% trans "by" %} <a href="{% url 'djangocms_blog:posts-author' post.author.username %}">{{ post.author.get_full_name }}</a>
</li>
<li>
{{ post.date_published|date:"M d, Y" }}
@ -16,12 +16,12 @@
<ul class="post-detail tags">
{% if post.categories.exists %}
{% for category in post.categories.all %}
<li class="category_{{ forloop.counter }}"><a href="{% url 'djangocms_blog:category-posts' category=category.slug %}" class="blog-categories-{{ category.count }}">{{ category.name }}</a>{% if not forloop.last %}, {% endif %}</li>
<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>
{% endfor %}
{% endif %}
{% if post.tags.exists %}
{% for tag in post.tags.all %}
<li class="tag_{{ forloop.counter }}"><a href="{% url 'djangocms_blog:tagged-posts' tag=tag.slug %}" class="blog-tag blog-tag-{{ tag.count }}">{{ tag.name }}</a>{% if not forloop.last %}, {% endif %}</li>
<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>

View file

@ -7,11 +7,11 @@
<ul class="blog-archive">
{% for year in years %}
<li{% if year.grouper == current_year %} class="active"{% endif %}>
<a href="{% url 'djangocms_blog:archive-year' year=year.grouper %}">{{ year.grouper }}</a>
<a href="{% url 'djangocms_blog:posts-archive' year=year.grouper %}">{{ year.grouper }}</a>
<ul>
{% for month in year.list %}
<li{% if year.grouper == current_year and month.date.month == current_month %} class="active"{% else %} class="month"{% endif %}>
<a href="{% url 'djangocms_blog:archive-month' year=year.grouper month=month.date|date:"n" %}">
<a href="{% url 'djangocms_blog:posts-archive' year=year.grouper month=month.date|date:"n" %}">
{{ month.date|date:"F" }}
<span>(
{% if month.count > 0 %}

View file

@ -3,7 +3,7 @@
<h3>{% trans "Authors" %}</h3>
<ul class="blog-authors">
{% for author in instance.get_authors %}
<li><a href="{% url 'djangocms_blog:author-posts' author.username %}">
<li><a href="{% url 'djangocms_blog:posts-author' author.username %}">
{{ author.get_full_name }}
<span>(
{% if author.count > 0 %}

View file

@ -4,7 +4,7 @@
<h3>{% trans "Categories" %}</h3>
<ul class="blog-categories">
{% for category in categories %}
<li><a href="{% url 'djangocms_blog:category-posts' category=category.slug %}" class="blog-categories-{{ category.count }}">
<li><a href="{% url 'djangocms_blog:posts-category' category=category.slug %}" class="blog-categories-{{ category.count }}">
{{ category.name }}
<span>(
{% if category.count > 0 %}

View file

@ -4,7 +4,7 @@
<h3>{% trans "Tags" %}</h3>
<ul class="blog-tags">
{% for tag in tags %}
<li><a href="{% url 'djangocms_blog:tagged-posts' tag=tag.slug %}" class="blog-tag-{{ tag.count }}">
<li><a href="{% url 'djangocms_blog:posts-tagged' tag=tag.slug %}" class="blog-tag-{{ tag.count }}">
{{ tag.name }}
<span>(
{% if tag.count > 0 %}

View file

@ -4,6 +4,7 @@
{% 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 content_blog %}{% spaceless %}
<article id="post-{{ post.slug }}" class="post-item post-detail">
@ -12,7 +13,7 @@
{% block blog_meta %}
<ul class="post-detail">
<li>
{% trans "by" %} <a href="{% url 'djangocms_blog:author-posts' post.author.username %}">{{ post.author.get_full_name }}</a>
{% trans "by" %} <a href="{% url 'djangocms_blog:posts-author' post.author.username %}">{{ post.author.get_full_name }}</a>
</li>
<li>
{{ post.date_published|date:"M d, Y" }}
@ -21,12 +22,12 @@
<ul class="post-detail tags">
{% if post.categories.exists %}
{% for category in post.categories.all %}
<li class="category_{{ forloop.counter }}"><a href="{% url 'djangocms_blog:category-posts' category=category.slug %}" class="blog-categories-{{ category.count }}">{{ category.name }}</a>{% if not forloop.last %}, {% endif %}</li>
<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>
{% endfor %}
{% endif %}
{% if post.tags.exists %}
{% for tag in post.tags.all %}
<li class="tag_{{ forloop.counter }}"><a href="{% url 'djangocms_blog:tagged-posts' tag=tag.slug %}" class="blog-tag blog-tag-{{ tag.count }}">{{ tag.name }}</a>{% if not forloop.last %}, {% endif %}</li>
<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>

View file

@ -1,6 +1,8 @@
{% extends "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 %}
@ -19,7 +21,7 @@
<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:latest-posts' %}">{% trans "Back" %}</a></p>
<p class="blog-back"><a href="{% url 'djangocms_blog:posts-latest' %}">{% trans "Back" %}</a></p>
{% endif %}
{% if is_paginated %}

View file

@ -8,13 +8,13 @@ from .feeds import LatestEntriesFeed, TagFeed
urlpatterns = patterns(
'',
url(r'^$', PostListView.as_view(), name='latest-posts'),
url(r'^feed/$', LatestEntriesFeed(), name='latest-posts-feed'),
url(r'^(?P<year>\d{4})/$', PostArchiveView.as_view(), name='archive-year'),
url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/$', PostArchiveView.as_view(), name='archive-month'),
url(r'^$', PostListView.as_view(), name='posts-latest'),
url(r'^feed/$', LatestEntriesFeed(), name='posts-latest-feed'),
url(r'^(?P<year>\d{4})/$', PostArchiveView.as_view(), name='posts-archive'),
url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/$', PostArchiveView.as_view(), name='posts-archive'),
url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<slug>\w[-\w]*)/$', PostDetailView.as_view(), name='post-detail'),
url(r'^author/(?P<username>[\w\.@+-]+)/$', AuthorEntriesView.as_view(), name='author-posts'),
url(r'^category/(?P<category>[\w\.@+-]+)/$', CategoryEntriesView.as_view(), name='category-posts'),
url(r'^tag/(?P<tag>[-\w]+)/$', TaggedListView.as_view(), name='tagged-posts'),
url(r'^tag/(?P<tag>[-\w]+)/feed/$', TagFeed(), name='tagged-posts-feed'),
url(r'^author/(?P<username>[\w\.@+-]+)/$', AuthorEntriesView.as_view(), name='posts-author'),
url(r'^category/(?P<category>[\w\.@+-]+)/$', CategoryEntriesView.as_view(), name='posts-category'),
url(r'^tag/(?P<tag>[-\w]+)/$', TaggedListView.as_view(), name='posts-tagged'),
url(r'^tag/(?P<tag>[-\w]+)/feed/$', TagFeed(), name='posts-tagged-feed'),
)

View file

@ -1,23 +1,23 @@
# -*- coding: utf-8 -*-
import datetime
from cms.utils import get_language_from_request
from django.utils.translation import get_language
from django.contrib.auth.models import User
from django.core.urlresolvers import resolve
from django.db.models import Count
from django.http import Http404
from django.utils.translation import ugettext_lazy as _
from django.views.generic import ListView, DetailView
from parler.utils import get_active_language_choices
from .models import Post, BlogCategory
from parler.views import ViewUrlMixin
from .models import Post, BlogCategory, BLOG_CURRENT_POST_IDENTIFIER
from .settings import BLOG_PAGINATION, BLOG_POSTS_LIST_TRUNCWORDS_COUNT
class BaseBlogView(object):
class BaseBlogView(ViewUrlMixin):
def get_queryset(self):
language = get_language_from_request(self.request)
manager = self.model._default_manager.translated(language)
language = get_language()
manager = self.model._default_manager.language(language)
if not self.request.user.is_staff:
manager = manager.filter(publish=True)
return manager
@ -32,6 +32,7 @@ class PostListView(BaseBlogView, ListView):
context_object_name = 'post_list'
template_name = "djangocms_blog/post_list.html"
paginate_by = BLOG_PAGINATION
view_url_name = 'djangocms_blog:posts-latest'
def get_context_data(self, **kwargs):
context = super(PostListView, self).get_context_data(**kwargs)
@ -43,18 +44,22 @@ class PostDetailView(BaseBlogView, DetailView):
model = Post
context_object_name = 'post'
template_name = "djangocms_blog/post_detail.html"
slug_field = 'translations__slug'
slug_field = 'slug'
view_url_name = 'djangocms_blog:post-detail'
def get_object(self, queryset=None):
try:
qs = self.model._default_manager.get(**{
'translations__language_code': get_language_from_request(self.request),
qs = self.model._default_manager.active_translations(**{
self.slug_field: self.kwargs.get(self.slug_url_kwarg, None)
})
}).latest()
except Post.DoesNotExist:
raise Http404()
return qs
def get_context_data(self, **kwargs):
context = super(PostDetailView, self).get_context_data(**kwargs)
setattr(self.request, BLOG_CURRENT_POST_IDENTIFIER, self.get_object())
return context
class PostArchiveView(BaseBlogView, ListView):
model = Post
@ -64,6 +69,7 @@ class PostArchiveView(BaseBlogView, ListView):
allow_empty = True
allow_future = True
paginate_by = BLOG_PAGINATION
view_url_name = 'djangocms_blog:posts-archive'
def get_queryset(self):
qs = super(PostArchiveView, self).get_queryset()
@ -86,6 +92,7 @@ class TaggedListView(BaseBlogView, ListView):
context_object_name = 'post_list'
template_name = "djangocms_blog/post_list.html"
paginate_by = BLOG_PAGINATION
view_url_name = 'djangocms_blog:posts-tagged'
def get_queryset(self):
qs = super(TaggedListView, self).get_queryset()
@ -102,6 +109,7 @@ class AuthorEntriesView(BaseBlogView, ListView):
context_object_name = 'post_list'
template_name = "djangocms_blog/post_list.html"
paginate_by = BLOG_PAGINATION
view_url_name = 'djangocms_blog:posts-authors'
def get_queryset(self):
qs = super(AuthorEntriesView, self).get_queryset()
@ -120,11 +128,12 @@ class CategoryEntriesView(BaseBlogView, ListView):
template_name = "djangocms_blog/post_list.html"
_category = None
paginate_by = BLOG_PAGINATION
view_url_name = 'djangocms_blog:posts-category'
@property
def category(self):
if not self._category:
language = get_language_from_request(self.request)
language = get_language()
self._category = BlogCategory._default_manager.language(language).get(
translations__language_code=language,
translations__slug=self.kwargs['category'])

View file

@ -30,14 +30,14 @@ setup(
long_description=readme + '\n\n' + history,
author='Iacopo Spalletti',
author_email='i.spalletti@nephila.it',
url='https://github.com/yakky/djangocms-blog',
url='https://github.com/nephila/djangocms-blog',
packages=[
'djangocms_blog',
],
include_package_data=True,
install_requires=[
'django-parler>0.9.4',
'django-cms>=3.0b4.dev6',
'django-parler>=1.0',
'django-cms>=3.0c1',
'django-taggit',
'django-filer',
'django-select2',
@ -47,8 +47,7 @@ setup(
'django-admin-enhancer',
],
dependency_links=[
'https://github.com/edoburu/django-parler/archive/master.zip#egg=django-parler-0.9.5',
'https://github.com/divio/django-cms/archive/develop.zip#egg=django-cms-3.0b4.dev6'
'https://github.com/edoburu/django-parler/archive/cdd500bb28a234d870274e73cba9d7020f1ef0b1.zip#egg=django-parler-1.0',
],
license="BSD",
zip_safe=False,