def show(post): others = Post.objects(id__ne=post.id).published() older = others(published__lt=post.published) newer = others(published__gt=post.published) return theme.render('post/display.html', post=post, previous_post=older.first(), next_post=newer.first())
def home(): context = { 'recent_datasets': Dataset.objects.visible(), 'recent_reuses': Reuse.objects(featured=True).visible(), 'last_post': Post.objects(private=False).first(), } processor = theme.current.get_processor('home') context = processor(context) return theme.render('home.html', **context)
def home(): # TODO:allow customization recent_datasets, recent_reuses, featured_datasets, featured_reuses, popular_datasets, popular_reuses = multiquery( SearchQuery(DatasetSearch, sort="-created", page_size=TAB_SIZE), SearchQuery(ReuseSearch, sort="-created", page_size=TAB_SIZE), SearchQuery(DatasetSearch, featured=True, page_size=3), SearchQuery(ReuseSearch, featured=True, page_size=3), SearchQuery(DatasetSearch, page_size=TAB_SIZE), SearchQuery(ReuseSearch, page_size=TAB_SIZE), ) return render( "home.html", recent_datasets=recent_datasets, recent_reuses=recent_reuses, featured_datasets=featured_datasets, featured_reuses=featured_reuses, popular_datasets=popular_datasets, popular_reuses=popular_reuses, last_post=Post.objects(private=False).order_by("-created_at").first(), # TODO extract into extension )
def sitemap_urls(): for post in Post.objects(private=False).only('id', 'slug'): yield 'posts.show_redirect', {'post': post}, None, "weekly", 0.6
def sitemap_urls(): for post in Post.objects(private=False): yield 'posts.show_redirect', {'post': post.slug}, None, "weekly", 0.5