From b2fff1c0cb13d720e305f7835044da7360aab273 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Tue, 2 Jun 2020 18:33:32 +0200 Subject: Add simple admin interface test --- admin/admin.py | 39 +++++++++++++++++++++++++++++++++++++++ admin/static/cccms.js | 7 +++++++ admin/static/style.css | 27 +++++++++++++++++++++++++++ admin/templates/index.html | 45 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 118 insertions(+) create mode 100644 admin/admin.py create mode 100644 admin/static/cccms.js create mode 100644 admin/static/style.css create mode 100644 admin/templates/index.html (limited to 'admin') diff --git a/admin/admin.py b/admin/admin.py new file mode 100644 index 00000000..cbd92192 --- /dev/null +++ b/admin/admin.py @@ -0,0 +1,39 @@ +#!python3 + +import pygit2 +from flask import Flask, render_template, jsonify, request, redirect, send_from_directory +from flask_dropzone import Dropzone +from argparse import ArgumentParser + +app = Flask(__name__) +app.config['SECRET_KEY'] = 'OlbodTyshnokTyafveg' + +app.config['PREFERRED_URL_SCHEME'] = 'https' +app.config['DROPZONE_SERVE_LOCAL'] = True +app.config['DROPZONE_MAX_FILE_SIZE'] = 128 +app.config['DROPZONE_UPLOAD_MULTIPLE'] = True +app.config['DROPZONE_PARALLEL_UPLOADS'] = 10 + +app.config['DROPZONE_ALLOWED_FILE_CUSTOM'] = True +app.config['DROPZONE_ALLOWED_FILE_TYPE'] = '' + +app.config['DROPZONE_DEFAULT_MESSAGE'] = 'Ziehe die Dateien hier hin, um sie hochzuladen oder klicken Sie zur Auswahl.' + +dropzone = Dropzone(app) + +@app.route("/admin", methods=['GET']) +def admin(): + repo = pygit2.Repository('.') + commit = repo[repo.lookup_branch("master").target] + + url_root = request.url_root.replace('http://', 'https://', 1) + return render_template('index.html', tree = commit.tree, url_root = url_root) + +if __name__ == "__main__": + parser = ArgumentParser(description="CCCMS") + parser.add_argument("-H", "--host", help="Hostname of the Flask app " + "[default %s]" % "127.0.0.1", default="127.0.0.1") + parser.add_argument("-P", "--port", help="Port for the Flask app " + "[default %s]" % "5000", default="5000") + + args = parser.parse_args() + + app.run(host=args.host, port=int(args.port)) diff --git a/admin/static/cccms.js b/admin/static/cccms.js new file mode 100644 index 00000000..873007ce --- /dev/null +++ b/admin/static/cccms.js @@ -0,0 +1,7 @@ +function toggle_hide(oid) { + el = document.getElementById(oid); + el.classList.toggle('hidden'); +} + +function load_object(oid) { +} diff --git a/admin/static/style.css b/admin/static/style.css new file mode 100644 index 00000000..1e66d2ef --- /dev/null +++ b/admin/static/style.css @@ -0,0 +1,27 @@ +.hidden { + display: none; +} + +.tree li { + margin: 0; + list-style-type: none; +} + +.tree .entry_node { + cursor: pointer; +} + +.tree .entry_node:after { + content: ' >>'; +} + +#edit_update label { + display: inline-block; + min-width: 8em; +} + +#page_teaser, #page_content { + margin: 1em; + width: 100%; + min-height: 4em; +} diff --git a/admin/templates/index.html b/admin/templates/index.html new file mode 100644 index 00000000..87238d50 --- /dev/null +++ b/admin/templates/index.html @@ -0,0 +1,45 @@ + + + +CCCMS Admin + +{{ dropzone.load_css() }} +{{ dropzone.style('border: 2px dashed #0087F7; min-height: 3em;') }} + + + + +{{ dropzone.load_js() }} + + + + + + +
{{ dropzone.create(action='/admin') }}
+ + + +{{ dropzone.config() }} + + -- cgit v1.2.3