From 5b2f01252c81e3957de1119ce6e15d02d9405f21 Mon Sep 17 00:00:00 2001 From: Dave Kliczbor <dave@fsinfo.cs.tu-dortmund.de> Date: Sun, 2 Aug 2015 05:22:08 +0200 Subject: [PATCH] some cosmetic changes --- README.md | 86 ++++++++++++++++----------- data/GenericEvent42-1331353749.schild | 2 +- data/GenericEvent42-1545270496.schild | 1 + data/Generic_Event_42897947894.schild | 1 - schilder.py | 11 ++-- templates/edit.html | 2 +- 6 files changed, 62 insertions(+), 41 deletions(-) create mode 100644 data/GenericEvent42-1545270496.schild delete mode 100644 data/Generic_Event_42897947894.schild diff --git a/README.md b/README.md index 5b4f89d..e9e1490 100644 --- a/README.md +++ b/README.md @@ -7,49 +7,67 @@ Especially useful for events. Dependencies ------------ - * python-flask python-genshi python-pythonmagick + * python-flask python-genshi + * python-pythonmagick + graphicsmagick * pdflatex latex-beamer * libapache2-mod-wsgi for production use (or [anything capable of running WSGI apps](http://wsgi.readthedocs.org/en/latest/servers.html) really…) + +Download +-------- + + $ git clone https://github.com/kif-ev/schildergenerator.git + + Config ------ - * copy config.py.example to config.py and edit it to your needs. - * copy schildergen.wsgi.example to schildergen.wsgi and edit it. + * for all uses: copy config.py.example to config.py and edit it to your needs. + * for production use: copy schildergen.wsgi.example to schildergen.wsgi and edit it. -Apache Config -------------- +Running in test/debug mode +-------------------------- + +You need to have the config done. Then you could just start the server in debug mode: + + $ python schilder.py + + +Webserver Deployment +-------------------- + +See http://flask.pocoo.org/docs/0.10/deploying/ for all deployment options. + +Example config for the Apache Webserver, following http://flask.pocoo.org/docs/deploying/mod_wsgi/: + + LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so + WSGIRestrictStdout Off + + <VirtualHost *:443> + ServerAdmin admin@server.test + DocumentRoot /path/to/schildergen + ServerName server.name.org + AddDefaultCharset utf-8 + ErrorLog /path/to/log + CustomLog /path/to/log + + SSLEngine on + SSLCertificateFile /path/to/www.example.com.cert + SSLCertificateKeyFile /path/to/www.example.com.key + + WSGIDaemonProcess schildergen user=www-data group=www-data threads=2 + WSGIScriptAlias / /path/to/schildergen.wsgi -See also http://flask.pocoo.org/docs/deploying/mod_wsgi/ - -LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so -WSGIRestrictStdout Off - - <VirtualHost *:443> - ServerAdmin admin@server.test - DocumentRoot /path/to/schildergen - ServerName server.name.org - AddDefaultCharset utf-8 - ErrorLog /path/to/log - CustomLog /path/to/log - - SSLEngine on - SSLCertificateFile /path/to/www.example.com.cert - SSLCertificateKeyFile /path/to/www.example.com.key - - WSGIDaemonProcess schildergen user=www-data group=www-data threads=2 - WSGIScriptAlias / /path/to/schildergen.wsgi - - <Directory /path/to/schildergen.wsgi> - AllowOverride All - WSGIProcessGroup schildergen - WSGIApplicationGroup %{GLOBAL} - WSGIScriptReloading On - Order deny,allow - Allow from all - </Directory> - </VirtualHost> + <Directory /path/to/schildergen.wsgi> + AllowOverride All + WSGIProcessGroup schildergen + WSGIApplicationGroup %{GLOBAL} + WSGIScriptReloading On + Order deny,allow + Allow from all + </Directory> + </VirtualHost> Contributors ============ diff --git a/data/GenericEvent42-1331353749.schild b/data/GenericEvent42-1331353749.schild index dc15a02..751fd5f 100644 --- a/data/GenericEvent42-1331353749.schild +++ b/data/GenericEvent42-1331353749.schild @@ -1 +1 @@ -{"pdfname": "GenericEvent42-1331353749.schild.pdf", "img": "pictograms-nps-misc-camera.png", "headline": "Generic\r\nEvent42", "text": "Man kann Wiki-Syntax benutzen.\r\n\r\n* Zum Beispiel f\u00fcr\r\n\r\n* Bullet Lists", "markup": "latex", "reusefilename": "on", "textemplate": "image-left_bothtext-right.tex", "filename": "GenericEvent42-1331353749.schild"} \ No newline at end of file +{"pdfname": "GenericEvent42-1331353749.schild.pdf", "img": "pictograms-nps-misc-camera.png", "headline": "Generic\r\nEvent42", "text": "Man kann Wiki-Syntax benutzen.\r\n\r\n* Zum Beispiel f\u00fcr\r\n* Bullet Lists\r\n", "markup": "rst", "reusefilename": "on", "textemplate": "image-left_bothtext-right.tex", "filename": "GenericEvent42-1331353749.schild"} \ No newline at end of file diff --git a/data/GenericEvent42-1545270496.schild b/data/GenericEvent42-1545270496.schild new file mode 100644 index 0000000..aaf74cb --- /dev/null +++ b/data/GenericEvent42-1545270496.schild @@ -0,0 +1 @@ +{"img": "pictograms-nps-parking-2.png", "headline": "GenericEvent42", "text": "", "markup": "latex", "textemplate": "headline-top_arrowup_image-right.tex", "filename": "GenericEvent42-1545270496.schild", "pdfname": "GenericEvent42-1545270496.schild.pdf", "reusefilename": ""} \ No newline at end of file diff --git a/data/Generic_Event_42897947894.schild b/data/Generic_Event_42897947894.schild deleted file mode 100644 index be38e66..0000000 --- a/data/Generic_Event_42897947894.schild +++ /dev/null @@ -1 +0,0 @@ -{"pdfname": "Generic_Event_42897947894.schild.pdf", "img": "pictograms-nps-parking-2.png", "headline": "GenericEvent42", "text": "", "markup": "rst", "reusefilename": "on", "textemplate": "headline-top_arrowup_image-right.tex", "filename": "Generic_Event_42897947894.schild"} \ No newline at end of file diff --git a/schilder.py b/schilder.py index f0c09de..9efca74 100755 --- a/schilder.py +++ b/schilder.py @@ -22,8 +22,11 @@ import tempfile import config app = Flask(__name__) -app.config['UPLOAD_FOLDER'] = config.uploaddir -app.config['PROPAGATE_EXCEPTIONS'] = True +app.config.update( + UPLOAD_FOLDER = config.uploaddir, + PROPAGATE_EXCEPTIONS = True, + MAX_CONTENT_LENGTH = 8388608L +) app.secret_key = config.app_secret genshi = Genshi(app) genshi.extensions['html'] = 'html5' @@ -92,8 +95,8 @@ def run_pdflatex(context, outputfilename, overwrite=True): tmpdir = tempfile.mkdtemp(dir=config.tmpdir) if context.has_key('img') and context['img'] and context['img'] != '__none': try: - shutil.copy(os.path.join(config.imagedir, context[ - 'img']), os.path.join(tmpdir, context['img'])) + shutil.copy(os.path.join(config.imagedir, context['img']), + os.path.join(tmpdir, context['img'])) except: raise IOError("COULD NOT COPY") else: diff --git a/templates/edit.html b/templates/edit.html index e54062f..24d8714 100644 --- a/templates/edit.html +++ b/templates/edit.html @@ -20,7 +20,7 @@ <ul py:attrs="{'class':'collapsed'} if defined('form') else {}"> <li py:for="textemplate in templates"> <input type="radio" name="textemplate" id="tpl:${textemplate}" value="${textemplate}" py:attrs="{'checked':'checked', 'onfocus':'this.parentElement.parentElement.className=\'\';'} if defined('form') and textemplate == form.textemplate else {}"/> - <label for="tpl:${textemplate}"><img src="${ url_for('tplthumbnail', tplname=textemplate, maxgeometry=72) }" alt="${textemplate}" title="${textemplate}"/></label> + <label for="tpl:${textemplate}"><img src="${ url_for('tplthumbnail', tplname=textemplate, maxgeometry=80) }" alt="${textemplate}" title="${textemplate}"/></label> </li> <li class="onlywhencollapsed"> <button onclick="this.parentElement.parentElement.className=''; return false;" >Auswahl anzeigen</button> -- GitLab