Beispiel #1
0
def list(request):
    stories_latest = Story.objects.filter(is_published=True)\
        .order_by('-date_published').select_related('series')
    stories_featured = Story.objects\
        .filter(highlight=True, is_published=True)\
        .order_by('-date_published').select_related('series')
    stories_featured_count = Story.objects\
        .filter(highlight=True, is_published=True)\
        .order_by('-date_published').select_related('series').count()
    stories_count = Story.objects.filter(is_published=True).count()
    series = StorySeries.objects.all()
    series_count = StorySeries.objects.all().count()
    meta = create_meta(
        title='stories.harshp.com',
        description='stories at harshp.com',
        keywords=['stories', 'harshp.com', 'coolharsh55'],
        url=request.build_absolute_uri(),
    )
    return render(request, 'stories/homepage.html', {
        'meta': meta,
        'stories_all': stories_latest,
        'stories_count': stories_count,
        'stories_featured': stories_featured[:5],
        'stories_featured_count': stories_featured_count,
        'stories_latest': stories_latest[:5],
        'series_all': series[:5],
        'series_count': series_count})
Beispiel #2
0
 def get_seo_meta(self):
     """get meta properties for this object"""
     meta = create_meta(
         title=self.title,
         description=self.short_description,
         keywords=[tag.name for tag in self.tags.all()],
         url=self.get_absolute_url(),
     )
     return meta
Beispiel #3
0
def home(request):
    meta = create_meta(
        title='harshp.com',
        description='personal website & project',
        keywords=['harshp.com', 'coolharsh55'],
        url=request.build_absolute_uri(),
    )

    latest_posts = [
        (post.__class__.__name__, post) for post in
        sorted(
            chain(
                _get_latest(Article)[:5],
                _get_latest(BlogPost)[:5],
                _get_latest(Poem)[:5],
                _get_latest(Story)[:5]),
            reverse=True,
            key=lambda p: p.date_published)[:5]
    ]

    featured_posts = [
        (post.__class__.__name__, post) for post in
        sorted(
            chain(
                _get_featured(Article)[:5],
                _get_featured(BlogPost)[:5],
                _get_featured(Poem)[:5],
                _get_featured(Story)[:5]),
            reverse=True,
            key=lambda p: p.date_published)[:5]
    ]

    latest_week = latest_week = LifeXWeek.objects.order_by('-number').first()

    return render(
        request, 'sitebase/homepage.html',
        {
            'meta': meta,
            'latest_posts': latest_posts,
            'latest_week': latest_week,
            'featured_posts': featured_posts,
        })
Beispiel #4
0
def list(request):
    poems_latest = Poem.objects.filter(is_published=True)\
        .order_by('-date_published')
    poems_featured = Poem.objects.filter(highlight=True, is_published=True)\
        .order_by('-date_published')
    poems_count = Poem.objects.filter(is_published=True).count()
    poems_featured_count = Poem.objects\
        .filter(highlight=True, is_published=True)\
        .count()
    meta = create_meta(
        title='poems.harshp.com',
        description='poems for harshp.com',
        keywords=['blog', 'poem', 'poetry', 'harshp.com', 'coolharsh55'],
        url=request.build_absolute_uri(),
    )
    return render(request, 'poems/homepage.html', {
        'meta': meta,
        'poems_all': poems_latest,
        'poems_count': poems_count,
        'poems_featured': poems_featured[:5],
        'poems_featured_count': poems_featured_count,
        'poems_latest': poems_latest[:5],
    })