feat: full page for thread
This commit is contained in:
parent
5f4971f7c5
commit
d25a2dd6b3
2 changed files with 47 additions and 31 deletions
|
@ -22,19 +22,7 @@
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
main {
|
|
||||||
& p, & img, & video {
|
|
||||||
margin-top: 5px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
summary:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
summary {
|
|
||||||
color: blue;
|
|
||||||
cursor: pointer;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
ul {
|
ul {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
|
@ -62,6 +50,10 @@
|
||||||
content: '...'
|
content: '...'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
& img, & video, & p {
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
& img, & video {
|
& img, & video {
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
@ -81,6 +73,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
& .action {
|
||||||
|
color: blue;
|
||||||
|
margin: 1em 0;
|
||||||
|
cursor: pointer;
|
||||||
|
margin-top: 1em;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.card_avatar img {
|
.card_avatar img {
|
||||||
|
@ -99,6 +98,7 @@
|
||||||
<p>See the <a href="https://ayco.io/sh/threads">source code</a>. Or <a href="/">go home</a>.</p>
|
<p>See the <a href="https://ayco.io/sh/threads">source code</a>. Or <a href="/">go home</a>.</p>
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{% for thread in threads %}
|
{% for thread in threads %}
|
||||||
<li class="card">
|
<li class="card">
|
||||||
|
@ -111,9 +111,7 @@
|
||||||
|
|
||||||
|
|
||||||
<div class="card_content">
|
<div class="card_content">
|
||||||
<div class="meta">
|
|
||||||
<a href="{{thread.url}}" target="_blank">{{ thread.created_at }}</a>
|
|
||||||
</div>
|
|
||||||
{{thread.content | safe}}
|
{{thread.content | safe}}
|
||||||
|
|
||||||
{% for media in thread.media_attachments %}
|
{% for media in thread.media_attachments %}
|
||||||
|
@ -127,8 +125,11 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
<details>
|
{% if thread.descendants %}
|
||||||
<summary>See more ({{ thread.descendants | length }})</summary>
|
<div class="meta">
|
||||||
|
<a href="{{thread.url}}" target="_blank">{{ thread.created_at }}</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{% for descendant in thread.descendants %}
|
{% for descendant in thread.descendants %}
|
||||||
<li class="card descendant">
|
<li class="card descendant">
|
||||||
|
@ -139,9 +140,6 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card_content">
|
<div class="card_content">
|
||||||
<div class="meta">
|
|
||||||
<a href="{{descendant.url}}" target="_blank">{{ descendant.created_at }}</a>
|
|
||||||
</div>
|
|
||||||
{{ descendant.content | safe }}
|
{{ descendant.content | safe }}
|
||||||
{% for media in descendant.media_attachments%}
|
{% for media in descendant.media_attachments%}
|
||||||
{% if media.type == 'image'%}
|
{% if media.type == 'image'%}
|
||||||
|
@ -153,11 +151,17 @@
|
||||||
</video>
|
</video>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
<div class="meta">
|
||||||
|
<a href="{{descendant.url}}" target="_blank">{{ descendant.created_at }}</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<li>
|
<li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</details>
|
|
||||||
|
{% else %}
|
||||||
|
<a class="action" href="{{ url_for('threads.thread', id=thread.id) }}">Read full thread</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|
28
threads.py
28
threads.py
|
@ -7,24 +7,36 @@ threads = Blueprint('threads', __name__, template_folder='template')
|
||||||
server = 'https://social.ayco.io'
|
server = 'https://social.ayco.io'
|
||||||
thread_ids = ['112319729193615365', '112258065967208438']
|
thread_ids = ['112319729193615365', '112258065967208438']
|
||||||
|
|
||||||
|
# TODO: fetch only parent statuses
|
||||||
@threads.route('/')
|
@threads.route('/')
|
||||||
def home():
|
def home():
|
||||||
threads = fetch_threads();
|
statuses = fetch_statuses()
|
||||||
return render_template('threads.html', threads=threads)
|
return render_template('threads.html', threads=statuses)
|
||||||
|
|
||||||
|
# TODO: given parent status id, show page for full thread
|
||||||
|
@threads.route('/<path:id>')
|
||||||
|
def thread(id):
|
||||||
|
thread = fetch_thread(id)
|
||||||
|
return thread
|
||||||
|
|
||||||
@threads.route('/api')
|
@threads.route('/api')
|
||||||
def api():
|
def api():
|
||||||
threads = fetch_threads();
|
return fetch_threads();
|
||||||
return threads;
|
|
||||||
|
|
||||||
def fetch_threads():
|
def fetch_statuses():
|
||||||
threads = []
|
statuses = []
|
||||||
for id in thread_ids:
|
for id in thread_ids:
|
||||||
|
status = requests.get(server + '/api/v1/statuses/' + id ).json()
|
||||||
|
status = clean_status(status)
|
||||||
|
statuses.append(status)
|
||||||
|
return statuses
|
||||||
|
|
||||||
|
|
||||||
|
def fetch_thread(id):
|
||||||
status = requests.get(server + '/api/v1/statuses/' + id ).json()
|
status = requests.get(server + '/api/v1/statuses/' + id ).json()
|
||||||
status = clean_status(status)
|
status = clean_status(status)
|
||||||
status['descendants'] = get_descendants(server, status)
|
status['descendants'] = get_descendants(server, status)
|
||||||
threads.append(status)
|
return render_template('threads.html', threads=[status])
|
||||||
return threads
|
|
||||||
|
|
||||||
def get_descendants(server, status):
|
def get_descendants(server, status):
|
||||||
author_id = status['account']['id']
|
author_id = status['account']['id']
|
||||||
|
|
Loading…
Reference in a new issue