diff --git a/main.py b/main.py index b5095d7..5aff984 100644 --- a/main.py +++ b/main.py @@ -10,21 +10,23 @@ if glob.config["git"]["auto_pull_and_restart"]: # Only used on the VPS (Do not e @glob.app.route(glob.config["git"]["webhook_endpoint"], methods = ["POST"]) def git_fetch(): if request.method != "POST": - return "No" + return "No", 400 data = json.loads( request.data.decode() ) if data["secret"] != glob.config["git"]["secret"]: - return "No" - - import subprocess, os, sys - process = subprocess.Popen(["git", "pull"], stdout=subprocess.PIPE) - output = process.communicate()[0] + return "No", 400 + + from subprocess import check_output + output = check_output(["git", "pull", "origin", "master"]) + + print( "GIT: {}".format( output.decode() ) ) if output.decode().split("\n")[-2].find("fail") != -1: - return "Failed to pull changes" + return "Failed to pull changes", 500 # If needed; every open file or connection HAVE to be closed at this point + import os, sys os.execv(sys.executable, ["python"] + sys.argv) # Restart service if glob.config["disable-static-cache"]: @@ -37,7 +39,7 @@ if glob.config["disable-static-cache"]: caching static files. """ return dict(url_for=dated_url_for) - + def dated_url_for(endpoint, **values): if endpoint == "static": filename = values.get("filename", None) diff --git a/routes.py b/routes.py index ae7338c..4392b5b 100644 --- a/routes.py +++ b/routes.py @@ -1,7 +1,30 @@ -from flask import render_template, url_for +from flask import render_template, url_for, request from objects import glob # Global sharing of python objects in a manageable way @glob.app.route("/") @glob.app.route("/home") def home(): return render_template("home.html") + +@glob.app.route("/login", methods = ["GET", "POST"]) +def serve_login(): + if request.method == "POST": + return "TODO: Login handle", 501 + return render_template("login.html") + +@glob.app.route("/testing") +def we_are_testing(): + return render_template("testing.html") + +@glob.app.route("/bill") +def serve_bill(): + return render_template("bill.html") + +@glob.app.route("/regninger") +def serve_regninger(): + return render_template("regninger.html") + +@glob.app.route("/kvittering") +def serve_kvittering(): + return render_template("kvittering.html") + diff --git a/static/js/alerts.js b/static/js/alerts.js new file mode 100644 index 0000000..bb6f417 --- /dev/null +++ b/static/js/alerts.js @@ -0,0 +1,20 @@ +function _findAlertDom(caller) { + let selectedDOM = caller; + do { + if (selectedDOM.classList.contains("alert-section")){ + return selectedDOM; + } + selectedDOM = selectedDOM.parentElement; + } while (selectedDOM != null); + throw Error("Missing alert-section class for self/parent(s)"); +} + +function alertAbove(caller, t, s) { + let dom = _findAlertDom(caller); + dom.outerHTML = `` + dom.outerHTML; +} + +function alertUnder(caller, t, s) { + let dom = _findAlertDom(caller); + dom.outerHTML += ``; +} \ No newline at end of file diff --git a/templates/bill.html b/templates/bill.html new file mode 100644 index 0000000..ea43231 --- /dev/null +++ b/templates/bill.html @@ -0,0 +1,11 @@ +{% set title = "bill:)" %} + +{% extends "layout/bootstrap.html" %} + +{% block content %} +

lotsa bills

+

many bills

+ + + +{% endblock %} \ No newline at end of file diff --git a/templates/kvittering.html b/templates/kvittering.html new file mode 100644 index 0000000..5743bef --- /dev/null +++ b/templates/kvittering.html @@ -0,0 +1,10 @@ +{% set title = "Kvitteringer" %} + +{% extends "layout/bootstrap.html" %} + +{% block content %} + +

Tester siden!

+

KVITTERINGER FOR FAEN!

+ +{% endblock %} \ No newline at end of file diff --git a/templates/layout/bootstrap.html b/templates/layout/bootstrap.html index 2cc0837..48653a8 100644 --- a/templates/layout/bootstrap.html +++ b/templates/layout/bootstrap.html @@ -1,7 +1,7 @@ -{% include 'includes/boot-head.html' %} +{% include 'layout/includes/boot-head.html' %} {% if title %} Husstanden - {{ title }} {% else %} @@ -10,6 +10,6 @@ {% block content %}{% endblock %} -{% include 'includes/boot-body.html' %} +{% include 'layout/includes/boot-body.html' %} \ No newline at end of file diff --git a/templates/layout/dash.html b/templates/layout/dash.html index 2cc0837..48653a8 100644 --- a/templates/layout/dash.html +++ b/templates/layout/dash.html @@ -1,7 +1,7 @@ -{% include 'includes/boot-head.html' %} +{% include 'layout/includes/boot-head.html' %} {% if title %} Husstanden - {{ title }} {% else %} @@ -10,6 +10,6 @@ {% block content %}{% endblock %} -{% include 'includes/boot-body.html' %} +{% include 'layout/includes/boot-body.html' %} \ No newline at end of file diff --git a/templates/login.html b/templates/login.html new file mode 100644 index 0000000..d2a17bc --- /dev/null +++ b/templates/login.html @@ -0,0 +1,42 @@ +{% set title = "Login" %} + +{% extends "layout/bootstrap.html" %} + +{% block content %} +
+
+
+
+
+

Login Methods

+
+
+
+
Electronic ID
+

+ Secure login using Electronic ID allows Husstanden to show you banking details, bills and receipts.
+ How to obtain an Electronic ID +

+
+
+
House Account
+

+ Accounts with less privileges and fast login to view non-sensitive information.
+ Multiple house accounts can be created by logging in with house holder's verified Electronic ID. +

+
+
+
+ +
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/templates/regninger.html b/templates/regninger.html new file mode 100644 index 0000000..87e0e34 --- /dev/null +++ b/templates/regninger.html @@ -0,0 +1,8 @@ +{% set title = "Regninger" %} + +{% extends "layout/bootstrap.html" %} + +{% block content %} +

Regninger :D

+

test

+{% endblock %} \ No newline at end of file diff --git a/templates/testing.html b/templates/testing.html new file mode 100644 index 0000000..91a7ad0 --- /dev/null +++ b/templates/testing.html @@ -0,0 +1,8 @@ +{% set title = "testing" %} + +{% extends "layout/bootstrap.html" %} + +{% block content %} +

testing

+

tester dette

+{% endblock %} \ No newline at end of file