From 4793464be0dca83443dbd1f5fe6437614e50d11a Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Wed, 14 Dec 2022 18:07:22 +0100 Subject: [PATCH] more, understandable text --- Makefile | 20 +++++++++---- .../{main.py => cli.py} | 4 +-- .../server/flask_server.py | 3 +- templates/index.html | 28 ++++++++++++++----- templates/updates.html | 4 +-- 5 files changed, 42 insertions(+), 17 deletions(-) rename src/mastodon_toot_follower/{main.py => cli.py} (93%) diff --git a/Makefile b/Makefile index 5dd20d1..e2d5212 100644 --- a/Makefile +++ b/Makefile @@ -15,20 +15,25 @@ SHELL := bash all: prod .PHONY: prod -prod: requirements.txt +prod: requirements.txt ## Starts a production webserver. source venv/bin/activate export PYTHONPATH="${PYTHONPATH}:src" python3 src/mastodon_toot_follower/server/waitress_server.py .PHONY: dev -dev: requirements.txt +dev: requirements.txt ## Starts a development webserver. source venv/bin/activate export PYTHONPATH="${PYTHONPATH}:src" python3 src/mastodon_toot_follower/server/flask_server.py +.PHONY: cli +cli: requirements.txt ## Runs the commandline version. + source venv/bin/activate + export PYTHONPATH="${PYTHONPATH}:src" + python3 src/mastodon_toot_follower/cli.py $(MASTODON_TOOT_URL) .PHONY: requirements.txt -requirements.txt: +requirements.txt: ## Creates a virtual environment including the python dependencies. if ! [ -d venv ]; then python3 -m venv venv source venv/bin/activate @@ -36,5 +41,10 @@ requirements.txt: fi .PHONY: clean -clean: - rm -rf venv +clean: ## Removes all created files. + rm -rf venv ~/.MastodonTootFollower + sudo rm -rf data + +.PHONY: help +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' diff --git a/src/mastodon_toot_follower/main.py b/src/mastodon_toot_follower/cli.py similarity index 93% rename from src/mastodon_toot_follower/main.py rename to src/mastodon_toot_follower/cli.py index dc38b56..574ca3e 100644 --- a/src/mastodon_toot_follower/main.py +++ b/src/mastodon_toot_follower/cli.py @@ -30,9 +30,9 @@ def main(): print(f'Conversation length: {conversation.conversation_length()}') new_updates = conversation.updates(reading_position=reading_position) if len(new_updates) == 0: - print('No new updates.') + print('There is no news from the conversation.') else: - print(f'New updates:\n') + print(f'News from the conversation:\n') print('\n'.join([str(update) for update in new_updates])) diff --git a/src/mastodon_toot_follower/server/flask_server.py b/src/mastodon_toot_follower/server/flask_server.py index 9850f4f..5aac389 100644 --- a/src/mastodon_toot_follower/server/flask_server.py +++ b/src/mastodon_toot_follower/server/flask_server.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- from enum import Enum +from secrets import token_urlsafe from flask import Flask, Response, render_template from flask import request @@ -27,7 +28,7 @@ class Templates(Enum): @app.route('/', methods=['GET']) def hello_world(): - return render_template(Templates.index.value) + return render_template(Templates.index.value, seed=token_urlsafe(16)) @app.route('/rss/') diff --git a/templates/index.html b/templates/index.html index c13d277..b5a933f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -13,25 +13,39 @@

MastodonTootFollower

- + In the following you can generate a link to follow a conversation on Mastodon. +

+

+ You can either follow a conversation with a feed reader (Atom/RSS) of your choice + or view new replies and edits each time you open the link in your webbrowser (HTML page or JSON file). +

+

+ To get started, fill in the URL of the Toot that has started the conversation + and click one of the three buttons. Then open your generated link (either with a feed reader or in your webbrowser). +

+

+ The random seed is used to store your reading position. +

+

+

- - + +

-

Resulting link:

+

Generated link:

diff --git a/templates/updates.html b/templates/updates.html index 0797cf8..08b18e3 100644 --- a/templates/updates.html +++ b/templates/updates.html @@ -11,8 +11,8 @@ -

Consecutive Toot Updates

- +

News from the conversation

+

List of changes from the conversation since your last visit.