commit - 9bfc216b59d0136876cfb9a75353054d0c0518a6
commit + 7c41d2555ab3a031a8ec5b52779a65413fc33939
blob - cc2de86de87a68e6d41f4b2a9cbc8e9ec8ea924b
blob + 0ef848b046556ce47cd1009940c80817b1a60558
--- lonk.py
+++ lonk.py
url TEXT,
html TEXT,
date TEXT,
+ public INTEGER,
FOREIGN KEY (client_id) REFERENCES client (client_id),
UNIQUE (convoy, client_id),
UNIQUE (honk_id, client_id)
class _LonkTreeItem:
- def __init__(self, convoy_id, convoy, honk_id, honker, url, html, date):
+ def __init__(self, convoy_id, convoy, honk_id, honker, url, html, date, public):
self.convoy_id = convoy_id
self.convoy = convoy
self.honk_id = honk_id
self.url = url
self.html = html
self.date = date
+ self.public = bool(public)
self.donks = []
self.reposters = []
self.thread = []
"XID": self.url,
"HTML": self.html,
"Date": self.date,
+ "Public": self.public,
"Donks": [
{"URL": donk[0], "Media": donk[1], "Desc": donk[2]}
for donk in self.donks
if convoy not in lonk_page:
row = db_con.execute(
- "SELECT convoy_id, convoy, honk_id, honker, url, html, date FROM convoy WHERE client_id=? AND convoy=?",
+ "SELECT convoy_id, convoy, honk_id, honker, url, html, date, public FROM convoy WHERE client_id=? AND convoy=?",
(client_id, convoy)
).fetchone()
if row:
if convoy not in lonk_page:
def _save_convoy(convoy, honker, honk):
+ is_public = 1 if honk.get("Public") else 0
row = db_con.execute(
"""
INSERT INTO
- convoy(convoy, client_id, honk_id, honker, url, html, date)
+ convoy(convoy, client_id, honk_id, honker, url, html, date, public)
VALUES
- (?, ?, ?, ?, ?, ?, ?)
+ (?, ?, ?, ?, ?, ?, ?, ?)
RETURNING
convoy_id
""",
- (convoy, client_id, honk["ID"], honker, honk["XID"], honk["HTML"], honk["Date"])
+ (convoy, client_id, honk["ID"], honker, honk["XID"], honk["HTML"], honk["Date"], is_public)
).fetchone()
convoy_id, = row
lonk_page[convoy] = _LonkTreeItem(
- convoy_id, convoy, honk["ID"], honker, honk["XID"], honk["HTML"], honk["Date"]
+ convoy_id, convoy, honk["ID"], honker, honk["XID"], honk["HTML"], honk["Date"], is_public
)
for donk in (honk.get("Donks") or []):
def _menu():
print(f"=> {honk_url.build_url(path='newhonk')} new honk\r")
+ print(f"=> {lonk_url.build([])} lonk home\r")
line = f"=> {lonk_url.build('atme')} @me"
if gethonks_answer["mecount"]:
line += f' ({gethonks_answer["mecount"]})'
if donk_text:
lines.append(donk_text)
lines.append("")
- lines.append(f'=> {lonk_url.build("bonk", urlencode({"w": honk["XID"]}))} ↺ bonk')
+ if honk.get("Public"):
+ lines.append(f'=> {lonk_url.build("bonk", urlencode({"w": honk["XID"]}))} ↺ bonk')
lines.append(f'=> {honk_url.build_url(path="newhonk", query=urlencode({"rid": honk["XID"]}))} ↱ honk back')
print("\r\n".join(lines))
print("\r")