Esempio n. 1
0
def page(path):
    posts = [page for page in pages]
    sorted_posts = sorted(posts,
                          reverse=True,
                          key=lambda page: page.meta['date'])
    page = pages.get_or_404(path)
    return render_template('page.html', page=page, pages=sorted_posts)
Esempio n. 2
0
def post_detail(path):
    post = pages.get_or_404(path)
    recent_posts = [p for p in pages if 'blog' in p.path]
    recent_posts = sorted(recent_posts, reverse=True, key=lambda p: p.meta.get('published', date.today()))
    recent_posts = recent_posts[:5]
    
    return render_template('blog_post.html', title=post['title'], ogimage=post.meta.get('image', None), ogdescription=post.meta.get('description', post), post=post, recent_posts=recent_posts)
Esempio n. 3
0
def page(path):
    # `path` is the filename of a page, without the file extension
    # e.g. "first-post"
    page = pages.get_or_404(path)
    return render_template('page.html', page=page)


#Credit for this code goes to http://stevenloria.com/hosting-static-flask-sites-for-free-on-github-pages/
Esempio n. 4
0
File: views.py Progetto: vsoch/nipy
def page(path):

    projects, n, m = get_data()

    # Path is the filename of a page, without the file extension
    # e.g. "welcome.md" --> "welcome"
    page = pages.get_or_404(path)
    return render_template("page.html", page=page, projects=projects, n=n, m=m)
Esempio n. 5
0
def page_detail(path):
    # Path is the filename of a page, without the file extension
    # e.g. "first-post"
    page = pages.get_or_404(path)

    all_pages = sorted(
        [p for p in pages if 'date' in p.meta],
        reverse=True,
        key=lambda p: p.meta['date']
    )

    if len(all_pages) > 10:
        all_pages = all_pages[0:10]

    return render_template('page.html', page=page, pages=all_pages, now=datetime.datetime.now())
Esempio n. 6
0
def edit_page(path):
    page = pages.get_or_404(path)
    form = EditPageForm()
    if form.validate_on_submit():
        # Save over the page, and force a reload.
        page_path = os.path.join(app.root_path, app.config['FLATPAGES_ROOT'], path) + app.config['FLATPAGES_EXTENSION']

        with open(page_path, 'w') as page_file:
            page_file.write(form.page.data)
        return redirect(url_for('post_detail', path=path))
    else:
        # Construct the full page, including meta:
        full_page = ''
        for k, v in page.meta.iteritems():
            full_page += str(k) + ': ' + str(v) + '\n'
        full_page += '\n'
        full_page += page.body
        form.page.data = full_page
    return render_template('admin_edit_page.html', form=form, page=page)
Esempio n. 7
0
def get_article(path):
    page = pages.get_or_404(path)
    with open('/home/longzx/src/study/flask/app/pages/我的文章.md') as f:
        content = f.read()
    content = markdown2.markdown(content)
    return render_template('article.html', page=page, content=content)
Esempio n. 8
0
def about():
    page = pages.get_or_404('pages/about')
    return render_template('page.html', page=page)
Esempio n. 9
0
def post(path):
    post = pages.get_or_404(path)
    return render_template('post.html', post=post)
Esempio n. 10
0
def home():
    page = pages.get_or_404(posts[0].path)
    return render_template('page.html', page=page, base=base, nav='home')
Esempio n. 11
0
def page(path):
    print("HELLO\t" + path, file=sys.stderr)
    page = pages.get_or_404(path)
    return render_template('page.html', page=page)
Esempio n. 12
0
def page(path):
    page = pages.get_or_404(path)
    return render_template('page.html', page=page)
Esempio n. 13
0
def page(path):
    page = pages.get_or_404(path)
    dep_list = page.meta.get('deps', [])
    dep_pages = [pages.get(dep) for dep in dep_list]
    template = page.meta.get('template', 'page.html')
    return render_template(template, page=page, deps=dep_pages)
Esempio n. 14
0
def page(path):
    # path is the filename of the page without extension
    page = pages.get_or_404(path)
    return render_template('page.html', page=page)
Esempio n. 15
0
def post(path):
    """ Individual blog post page """
    blog_post = pages.get_or_404(path)
    return render_template('blog/post.html', post=blog_post)
Esempio n. 16
0
def tutor(path):
    page = pages.get_or_404(path)
    return render_template("article.html", page=page)
Esempio n. 17
0
def page(path):
	page = pages.get_or_404(path)
	return render_template('page.html', page=page)
Esempio n. 18
0
def page(path):
    print 'Generating post: %s' % path
    page = pages.get_or_404(path)
    return render_template('page.html', page=page)
Esempio n. 19
0
def about():
    page = pages.get_or_404('pages/about')
    return render_template('page.html', page=page)
Esempio n. 20
0
def contribute():
    page = pages.get_or_404('contribute')
    return render_template('page.html', page=page)
Esempio n. 21
0
def page(path):
    page = pages.get_or_404(path)
    dep_list = page.meta.get('deps', [])
    dep_pages = [pages.get(dep) for dep in dep_list]
    template = page.meta.get('template', 'page.html')
    return render_template(template, page=page, deps=dep_pages)
Esempio n. 22
0
def page(path):
    # `path` is the filename of a page, without the file extension
    # e.g. "first-post"
    page = pages.get_or_404(path)
    template = page.meta.get('template', 'post.html')
    return render_template(template, page=page)
Esempio n. 23
0
def page(path):
    
    # Path is the filename of a page, without the file extension
    # e.g. "first-post"
    page = pages.get_or_404(path)
    return render_template('page.html', page=page)
Esempio n. 24
0
def contribute():
    page = pages.get_or_404('contribute')
    return render_template('page.html', page=page)
Esempio n. 25
0
def flatpage(path):
    page = pages.get_or_404(path)
    template = page.meta.get('template', 'flatpage.html')
    return render_template(template, page=page)
Esempio n. 26
0
def page_helper(path):
    page = pages.get_or_404(path)
    template = page.meta.get('template', 'page.html')
    return render_template(template, page=page)
Esempio n. 27
0
def page(path):
    print("HELLO\t" + path, file=sys.stderr)
    page = pages.get_or_404(path)
    return render_template('page.html', page=page)
Esempio n. 28
0
def page(path):
    print 'Generating post: %s' % path
    page = pages.get_or_404(path)
    return render_template('page.html', page=page)
Esempio n. 29
0
def page(path):     # Path is the filename of a page, without the file extension  e.g. "first-post"
    page = pages.get_or_404(path)
    return render_template('page.html', page=page)
Esempio n. 30
0
def page(path):
    # `path` is the filename of a page, without the file extension
    # e.g. "first-post"
    page = pages.get_or_404(path)
    template = page.meta.get('template', 'post.html')
    return render_template(template, page=page)