From 3ef82c8024aeda826679a65803ce5bed0e454e61 Mon Sep 17 00:00:00 2001 From: xenofem Date: Tue, 23 Jan 2024 00:49:58 -0500 Subject: [PATCH] add work overview pages --- dlibrary/dlibrary.py | 8 ++++-- dlibrary/static/dlibrary.css | 37 +++++++++++++++++++++++- dlibrary/static/viewer.js | 2 +- dlibrary/templates/categorization.html | 7 +++-- dlibrary/templates/list.html | 4 +-- dlibrary/templates/nav.html | 2 ++ dlibrary/templates/utils.html | 1 + dlibrary/templates/viewer.html | 1 - dlibrary/templates/work.html | 40 ++++++++++++++++++++++++++ 9 files changed, 92 insertions(+), 10 deletions(-) create mode 100644 dlibrary/templates/nav.html create mode 100644 dlibrary/templates/work.html diff --git a/dlibrary/dlibrary.py b/dlibrary/dlibrary.py index 8959eb5..a24638d 100755 --- a/dlibrary/dlibrary.py +++ b/dlibrary/dlibrary.py @@ -309,6 +309,7 @@ def publish(args): viewer_template = jenv.get_template("viewer.html") list_template = jenv.get_template("list.html") categorization_template = jenv.get_template("categorization.html") + work_template = jenv.get_template("work.html") con = sqlite3.connect(args.destdir / 'meta.db') cur = con.cursor() @@ -339,9 +340,12 @@ def publish(args): images.sort() work_dir = args.destdir / 'site' / 'works' / work_id - work_dir.mkdir(parents=True, exist_ok=True) + viewer_dir = work_dir / 'view' + viewer_dir.mkdir(parents=True, exist_ok=True) with open(work_dir / 'index.html', 'w') as f: - f.write(viewer_template.render(depth=2, work=work, title=title, images=images)) + f.write(work_template.render(depth=2, work=work, title=title, images=images)) + with open(viewer_dir / 'index.html', 'w') as f: + f.write(viewer_template.render(depth=3, work=work, title=title, images=images)) def make_categorization(categorization, query, work_filter): categorization_dir = args.destdir / 'site' / categorization diff --git a/dlibrary/static/dlibrary.css b/dlibrary/static/dlibrary.css index c2a8275..d02110d 100644 --- a/dlibrary/static/dlibrary.css +++ b/dlibrary/static/dlibrary.css @@ -2,11 +2,12 @@ body { background: #111; color: #eee; font-family: sans-serif; + font-size: 18px; } /* listing stuff */ -#list-title, nav { +#title, nav { text-align: center; } @@ -46,6 +47,40 @@ body { max-width: 240px; } +/* work stuff */ + +.work-container { + display: flex; + justify-content: center; + gap: 30px; +} + +.work-info { + max-width: min(50%, 500px); +} + +.work-info td, .work-info th { + vertical-align: top; +} + +.work-info td { + padding-top: 5px; +} + +.work-info th { + text-align: right; + padding-right: 10px; + padding-top: 10px; +} + +.work-info-link { + background: #333; + padding: 5px; + border-radius: 5px; + display: inline-block; + margin-bottom: 5px; +} + /* viewer stuff */ #viewer-images { diff --git a/dlibrary/static/viewer.js b/dlibrary/static/viewer.js index 89760d2..f2dd772 100644 --- a/dlibrary/static/viewer.js +++ b/dlibrary/static/viewer.js @@ -113,7 +113,7 @@ document.addEventListener('DOMContentLoaded', () => { case 13: //enter changeDuration(duration, true); localStorage.setItem(`${WORK_ID}-currentPage`, 0); - window.location.href = ROOT; + window.location.href = "../"; break; } }; diff --git a/dlibrary/templates/categorization.html b/dlibrary/templates/categorization.html index 0aaf4c7..3a5a3ac 100644 --- a/dlibrary/templates/categorization.html +++ b/dlibrary/templates/categorization.html @@ -1,12 +1,13 @@ {% extends "base.html" %} {% block title %}{{ categorization.capitalize() }} - DLibrary{% endblock %} {% block body %} -{% from 'utils.html' import root with context %} -

DLibrary > {{ categorization.capitalize() }}

+{% from 'utils.html' import urlcat, root with context %} +

DLibrary > {{ categorization.capitalize() }}

+{% include 'nav.html' %}
{% for cat in categories %}
- +
{{ cat }}
diff --git a/dlibrary/templates/list.html b/dlibrary/templates/list.html index 1d5b15b..f882c21 100644 --- a/dlibrary/templates/list.html +++ b/dlibrary/templates/list.html @@ -1,8 +1,8 @@ {% extends 'base.html' %} {% block body %} {% from 'utils.html' import root with context %} -

DLibrary{% if categorization %} > {{ categorization.capitalize() }}{% endif %}{% if title %} > {{ title }}{% endif %}

- +

DLibrary{% if categorization %} > {{ categorization.capitalize() }}{% endif %}{% if title %} > {{ title }}{% endif %}

+{% include 'nav.html' %}
{% for work in works %}
diff --git a/dlibrary/templates/nav.html b/dlibrary/templates/nav.html new file mode 100644 index 0000000..cbd9527 --- /dev/null +++ b/dlibrary/templates/nav.html @@ -0,0 +1,2 @@ +{% from 'utils.html' import root with context %} + diff --git a/dlibrary/templates/utils.html b/dlibrary/templates/utils.html index 7990bda..10ccd00 100644 --- a/dlibrary/templates/utils.html +++ b/dlibrary/templates/utils.html @@ -1 +1,2 @@ {% macro root() %}{% for i in range(depth) %}../{% endfor %}{% endmacro %} +{% macro urlcat(s) %}{{ s | replace('/', ' ') | urlencode }}{% endmacro %} diff --git a/dlibrary/templates/viewer.html b/dlibrary/templates/viewer.html index 3ff1918..77f8076 100644 --- a/dlibrary/templates/viewer.html +++ b/dlibrary/templates/viewer.html @@ -4,7 +4,6 @@ {% endblock %} diff --git a/dlibrary/templates/work.html b/dlibrary/templates/work.html new file mode 100644 index 0000000..b9e568c --- /dev/null +++ b/dlibrary/templates/work.html @@ -0,0 +1,40 @@ +{% extends 'base.html' %} +{% block body %} +{% from 'utils.html' import urlcat, root with context %} +

DL > {{ title }}

+
+
+ + + +
+
+ + {% if work['circle'] %} + + + + + {% endif %} + {% if work['authors'] %} + + + + + {% endif %} + {% if work['tags'] %} + + + + + {% endif %} + {% if work['series'] %} + + + + + {% endif %} +
Circle{{ work['circle'] }}
Authors{% for author in work['authors'] %}{{ author }} {% endfor %}
Tags{% for tag in work['tags'] %}{{ tag }} {% endfor %}
Series{{ work['series'] }}
+
+
+{% endblock %}