From aecfd2afe9622f5256f67a54105830ba5440fbc8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= jaakko.keranen@iki.fi
Date: Mon, 30 Dec 2024 20:42:35 +0200
Subject: [PATCH 1/1] Added editable license metadata field
booster.py | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/booster.py b/booster.py
index 81eccc1..3af9b7e 100755
--- a/booster.py
+++ b/booster.py
@@ -70,7 +70,7 @@ def report_error(code, msg):
class Tinylog:
TIME_FORMAT = '%Y-%m-%d %H:%M:%S %Z'
MONTH_FORMAT = '/%Y/%m/'
YEAR_FORMAT = '/%Y/'
@@ -80,6 +80,7 @@ class Tinylog:
self.info = ''
self.author = ''
self.avatar = ''
self.license = ''
self.entries = {} # timestamp -> text
self.editable = editable
self.base_url = base_url
@@ -104,6 +105,8 @@ class Tinylog:
self.avatar = line[7:].strip()
elif line.startswith('author:'):
self.author = line[7:].strip()
elif line.startswith('license:'):
self.license = line[8:].strip()
else:
self.info += line
else:
@@ -186,10 +189,12 @@ class Tinylog:
label = time.strftime('%B %Y' if is_recent else '%Y', tm)
output += f'=> gemini://{self.base_url}{cur_month} Archived: {label}\n'
if self.author or self.avatar:
#if self.info: output += '\n'
if self.author:
output += f'author: {self.author}\n'
if self.avatar:
output += f'avatar: {self.avatar}\n'
if self.license:
output += f'license: {self.license}\n'
if is_editable:
output += f'=> gemini://{self.base_url}/edit Edit metadata\n'
output += f'\n=> titan://{self.base_url} New post\n'
@@ -312,6 +317,9 @@ for file_group in CONFIG['files']:
print()
print(tinylog.avatar)
print(f'=> gemini://{tinylog.base_url}/avatar Edit avatar')
print()
print(tinylog.license)
print(f'=> gemini://{tinylog.base_url}/license Edit license')
sys.exit(0)
if path_info == '/title' and is_authorized:
@@ -347,6 +355,17 @@ for file_group in CONFIG['files']:
tinylog.write()
report_error(30, f'gemini://{tinylog.base_url}/edit')
if path_info == '/license' and is_authorized:
if not req_query:
report_error(10, 'Enter license:')
elif req_query == '-':
req_query = ''
else:
req_query = req_query.strip()
tinylog.license = req_query
tinylog.write()
report_error(30, f'gemini://{tinylog.base_url}/edit')
if req_edit and is_authorized:
if path_info == '/info':
print('20 text/gemini;charset=utf-8\r\n' + tinylog.info)
--
2.25.1
text/plain
This content has been proxied by September (ba2dc).