fix layout fet
This commit is contained in:
@@ -15,8 +15,8 @@ import re
|
||||
from PIL import Image, ExifTags, ImageOps
|
||||
from functools import partial
|
||||
from flask_csp.csp import csp_header, csp_default
|
||||
import slugify
|
||||
|
||||
#cfg = Config("./config.cfg")
|
||||
import environ
|
||||
env = environ.Env(
|
||||
# set casting, default value
|
||||
@@ -45,11 +45,16 @@ app.logger.setLevel(logging.DEBUG)
|
||||
# Initialize FlatPages Index
|
||||
|
||||
flatpages = FlatPagesIndex(app)
|
||||
flatpages_index.Links.endpoint="intern.post"
|
||||
flatpages_index.Links.image_url=lambda s,x: url_for(s.endpoint,name=x)
|
||||
|
||||
|
||||
|
||||
flatpages_index.Links.thumb_url=lambda s,x: url_for("intern.thumb",size=128,name=x)
|
||||
flatpages_index.Links.image_url=lambda s,x: url_for("intern.post",name=x)
|
||||
flatpages_index.Page.page_defaults={"type":"gallery", "template":"gallery.html"}
|
||||
|
||||
flatpages.cfg("url", lambda s,x: url_for("intern.post",name=x))
|
||||
flatpages.cfg("thumb_url", lambda s,x: url_for("intern.thumb",size=512,name=x))
|
||||
|
||||
flatpages.get('index')
|
||||
|
||||
app.logger.info('Initialize FET Foto Gallery App')
|
||||
@@ -57,17 +62,25 @@ app.logger.info('flatpages loaded %d pages' % len(flatpages._pages))
|
||||
app.logger.info("Data directory is: %s" % flatpages.root)
|
||||
|
||||
|
||||
#csp_d=csp_default()
|
||||
#csp_d.update({'default-src':"'self' 'unsafe-inline'", 'script-src': "'unsafe-inline' 'self'"})
|
||||
|
||||
|
||||
|
||||
freezer = Freezer(app)
|
||||
|
||||
|
||||
page_blueprint = Blueprint('intern', __name__)
|
||||
api_blueprint = Blueprint('api', __name__)
|
||||
|
||||
|
||||
|
||||
@app.template_filter()
|
||||
def thumbimage(post):
|
||||
if post.thumb_url:
|
||||
return post.thumb_url
|
||||
elif len(post.images)>0:
|
||||
return post.images[0]
|
||||
|
||||
@app.template_filter()
|
||||
def slug(string):
|
||||
return slugify.slugify(string)
|
||||
|
||||
@page_blueprint.route('/thumb<int:size>/<path:name>')
|
||||
def thumb(size=64,name=''):
|
||||
if not size in [32,64,128,256,512]:
|
||||
@@ -150,6 +163,8 @@ def postjson(name='index'):
|
||||
|
||||
|
||||
|
||||
|
||||
app.register_blueprint(page_blueprint, url_prefix=app.config["url_prefix"],static_folder='static')
|
||||
app.register_blueprint(api_blueprint, url_prefix="/api/"+app.config["url_prefix"],static_folder='static')
|
||||
app.add_url_rule('%s/<path:name>' % app.config["url_prefix"],'page', post)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user