Добавил вывод тегов на страницу со статьями

remotes/origin/upgrade-requirements
Dmitriy Shesterkin 9 years ago
parent 3d58880607
commit 0b5d5a8f8c
  1. 2
      packages/blog/templates/blog/plugins/tags.html
  2. 12
      packages/blog/templates/blog/post_list.html
  3. 5
      packages/blog/views.py
  4. 23
      zsite/static/less/blog.less

@ -17,4 +17,4 @@
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>
{% endspaceless %} {% endspaceless %}

@ -11,12 +11,20 @@
<h2> <h2>
{% if author %}{% trans "Articles by" %} {{ author.get_full_name }} {% if author %}{% trans "Articles by" %} {{ author.get_full_name }}
{% elif archive_date %}{% trans "Archive" %} &ndash; {% if month %}{{ archive_date|date:'F' }} {% endif %}{{ year }} {% elif archive_date %}{% trans "Archive" %} &ndash; {% if month %}{{ archive_date|date:'F' }} {% endif %}{{ year }}
{% elif tagged_entries %}{% trans "Tag" %} &ndash; {{ tagged_entries|capfirst }} {% elif tagged_entries %}{% trans "Tag" %} &ndash; {{ tag|capfirst }}
{% elif category %}{% trans "Category" %} &ndash; {{ category }}{% endif %} {% elif category %}{% trans "Category" %} &ndash; {{ category }}{% endif %}
{{ category }} {{ category }}
</h2> </h2>
</header> </header>
{% endblock %} {% endblock %}
{% if tags %}
<ul class="blog-tags">
{% for tag in tags %}
{{ tag.count }}
<li class="blog-tag"><a class="btn btn-xs btn-default" href="{% url "blog:posts-tagged" tag=tag.slug %}">{{ tag.name }}</a></li>
{% endfor %}
</ul>
{% endif %}
<div class="clearfix"></div> <div class="clearfix"></div>
<div class="blog-list-older"> <div class="blog-list-older">
{% for post in post_list %} {% for post in post_list %}
@ -48,4 +56,4 @@
{% endif %} {% endif %}
</section> </section>
{% endblock %} {% endblock %}
{% endspaceless %} {% endspaceless %}

@ -8,7 +8,7 @@ from django.views.generic import ListView, DetailView
from parler.views import ViewUrlMixin, TranslatableSlugMixin from parler.views import ViewUrlMixin, TranslatableSlugMixin
from aldryn_apphooks_config.mixins import AppConfigMixin from aldryn_apphooks_config.mixins import AppConfigMixin
from taggit.models import Tag
from .models import Post, BlogCategory, BLOG_CURRENT_POST_IDENTIFIER from .models import Post, BlogCategory, BLOG_CURRENT_POST_IDENTIFIER
from .settings import get_setting from .settings import get_setting
@ -45,6 +45,7 @@ class PostListView(BaseBlogView, ListView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(PostListView, self).get_context_data(**kwargs) context = super(PostListView, self).get_context_data(**kwargs)
context['TRUNCWORDS_COUNT'] = get_setting('POSTS_LIST_TRUNCWORDS_COUNT') context['TRUNCWORDS_COUNT'] = get_setting('POSTS_LIST_TRUNCWORDS_COUNT')
context['tags'] = Tag.objects.all()
return context return context
@ -106,6 +107,8 @@ class TaggedListView(BaseBlogView, ListView):
kwargs['tagged_entries'] = (self.kwargs.get('tag') kwargs['tagged_entries'] = (self.kwargs.get('tag')
if 'tag' in self.kwargs else None) if 'tag' in self.kwargs else None)
context = super(TaggedListView, self).get_context_data(**kwargs) context = super(TaggedListView, self).get_context_data(**kwargs)
if kwargs['tagged_entries']:
context['tag'] = Tag.objects.get(slug=kwargs['tagged_entries'])
context['TRUNCWORDS_COUNT'] = get_setting('POSTS_LIST_TRUNCWORDS_COUNT') context['TRUNCWORDS_COUNT'] = get_setting('POSTS_LIST_TRUNCWORDS_COUNT')
return context return context

@ -31,10 +31,10 @@
li { li {
.make-xs-column(12); .make-xs-column(12);
width: 100%; width: 100%;
font-size: 12px; font-size: 12px;
vertical-align: top; vertical-align: top;
@ -46,12 +46,12 @@
} }
} }
} }
@media (min-width: @screen-xs) { @media (min-width: @screen-xs) {
li { li {
.make-xs-column(6); .make-xs-column(6);
.make-sm-column(3); .make-sm-column(3);
min-height: 140px; min-height: 140px;
} }
} }
@ -85,12 +85,12 @@ article {
article.post-item { article.post-item {
.make-row(); .make-row();
content { content {
.make-xs-column(12); .make-xs-column(12);
.make-sm-column(9); .make-sm-column(9);
} }
side { side {
.make-xs-column(3); .make-xs-column(3);
@ -105,3 +105,14 @@ article.post-item {
} }
/* block tags template blog/post_list.html line 21 */
.blog-tags {
padding-left: 0;
}
.blog-tag {
display: inline-block;
margin: 2px 0;
}

Loading…
Cancel
Save