diff --git a/templates/threads.html b/templates/threads.html index 0914681..0c886e2 100644 --- a/templates/threads.html +++ b/templates/threads.html @@ -22,19 +22,7 @@ color: white; } } - main { - & p, & img, & video { - margin-top: 5px; - } - } - summary:hover { - text-decoration: underline; - } - summary { - color: blue; - cursor: pointer; - margin-top: 1em; - } + ul { list-style: none; } @@ -62,6 +50,10 @@ content: '...' } + & img, & video, & p { + margin-bottom: 1em; + } + & img, & video { border-radius: 5px; max-width: 100%; @@ -81,6 +73,13 @@ } } + + & .action { + color: blue; + margin: 1em 0; + cursor: pointer; + margin-top: 1em; + } } .card_avatar img { @@ -99,6 +98,7 @@

See the source code. Or go home.

+ - + + {% else %} + Read full thread + {% endif %} diff --git a/threads.py b/threads.py index 53ca14b..ca9e540 100755 --- a/threads.py +++ b/threads.py @@ -7,24 +7,36 @@ threads = Blueprint('threads', __name__, template_folder='template') server = 'https://social.ayco.io' thread_ids = ['112319729193615365', '112258065967208438'] +# TODO: fetch only parent statuses @threads.route('/') def home(): - threads = fetch_threads(); - return render_template('threads.html', threads=threads) + statuses = fetch_statuses() + return render_template('threads.html', threads=statuses) + +# TODO: given parent status id, show page for full thread +@threads.route('/') +def thread(id): + thread = fetch_thread(id) + return thread @threads.route('/api') def api(): - threads = fetch_threads(); - return threads; + return fetch_threads(); -def fetch_threads(): - threads = [] +def fetch_statuses(): + statuses = [] for id in thread_ids: status = requests.get(server + '/api/v1/statuses/' + id ).json() status = clean_status(status) - status['descendants'] = get_descendants(server, status) - threads.append(status) - return threads + statuses.append(status) + return statuses + + +def fetch_thread(id): + status = requests.get(server + '/api/v1/statuses/' + id ).json() + status = clean_status(status) + status['descendants'] = get_descendants(server, status) + return render_template('threads.html', threads=[status]) def get_descendants(server, status): author_id = status['account']['id']