From a0c0d69c5e1c05a6aa23f869024c2f7be221e100 Mon Sep 17 00:00:00 2001 From: Ville Rantanen Date: Mon, 24 Jul 2023 20:02:49 +0300 Subject: [PATCH] restructure for docker --- SECURITY.md | 10 +- forum/main.py | 2 +- forum/static/theme.css | 80 ++++++++++++++- forum/templates/admin/base.html | 33 +----- forum/templates/admin/index.html | 170 +++++++++++++++++-------------- forum/templates/base.html | 35 ++++++- forum/tool.py | 3 + restart.sh | 26 +---- 8 files changed, 213 insertions(+), 146 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 3584cc3..c94240f 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,11 +1,3 @@ # Security Policy -## Supported Versions - -Only the latest version is supported. - -## Reporting a Vulnerability - -Please send a mail to agreper+security@demindiro.com - -PGP key: [7897 2A80 BC74 A394 1C50 F060 A915 6EA5 E4B6 44FF](https://www.demindiro.com/pubkey.pgp.asc) +Use at your own risk. diff --git a/forum/main.py b/forum/main.py index f263178..d19a341 100644 --- a/forum/main.py +++ b/forum/main.py @@ -1,4 +1,4 @@ -VERSION = "agreper-v0.1.1q1" +from version import VERSION # TODO put in config table THREADS_PER_PAGE = 50 diff --git a/forum/static/theme.css b/forum/static/theme.css index 3ab2203..25e5a5f 100644 --- a/forum/static/theme.css +++ b/forum/static/theme.css @@ -73,8 +73,6 @@ td > input[type=text], td > input[type=password] { .logo { margin: 0; - padding: 5px; - padding-left: 15px; font-size: 3em; font-weight: bold; } @@ -138,3 +136,81 @@ table.form > * > tr > td, th { opacity: 1; color: white; } + +/* Dropdown menu */ +.navbar { + overflow: hidden; + background-color: #333; + font-family: inherit; +} + +.navbar a { + float: left; + font-size: 16px; + color: white; + text-align: center; + text-decoration: none; +} + +.dropdown { + float: left; + overflow: hidden; +} + +.dropdown .dropbtn { + font-size: 16px; + border: none; + outline: none; + color: white; + padding: 0px 0px; + background-color: inherit; + font-family: inherit; /* Important for vertical align on mobile phones */ + margin: 0; /* Important for vertical align on mobile phones */ +} + +.button_image { + height: 50px; +} + +.navbar a:hover, .dropdown:hover .dropbtn { + background-color: black; +} + +/* Dropdown content (hidden by default) */ +.dropdown-content { + display: none; + position: absolute; + background-color: #444; + min-width: 160px; + box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); + z-index: 1; +} + +/* Links inside the dropdown */ +.dropdown-content a { + float: none; + color: #F9F6EE; + padding: 12px 16px; + text-decoration: none; + display: block; + text-align: left; +} + +/* Add a grey background color to dropdown links on hover */ +.dropdown-content a:hover { + background-color: #555; +} +.dropdown-content a:visited { + color: #F9F6EE; +} + +/* Show the dropdown menu on hover */ +.dropdown:hover .dropdown-content { + display: block; +} + + +/* Admin */ +.admin_h2 { + background-color: rgba(0,0,0,0.15); +} diff --git a/forum/templates/admin/base.html b/forum/templates/admin/base.html index a864555..030f9a5 100644 --- a/forum/templates/admin/base.html +++ b/forum/templates/admin/base.html @@ -4,38 +4,15 @@ {{ title }} - + +{%- if config.server_name -%} + +{%- endif -%}

{{ title }}

-Admin panel +Admin panel | Home page

{%- for category, msg in get_flashed_messages(True) -%} diff --git a/forum/templates/admin/index.html b/forum/templates/admin/index.html index 38c1627..3bcecef 100644 --- a/forum/templates/admin/index.html +++ b/forum/templates/admin/index.html @@ -1,84 +1,7 @@ {% extends 'admin/base.html' -%} {% block content -%} -

Query

-

⚠ Only use queries if you know what you're doing ⚠

-
- - -
-

Configuration

-
- - - - - - - - - - - - - - - - - -
Server name
Server description
Registration enabled
Login required
- -
-

-

- -
-

-

-

- -
-

-

Forums

- - - - - - - -{% for id, name, description, _, _, _ in forums %} - - - - - -{% endfor %} -
IDNameDescriptionActions
{{ id }} -
- - -
-
-
- - -
-
Remove
-

Add forum

-
- - - - - - - - - -
Name
Description
- -
-

Users

+ +

Users

@@ -126,4 +49,93 @@
ID
+ + +

Forums

+ + + + + + + +{% for id, name, description, _, _, _ in forums %} + + + + + +{% endfor %} +
IDNameDescriptionActions
{{ id }} +
+ + +
+
+
+ + +
+
Remove
+ +

Add forum

+
+ + + + + + + + + +
Name
Description
+ +
+ + + +

Configuration

+
+ + + + + + + + + + + + + + + + + +
Server name
Server description
Registration enabled
Login required
+ +
+

+

+ +
+

+

+

+ +
+

+ + + + + +

Query

+

⚠ Only use queries if you know what you're doing ⚠

+
+ + +
{%- endblock %} diff --git a/forum/templates/base.html b/forum/templates/base.html index 1daf43a..30a12fc 100644 --- a/forum/templates/base.html +++ b/forum/templates/base.html @@ -11,7 +11,8 @@

{{ title }}

diff --git a/forum/tool.py b/forum/tool.py index 592a716..6c7cc75 100755 --- a/forum/tool.py +++ b/forum/tool.py @@ -23,6 +23,9 @@ cmd = arg(1, f"usage: {proc} [...]") if cmd == "password": pwd = arg_last(2, "usage: {proc} password ") print(password.hash(pwd)) +elif cmd == "version": + from version import VERSION + print(VERSION) else: print("unknown command ", cmd) sys.exit(1) diff --git a/restart.sh b/restart.sh index fb84270..fc77957 100755 --- a/restart.sh +++ b/restart.sh @@ -1,27 +1,5 @@ #!/usr/bin/env bash set -e - -if [ -z "$SERVER" ] -then - echo "SERVER is not set" >&2 - exit 1 -fi - -case "$SERVER" in - dev) - touch main.py - ;; - gunicorn) - if [ -z "$PID" ] - then - echo "PID is not set" >&2 - exit 1 - fi - kill -hup $(cat "$PID") - ;; - *) - echo "Unsupported $SERVER" >&2 - exit 1 - ;; -esac +docker-compose up -d -t 0 --build forum +docker-compose logs -f