comments and pygments fix
This commit is contained in:
@@ -3,6 +3,7 @@ import os
|
||||
from flask import Flask
|
||||
from flaskpages import pages
|
||||
import logging
|
||||
from flask_flatpages import pygments_style_defs
|
||||
def create_app(test_config=None):
|
||||
"""Create and configure an instance of the Flask application."""
|
||||
app = Flask(__name__, instance_relative_config=True)
|
||||
@@ -24,6 +25,7 @@ def create_app(test_config=None):
|
||||
os.makedirs(app.instance_path)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
if app.config["DEBUG"]:
|
||||
app.logger.setLevel(logging.DEBUG)
|
||||
@app.route("/hello")
|
||||
|
||||
@@ -4,19 +4,19 @@ from flatpages_index import FlatPagesIndex
|
||||
import flatpages_index
|
||||
import os
|
||||
def create_bp(app):
|
||||
|
||||
flatpages = FlatPagesIndex(app)
|
||||
flatpages_index.Links.endpoint="pages.page"
|
||||
flatpages_index.Links.url=(lambda s,x: url_for(s.endpoint, name=x))
|
||||
"""Create Blueprint to register with Flask"""
|
||||
flatpages = FlatPagesIndex(app) # Init with the Flask App as argument
|
||||
flatpages_index.Links.endpoint="pages.page" #set the name of the endpoint for Links to pages
|
||||
flatpages_index.Links.url=(lambda s,x: url_for(s.endpoint, name=x)) # shorthand expects a function that creates urls for pages
|
||||
#flatpages_index.Links.image_url=(lambda s,x: url_for('stuff.page', name=x))
|
||||
flatpages_index.Links.file_url=(lambda s,x: url_for('pages.page', name=x))
|
||||
flatpages_index.Links.thumb_url=(lambda s,x: url_for('pages.thumb', size=128,name=x))
|
||||
flatpages_index.Links.file_url=(lambda s,x: url_for('pages.page', name=x)) # shorthand to create a link to a file
|
||||
flatpages_index.Links.thumb_url=(lambda s,x: url_for('pages.thumb', size=128,name=x)) # shorthand for thumbnails that may be used with pictures
|
||||
|
||||
flatpages.get('index')
|
||||
flatpages.get('index') # this ensures, that the pages are loaded
|
||||
app.logger.debug('flatpages loaded %d pages' % len(flatpages._pages))
|
||||
app.logger.debug("Data directory is: %s" % flatpages.root)
|
||||
page_blueprint = Blueprint('pages', __name__)
|
||||
|
||||
page_blueprint = Blueprint('pages', __name__)
|
||||
@page_blueprint.route('/thumb<int:size>/<path:name>/')
|
||||
def thumb(size=64,name=''):
|
||||
pass
|
||||
@@ -24,6 +24,7 @@ def create_bp(app):
|
||||
@page_blueprint.route('/<path:name>/')
|
||||
@page_blueprint.route('/')
|
||||
def page(name='index'):
|
||||
"""This is the main endpoint of the application for all flatpages"""
|
||||
page = flatpages.get(name)
|
||||
|
||||
if page:
|
||||
@@ -38,8 +39,6 @@ def create_bp(app):
|
||||
return send_from_directory('static',name)
|
||||
|
||||
|
||||
|
||||
|
||||
@page_blueprint.route('/<path:name>.json',strict_slashes=False)
|
||||
def pagejson(name='index'):
|
||||
page = flatpages.get(name)
|
||||
|
||||
Reference in New Issue
Block a user