示例#1
0
def post_list_by_tags(request, slug):
    tag = get_object_or_404(Tag, slug=slug, site=settings.SITE_ID)
    posts = get_post_list(request, tags=tag)
    return render(request,
                  'blog/post_list.haml',
                  {'posts': posts,
                  'obj': {'name': tag.name,
                          'feed': tag.get_feed_url(),
                          'url': tag.get_absolute_url(),
                          'seo': tag.seo}
                   })
示例#2
0
def post_list_by_categories(request, slug):
    cat = get_object_or_404(Category, slug=slug, site=settings.SITE_ID)
    cat_list = Category.objects.filter(site=settings.SITE_ID)
    posts = get_post_list(request, category__in=cat_list)
    return render(
        request,
        'blog/post_list.haml',
        {'posts': posts,
         'obj': {'name': cat.name,
                 'feed': cat.get_feed_url(),
                 'url': cat.get_absolute_url(),
                 'seo': cat.seo}
          })
示例#3
0
def post_list_by_archives(request, year, month=None, day=None):
    kwargs = {}
    if year and month and day:
        archive_date = _date(datetime.date(int(year), int(month), int(day)))
        kwargs['pub_date__year'] = year
        kwargs['pub_date__month'] = month
        kwargs['pub_date__day'] = day
    elif year and month:
        archive_date = _date(datetime.date(int(year), int(month), 1), "F Y")
        kwargs['pub_date__year'] = year
        kwargs['pub_date__month'] = month
    else:
        archive_date = year
        kwargs['pub_date__year'] = year

    posts = get_post_list(request, **kwargs)
    obj_name = _('Archives from %(date)s') % {'date': archive_date}
    return render(request,
                  "blog/post_list.haml",
                  {"posts": posts,
                   'obj': {'name': obj_name,
                           'url': request.path,
                           'date': archive_date}
       })
示例#4
0
def home(request):
    posts = get_post_list(request)
    return render(request, "blog/home.haml", {"posts": posts})