From cf536a860cf03fd082743e0c6225d6fdc064c7a9 Mon Sep 17 00:00:00 2001 From: lichenblankie Date: Fri, 27 Mar 2026 10:59:37 -0700 Subject: [PATCH] added junimo theme, bumped browse to 50 --- app.py | 2 +- handlers.py | 20 +- themes/junimo.html | 1625 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1637 insertions(+), 10 deletions(-) create mode 100644 themes/junimo.html diff --git a/app.py b/app.py index 4b3fb5e..9f09a59 100644 --- a/app.py +++ b/app.py @@ -4,7 +4,7 @@ import threading import RNS from http.server import HTTPServer -from db import init_db, set_setting +from db import init_db, get_setting, set_setting from handlers import dispatch_request from gateway import GatewayState, GatewayHandler, GATEWAY_PORT diff --git a/handlers.py b/handlers.py index abd0d13..2f6f31f 100644 --- a/handlers.py +++ b/handlers.py @@ -116,6 +116,7 @@ def _error(status): PER_PAGE = 10 +BROWSE_PER_PAGE = 50 def _paginate(query, key="p"): @@ -126,10 +127,11 @@ def _paginate(query, key="p"): return max(1, page) -def _page_nav(page, total, base_url): - if total <= PER_PAGE: +def _page_nav(page, total, base_url, per_page=None): + per_page = per_page or PER_PAGE + if total <= per_page: return "" - total_pages = (total + PER_PAGE - 1) // PER_PAGE + total_pages = (total + per_page - 1) // per_page sep = "&" if "?" in base_url else "?" parts = [] if page > 1: @@ -377,13 +379,13 @@ def handle_add_submit(body): def handle_pages(query=None): page = _paginate(query or {}) - offset = (page - 1) * PER_PAGE + offset = (page - 1) * BROWSE_PER_PAGE db = get_db() try: total = db.execute("SELECT count(*) FROM pages").fetchone()[0] rows = db.execute( "SELECT id, url, title, note FROM pages ORDER BY id DESC LIMIT ? OFFSET ?", - (PER_PAGE, offset), + (BROWSE_PER_PAGE, offset), ).fetchall() items = "" for r in rows: @@ -404,7 +406,7 @@ def handle_pages(query=None): return _respond( f"

indexed pages ({total})

" f"" - f'{_page_nav(page, total, "/pages")}' + f'{_page_nav(page, total, "/pages", BROWSE_PER_PAGE)}' f'

export | import

' f'back' ) @@ -678,7 +680,7 @@ def handle_tags(): def handle_tag_browse(tag_name, query=None): page = _paginate(query or {}) - offset = (page - 1) * PER_PAGE + offset = (page - 1) * BROWSE_PER_PAGE db = get_db() try: total = db.execute( @@ -690,7 +692,7 @@ def handle_tag_browse(tag_name, query=None): "JOIN page_tags pt ON p.id = pt.page_id " "JOIN tags t ON t.id = pt.tag_id " "WHERE t.name = ? ORDER BY p.id DESC LIMIT ? OFFSET ?", - (tag_name, PER_PAGE, offset), + (tag_name, BROWSE_PER_PAGE, offset), ).fetchall() items = "" for r in rows: @@ -707,7 +709,7 @@ def handle_tag_browse(tag_name, query=None): f'

tag: {esc(tag_name)}

' f'

{total} page(s)

' f'' - f'{_page_nav(page, total, f"/tags/{esc(tag_name)}")}' + f'{_page_nav(page, total, f"/tags/{esc(tag_name)}", BROWSE_PER_PAGE)}' f'all tags | back' ) diff --git a/themes/junimo.html b/themes/junimo.html new file mode 100644 index 0000000..25688b7 --- /dev/null +++ b/themes/junimo.html @@ -0,0 +1,1625 @@ + + + + + + + + + + + + +
+
+
+ +
+
+
+
+
+
+ +
+
+
+ G +
+ +
+
+
+
+ E + +
+
+
+
+ +
+
+ {{content}} +
+
+
curated by hand · shared over mesh
+
+
+
+ + +