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)
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)
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/
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)
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())
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)
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)
def about(): page = pages.get_or_404('pages/about') return render_template('page.html', page=page)
def post(path): post = pages.get_or_404(path) return render_template('post.html', post=post)
def home(): page = pages.get_or_404(posts[0].path) return render_template('page.html', page=page, base=base, nav='home')
def page(path): print("HELLO\t" + path, file=sys.stderr) page = pages.get_or_404(path) return render_template('page.html', page=page)
def page(path): page = pages.get_or_404(path) return render_template('page.html', page=page)
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)
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)
def post(path): """ Individual blog post page """ blog_post = pages.get_or_404(path) return render_template('blog/post.html', post=blog_post)
def tutor(path): page = pages.get_or_404(path) return render_template("article.html", page=page)
def page(path): print 'Generating post: %s' % path page = pages.get_or_404(path) return render_template('page.html', page=page)
def contribute(): page = pages.get_or_404('contribute') return render_template('page.html', page=page)
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)
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)
def flatpage(path): page = pages.get_or_404(path) template = page.meta.get('template', 'flatpage.html') return render_template(template, page=page)
def page_helper(path): page = pages.get_or_404(path) template = page.meta.get('template', 'page.html') return render_template(template, page=page)
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)