Ejemplo n.º 1
0
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())
Ejemplo n.º 2
0
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())
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
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
    )
Ejemplo n.º 6
0
def sitemap_urls():
    for post in Post.objects(private=False).only('id', 'slug'):
        yield 'posts.show_redirect', {'post': post}, None, "weekly", 0.6
Ejemplo n.º 7
0
def sitemap_urls():
    for post in Post.objects(private=False).only('id', 'slug'):
        yield 'posts.show_redirect', {'post': post}, None, "weekly", 0.6
Ejemplo n.º 8
0
def sitemap_urls():
    for post in Post.objects(private=False):
        yield 'posts.show_redirect', {'post': post.slug}, None, "weekly", 0.5