From 5bb76173dd5599b9e3ea3475f1f69eb2293eb597 Mon Sep 17 00:00:00 2001
From: 3wordchant <3wordchant@noreply.git.autonomic.zone>
Date: Thu, 22 Jul 2021 01:15:39 +0200
Subject: [PATCH] Add custom themes, THEME setting, basic "yolocolo" theme (#7)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Specify `THEME=yourtheme`, add some HTML files in `capsulflask/theme/yourtheme` 👌
We probably want to reduce copypasta in the current `yolocolo` theme by using template inheritance, at some point.
Reviewed-on: https://git.autonomic.zone/3wordchant/capsul-flask/pulls/7
Co-authored-by: 3wordchant <3wordchant@noreply.git.autonomic.zone>
Co-committed-by: 3wordchant <3wordchant@noreply.git.autonomic.zone>
---
capsulflask/__init__.py | 13 ++-
capsulflask/static/favicon.yolocolo.ico | Bin 0 -> 1758 bytes
capsulflask/static/icon.yolocolo.png | Bin 0 -> 1209 bytes
capsulflask/static/style.yolocolo.css | 35 +++++++
.../theme/yolocolo/account-balance.html | 94 ++++++++++++++++++
capsulflask/theme/yolocolo/base.html | 60 +++++++++++
capsulflask/theme/yolocolo/capsuls.html | 68 +++++++++++++
capsulflask/theme/yolocolo/faq.html | 46 +++++++++
capsulflask/theme/yolocolo/index.html | 28 ++++++
capsulflask/theme/yolocolo/pricing.html | 23 +++++
capsulflask/theme/yolocolo/support.html | 21 ++++
11 files changed, 387 insertions(+), 1 deletion(-)
create mode 100644 capsulflask/static/favicon.yolocolo.ico
create mode 100644 capsulflask/static/icon.yolocolo.png
create mode 100644 capsulflask/static/style.yolocolo.css
create mode 100644 capsulflask/theme/yolocolo/account-balance.html
create mode 100644 capsulflask/theme/yolocolo/base.html
create mode 100644 capsulflask/theme/yolocolo/capsuls.html
create mode 100644 capsulflask/theme/yolocolo/faq.html
create mode 100644 capsulflask/theme/yolocolo/index.html
create mode 100644 capsulflask/theme/yolocolo/pricing.html
create mode 100644 capsulflask/theme/yolocolo/support.html
diff --git a/capsulflask/__init__.py b/capsulflask/__init__.py
index 55643bb..7aabe3f 100644
--- a/capsulflask/__init__.py
+++ b/capsulflask/__init__.py
@@ -2,6 +2,7 @@ import logging
from logging.config import dictConfig as logging_dict_config
import atexit
+import jinja2
import os
import hashlib
import requests
@@ -71,7 +72,9 @@ app.config.from_mapping(
#STRIPE_WEBHOOK_SECRET=os.environ.get("STRIPE_WEBHOOK_SECRET", default="")
BTCPAY_PRIVATE_KEY=os.environ.get("BTCPAY_PRIVATE_KEY", default="").replace("\\n", "\n"),
- BTCPAY_URL=os.environ.get("BTCPAY_URL", default="")
+ BTCPAY_URL=os.environ.get("BTCPAY_URL", default=""),
+
+ THEME=os.environ.get("THEME", default="")
)
app.config['HUB_URL'] = os.environ.get("HUB_URL", default=app.config['BASE_URL'])
@@ -154,6 +157,14 @@ is_running_server = ('flask run' in command_line) or ('gunicorn' in command_line
app.logger.info(f"is_running_server: {is_running_server}")
+if app.config['THEME'] != "":
+ my_loader = jinja2.ChoiceLoader([
+ jinja2.FileSystemLoader(
+ [os.path.join('capsulflask', 'theme', app.config['THEME']),
+ 'capsulflask/templates']),
+ ])
+ app.jinja_loader = my_loader
+
if app.config['HUB_MODE_ENABLED']:
if app.config['HUB_MODEL'] == "capsul-flask":
diff --git a/capsulflask/static/favicon.yolocolo.ico b/capsulflask/static/favicon.yolocolo.ico
new file mode 100644
index 0000000000000000000000000000000000000000..bb2e8850fa0c99ebdfa1e36bb22eab929911bfd5
GIT binary patch
literal 1758
zcmeIyOGs2v7{KxWJgO-tn_gx$HPiHR%*vUXM^;l!Wjdvk&CF>dxNsu~f-6DY=)#TY
z&b5Mqf*VmmS1!cG-~)Vt2#O%$V=FW You don't have any Capsuls running. Create one today!
+
+ This is a technical demo of Capsul, for the
+ as-yet-untitled Cotech server hosting
+ initiative, which you can read
+ about on the Cotech forum.
+ No backups No service level agreement "Best effort" support Cyberia, the authors of this platform, run the canonical instance, Capsul.org, on hardware they own. Please
+ send them your money! (cash, crypto, or card accepted). Please see the official Capsul FAQ
+ page.Account Balance: ${{ account_balance }}
+
+{{ warning_text }}
+ Payments
+
+
+
+
+
+
+
+ {% for payment in payments %}
+ amount
+ date
+
+
+ {% endfor %}
+
+ ${{ payment["dollars"] }}
+ {{ payment["created"] }}
+
+
+
+ PAYMENT OPTIONS
+
+
+
+ Capsuls Billed
+
+
+
+
+
+
+
+ {% for vm in vms_billed %}
+ id
+ created
+ deleted
+ $/month
+ months
+ $ billed
+
+
+ {% endfor %}
+
+ {{ vm["id"] }}
+ {{ vm["created"] }}
+ {{ vm["deleted"] }}
+ ${{ vm["dollars_per_month"] }}
+ {{ vm["months"] }}
+ ${{ vm["dollars"] }}
+ Capsuls
+
+
+
+
+
+
+
+ {% for vm in vms %}
+ ❦
+ id
+ size
+ cpu
+ mem
+ ipv4
+ os
+ created
+
+ {% if vm['state'] == 'starting' or vm['state'] == 'stopping' %}
+
+ {% endfor %}
+
+ •
+ {% elif vm['state'] == 'crashed' or vm['state'] == 'blocked' or vm['state'] == 'stopped' %}
+ •
+ {% elif vm['state'] == 'unknown' %}
+ ?
+ {% else %}
+ •
+ {% endif %}
+
+ {{ vm["id"] }}
+ {{ vm["size"] }}
+
+
+ {{ vm["ipv4"] }}
+ {{ vm["os"] }}
+ {{ vm["created"] }}
+ Frequently Asked Questions
+
+
+ _ _ + _ _ ___ | | ___ ___ ___ | | ___ +| | | |/ _ \| |/ _ \ / __/ _ \| |/ _ \ +| |_| | (_) | | (_) | (_| (_) | | (_) | + \__, |\___/|_|\___/ \___\___/|_|\___/ + |___/ + ++ Co-operative hosting using Cyberia's Capsul +{% endblock %} + +{% block subcontent %} +
+
+ Rates for this service aren't set yet. You can see Cyberia's Capsul pricing + on their website. +
++ SUPPORTED OPERATING SYSTEMS: + + {% for os_id, os in operating_systems.items() %} - {{ os.description }} + {% endfor %} ++
+ You can also find us on Matrix: #untitled-hosting.public:autonomic.zone. +
+{% endblock %} + +{% block pagesource %}/templates/support.html{% endblock %}