Ejemplo n.º 1
0
def before_app_request():
    g.user = None
    # g.theme =
    g.upload_directory = get_setting('upload-directory', 'uploads/')
    g.allowed_extensions = get_setting('allowed-extensions', ['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif', 'tiff'])
    g.max_file_size = get_setting('max-file-size', 16777216)  # 16 MB
    g.user = import_user()
Ejemplo n.º 2
0
def index():
    user_count = User.count()
    print(user_count)
    if user_count == 0:
        # Run setup wizard.
        print('Redirecting to setup.')
        return redirect(url_for('.setup'))

    custom_front_page = get_setting('custom-front-page', '')
    if custom_front_page:
        try:
            return render(custom_front_page)
        except TemplateNotFound:
            return render("error.html", title="Custom Front Page", error="You have configured a custom front page but the file ({}) was not found in your theme's template directory.".format(custom_front_page))

    return redirect('/blog/')
Ejemplo n.º 3
0
def blog_index(page=1, tag=None):
    tag_chunks = []
    tags = json.loads(get_tags_in_use())
    if tags:
        if len(tags) > 16:
            tags = tags[:16]
        tag_chunks = chunks(tags, 4)

    limit = get_setting("posts-per-page", 4)

    posts = Content.filter(Content.published == True)\
                   .filter(Content.type == "post")\
                   .order_by(Content.published_on.desc())

    if tag:
        posts = posts.filter(Content.tags.contains(tag))

    posts, max_pages = paginate(posts, page, limit)
    return render('index.html', user=import_user(), posts=posts, current_page=page,
                  max_pages=max_pages, tag_chunks=tag_chunks, tag=tag,
                  menu_items=get_menu_items())