From caabc732950d6f33c0c739650e2f2d9a98528802 Mon Sep 17 00:00:00 2001 From: Ayo Date: Tue, 26 Aug 2025 02:07:03 +0200 Subject: [PATCH] feat: configuration for max_summary_length (for og:description) --- example_config.json | 3 ++- threads.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/example_config.json b/example_config.json index 030f620..0fb8862 100644 --- a/example_config.json +++ b/example_config.json @@ -5,7 +5,8 @@ "title": "Thoughts", "description": "Hand-picked public posts from my social feed", "server": "https://social.ayco.io", - "user_id": "0123456789" + "user_id": "0123456789", + "max_summary_length": 100 } }, "ATTRIBUTION": { diff --git a/threads.py b/threads.py index 6b4ac1b..a254349 100755 --- a/threads.py +++ b/threads.py @@ -170,10 +170,11 @@ async def tag(id): def thread(id): attribution = get_attribution() app = get_app_config() + max_length = app.get('max_summary_length', 69) # Configure max summary length status = fetch_thread(id) status['summary'] = utils.clean_html(status['content']).strip() - if len(status['summary']) > 69: - status['summary'] = status['summary'][:69] + '...' + if len(status['summary']) > max_length: + status['summary'] = status['summary'][:max_length] + '...' return render_template('_home.html', threads=[status], app=app, attribution=attribution, render_date=datetime.now()) @threads.route('/api')