render timeline with takahe posts

This commit is contained in:
Your Name 2024-06-18 00:10:31 -04:00 committed by Henri Dickson
parent 250f13eb5a
commit 3bf583930e
14 changed files with 322 additions and 128 deletions

View file

@ -1,29 +1,34 @@
section.replies {
border-left: 1px solid var(--pico-muted-color);
margin-left: var(--pico-spacing);
padding-left: var(--pico-spacing);
margin-bottom: 0 !important;
>div {
margin-bottom: calc(var(--pico-spacing));
}
.post {
p {
margin-bottom: 0;
margin-bottom: 0.5em;
}
details {
summary {
text-decoration: underline;
section.replies {
border-left: 1px solid var(--pico-muted-color);
margin-left: var(--pico-spacing);
padding-left: var(--pico-spacing);
margin-bottom: 0 !important;
>div {
margin-bottom: calc(var(--pico-spacing));
}
}
form {
margin-bottom: 0;
select {
width: min-content;
p {
margin-bottom: 0;
}
button{
height: calc(1rem * var(--pico-line-height) + var(--pico-form-element-spacing-vertical) * 2 + var(--pico-border-width) * 2)
details {
summary {
text-decoration: underline;
}
}
details.dropdown > summary::after {
display: none;
form {
margin-bottom: 0;
select {
width: min-content;
}
button{
height: calc(1rem * var(--pico-line-height) + var(--pico-form-element-spacing-vertical) * 2 + var(--pico-border-width) * 2)
}
details.dropdown > summary::after {
display: none;
}
}
}
}

View file

@ -1,6 +1,9 @@
.sidebar {
article {
padding: calc(var(--pico-block-spacing-horizontal));
article {
box-shadow: unset;
}
}
details {
@ -77,7 +80,7 @@
@media (max-width: 768px) {
section,
article,
>section>article,
details {
margin-bottom: 0;
}

View file

@ -11,7 +11,6 @@
@import '_legacy.sass';
@import '_legacy2.scss';
@import '_collection.scss';
@import '_feed.scss';
@import '_card.scss';
@import '_gallery.scss';
@import '_sidebar.scss';

View file

@ -128,6 +128,10 @@ class Piece(PolymorphicModel, UserOwnedObjectMixin):
"takahe.Post", related_name="pieces", through="PiecePost"
)
@property
def classname(self) -> str:
return self.__class__.__name__.lower()
def get_mastodon_crosspost_url(self):
return (
(self.metadata or {}).get("shared_link")

View file

@ -210,9 +210,13 @@ class Note(Content):
if len(lines) < 3 or lines[-2].strip() not in _separaters:
return content, None, None
progress_type, progress_value = cls.extract_progress(lines[-1])
# if progress_value is None and not lines[-2].startswith("https://"):
# if progress_value is None and not lines[-1].startswith("https://"):
# return content, None, None
return "\n".join(lines[:-2]), progress_type, progress_value
return ( # remove one extra empty line generated from <p> tags
"\n".join(lines[: (-3 if lines[-3] == "" else -2)]),
progress_type,
progress_value,
)
@classmethod
def extract_progress(cls, content) -> tuple[str | None, str | None]:
@ -224,7 +228,7 @@ class Note(Content):
return None, ""
m = m.groupdict()
typ_ = "percentage" if m["postfix"] == "%" else m.get("prefix", "")
match typ_:
match typ_.lower():
case "p" | "pg" | "page":
typ = Note.ProgressType.PAGE
case "ch" | "chapter":

View file

@ -3,7 +3,7 @@
{% load humanize %}
{% load i18n %}
{% for post in posts %}
<section class="activity">
<section class="activity post">
<div style="display:flex;">
<div>
<div class="avatar" style="margin:0.6em 0.6em 0.6em 0;">

View file

@ -264,6 +264,12 @@ class NoteTest(TestCase):
self.assertEqual(t, Note.ProgressType.PAGE)
self.assertEqual(v, "1")
c0 = "test \n - \nP 99"
c, t, v = Note.strip_footer(c0)
self.assertEqual(c, "test ")
self.assertEqual(t, Note.ProgressType.PAGE)
self.assertEqual(v, "99")
c0 = "test \n - \n pt 1 "
c, t, v = Note.strip_footer(c0)
self.assertEqual(c, "test ")

View file

@ -53,7 +53,7 @@ def post_boost(request: AuthedHttpRequest, post_id: int):
post = Takahe.get_post(post_id)
if not post:
raise BadRequest(_("Invalid parameter"))
if request.user.mastodon_site:
if request.user.mastodon_site and request.user.preference.mastodon_repost_mode == 1:
boost_toot_later(request.user, post.object_uri)
else:
Takahe.boost_post(post_id, request.user.identity.pk)

View file

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-06-16 21:51-0400\n"
"POT-Creation-Date: 2024-06-18 00:07-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -15,15 +15,15 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: boofilsic/settings.py:393
#: boofilsic/settings.py:394
msgid "English"
msgstr "英语"
#: boofilsic/settings.py:394
#: boofilsic/settings.py:395
msgid "Simplified Chinese"
msgstr "简体中文"
#: boofilsic/settings.py:395
#: boofilsic/settings.py:396
msgid "Traditional Chinese"
msgstr "繁体中文"
@ -401,27 +401,27 @@ msgstr "元数据"
msgid "cover"
msgstr "封面"
#: catalog/common/models.py:620
#: catalog/common/models.py:628
msgid "source site"
msgstr "来源站点"
#: catalog/common/models.py:622
#: catalog/common/models.py:630
msgid "ID on source site"
msgstr "来源站点标识"
#: catalog/common/models.py:624
#: catalog/common/models.py:632
msgid "source url"
msgstr "来源站点网址"
#: catalog/common/models.py:640
#: catalog/common/models.py:648
msgid "IdType of the source site"
msgstr "来源站点的主要标识类型"
#: catalog/common/models.py:646
#: catalog/common/models.py:654
msgid "Primary Id on the source site"
msgstr "来源站点的主要标识数据"
#: catalog/common/models.py:649
#: catalog/common/models.py:657
msgid "url to the resource"
msgstr "指向外部资源的网址"
@ -675,6 +675,7 @@ msgstr "显示更多"
#: catalog/templates/_item_reviews.html:47
#: catalog/templates/podcast_episode_data.html:44
#: social/templates/events.html:43 social/templates/feed_data.html:44
#: social/templates/feed_events.html:114
msgid "nothing more."
msgstr "没有更多内容了。"
@ -1538,6 +1539,7 @@ msgid "Set a username."
msgstr "设置用户名"
#: common/templates/_sidebar.html:53
#: users/templates/users/profile_actions.html:29
msgid "approving followers manually"
msgstr "已开启关注审核"
@ -1746,64 +1748,64 @@ msgstr "仅关注者"
msgid "Mentioned Only"
msgstr "自己和提到的人"
#: journal/models/note.py:33
#: journal/models/note.py:35
msgid "Page"
msgstr "页码"
#: journal/models/note.py:34
#: journal/models/note.py:36
msgid "Chapter"
msgstr "章节"
#: journal/models/note.py:37
#: journal/models/note.py:39
msgid "Part"
msgstr "分部"
#: journal/models/note.py:38
#: journal/models/note.py:40
msgid "Episode"
msgstr "单集"
#: journal/models/note.py:39
#: journal/models/note.py:41
msgid "Track"
msgstr "曲目"
#: journal/models/note.py:40
#: journal/models/note.py:42
msgid "Cycle"
msgstr "周目"
#: journal/models/note.py:41
#: journal/models/note.py:43
msgid "Timestamp"
msgstr "时间戳"
#: journal/models/note.py:42
#: journal/models/note.py:44
msgid "Percentage"
msgstr "百分比"
#: journal/models/note.py:59
#: journal/models/note.py:61
#, python-brace-format
msgid "Page {value}"
msgstr "第{value}页"
#: journal/models/note.py:60
#: journal/models/note.py:62
#, python-brace-format
msgid "Chapter {value}"
msgstr "第{value}章"
#: journal/models/note.py:63
#: journal/models/note.py:65
#, python-brace-format
msgid "Part {value}"
msgstr "第{value}部"
#: journal/models/note.py:64
#: journal/models/note.py:66
#, python-brace-format
msgid "Episode {value}"
msgstr "第{value}集"
#: journal/models/note.py:65
#: journal/models/note.py:67
#, python-brace-format
msgid "Track {value}"
msgstr "第{value}首"
#: journal/models/note.py:66
#: journal/models/note.py:68
#, python-brace-format
msgid "Cycle {value}"
msgstr "{value}周目"
@ -2671,7 +2673,7 @@ msgstr "列表未找到"
msgid "Content too long for your Fediverse instance."
msgstr "内容过长,超出了你的联邦实例的限制。"
#: journal/views/mark.py:163 journal/views/note.py:94
#: journal/views/mark.py:163 journal/views/note.py:98
#: journal/views/review.py:30
msgid "Content not found"
msgstr "内容未找到"
@ -2688,11 +2690,11 @@ msgstr "笔记内容"
msgid "Content Warning (optional)"
msgstr "剧透或敏感内容提示(选填)"
#: journal/views/note.py:62
#: journal/views/note.py:66
msgid "Progress Type (optional)"
msgstr "进度类型(选填)"
#: journal/views/note.py:102
#: journal/views/note.py:106
msgid "Invalid form data"
msgstr "无效表单信息。"
@ -2792,6 +2794,7 @@ msgid "target site domain name"
msgstr "目标实例域名"
#: social/templates/activity/comment_child_item.html:12
#: social/templates/feed_events.html:34
msgid "play"
msgstr "播放"
@ -2816,6 +2819,7 @@ msgstr "赞了 <a href=\"%(owner_url)s\">%(owner_name)s</a> 的收藏单"
#: social/templates/activity/mark_item.html:19
#: social/templates/activity/review_item.html:12
#: social/templates/activity/review_item.html:19
#: social/templates/feed_events.html:45
msgid "mark"
msgstr "标记"
@ -2983,11 +2987,19 @@ msgstr ""
msgid "Activities from those you follow"
msgstr "好友动态"
#: social/templates/feed_data.html:48
#: social/templates/feed_data.html:48 social/templates/feed_events.html:118
#, python-format
msgid "Find and mark some books/movies/podcasts/games, <a href=\"%(import_url)s\">import your data</a> from Goodreads/Letterboxd/Douban, follow some fellow %(site_name)s users on the fediverse, so their recent activities and yours will show up here."
msgstr "搜索并标记一些书影音/播客/游戏,<a href=\"%(import_url)s\">导入你的豆瓣、Letterboxd或Goodreads记录</a>,去联邦宇宙(长毛象)关注一些正在使用%(site_name)s的用户这里就会显示你和她们的近期动态。"
#: social/templates/feed_events.html:19
msgid "boosted"
msgstr "转播了"
#: social/templates/feed_events.html:64
msgid "wrote a note"
msgstr "写了笔记"
#: social/templates/notification.html:28
msgid "mention"
msgstr "提及"
@ -3741,63 +3753,63 @@ msgstr "已屏蔽"
msgid "user profile"
msgstr "用户资料"
#: users/templates/users/profile_actions.html:32
#: users/templates/users/profile_actions.html:39
msgid "original home"
msgstr "原始主页"
#: users/templates/users/profile_actions.html:63
#: users/templates/users/profile_actions.html:72
msgid "accept follow request"
msgstr "接受关注请求"
#: users/templates/users/profile_actions.html:65
#: users/templates/users/profile_actions.html:74
msgid "sure to accept follow request?"
msgstr "确定接受关注请求吗?"
#: users/templates/users/profile_actions.html:73
#: users/templates/users/profile_actions.html:82
msgid "reject follow request"
msgstr "拒绝关注请求"
#: users/templates/users/profile_actions.html:75
#: users/templates/users/profile_actions.html:84
msgid "sure to reject follow request?"
msgstr "确定拒绝关注请求吗?"
#: users/templates/users/profile_actions.html:85
#: users/templates/users/profile_actions.html:94
msgid "click to unfollow"
msgstr "点击可取消关注"
#: users/templates/users/profile_actions.html:87
#: users/templates/users/profile_actions.html:96
msgid "sure to unfollow?"
msgstr "确定取消关注该用户吗?"
#: users/templates/users/profile_actions.html:96
#: users/templates/users/profile_actions.html:105
msgid "click to cancel follow request"
msgstr "点击可取消关注请求"
#: users/templates/users/profile_actions.html:98
#: users/templates/users/profile_actions.html:107
msgid "sure to cancel follow request?"
msgstr "确定取消关注请求吗?"
#: users/templates/users/profile_actions.html:107
#: users/templates/users/profile_actions.html:116
msgid "click to follow"
msgstr "点击可关注"
#: users/templates/users/profile_actions.html:108
#: users/templates/users/profile_actions.html:117
msgid "sure to follow?"
msgstr "确定关注该用户吗?"
#: users/templates/users/profile_actions.html:118
msgid "click to mute"
msgstr "点击可取消屏蔽"
#: users/templates/users/profile_actions.html:127
msgid "click to mute"
msgstr "点击可静音"
#: users/templates/users/profile_actions.html:136
msgid "click to unmute"
msgstr "点击可取消静音"
#: users/templates/users/profile_actions.html:137
#: users/templates/users/profile_actions.html:146
msgid "click to block"
msgstr "点击可屏蔽"
#: users/templates/users/profile_actions.html:138
#: users/templates/users/profile_actions.html:147
msgid "sure to block?"
msgstr "确定屏蔽该用户吗?"

View file

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-06-16 21:51-0400\n"
"POT-Creation-Date: 2024-06-18 00:07-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -15,15 +15,15 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: boofilsic/settings.py:393
#: boofilsic/settings.py:394
msgid "English"
msgstr "英語"
#: boofilsic/settings.py:394
#: boofilsic/settings.py:395
msgid "Simplified Chinese"
msgstr "簡體中文"
#: boofilsic/settings.py:395
#: boofilsic/settings.py:396
msgid "Traditional Chinese"
msgstr "繁體中文"
@ -401,27 +401,27 @@ msgstr "元數據"
msgid "cover"
msgstr "封面"
#: catalog/common/models.py:620
#: catalog/common/models.py:628
msgid "source site"
msgstr "來源站點"
#: catalog/common/models.py:622
#: catalog/common/models.py:630
msgid "ID on source site"
msgstr "來源站點標識"
#: catalog/common/models.py:624
#: catalog/common/models.py:632
msgid "source url"
msgstr "來源站點網址"
#: catalog/common/models.py:640
#: catalog/common/models.py:648
msgid "IdType of the source site"
msgstr "來源站點的主要標識類型"
#: catalog/common/models.py:646
#: catalog/common/models.py:654
msgid "Primary Id on the source site"
msgstr "來源站點的主要標識數據"
#: catalog/common/models.py:649
#: catalog/common/models.py:657
msgid "url to the resource"
msgstr "指向外部資源的網址"
@ -675,6 +675,7 @@ msgstr "顯示更多"
#: catalog/templates/_item_reviews.html:47
#: catalog/templates/podcast_episode_data.html:44
#: social/templates/events.html:43 social/templates/feed_data.html:44
#: social/templates/feed_events.html:114
msgid "nothing more."
msgstr "沒有更多內容了。"
@ -1538,6 +1539,7 @@ msgid "Set a username."
msgstr "設置用戶名"
#: common/templates/_sidebar.html:53
#: users/templates/users/profile_actions.html:29
msgid "approving followers manually"
msgstr "已開啓關注審覈"
@ -1746,64 +1748,64 @@ msgstr "僅關注者"
msgid "Mentioned Only"
msgstr "自己和提到的人"
#: journal/models/note.py:33
#: journal/models/note.py:35
msgid "Page"
msgstr "頁碼"
#: journal/models/note.py:34
#: journal/models/note.py:36
msgid "Chapter"
msgstr "章節"
#: journal/models/note.py:37
#: journal/models/note.py:39
msgid "Part"
msgstr "分部"
#: journal/models/note.py:38
#: journal/models/note.py:40
msgid "Episode"
msgstr "單集"
#: journal/models/note.py:39
#: journal/models/note.py:41
msgid "Track"
msgstr "曲目"
#: journal/models/note.py:40
#: journal/models/note.py:42
msgid "Cycle"
msgstr "周目"
#: journal/models/note.py:41
#: journal/models/note.py:43
msgid "Timestamp"
msgstr "時間戳"
#: journal/models/note.py:42
#: journal/models/note.py:44
msgid "Percentage"
msgstr "百分比"
#: journal/models/note.py:59
#: journal/models/note.py:61
#, python-brace-format
msgid "Page {value}"
msgstr "第{value}頁"
#: journal/models/note.py:60
#: journal/models/note.py:62
#, python-brace-format
msgid "Chapter {value}"
msgstr "第{value}章"
#: journal/models/note.py:63
#: journal/models/note.py:65
#, python-brace-format
msgid "Part {value}"
msgstr "第{value}部"
#: journal/models/note.py:64
#: journal/models/note.py:66
#, python-brace-format
msgid "Episode {value}"
msgstr "第{value}集"
#: journal/models/note.py:65
#: journal/models/note.py:67
#, python-brace-format
msgid "Track {value}"
msgstr "第{value}首"
#: journal/models/note.py:66
#: journal/models/note.py:68
#, python-brace-format
msgid "Cycle {value}"
msgstr "{value}周目"
@ -2671,7 +2673,7 @@ msgstr "列表未找到"
msgid "Content too long for your Fediverse instance."
msgstr "內容過長,超出了你的聯邦實例的限制。"
#: journal/views/mark.py:163 journal/views/note.py:94
#: journal/views/mark.py:163 journal/views/note.py:98
#: journal/views/review.py:30
msgid "Content not found"
msgstr "內容未找到"
@ -2688,11 +2690,11 @@ msgstr "筆記內容"
msgid "Content Warning (optional)"
msgstr "劇透或敏感內容提示(選填)"
#: journal/views/note.py:62
#: journal/views/note.py:66
msgid "Progress Type (optional)"
msgstr "進度類型(選填)"
#: journal/views/note.py:102
#: journal/views/note.py:106
msgid "Invalid form data"
msgstr "無效表單信息。"
@ -2792,6 +2794,7 @@ msgid "target site domain name"
msgstr "目標實例域名"
#: social/templates/activity/comment_child_item.html:12
#: social/templates/feed_events.html:34
msgid "play"
msgstr "播放"
@ -2816,6 +2819,7 @@ msgstr "讚了 <a href=\"%(owner_url)s\">%(owner_name)s</a> 的收藏單"
#: social/templates/activity/mark_item.html:19
#: social/templates/activity/review_item.html:12
#: social/templates/activity/review_item.html:19
#: social/templates/feed_events.html:45
msgid "mark"
msgstr "標記"
@ -2983,11 +2987,23 @@ msgstr ""
msgid "Activities from those you follow"
msgstr "好友動態"
#: social/templates/feed_data.html:48
#: social/templates/feed_data.html:48 social/templates/feed_events.html:118
#, python-format
msgid "Find and mark some books/movies/podcasts/games, <a href=\"%(import_url)s\">import your data</a> from Goodreads/Letterboxd/Douban, follow some fellow %(site_name)s users on the fediverse, so their recent activities and yours will show up here."
msgstr "搜索並標記一些書影音/播客/遊戲,<a href=\"%(import_url)s\">導入你的豆瓣、Letterboxd或Goodreads記錄</a>,去聯邦宇宙(長毛象)關注一些正在使用%(site_name)s的用戶這裏就會顯示你和她們的近期動態。"
#: social/templates/feed_events.html:19
#, fuzzy
#| msgid "boost"
msgid "boosted"
msgstr "轉播"
#: social/templates/feed_events.html:64
#, fuzzy
#| msgid "create a new post"
msgid "wrote a note"
msgstr "另發新帖文"
#: social/templates/notification.html:28
msgid "mention"
msgstr "提及"
@ -3741,63 +3757,63 @@ msgstr "已屏蔽"
msgid "user profile"
msgstr "用戶資料"
#: users/templates/users/profile_actions.html:32
#: users/templates/users/profile_actions.html:39
msgid "original home"
msgstr "原始主頁"
#: users/templates/users/profile_actions.html:63
#: users/templates/users/profile_actions.html:72
msgid "accept follow request"
msgstr "接受關注請求"
#: users/templates/users/profile_actions.html:65
#: users/templates/users/profile_actions.html:74
msgid "sure to accept follow request?"
msgstr "確定接受關注請求嗎?"
#: users/templates/users/profile_actions.html:73
#: users/templates/users/profile_actions.html:82
msgid "reject follow request"
msgstr "拒絕關注請求"
#: users/templates/users/profile_actions.html:75
#: users/templates/users/profile_actions.html:84
msgid "sure to reject follow request?"
msgstr "確定拒絕關注請求嗎?"
#: users/templates/users/profile_actions.html:85
#: users/templates/users/profile_actions.html:94
msgid "click to unfollow"
msgstr "點擊可取消關注"
#: users/templates/users/profile_actions.html:87
#: users/templates/users/profile_actions.html:96
msgid "sure to unfollow?"
msgstr "確定取消關注該用戶嗎?"
#: users/templates/users/profile_actions.html:96
#: users/templates/users/profile_actions.html:105
msgid "click to cancel follow request"
msgstr "點擊可取消關注請求"
#: users/templates/users/profile_actions.html:98
#: users/templates/users/profile_actions.html:107
msgid "sure to cancel follow request?"
msgstr "確定取消關注請求嗎?"
#: users/templates/users/profile_actions.html:107
#: users/templates/users/profile_actions.html:116
msgid "click to follow"
msgstr "點擊可關注"
#: users/templates/users/profile_actions.html:108
#: users/templates/users/profile_actions.html:117
msgid "sure to follow?"
msgstr "確定關注該用戶嗎?"
#: users/templates/users/profile_actions.html:118
msgid "click to mute"
msgstr "點擊可取消屏蔽"
#: users/templates/users/profile_actions.html:127
msgid "click to mute"
msgstr "點擊可靜音"
#: users/templates/users/profile_actions.html:136
msgid "click to unmute"
msgstr "點擊可取消靜音"
#: users/templates/users/profile_actions.html:137
#: users/templates/users/profile_actions.html:146
msgid "click to block"
msgstr "點擊可屏蔽"
#: users/templates/users/profile_actions.html:138
#: users/templates/users/profile_actions.html:147
msgid "sure to block?"
msgstr "確定屏蔽該用戶嗎?"

View file

@ -0,0 +1,124 @@
{% load bleach_tags %}
{% load static %}
{% load i18n %}
{% load l10n %}
{% load humanize %}
{% load mastodon %}
{% load thumb %}
{% load user_actions %}
{% load duration %}
{% for event in events %}
{% with event.subject_post as post %}
<section class="activity post">
{% if event.type == "boost" %}
<div class="boosted">
<i class="fa-solid fa-retweet"
title="{{ event.published|naturaldelta }}"></i>
<a href="{{ event.subject_identity.url }}"
class="nickname"
title="@{{ event.subject_identity.handle }}">{{ event.subject_identity.name }}</a>
{% trans 'boosted' %}
</div>
{% endif %}
<div style="display:flex;">
<div>
<div class="avatar" style="margin:0.6em 0.6em 0.6em 0;">
<img src="{{ post.author.icon_uri }}" alt="@{{ post.author.handle }}" />
</div>
</div>
<div style="flex-grow:1;">
<span class="action">
<span class="timestamp">{{ post.published|naturaldelta }}</span>
{% if post.piece and post.piece.item and post.piece.item.classname != 'tvepisode' %}
<span>
{% if post.piece.item.classname == 'podcastepisode' %}
<a title="{% trans "play" %}"
class="episode"
data-uuid="{{ post.piece.item.uuid }}"
data-media="{{ post.piece.item.media_url }}"
data-cover="{{ post.piece.item.cover_url|default:post.piece.item.parent_item.cover.url }}"
data-title="{{ post.piece.item.title }}"
data-album="{{ post.piece.item.parent_item.title }}"
data-hosts="{{ post.piece.item.parent_item.hosts|join:' / ' }}"
{% if request.user.is_authenticated %} data-comment-href="{% url 'journal:comment' post.piece.item.uuid %}" {% endif %}
data-position="{{ post.piece.metadata.position | default:0 }}"><i class="fa-solid fa-circle-play"></i></a>
{% else %}
<a title="{% trans "mark" %}"
hx-get="{% url 'journal:mark' post.piece.item.uuid %}?shelf_type=wishlist"
hx-target="body"
hx-swap="beforeend">
<i class="fa-regular fa-bookmark"></i>
</a>
{% endif %}
</span>
{% endif %}
{% include "action_reply_post.html" %}
{% include "action_like_post.html" %}
{% include "action_boost_post.html" %}
{% include "action_open_post.html" %}
</span>
<span>
<a href="{{ post.author.url }}"
class="nickname"
title="@{{ post.author.handle }}">{{ post.author.name }}</a>
{% if post.piece and post.piece.classname == 'note' %}
{% trans "wrote a note" %}
{% endif %}
</span>
<div>{{ post.summary|default:'' }}</div>
<div {% if post.summary or post.sensitive %}class="spoiler" _="on click toggle .revealed on me"{% endif %}>
<div class="attachments">
{% for attachment in post.attachments.all %}
{% if attachment.is_image %}
<a href="#img_{{ post.pk }}_{{ loop.index }}">
<img src="{{ attachment.thumbnail_url.relative }}"
alt="image attachment"
class="preview">
</a>
<a href="#" class="lightbox" id="img_{{ post.pk }}_{{ loop.index }}">
<span style="background-image: url('{{ attachment.full_url.relative }}')"></span>
</a>
{% endif %}
{% endfor %}
</div>
{% if post.piece and post.piece.classname == 'note' %}
<blockquote class="tldr"
_="on click toggle .tldr on me"
style="margin:0;
padding-top:0;
padding-bottom:0">
{{ post.content|bleach:"a,p,span,br,div,img"|default:"" }}
</blockquote>
{% else %}
{{ post.content|bleach:"a,p,span,br,div,img"|default:"" }}
{% endif %}
</div>
{% if post.piece %}
{% if post.piece.item %}
<article>{% include "_item_card.html" with item=post.piece.item allow_embed=1 %}</article>
{% endif %}
{% endif %}
</div>
</div>
<div id="replies_{{ post.pk }}"></div>
</section>
{% endwith %}
{% if forloop.last %}
<div class="htmx-indicator"
style="margin-left: 60px"
hx-get="{% url 'social:data' %}?last={{ event.pk }}"
hx-trigger="revealed"
hx-swap="outerHTML">
<i class="fa-solid fa-compact-disc fa-spin loading"></i>
</div>
{% endif %}
{% empty %}
{% if request.GET.last %}
<div class="empty">{% trans 'nothing more.' %}</div>
{% else %}
<div class="empty">
{% url 'users:data' as import_url %}
{% blocktrans %}Find and mark some books/movies/podcasts/games, <a href="{{ import_url }}">import your data</a> from Goodreads/Letterboxd/Douban, follow some fellow {{ site_name }} users on the fediverse, so their recent activities and yours will show up here.{% endblocktrans %}
</div>
{% endif %}
{% endfor %}

View file

@ -5,6 +5,7 @@ from django.views.decorators.http import require_http_methods
from catalog.models import *
from journal.models import *
from takahe.models import TimelineEvent
from takahe.utils import Takahe
from .models import *
@ -57,15 +58,28 @@ def feed(request):
@login_required
@require_http_methods(["GET"])
def data(request):
return render(
request,
"feed_data.html",
{
"activities": ActivityManager(request.user.identity).get_timeline(
before_time=request.GET.get("last")
)[:PAGE_SIZE],
},
)
since_id = int(request.GET.get("last", 0))
events = TimelineEvent.objects.filter(
identity_id=request.user.identity.pk,
type__in=[TimelineEvent.Types.post, TimelineEvent.Types.boost],
).order_by("-id")
if since_id:
events = events.filter(id__lt=since_id)
return render(request, "feed_events.html", {"events": events})
# @login_required
# @require_http_methods(["GET"])
# def data(request):
# return render(
# request,
# "feed_data.html",
# {
# "activities": ActivityManager(request.user.identity).get_timeline(
# before_time=request.GET.get("last")
# )[:PAGE_SIZE],
# },
# )
@require_http_methods(["GET"])

View file

@ -1084,7 +1084,7 @@ class Post(models.Model):
def piece(self):
from journal.models import Piece, ShelfMember
pcs = Piece.objects.filter(post_id=self.pk)
pcs = Piece.objects.filter(posts=self.pk)
if len(pcs) == 1:
return pcs[0]
return next((p for p in pcs if p.__class__ == ShelfMember), None)

View file

@ -24,6 +24,13 @@
</a>
</span>
{% endif %}
{% if identity.locked %}
<span>
<a title="{% trans "approving followers manually" %}">
<i class="fa-solid fa-user-shield"></i>
</a>
</span>
{% endif %}
{% if not identity.local %}
<span>
<a href="{{ identity.profile_uri }}"