Add junimo theme and increase browse page size to 50
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
395fc17092
commit
299735f816
3 changed files with 1637 additions and 10 deletions
2
app.py
2
app.py
|
|
@ -4,7 +4,7 @@ import threading
|
||||||
import RNS
|
import RNS
|
||||||
from http.server import HTTPServer
|
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 handlers import dispatch_request
|
||||||
from gateway import GatewayState, GatewayHandler, GATEWAY_PORT
|
from gateway import GatewayState, GatewayHandler, GATEWAY_PORT
|
||||||
|
|
||||||
|
|
|
||||||
20
handlers.py
20
handlers.py
|
|
@ -116,6 +116,7 @@ def _error(status):
|
||||||
|
|
||||||
|
|
||||||
PER_PAGE = 10
|
PER_PAGE = 10
|
||||||
|
BROWSE_PER_PAGE = 50
|
||||||
|
|
||||||
|
|
||||||
def _paginate(query, key="p"):
|
def _paginate(query, key="p"):
|
||||||
|
|
@ -126,10 +127,11 @@ def _paginate(query, key="p"):
|
||||||
return max(1, page)
|
return max(1, page)
|
||||||
|
|
||||||
|
|
||||||
def _page_nav(page, total, base_url):
|
def _page_nav(page, total, base_url, per_page=None):
|
||||||
if total <= PER_PAGE:
|
per_page = per_page or PER_PAGE
|
||||||
|
if total <= per_page:
|
||||||
return ""
|
return ""
|
||||||
total_pages = (total + PER_PAGE - 1) // PER_PAGE
|
total_pages = (total + per_page - 1) // per_page
|
||||||
sep = "&" if "?" in base_url else "?"
|
sep = "&" if "?" in base_url else "?"
|
||||||
parts = []
|
parts = []
|
||||||
if page > 1:
|
if page > 1:
|
||||||
|
|
@ -377,13 +379,13 @@ def handle_add_submit(body):
|
||||||
|
|
||||||
def handle_pages(query=None):
|
def handle_pages(query=None):
|
||||||
page = _paginate(query or {})
|
page = _paginate(query or {})
|
||||||
offset = (page - 1) * PER_PAGE
|
offset = (page - 1) * BROWSE_PER_PAGE
|
||||||
db = get_db()
|
db = get_db()
|
||||||
try:
|
try:
|
||||||
total = db.execute("SELECT count(*) FROM pages").fetchone()[0]
|
total = db.execute("SELECT count(*) FROM pages").fetchone()[0]
|
||||||
rows = db.execute(
|
rows = db.execute(
|
||||||
"SELECT id, url, title, note FROM pages ORDER BY id DESC LIMIT ? OFFSET ?",
|
"SELECT id, url, title, note FROM pages ORDER BY id DESC LIMIT ? OFFSET ?",
|
||||||
(PER_PAGE, offset),
|
(BROWSE_PER_PAGE, offset),
|
||||||
).fetchall()
|
).fetchall()
|
||||||
items = ""
|
items = ""
|
||||||
for r in rows:
|
for r in rows:
|
||||||
|
|
@ -404,7 +406,7 @@ def handle_pages(query=None):
|
||||||
return _respond(
|
return _respond(
|
||||||
f"<h1>indexed pages ({total})</h1>"
|
f"<h1>indexed pages ({total})</h1>"
|
||||||
f"<ul>{items}</ul>"
|
f"<ul>{items}</ul>"
|
||||||
f'{_page_nav(page, total, "/pages")}'
|
f'{_page_nav(page, total, "/pages", BROWSE_PER_PAGE)}'
|
||||||
f'<p><a href="/export">export</a> | <a href="/import">import</a></p>'
|
f'<p><a href="/export">export</a> | <a href="/import">import</a></p>'
|
||||||
f'<a href="/">back</a>'
|
f'<a href="/">back</a>'
|
||||||
)
|
)
|
||||||
|
|
@ -678,7 +680,7 @@ def handle_tags():
|
||||||
|
|
||||||
def handle_tag_browse(tag_name, query=None):
|
def handle_tag_browse(tag_name, query=None):
|
||||||
page = _paginate(query or {})
|
page = _paginate(query or {})
|
||||||
offset = (page - 1) * PER_PAGE
|
offset = (page - 1) * BROWSE_PER_PAGE
|
||||||
db = get_db()
|
db = get_db()
|
||||||
try:
|
try:
|
||||||
total = db.execute(
|
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 page_tags pt ON p.id = pt.page_id "
|
||||||
"JOIN tags t ON t.id = pt.tag_id "
|
"JOIN tags t ON t.id = pt.tag_id "
|
||||||
"WHERE t.name = ? ORDER BY p.id DESC LIMIT ? OFFSET ?",
|
"WHERE t.name = ? ORDER BY p.id DESC LIMIT ? OFFSET ?",
|
||||||
(tag_name, PER_PAGE, offset),
|
(tag_name, BROWSE_PER_PAGE, offset),
|
||||||
).fetchall()
|
).fetchall()
|
||||||
items = ""
|
items = ""
|
||||||
for r in rows:
|
for r in rows:
|
||||||
|
|
@ -707,7 +709,7 @@ def handle_tag_browse(tag_name, query=None):
|
||||||
f'<h1>tag: {esc(tag_name)}</h1>'
|
f'<h1>tag: {esc(tag_name)}</h1>'
|
||||||
f'<p>{total} page(s)</p>'
|
f'<p>{total} page(s)</p>'
|
||||||
f'<ul>{items}</ul>'
|
f'<ul>{items}</ul>'
|
||||||
f'{_page_nav(page, total, f"/tags/{esc(tag_name)}")}'
|
f'{_page_nav(page, total, f"/tags/{esc(tag_name)}", BROWSE_PER_PAGE)}'
|
||||||
f'<a href="/tags">all tags</a> | <a href="/">back</a>'
|
f'<a href="/tags">all tags</a> | <a href="/">back</a>'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
1625
themes/junimo.html
Normal file
1625
themes/junimo.html
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue