From 3bf583930eb8da5a9fccdfe60e3d4705dcd977a7 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 18 Jun 2024 00:10:31 -0400 Subject: [PATCH] render timeline with takahe posts --- common/static/scss/_post.scss | 47 ++++---- common/static/scss/_sidebar.scss | 5 +- common/static/scss/neodb.scss | 1 - journal/models/common.py | 4 + journal/models/note.py | 10 +- journal/templates/posts.html | 2 +- journal/tests.py | 6 + journal/views/post.py | 2 +- locale/zh_Hans/LC_MESSAGES/django.po | 102 +++++++++-------- locale/zh_Hant/LC_MESSAGES/django.po | 106 ++++++++++-------- social/templates/feed_events.html | 124 +++++++++++++++++++++ social/views.py | 32 ++++-- takahe/models.py | 2 +- users/templates/users/profile_actions.html | 7 ++ 14 files changed, 322 insertions(+), 128 deletions(-) create mode 100644 social/templates/feed_events.html diff --git a/common/static/scss/_post.scss b/common/static/scss/_post.scss index 5bba7e20..63aba35f 100644 --- a/common/static/scss/_post.scss +++ b/common/static/scss/_post.scss @@ -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; + } } } } diff --git a/common/static/scss/_sidebar.scss b/common/static/scss/_sidebar.scss index 469f8eb4..5d7b35f9 100644 --- a/common/static/scss/_sidebar.scss +++ b/common/static/scss/_sidebar.scss @@ -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; } diff --git a/common/static/scss/neodb.scss b/common/static/scss/neodb.scss index 7e031ea4..9aa66d03 100644 --- a/common/static/scss/neodb.scss +++ b/common/static/scss/neodb.scss @@ -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'; diff --git a/journal/models/common.py b/journal/models/common.py index d9e415d4..cde18ce2 100644 --- a/journal/models/common.py +++ b/journal/models/common.py @@ -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") diff --git a/journal/models/note.py b/journal/models/note.py index 5b445e00..062f2bb8 100644 --- a/journal/models/note.py +++ b/journal/models/note.py @@ -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

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": diff --git a/journal/templates/posts.html b/journal/templates/posts.html index c88b46a6..539de1d5 100644 --- a/journal/templates/posts.html +++ b/journal/templates/posts.html @@ -3,7 +3,7 @@ {% load humanize %} {% load i18n %} {% for post in posts %} -

+
diff --git a/journal/tests.py b/journal/tests.py index 3134c998..c31d5354 100644 --- a/journal/tests.py +++ b/journal/tests.py @@ -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 ") diff --git a/journal/views/post.py b/journal/views/post.py index 9027f833..f46f3763 100644 --- a/journal/views/post.py +++ b/journal/views/post.py @@ -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) diff --git a/locale/zh_Hans/LC_MESSAGES/django.po b/locale/zh_Hans/LC_MESSAGES/django.po index bde5d26e..1e94b676 100644 --- a/locale/zh_Hans/LC_MESSAGES/django.po +++ b/locale/zh_Hans/LC_MESSAGES/django.po @@ -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 \n" "Language-Team: LANGUAGE \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 "赞了 %(owner_name)s 的收藏单" #: 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, import your data 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 "搜索并标记一些书影音/播客/游戏,导入你的豆瓣、Letterboxd或Goodreads记录,去联邦宇宙(长毛象)关注一些正在使用%(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 "确定屏蔽该用户吗?" diff --git a/locale/zh_Hant/LC_MESSAGES/django.po b/locale/zh_Hant/LC_MESSAGES/django.po index 589d38b0..3eaf0f1a 100644 --- a/locale/zh_Hant/LC_MESSAGES/django.po +++ b/locale/zh_Hant/LC_MESSAGES/django.po @@ -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 \n" "Language-Team: LANGUAGE \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 "讚了 %(owner_name)s 的收藏單" #: 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, import your data 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 "搜索並標記一些書影音/播客/遊戲,導入你的豆瓣、Letterboxd或Goodreads記錄,去聯邦宇宙(長毛象)關注一些正在使用%(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 "確定屏蔽該用戶嗎?" diff --git a/social/templates/feed_events.html b/social/templates/feed_events.html new file mode 100644 index 00000000..520083c1 --- /dev/null +++ b/social/templates/feed_events.html @@ -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 %} +
+ {% if event.type == "boost" %} +
+ + {{ event.subject_identity.name }} + {% trans 'boosted' %} +
+ {% endif %} +
+
+
+ @{{ post.author.handle }} +
+
+
+ + {{ post.published|naturaldelta }} + {% if post.piece and post.piece.item and post.piece.item.classname != 'tvepisode' %} + + {% if post.piece.item.classname == 'podcastepisode' %} + + {% else %} + + + + {% endif %} + + {% endif %} + {% include "action_reply_post.html" %} + {% include "action_like_post.html" %} + {% include "action_boost_post.html" %} + {% include "action_open_post.html" %} + + + {{ post.author.name }} + {% if post.piece and post.piece.classname == 'note' %} + {% trans "wrote a note" %} + {% endif %} + +
{{ post.summary|default:'' }}
+
+
+ {% for attachment in post.attachments.all %} + {% if attachment.is_image %} + + image attachment + + + + + {% endif %} + {% endfor %} +
+ {% if post.piece and post.piece.classname == 'note' %} +
+ {{ post.content|bleach:"a,p,span,br,div,img"|default:"" }} +
+ {% else %} + {{ post.content|bleach:"a,p,span,br,div,img"|default:"" }} + {% endif %} +
+ {% if post.piece %} + {% if post.piece.item %} +
{% include "_item_card.html" with item=post.piece.item allow_embed=1 %}
+ {% endif %} + {% endif %} +
+
+
+
+ {% endwith %} + {% if forloop.last %} +
+ +
+ {% endif %} +{% empty %} + {% if request.GET.last %} +
{% trans 'nothing more.' %}
+ {% else %} +
+ {% url 'users:data' as import_url %} + {% blocktrans %}Find and mark some books/movies/podcasts/games, import your data from Goodreads/Letterboxd/Douban, follow some fellow {{ site_name }} users on the fediverse, so their recent activities and yours will show up here.{% endblocktrans %} +
+ {% endif %} +{% endfor %} diff --git a/social/views.py b/social/views.py index 9fc136e3..296d9bcc 100644 --- a/social/views.py +++ b/social/views.py @@ -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"]) diff --git a/takahe/models.py b/takahe/models.py index 7cacce04..4c14a2ca 100644 --- a/takahe/models.py +++ b/takahe/models.py @@ -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) diff --git a/users/templates/users/profile_actions.html b/users/templates/users/profile_actions.html index 14401372..6b492c1e 100644 --- a/users/templates/users/profile_actions.html +++ b/users/templates/users/profile_actions.html @@ -24,6 +24,13 @@ {% endif %} + {% if identity.locked %} + + + + + + {% endif %} {% if not identity.local %}