From 79754877e5ed188961abe474a794efc1b0f4d4b1 Mon Sep 17 00:00:00 2001 From: www Date: Sun, 30 Aug 2020 17:39:15 +0000 Subject: [PATCH] design & fixes --- blueimp/.github/workflows/nodejs.yml | 25 + blueimp/.gitignore | 1 + design | 1 + foto_gallery/__init__.py | 33 +- foto_gallery/templates/gallery.html | 12 +- foto_gallery/templates/gallery_index.html | 28 +- foto_gallery/templates/layout.html | 104 +- run.py | 2 +- static/app.css | 8872 ++++++++ static/app.js | 22644 ++++++++++++++++++++ static/img | 1 + static/init.js | 28 +- static/jquery-3.5.1.min.js | 2 + uwsgi.ini | 4 +- 14 files changed, 31661 insertions(+), 96 deletions(-) create mode 100644 blueimp/.github/workflows/nodejs.yml create mode 100644 blueimp/.gitignore create mode 120000 design create mode 100644 static/app.css create mode 100644 static/app.js create mode 120000 static/img create mode 100644 static/jquery-3.5.1.min.js diff --git a/blueimp/.github/workflows/nodejs.yml b/blueimp/.github/workflows/nodejs.yml new file mode 100644 index 0000000..89973ab --- /dev/null +++ b/blueimp/.github/workflows/nodejs.yml @@ -0,0 +1,25 @@ +name: Node CI + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [8.x, 10.x, 12.x] + + steps: + - uses: actions/checkout@v1 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: npm install, build, and test + run: | + npm install + npm run build --if-present + npm test + env: + CI: true diff --git a/blueimp/.gitignore b/blueimp/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/blueimp/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/design b/design new file mode 120000 index 0000000..43073c8 --- /dev/null +++ b/design @@ -0,0 +1 @@ +/srv/fet2020/design1/ \ No newline at end of file diff --git a/foto_gallery/__init__.py b/foto_gallery/__init__.py index 8364192..21a02fe 100644 --- a/foto_gallery/__init__.py +++ b/foto_gallery/__init__.py @@ -15,7 +15,7 @@ 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") # Initialize application @@ -25,10 +25,12 @@ 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={"has_img":True} + +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_index.Page.page_defaults={"type":"gallery"} flatpages.get('index') @@ -37,8 +39,8 @@ app.logger.info('flatpages loaded %d pages' % len(flatpages._pages)) app.logger.info("Data directory is: %s" % flatpages.root) app.logger.info("Url prefix;: %s" % cfg.url_prefix) -csp_d=csp_default() -csp_d.update({'default-src':"'self' 'unsafe-inline'", 'script-src': "'unsafe-inline' 'self'"}) +#csp_d=csp_default() +#csp_d.update({'default-src':"'self' 'unsafe-inline'", 'script-src': "'unsafe-inline' 'self'"}) @@ -48,6 +50,19 @@ 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/') def thumb(size=64,name=''): if not size in [32,64,128,256,512]: @@ -87,7 +102,7 @@ def thumb(size=64,name=''): @page_blueprint.route('//',strict_slashes=False) @page_blueprint.route('/') -@csp_header() +#@csp_header() def post(name=''): print("Post: %s" % name) page = flatpages.get(name) @@ -134,5 +149,5 @@ def postjson(name='index'): app.register_blueprint(page_blueprint, url_prefix=cfg.url_prefix,static_folder='static') -app.register_blueprint(api_blueprint, url_prefix="/api/"+cfg.url_prefix,static_folder='static') +app.register_blueprint(api_blueprint, url_prefix=cfg.url_prefix+"/api/",static_folder='static') app.add_url_rule('%s/' % cfg.url_prefix,'page', post) diff --git a/foto_gallery/templates/gallery.html b/foto_gallery/templates/gallery.html index 0f976cd..e014262 100644 --- a/foto_gallery/templates/gallery.html +++ b/foto_gallery/templates/gallery.html @@ -1,9 +1,7 @@ {# -*-jinja2-*- #} -{% extends "layoutfetbs3.html" %} +{% extends "layout.html" %} {% block head %} - - {% endblock %} @@ -12,6 +10,7 @@

{{post.title}}

von {{post.author}} {{post.html | safe}} + {% if post.links.images |length > 0 %}
@@ -28,16 +27,17 @@
    -