From 787a9421d1a61229b838dcbf17734c42172800f7 Mon Sep 17 00:00:00 2001 From: jwansek Date: Thu, 25 Aug 2022 14:19:10 +0000 Subject: Renamed template files, added active for torrents --- app.py | 21 ++++---- services.py | 11 ++-- templates/discord.html.j2 | 5 ++ templates/discord.jinja | 5 -- templates/index.html.j2 | 36 +++++++++++++ templates/index.jinja | 36 ------------- templates/isocd.html.j2 | 32 ++++++++++++ templates/isocd.jinja | 32 ------------ templates/isocd_confirmation.html.j2 | 16 ++++++ templates/isocd_confirmation.jinja | 16 ------ templates/nhdl.html.j2 | 8 +++ templates/nhdl.jinja | 8 --- templates/random.html.j2 | 22 ++++++++ templates/random.jinja | 22 -------- templates/services.html.j2 | 99 ++++++++++++++++++++++++++++++++++++ templates/services.jinja | 95 ---------------------------------- templates/template.html.j2 | 58 +++++++++++++++++++++ templates/template.jinja | 58 --------------------- templates/thought.html.j2 | 29 +++++++++++ templates/thought.jinja | 29 ----------- templates/thoughts.html.j2 | 12 +++++ templates/thoughts.jinja | 12 ----- 22 files changed, 332 insertions(+), 330 deletions(-) create mode 100755 templates/discord.html.j2 delete mode 100755 templates/discord.jinja create mode 100755 templates/index.html.j2 delete mode 100755 templates/index.jinja create mode 100755 templates/isocd.html.j2 delete mode 100755 templates/isocd.jinja create mode 100755 templates/isocd_confirmation.html.j2 delete mode 100755 templates/isocd_confirmation.jinja create mode 100755 templates/nhdl.html.j2 delete mode 100755 templates/nhdl.jinja create mode 100755 templates/random.html.j2 delete mode 100755 templates/random.jinja create mode 100755 templates/services.html.j2 delete mode 100755 templates/services.jinja create mode 100755 templates/template.html.j2 delete mode 100755 templates/template.jinja create mode 100755 templates/thought.html.j2 delete mode 100755 templates/thought.jinja create mode 100755 templates/thoughts.html.j2 delete mode 100755 templates/thoughts.jinja diff --git a/app.py b/app.py index bc99d03..e06ac8e 100755 --- a/app.py +++ b/app.py @@ -55,7 +55,7 @@ def index(): with database.Database() as db: with open(os.path.join("static", "index.md"), "r") as f: return flask.render_template( - "index.jinja", + "index.html.j2", **get_template_items("eden's site :3", db), markdown = parser.parse_text(f.read())[0], featured_thoughts = db.get_featured_thoughts(), @@ -71,7 +71,7 @@ def robots(): def discord(): with database.Database() as db: return flask.render_template( - "discord.jinja", + "discord.html.j2", **get_template_items("discord", db), discord = CONFIG["discord"]["username"] ) @@ -80,10 +80,9 @@ def discord(): def serve_services(): with database.Database() as db: return flask.render_template( - "services.jinja", + "services.html.j2", **get_template_items("services", db), docker = services.get_docker_stats(), - qbit = services.get_qbit_stats(), trans = services.get_trans_stats(), pihole = services.get_pihole_stats() ) @@ -99,7 +98,7 @@ def get_thought(): flask.abort(404) return return flask.render_template( - "thought.jinja", + "thought.html.j2", **get_template_items(title, db), md_html = parsed, contents_html = headers, @@ -121,7 +120,7 @@ def get_thoughts(): tree[category].append((id_, title, str(dt))) return flask.render_template( - "thoughts.jinja", + "thoughts.html.j2", **get_template_items("thoughts", db), tree = tree ) @@ -155,7 +154,7 @@ def serve_nhdl(): except (KeyError, ValueError): return flask.render_template( - "nhdl.jinja", + "nhdl.html.j2", **get_template_items("Hentai Downloader", db) ) @@ -163,7 +162,7 @@ def serve_nhdl(): def serve_iso_form(): with database.Database() as db: return flask.render_template( - "isocd.jinja", + "isocd.html.j2", **get_template_items("Get a GNU/Linux install CD", db), iso_options = db.get_iso_cd_options() ) @@ -188,7 +187,7 @@ def get_iso_cd(): id_ = db.append_cd_orders(**req) print(id_) return flask.render_template( - "isocd_confirmation.jinja", + "isocd_confirmation.html.j2", **get_template_items("Get a GNU/Linux install CD", db), email = req["email"], req = req, @@ -210,7 +209,7 @@ def serve_random(): with database.Database() as db: return flask.render_template( - "random.jinja", + "random.html.j2", **get_template_items("random image", db), sbi = sbi, localimg = "/img/random.jpg?seed=%i" % random.randint(0, 9999) @@ -222,7 +221,7 @@ def preview(): if "PREVIEW" in os.environ: with database.Database() as db: return flask.render_template_string( - '{% extends "template.jinja" %}\n{% block content %}\n' + os.environ["PREVIEW"] + '\n{% endblock %}', + '{% extends "template.html.j2" %}\n{% block content %}\n' + os.environ["PREVIEW"] + '\n{% endblock %}', **get_template_items(os.environ["PREVIEW_TITLE"], db), thought = True, dt = "preview rendered: " + str(datetime.datetime.now()), diff --git a/services.py b/services.py index 681c82a..3680216 100755 --- a/services.py +++ b/services.py @@ -70,6 +70,7 @@ def get_docker_stats(): for container in client.containers.list(all = True) } +# currently unused @timeout def get_qbit_stats(): numtorrents = 0 @@ -98,11 +99,13 @@ def get_trans_stats(): # password = app.CONFIG["transmission"]["passwd"] ) stats = json.loads(client.session.stats().json()) + active_for = datetime.timedelta(seconds = stats["arguments"]["cumulative_stats"]["seconds_active"]) return { "bytes_dl": humanbytes(stats["arguments"]["cumulative_stats"]["downloaded_bytes"]), "bytes_up": humanbytes(stats["arguments"]["cumulative_stats"]["uploaded_bytes"]), "num": stats["arguments"]["torrent_count"], - "ratio": "%.3f" % (float(stats["arguments"]["cumulative_stats"]["uploaded_bytes"]) / float(stats["arguments"]["cumulative_stats"]["downloaded_bytes"])) + "ratio": "%.3f" % (float(stats["arguments"]["cumulative_stats"]["uploaded_bytes"]) / float(stats["arguments"]["cumulative_stats"]["downloaded_bytes"])), + "active_for": str(active_for) } @timeout @@ -228,8 +231,4 @@ def link_deleted(url): return text[text.find("") + 7 : text.find("")] in ["Error | nitter", "イラストコミュニケーションサービス[pixiv]"] if __name__ == "__main__": - sbi = get_random_image(["lio_fotia", "promare"]) - print(sbi.tags) - print(sbi.source) - print(sbi.imurl) - print(sbi.remove_tag("promare")) + print(get_trans_stats()) diff --git a/templates/discord.html.j2 b/templates/discord.html.j2 new file mode 100755 index 0000000..597fb4b --- /dev/null +++ b/templates/discord.html.j2 @@ -0,0 +1,5 @@ +{% extends "template.html.j2" %} +{% block content %} +

You can contact me on discord (telegram preferred):

+

{{discord}}

+ {% endblock %} \ No newline at end of file diff --git a/templates/discord.jinja b/templates/discord.jinja deleted file mode 100755 index 73d6ea3..0000000 --- a/templates/discord.jinja +++ /dev/null @@ -1,5 +0,0 @@ -{% extends "template.jinja" %} -{% block content %} -

You can contact me on discord (telegram preferred):

-

{{discord}}

- {% endblock %} \ No newline at end of file diff --git a/templates/index.html.j2 b/templates/index.html.j2 new file mode 100755 index 0000000..31c6207 --- /dev/null +++ b/templates/index.html.j2 @@ -0,0 +1,36 @@ +{% extends "template.html.j2" %} +{% block content %} + + {{markdown|safe}} + {% if tweets != None %} +
+

recent tweets

+ +
+ {% endif %} +
+

recent git commits:

+ +
+{% endblock %} \ No newline at end of file diff --git a/templates/index.jinja b/templates/index.jinja deleted file mode 100755 index 5a2acb7..0000000 --- a/templates/index.jinja +++ /dev/null @@ -1,36 +0,0 @@ -{% extends "template.jinja" %} -{% block content %} - - {{markdown|safe}} - {% if tweets != None %} -
-

recent tweets

- -
- {% endif %} -
-

recent git commits:

- -
-{% endblock %} \ No newline at end of file diff --git a/templates/isocd.html.j2 b/templates/isocd.html.j2 new file mode 100755 index 0000000..3c532c0 --- /dev/null +++ b/templates/isocd.html.j2 @@ -0,0 +1,32 @@ +{% extends "template.html.j2" %} +{% block content %} +

As discussed here, I will post a GNU/Linux install CD to you for free (provided you live in the United Kingdom). Just fill out the form below:

+
+ +

+ +

+

Sadly there is an upper limit on ISOs of 700Mb coz thats what u can fit on a cd ;_; so big isos arent listed


+ +

+ +

+ +

+ +

+ +

+ +

+ +
+

I make no promises how long this will actually take, but you might get a special present too uwu

+

btw if u abuse this service i'll just ignore u

+

Testimonials

+ +{% endblock %} \ No newline at end of file diff --git a/templates/isocd.jinja b/templates/isocd.jinja deleted file mode 100755 index ee8ac61..0000000 --- a/templates/isocd.jinja +++ /dev/null @@ -1,32 +0,0 @@ -{% extends "template.jinja" %} -{% block content %} -

As discussed here, I will post a GNU/Linux install CD to you for free (provided you live in the United Kingdom). Just fill out the form below:

-
- -

- -

-

Sadly there is an upper limit on ISOs of 700Mb coz thats what u can fit on a cd ;_; so big isos arent listed


- -

- -

- -

- -

- -

- -

- -
-

I make no promises how long this will actually take, but you might get a special present too uwu

-

btw if u abuse this service i'll just ignore u

-

Testimonials

- -{% endblock %} \ No newline at end of file diff --git a/templates/isocd_confirmation.html.j2 b/templates/isocd_confirmation.html.j2 new file mode 100755 index 0000000..81045a8 --- /dev/null +++ b/templates/isocd_confirmation.html.j2 @@ -0,0 +1,16 @@ +{% extends "template.html.j2" %} +{% block content %} +

Your order has been placed. Expect a confirmation email to {{ email }} when I can be bothered to sort it out.

+
+

Your order/reference id is {{ id_ }}

+
+

The details were as follows:

+ + {% for k, v in req.items() %} + + + + + {% endfor %} +
{{ k.upper() }}{{ v }}
+{% endblock %} \ No newline at end of file diff --git a/templates/isocd_confirmation.jinja b/templates/isocd_confirmation.jinja deleted file mode 100755 index bed09d6..0000000 --- a/templates/isocd_confirmation.jinja +++ /dev/null @@ -1,16 +0,0 @@ -{% extends "template.jinja" %} -{% block content %} -

Your order has been placed. Expect a confirmation email to {{ email }} when I can be bothered to sort it out.

-
-

Your order/reference id is {{ id_ }}

-
-

The details were as follows:

- - {% for k, v in req.items() %} - - - - - {% endfor %} -
{{ k.upper() }}{{ v }}
-{% endblock %} \ No newline at end of file diff --git a/templates/nhdl.html.j2 b/templates/nhdl.html.j2 new file mode 100755 index 0000000..5ab62c2 --- /dev/null +++ b/templates/nhdl.html.j2 @@ -0,0 +1,8 @@ +{% extends "template.html.j2" %} +{% block content %} +
+ +

+ +
+{% endblock %} \ No newline at end of file diff --git a/templates/nhdl.jinja b/templates/nhdl.jinja deleted file mode 100755 index a4e4d56..0000000 --- a/templates/nhdl.jinja +++ /dev/null @@ -1,8 +0,0 @@ -{% extends "template.jinja" %} -{% block content %} -
- -

- -
-{% endblock %} \ No newline at end of file diff --git a/templates/random.html.j2 b/templates/random.html.j2 new file mode 100755 index 0000000..76b433b --- /dev/null +++ b/templates/random.html.j2 @@ -0,0 +1,22 @@ +{% extends "template.html.j2" %} +{% block content %} + +
+ +

generate another

+

artist link

+
+{% endblock %} \ No newline at end of file diff --git a/templates/random.jinja b/templates/random.jinja deleted file mode 100755 index 1bc7eb8..0000000 --- a/templates/random.jinja +++ /dev/null @@ -1,22 +0,0 @@ -{% extends "template.jinja" %} -{% block content %} - -
- -

generate another

-

artist link

-
-{% endblock %} \ No newline at end of file diff --git a/templates/services.html.j2 b/templates/services.html.j2 new file mode 100755 index 0000000..35d47ae --- /dev/null +++ b/templates/services.html.j2 @@ -0,0 +1,99 @@ +{% extends "template.html.j2" %} +{% block content %} +
+
+

docker

+ {% if docker == None %} +

Couldn't access the docker API. Is sherpa running?

+ {% else %} + + {% for name, status in docker.items() %} + + + {% if status == "running" %} + + {% else %} + + {% endif %} + + {% endfor %} +
{{name}}{{status}}{{status}}
+ {% endif %} +
+
+

transmission

+ {% if trans == None %} +

Couldn't access the transmission API. Is docker container running?

+ {% else %} + + + + + + + + + + + + + + + + + + + + + +
downloaded{{trans["bytes_dl"]}}
uploaded{{trans["bytes_up"]}}
torrents{{trans["num"]}}
ratio{{trans["ratio"]}}
active for{{trans["active_for"]}}
+ {% endif %} +
+ statistics of my two old torrent clients which were shut down recently ;_; +
+ + +
+
+

pihole

+ {% if pihole == None %} +

Couldn't access the pihole API. Is docker container running?

+ {% else %} + + + + {% if pihole["status"] == "enabled" %} + + {% else %} + + {% endif %} + + + + + + + + + + + + + + + + + + + + + + + + + +
status{{pihole["status"]}}{{pihole["status"]}}
queries{{pihole["queries"]}}
clients{{pihole["clients"]}}
percentage blocked{{pihole["percentage"]}}%
blocked requests{{pihole["blocked"]}}
domains in blocklist{{pihole["domains"]}}
last updated{{pihole["last_updated"]}}
+ {% endif %} +
+
+{% endblock %} \ No newline at end of file diff --git a/templates/services.jinja b/templates/services.jinja deleted file mode 100755 index 310d148..0000000 --- a/templates/services.jinja +++ /dev/null @@ -1,95 +0,0 @@ -{% extends "template.jinja" %} -{% block content %} -
-
-

docker

- {% if docker == None %} -

Couldn't access the docker API. Is sherpa running?

- {% else %} - - {% for name, status in docker.items() %} - - - {% if status == "running" %} - - {% else %} - - {% endif %} - - {% endfor %} -
{{name}}{{status}}{{status}}
- {% endif %} -
-
-

transmission

- {% if trans == None %} -

Couldn't access the transmission API. Is docker container running?

- {% else %} - - - - - - - - - - - - - - - - - -
downloaded{{trans["bytes_dl"]}}
uploaded{{trans["bytes_up"]}}
torrents{{trans["num"]}}
ratio{{trans["ratio"]}}
- {% endif %} -
- - -
- statistics of my two old torrent clients which were shut down recently ;_; -
-
-

pihole

- {% if pihole == None %} -

Couldn't access the pihole API. Is docker container running?

- {% else %} - - - - {% if pihole["status"] == "enabled" %} - - {% else %} - - {% endif %} - - - - - - - - - - - - - - - - - - - - - - - - - -
status{{pihole["status"]}}{{pihole["status"]}}
queries{{pihole["queries"]}}
clients{{pihole["clients"]}}
percentage blocked{{pihole["percentage"]}}%
blocked requests{{pihole["blocked"]}}
domains in blocklist{{pihole["domains"]}}
last updated{{pihole["last_updated"]}}
- {% endif %} -
-
-{% endblock %} \ No newline at end of file diff --git a/templates/template.html.j2 b/templates/template.html.j2 new file mode 100755 index 0000000..2fd86f9 --- /dev/null +++ b/templates/template.html.j2 @@ -0,0 +1,58 @@ + + + + + + + eda.gay :: {{title}} + + +
+
+ +
+
+

{{title}}

+ +
+ + {{image[0]}} + +
+
+
+ {% block content %} + {% endblock %} +
+ +
+ + diff --git a/templates/template.jinja b/templates/template.jinja deleted file mode 100755 index 2fd86f9..0000000 --- a/templates/template.jinja +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - eda.gay :: {{title}} - - -
-
- -
-
-

{{title}}

- -
- - {{image[0]}} - -
-
-
- {% block content %} - {% endblock %} -
- -
- - diff --git a/templates/thought.html.j2 b/templates/thought.html.j2 new file mode 100755 index 0000000..2a5b519 --- /dev/null +++ b/templates/thought.html.j2 @@ -0,0 +1,29 @@ +{% extends "template.html.j2" %} +{% block content %} + + {{ md_html|safe }} +{% endblock %} \ No newline at end of file diff --git a/templates/thought.jinja b/templates/thought.jinja deleted file mode 100755 index df6fe7a..0000000 --- a/templates/thought.jinja +++ /dev/null @@ -1,29 +0,0 @@ -{% extends "template.jinja" %} -{% block content %} - - {{ md_html|safe }} -{% endblock %} \ No newline at end of file diff --git a/templates/thoughts.html.j2 b/templates/thoughts.html.j2 new file mode 100755 index 0000000..bf06f57 --- /dev/null +++ b/templates/thoughts.html.j2 @@ -0,0 +1,12 @@ +{% extends "template.html.j2" %} +{% block content %} + {% for category_name, thoughts in tree.items() %} +

{{category_name}}

+
+ {% for id_, title, dt in thoughts %} +
{{title}}
+
{{dt}}
+ {% endfor %} +
+ {% endfor %} +{% endblock %} \ No newline at end of file diff --git a/templates/thoughts.jinja b/templates/thoughts.jinja deleted file mode 100755 index 0a1e4de..0000000 --- a/templates/thoughts.jinja +++ /dev/null @@ -1,12 +0,0 @@ -{% extends "template.jinja" %} -{% block content %} - {% for category_name, thoughts in tree.items() %} -

{{category_name}}

-
- {% for id_, title, dt in thoughts %} -
{{title}}
-
{{dt}}
- {% endfor %} -
- {% endfor %} -{% endblock %} \ No newline at end of file -- cgit v1.2.3