diff --git a/app.py b/app.py index 94e3fc1..c43daff 100644 --- a/app.py +++ b/app.py @@ -121,6 +121,11 @@ def render_main(): ) +@app.route("/help") +def help(): + return render_template("help.html") + + @app.post("/login") def login(): username = request.form.get("username") @@ -142,6 +147,12 @@ def login(): return redirect(url_for(session.get("main", "index_ade"))) +@app.route("/logout") +def logout(): + session["username"] = None + return redirect(url_for("index_ade")) + + @app.route("/register", methods=["GET", "POST"]) def register(): if request.method == "POST": @@ -202,10 +213,11 @@ def register(): @app.route("/search") def search(): - stype = request.args.get("search-type") - query = request.args.get("search") - print(stype, query) - return redirect(url_for("index")) + abort(500) + # stype = request.args.get("search-type") + # query = request.args.get("search") + # print(stype, query) + # return redirect(url_for("index")) @app.route("/database", methods=["GET", "POST"]) @@ -224,7 +236,8 @@ def database(): query = json.loads(query) except: abort(400) - results = db[collection].find(query, {"_id": 1, "id": 1}) + results = list(db[collection].find(query, {"_id": 1, "id": 1})) + results.append({"_id": "new", "id": "new"}) return render_template( "database.html", cnames=cnames, collection=collection, results=results ) @@ -240,7 +253,9 @@ def database_edit(collection, oid): if document and "_id" in document: del document["_id"] try: - if not document: + if oid == "new": + db[collection].insert_one(document) + elif not document: db[collection].delete_one({"_id": ObjectId(oid)}) elif oid: db[collection].replace_one({"_id": ObjectId(oid)}, document) @@ -249,9 +264,13 @@ def database_edit(collection, oid): except: abort(500) return redirect(url_for("database")) - result = db[collection].find_one_or_404({"_id": ObjectId(oid)}) - name = result["id"] - document = bson.dumps(result, indent=4) + if oid == "new": + name = "New Document" + document = "{}" + else: + result = db[collection].find_one_or_404({"_id": ObjectId(oid)}) + name = result["id"] + document = bson.dumps(result, indent=4) return render_template( "database_edit.html", collection=collection, diff --git a/static/dialog.css b/static/dialog.css new file mode 100644 index 0000000..b2539f6 --- /dev/null +++ b/static/dialog.css @@ -0,0 +1,38 @@ +main { + display: flex; + flex-direction: row; + gap: 0.5em; + margin: 2em; + + >div { + border: 1px solid var(--color); + background-color: var(--color-bg2); + flex-grow: 1; + } +} + +p { + margin: 0.25em; +} + +#login { + flex-grow: 0; + min-width: 15em; + + >form { + display: flex; + flex-direction: column; + margin: 0 0.25em 0.25em 0.25em; + gap: 0.25em; + + label { + margin-bottom: -0.5em; + } + } +} + +@media (max-width: 750px) { + main { + flex-direction: column; + } +} \ No newline at end of file diff --git a/static/style.css b/static/style.css index 30c3a41..2931b58 100644 --- a/static/style.css +++ b/static/style.css @@ -182,6 +182,10 @@ header { transform: scale(1.005); } +#news { + display: none; +} + @media (max-width: 750px) { header { height: fit-content; diff --git a/templates/base.html b/templates/base.html index 9f0e813..246a3fa 100644 --- a/templates/base.html +++ b/templates/base.html @@ -24,8 +24,11 @@
- Account - Console + Help + Frontpage + {% if session["username"] %} + Log Out + {% endif %}
diff --git a/templates/help.html b/templates/help.html new file mode 100644 index 0000000..27023e5 --- /dev/null +++ b/templates/help.html @@ -0,0 +1,40 @@ +{% extends "base.html" %} + +{% block head %} + +{% endblock %} + +{% block content %} +
+
+

Index Help Page

+

Welcome to the Icolotl Index!

+

This website contains various projects, all under the Icolotl umbrella or one of our sub-sectors. Most of + these do require log-in, so if you're visiting the Index as a guest there might not be much for you here. If + you've forgotten your password or are missing authorizations, please contact one of our admins at their + email below. Thanks!

+ +
+
+

Index Unified Login

+
+ {% if session["username"] %} + Welcome, {{ session["username"] }}. + + {% else %} + + + + + + {% endif %} +
+
+
+{% endblock %} \ No newline at end of file