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})
def index(request): db_sections = DevSection.objects\ .filter(section_type=DevSection.MYSTACK)\ .order_by('title') # sections = [ # (section, section.devpost_set.count()) # for section in db_sections] posts = DevPost.objects\ .filter( section__section_type=DevSection.MYSTACK, is_published=True)\ .order_by('-date_published') sections = {} for post in posts: if post.section not in sections: sections[post.section] = [] sections[post.section].append(post) data = [(section, post) for section, post in sections.items()] meta = create_meta( title='My Stack', description='My Stack', keywords=['guide', 'tutorials', 'how-to', 'harshp.com', 'coolharsh55'], url=request.build_absolute_uri()) return render( request, 'dev/mystack/index.html', { 'meta': meta, 'section_type_title': 'my stack', 'section_type_url': reverse('dev:mystack:index'), 'data': data })
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(), ) template_objects = { 'meta': meta, 'poems_all': poems_latest, 'poems_count': poems_count, 'poems_featured': poems_featured, 'poems_featured_recent': poems_featured[:5], 'poems_featured_count': poems_featured_count, 'poems_latest': poems_latest[:5], } pagecommon(request, template_objects) return render(request, 'poems/homepage.html', template_objects)
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(), ) template_objects = { 'meta': meta, 'stories_all': stories_latest, 'stories_count': stories_count, 'stories_featured': stories_featured, 'stories_featured_recent': stories_featured[:5], 'stories_featured_count': stories_featured_count, 'stories_latest': stories_latest[:5], 'series_all': series[:5], 'series_count': series_count } pagecommon(request, template_objects) return render(request, 'stories/homepage.html', template_objects)
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
def home(request): meta = create_meta( title='harshp.com', description='personal website & project', keywords=['harshp.com', 'coolharsh55'], url=request.build_absolute_uri(), ) latest_posts = sorted( chain( _get_latest(BlogPost, 'blog', 10), _get_latest(Poem, 'poem', 10), _get_latest(Story, 'story', 10), _get_latest(DevPost, 'dev', 10), _get_latest(ResearchBlogPost, 'research', 10), ), reverse=True, key=lambda p: p[1].date_published)[:10] featured_posts = sorted( chain( _get_featured(BlogPost, 'blog', 10), _get_featured(Poem, 'poem', 10), _get_featured(Story, 'story', 10), _get_featured(DevPost, 'dev', 10), _get_featured(ResearchBlogPost, 'research', 10), ), reverse=True, key=lambda p: p[1].date_published)[:10]\ now = datetime.now() annotation_count = BookAnnotation.objects.count() random_annotation = BookAnnotation.objects.all()[ random.randint(0, annotation_count)] return render( request, 'sitebase/homepage.html', { 'meta': meta, 'latest_posts': latest_posts, 'featured_posts': featured_posts, 'current_financial_month': '{}/{}'.format(now.year, now.month), 'annotation': random_annotation, })
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, })
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], })