added an about page with slow-web pitch
Shows instance stats, destination hash for subscribing, and explains the slow web movement and how TinyWeb works. Destination hash is stored in settings on startup so the about page can display it.
This commit is contained in:
parent
acfa9f6d4f
commit
5480d84500
2 changed files with 58 additions and 2 deletions
3
app.py
3
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
|
from db import init_db, 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
|
||||||
|
|
||||||
|
|
@ -55,6 +55,7 @@ def main():
|
||||||
)
|
)
|
||||||
|
|
||||||
destination.announce()
|
destination.announce()
|
||||||
|
set_setting("dest_hash", destination.hash.hex())
|
||||||
start_gateway(reticulum)
|
start_gateway(reticulum)
|
||||||
|
|
||||||
print(f"TinyWeb running!")
|
print(f"TinyWeb running!")
|
||||||
|
|
|
||||||
57
handlers.py
57
handlers.py
|
|
@ -196,7 +196,8 @@ def handle_search(query):
|
||||||
f' | <a href="/pages">browse</a>'
|
f' | <a href="/pages">browse</a>'
|
||||||
f' | <a href="/tags">tags</a>'
|
f' | <a href="/tags">tags</a>'
|
||||||
f' | <a href="/subscriptions">subscriptions</a>'
|
f' | <a href="/subscriptions">subscriptions</a>'
|
||||||
f' | <a href="/style">customize</a></p>'
|
f' | <a href="/style">customize</a>'
|
||||||
|
f' | <a href="/about">about</a></p>'
|
||||||
f'<hr>{result_html}{trusted_html}{remote_html}'
|
f'<hr>{result_html}{trusted_html}{remote_html}'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -412,6 +413,58 @@ def handle_style_submit(body):
|
||||||
return handle_style_form("Saved.")
|
return handle_style_form("Saved.")
|
||||||
|
|
||||||
|
|
||||||
|
def handle_about():
|
||||||
|
name = get_site_name()
|
||||||
|
dest_hash = get_setting("dest_hash")
|
||||||
|
sharing = get_setting("sharing_enabled", "0") == "1"
|
||||||
|
db = get_db()
|
||||||
|
page_count = db.execute("SELECT count(*) FROM pages").fetchone()[0]
|
||||||
|
tag_count = db.execute("SELECT count(*) FROM tags").fetchone()[0]
|
||||||
|
sub_count = db.execute("SELECT count(*) FROM subscriptions").fetchone()[0]
|
||||||
|
db.close()
|
||||||
|
|
||||||
|
sharing_html = (
|
||||||
|
'<p>This instance shares its index publicly. Subscribe to join the network.</p>'
|
||||||
|
if sharing else
|
||||||
|
'<p>This instance is private.</p>'
|
||||||
|
)
|
||||||
|
|
||||||
|
hash_html = ""
|
||||||
|
if dest_hash:
|
||||||
|
hash_html = (
|
||||||
|
f'<h2>subscribe</h2>'
|
||||||
|
f'<p>To subscribe to this instance, add this destination hash in your TinyWeb:</p>'
|
||||||
|
f'<pre>{esc(dest_hash)}</pre>'
|
||||||
|
)
|
||||||
|
|
||||||
|
return _respond(
|
||||||
|
f'<h1>{esc(name)}</h1>'
|
||||||
|
f'<p>A personal search engine, built for the slow web.</p>'
|
||||||
|
f'<p>TinyWeb is about taking back the internet. No algorithms, no ads, no tracking. '
|
||||||
|
f'Just human-curated pages shared freely across a mesh network.</p>'
|
||||||
|
f'<ul>'
|
||||||
|
f'<li><b>{page_count}</b> page(s) indexed</li>'
|
||||||
|
f'<li><b>{tag_count}</b> tag(s)</li>'
|
||||||
|
f'<li><b>{sub_count}</b> subscription(s)</li>'
|
||||||
|
f'</ul>'
|
||||||
|
f'{sharing_html}'
|
||||||
|
f'{hash_html}'
|
||||||
|
f'<h2>what is the slow web?</h2>'
|
||||||
|
f'<p>The slow web is a movement for intentionality over speed, '
|
||||||
|
f'human curation over algorithmic feeds, privacy over surveillance, '
|
||||||
|
f'and community over corporations. Every page in this index was saved by a person '
|
||||||
|
f'because they found it valuable — not because an algorithm told them to click.</p>'
|
||||||
|
f'<h2>how it works</h2>'
|
||||||
|
f'<ul>'
|
||||||
|
f'<li>Save pages you find valuable with the bookmarklet or /add</li>'
|
||||||
|
f'<li>Search your personal index — queries never leave your machine</li>'
|
||||||
|
f'<li>Subscribe to friends over Reticulum — encrypted, decentralized, works without the internet</li>'
|
||||||
|
f'<li>Tag and organize your collection into curated lists</li>'
|
||||||
|
f'</ul>'
|
||||||
|
f'<p><a href="/">search</a> | <a href="/pages">browse</a> | <a href="/tags">tags</a></p>'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def handle_tags():
|
def handle_tags():
|
||||||
db = get_db()
|
db = get_db()
|
||||||
rows = db.execute(
|
rows = db.execute(
|
||||||
|
|
@ -774,6 +827,8 @@ def dispatch_request(data):
|
||||||
return handle_bookmark(query)
|
return handle_bookmark(query)
|
||||||
elif path == "/style":
|
elif path == "/style":
|
||||||
return handle_style_form()
|
return handle_style_form()
|
||||||
|
elif path == "/about":
|
||||||
|
return handle_about()
|
||||||
elif path == "/export":
|
elif path == "/export":
|
||||||
return handle_export()
|
return handle_export()
|
||||||
elif path == "/import":
|
elif path == "/import":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue