From 77eefa9e132c2f44d44d724ea6b7c1d7fcce2229 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 16 Jun 2024 21:54:20 -0400 Subject: [PATCH] rephrase share as crosspost --- journal/forms.py | 4 +-- journal/models/comment.py | 12 +++---- journal/models/common.py | 16 +++++----- journal/models/mark.py | 6 ++-- journal/models/note.py | 4 ++- journal/models/review.py | 14 +++++---- journal/templates/comment.html | 2 +- journal/templates/mark.html | 2 +- journal/views/common.py | 2 +- journal/views/mark.py | 2 +- journal/views/note.py | 2 +- journal/views/post.py | 2 +- journal/views/wrapped.py | 4 +-- locale/zh_Hans/LC_MESSAGES/django.po | 43 ++++++++++++-------------- locale/zh_Hant/LC_MESSAGES/django.po | 43 ++++++++++++-------------- users/templates/users/preferences.html | 6 ++-- 16 files changed, 81 insertions(+), 83 deletions(-) diff --git a/journal/forms.py b/journal/forms.py index 85567b94..ac8c9154 100644 --- a/journal/forms.py +++ b/journal/forms.py @@ -18,7 +18,7 @@ class ReviewForm(forms.ModelForm): title = forms.CharField(label=_("Title")) body = MarkdownxFormField(label=_("Content (Markdown)"), strip=False) share_to_mastodon = forms.BooleanField( - label=_("Post to Fediverse"), initial=True, required=False + label=_("Crosspost to timeline"), initial=True, required=False ) id = forms.IntegerField(required=False, widget=forms.HiddenInput()) visibility = forms.TypedChoiceField( @@ -40,7 +40,7 @@ class CollectionForm(forms.ModelForm): # id = forms.IntegerField(required=False, widget=forms.HiddenInput()) title = forms.CharField(label=_("Title")) brief = MarkdownxFormField(label=_("Content (Markdown)"), strip=False) - # share_to_mastodon = forms.BooleanField(label=_("Repost to Fediverse"), initial=True, required=False) + # share_to_mastodon = forms.BooleanField(label=_("Crosspost to timeline"), initial=True, required=False) visibility = forms.TypedChoiceField( label=_("Visibility"), initial=0, diff --git a/journal/models/comment.py b/journal/models/comment.py index e399c9e4..37869e6c 100644 --- a/journal/models/comment.py +++ b/journal/models/comment.py @@ -112,13 +112,13 @@ class Comment(Content): comment.save() return comment - def get_repost_postfix(self): + def get_crosspost_postfix(self): tags = render_post_with_macro( self.owner.user.preference.mastodon_append_tag, self.item ) return "\n" + tags if tags else "" - def get_repost_template(self): + def get_crosspost_template(self): return _( ShelfManager.get_action_template(ShelfType.PROGRESS, self.item.category) ) @@ -126,9 +126,9 @@ class Comment(Content): def to_mastodon_params(self): spoiler_text, txt = render_spoiler_text(self.text, self.item) content = ( - self.get_repost_template().format(item=self.item.display_title) + self.get_crosspost_template().format(item=self.item.display_title) + f"\n{txt}\n{settings.SITE_INFO['site_url']}{self.item_url}" - + self.get_repost_postfix() + + self.get_crosspost_postfix() ) params = { "content": content, @@ -140,13 +140,13 @@ class Comment(Content): def to_post_params(self): item_link = f"{settings.SITE_INFO['site_url']}/~neodb~{self.item_url}" prepend_content = ( - self.get_repost_template().format( + self.get_crosspost_template().format( item=f'{self.item.display_title}' ) + "
" ) spoiler_text, txt = render_spoiler_text(self.text, self.item) - content = f"{txt}\n{self.get_repost_postfix()}" + content = f"{txt}\n{self.get_crosspost_postfix()}" return { "prepend_content": prepend_content, "content": content, diff --git a/journal/models/common.py b/journal/models/common.py index 137e12c8..2ad07a8e 100644 --- a/journal/models/common.py +++ b/journal/models/common.py @@ -128,14 +128,14 @@ class Piece(PolymorphicModel, UserOwnedObjectMixin): "takahe.Post", related_name="pieces", through="PiecePost" ) - def get_mastodon_repost_url(self): + def get_mastodon_crosspost_url(self): return ( (self.metadata or {}).get("shared_link") if hasattr(self, "metadata") else None ) - def set_mastodon_repost_url(self, url: str | None): + def set_mastodon_crosspost_url(self, url: str | None): if not hasattr(self, "metadata"): logger.warning("metadata field not found") return @@ -152,7 +152,7 @@ class Piece(PolymorphicModel, UserOwnedObjectMixin): def delete(self, *args, **kwargs): if self.local: Takahe.delete_posts(self.all_post_ids) - toot_url = self.get_mastodon_repost_url() + toot_url = self.get_mastodon_crosspost_url() if toot_url: delete_toot_later(self.owner.user, toot_url) return super().delete(*args, **kwargs) @@ -314,7 +314,7 @@ class Piece(PolymorphicModel, UserOwnedObjectMixin): if user.preference.mastodon_repost_mode == 1: if delete_existing: self.delete_mastodon_repost() - return self.repost_to_mastodon() + return self.crosspost_to_mastodon() elif self.latest_post: return boost_toot_later(user, self.latest_post.url) else: @@ -322,17 +322,17 @@ class Piece(PolymorphicModel, UserOwnedObjectMixin): return False, 404 def delete_mastodon_repost(self): - toot_url = self.get_mastodon_repost_url() + toot_url = self.get_mastodon_crosspost_url() if toot_url: - self.set_mastodon_repost_url(None) + self.set_mastodon_crosspost_url(None) delete_toot(self.owner.user, toot_url) - def repost_to_mastodon(self): + def crosspost_to_mastodon(self): user = self.owner.user d = { "user": user, "visibility": self.visibility, - "update_toot_url": self.get_mastodon_repost_url(), + "update_toot_url": self.get_mastodon_crosspost_url(), } d.update(self.to_mastodon_params()) response = post_toot2(**d) diff --git a/journal/models/mark.py b/journal/models/mark.py index 2c107e9c..1e4d3e1c 100644 --- a/journal/models/mark.py +++ b/journal/models/mark.py @@ -294,10 +294,10 @@ class Mark: # publish a new or updated ActivityPub post user = self.owner.user post_as_new = shelf_type != last_shelf_type or visibility != last_visibility - classic_repost = user.preference.mastodon_repost_mode == 1 + classic_crosspost = user.preference.mastodon_repost_mode == 1 append = ( f"@{user.mastodon_acct}\n" - if visibility > 0 and share_to_mastodon and not classic_repost + if visibility > 0 and share_to_mastodon and not classic_crosspost else "" ) post = Takahe.post_mark(self, post_as_new, append) @@ -306,7 +306,7 @@ class Mark: Takahe.bookmark(post.pk, self.owner.pk) # async boost to mastodon if post and share_to_mastodon: - if classic_repost: + if classic_crosspost: share_mark(self, post_as_new) else: boost_toot_later(user, post.url) diff --git a/journal/models/note.py b/journal/models/note.py index 0aa3e52a..58b7ec64 100644 --- a/journal/models/note.py +++ b/journal/models/note.py @@ -177,7 +177,9 @@ class Note(Content): "content": self.content + footer, "sensitive": self.sensitive, "reply_to_toot_url": ( - self.shelfmember.get_mastodon_repost_url() if self.shelfmember else None + self.shelfmember.get_mastodon_crosspost_url() + if self.shelfmember + else None ), } if self.latest_post: diff --git a/journal/models/review.py b/journal/models/review.py index dd3a7ab2..079722cb 100644 --- a/journal/models/review.py +++ b/journal/models/review.py @@ -78,20 +78,20 @@ class Review(Content): p.link_post_id(post.id) return p - def get_repost_postfix(self): + def get_crosspost_postfix(self): tags = render_post_with_macro( self.owner.user.preference.mastodon_append_tag, self.item ) return "\n" + tags if tags else "" - def get_repost_template(self): + def get_crosspost_template(self): return _(ShelfManager.get_action_template("reviewed", self.item.category)) def to_mastodon_params(self): content = ( - self.get_repost_template().format(item=self.item.display_title) + self.get_crosspost_template().format(item=self.item.display_title) + f"\n{self.title}\n{self.absolute_url} " - + self.get_repost_postfix() + + self.get_crosspost_postfix() ) params = {"content": content} return params @@ -99,12 +99,14 @@ class Review(Content): def to_post_params(self): item_link = f"{settings.SITE_INFO['site_url']}/~neodb~{self.item.url}" prepend_content = ( - self.get_repost_template().format( + self.get_crosspost_template().format( item=f'{self.item.display_title}' ) + f'
{self.title}' ) - content = f"{render_rating(self.rating_grade, 1)}\n{self.get_repost_postfix()}" + content = ( + f"{render_rating(self.rating_grade, 1)}\n{self.get_crosspost_postfix()}" + ) return { "prepend_content": prepend_content, "content": content, diff --git a/journal/templates/comment.html b/journal/templates/comment.html index 02365b24..cfe45684 100644 --- a/journal/templates/comment.html +++ b/journal/templates/comment.html @@ -59,7 +59,7 @@ id="id_share_to_mastodon" value="1" {% if request.user.preference.mastodon_default_repost %}checked{% endif %}> - {% trans "Repost to timeline" %} + {% trans "Crosspost to timeline" %} {% endif %} diff --git a/journal/templates/mark.html b/journal/templates/mark.html index e9894c93..85df06e7 100644 --- a/journal/templates/mark.html +++ b/journal/templates/mark.html @@ -117,7 +117,7 @@ id="id_share_to_mastodon" value="1" {% if request.user.preference.mastodon_default_repost %}checked{% endif %}> - {% trans "Repost to timeline" %} + {% trans "Crosspost to timeline" %} {% endif %} diff --git a/journal/views/common.py b/journal/views/common.py index de46f5b7..dc62e3d4 100644 --- a/journal/views/common.py +++ b/journal/views/common.py @@ -30,7 +30,7 @@ def render_relogin(request): "common/error.html", { "url": reverse("users:connect") + "?domain=" + request.user.mastodon_site, - "msg": _("Data saved but unable to repost to Fediverse instance."), + "msg": _("Data saved but unable to crosspost to Fediverse instance."), "secondary_msg": _( "Redirecting to your Fediverse instance now to re-authenticate." ), diff --git a/journal/views/mark.py b/journal/views/mark.py index 0b010e53..e90d10b2 100644 --- a/journal/views/mark.py +++ b/journal/views/mark.py @@ -115,7 +115,7 @@ def mark(request: AuthedHttpRequest, item_uuid): "common/error.html", { "msg": _( - "Data saved but unable to repost to Fediverse instance." + "Data saved but unable to crosspost to Fediverse instance." ), "secondary_msg": err, }, diff --git a/journal/views/note.py b/journal/views/note.py index 3dcbf376..101fa513 100644 --- a/journal/views/note.py +++ b/journal/views/note.py @@ -23,7 +23,7 @@ class NoteForm(NeoModelForm): widget=forms.RadioSelect(), choices=VisibilityType.choices, initial=0 ) share_to_mastodon = forms.BooleanField( - label=_("Post to Fediverse"), initial=True, required=False + label=_("Crosspost to timeline"), initial=True, required=False ) uuid = forms.CharField(widget=forms.HiddenInput(), required=False) # content = forms.CharField(required=False, widget=forms.Textarea) diff --git a/journal/views/post.py b/journal/views/post.py index fdc35fd4..9027f833 100644 --- a/journal/views/post.py +++ b/journal/views/post.py @@ -49,7 +49,7 @@ def post_reply(request: AuthedHttpRequest, post_id: int): @require_http_methods(["POST"]) @login_required def post_boost(request: AuthedHttpRequest, post_id: int): - # classic_repost = request.user.preference.mastodon_repost_mode == 1 + # classic_crosspost = request.user.preference.mastodon_repost_mode == 1 post = Takahe.get_post(post_id) if not post: raise BadRequest(_("Invalid parameter")) diff --git a/journal/views/wrapped.py b/journal/views/wrapped.py index 4ed7b564..cd629c5c 100644 --- a/journal/views/wrapped.py +++ b/journal/views/wrapped.py @@ -127,8 +127,8 @@ class WrappedShareView(LoginRequiredMixin, TemplateView): Takahe.visibility_n2t(visibility, user.preference.post_public_mode), attachments=[media], ) - classic_repost = user.preference.mastodon_repost_mode == 1 - if classic_repost: + classic_crosspost = user.preference.mastodon_repost_mode == 1 + if classic_crosspost: post_toot_later( user, comment, diff --git a/locale/zh_Hans/LC_MESSAGES/django.po b/locale/zh_Hans/LC_MESSAGES/django.po index 3650d2ce..bde5d26e 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-15 23:28-0400\n" +"POT-Creation-Date: 2024-06-16 21:51-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1678,9 +1678,10 @@ msgstr "标题" msgid "Content (Markdown)" msgstr "内容 (Markdown格式)" -#: journal/forms.py:21 journal/views/note.py:26 -msgid "Post to Fediverse" -msgstr "发布到联邦宇宙" +#: journal/forms.py:21 journal/templates/comment.html:62 +#: journal/templates/mark.html:120 journal/views/note.py:26 +msgid "Crosspost to timeline" +msgstr "转发到时间轴" #: journal/forms.py:25 journal/forms.py:45 #: journal/templates/collection_share.html:24 @@ -1807,7 +1808,7 @@ msgstr "第{value}首" msgid "Cycle {value}" msgstr "{value}周目" -#: journal/models/renderers.py:94 mastodon/api.py:619 takahe/utils.py:543 +#: journal/models/renderers.py:94 mastodon/api.py:619 takahe/utils.py:550 #, python-brace-format msgid "regarding {item_title}, may contain spoiler or triggering content" msgstr "关于 {item_title},可能包含剧透或敏感内容" @@ -2387,10 +2388,6 @@ msgstr "写短评" msgid "Tips: use >!text!< for spoilers; some instances may not be able to show posts longer than 360 charactors." msgstr "提示: 善用 >!文字!< 标记可隐藏剧透; 超过360字可能无法分享到联邦宇宙实例时间轴。" -#: journal/templates/comment.html:62 journal/templates/mark.html:120 -msgid "Repost to timeline" -msgstr "转发到时间轴" - #: journal/templates/comment.html:75 msgid "share with playback position" msgstr "分享播放位置" @@ -2659,7 +2656,7 @@ msgid "Login required" msgstr "登录后访问" #: journal/views/common.py:33 journal/views/mark.py:118 -msgid "Data saved but unable to repost to Fediverse instance." +msgid "Data saved but unable to crosspost to Fediverse instance." msgstr "数据已保存但未能转发到联邦实例。" #: journal/views/common.py:35 @@ -2802,7 +2799,7 @@ msgstr "播放" msgid "comment" msgstr "写短评" -#: social/templates/activity/create_collection.html:16 takahe/utils.py:593 +#: social/templates/activity/create_collection.html:16 takahe/utils.py:600 msgid "created collection" msgstr "创建了收藏单" @@ -3195,39 +3192,39 @@ msgstr "登录信息已更新" msgid "Account mismatch." msgstr "账号信息不匹配。" -#: users/data.py:127 +#: users/data.py:131 msgid "Generating exports." msgstr "正在生成导出文件。" -#: users/data.py:139 +#: users/data.py:143 msgid "Export file expired. Please export again." msgstr "导出文件已失效,请重新导出" -#: users/data.py:150 +#: users/data.py:154 msgid "Sync in progress." msgstr "正在同步。" -#: users/data.py:164 +#: users/data.py:168 msgid "Settings saved." msgstr "设置已保存" -#: users/data.py:175 +#: users/data.py:179 msgid "Reset completed." msgstr "重置已完成。" -#: users/data.py:184 +#: users/data.py:188 msgid "Import in progress." msgstr "正在导出" -#: users/data.py:186 +#: users/data.py:190 msgid "Invalid URL." msgstr "无效网址。" -#: users/data.py:200 users/data.py:225 users/data.py:240 +#: users/data.py:204 users/data.py:229 users/data.py:244 msgid "File is uploaded and will be imported soon." msgstr "文件已上传,等待后台导入。" -#: users/data.py:203 users/data.py:243 +#: users/data.py:207 users/data.py:247 msgid "Invalid file." msgstr "无效文件。" @@ -3625,15 +3622,15 @@ msgid "local, this site only" msgstr "仅本站" #: users/templates/users/preferences.html:96 -msgid "Turn on repost to timeline by default" +msgid "Turn on crosspost to timeline by default" msgstr "发表时默认转发到时间轴" #: users/templates/users/preferences.html:104 -msgid "Method for reposting to timeline" +msgid "Method for crossposting to timeline" msgstr "转发到时间轴的方式" #: users/templates/users/preferences.html:118 -msgid "repost as new post" +msgid "create a new post" msgstr "另发新帖文" #: users/templates/users/preferences.html:119 diff --git a/locale/zh_Hant/LC_MESSAGES/django.po b/locale/zh_Hant/LC_MESSAGES/django.po index 7f9d503c..589d38b0 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-15 23:28-0400\n" +"POT-Creation-Date: 2024-06-16 21:51-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1678,9 +1678,10 @@ msgstr "標題" msgid "Content (Markdown)" msgstr "內容 (Markdown格式)" -#: journal/forms.py:21 journal/views/note.py:26 -msgid "Post to Fediverse" -msgstr "發佈到聯邦宇宙" +#: journal/forms.py:21 journal/templates/comment.html:62 +#: journal/templates/mark.html:120 journal/views/note.py:26 +msgid "Crosspost to timeline" +msgstr "轉發到時間軸" #: journal/forms.py:25 journal/forms.py:45 #: journal/templates/collection_share.html:24 @@ -1807,7 +1808,7 @@ msgstr "第{value}首" msgid "Cycle {value}" msgstr "{value}周目" -#: journal/models/renderers.py:94 mastodon/api.py:619 takahe/utils.py:543 +#: journal/models/renderers.py:94 mastodon/api.py:619 takahe/utils.py:550 #, python-brace-format msgid "regarding {item_title}, may contain spoiler or triggering content" msgstr "關於 {item_title},可能包含劇透或敏感內容" @@ -2387,10 +2388,6 @@ msgstr "寫短評" msgid "Tips: use >!text!< for spoilers; some instances may not be able to show posts longer than 360 charactors." msgstr "提示: 善用 >!文字!< 標記可隱藏劇透; 超過360字可能無法分享到聯邦宇宙實例時間軸。" -#: journal/templates/comment.html:62 journal/templates/mark.html:120 -msgid "Repost to timeline" -msgstr "轉發到時間軸" - #: journal/templates/comment.html:75 msgid "share with playback position" msgstr "分享播放位置" @@ -2659,7 +2656,7 @@ msgid "Login required" msgstr "登錄後訪問" #: journal/views/common.py:33 journal/views/mark.py:118 -msgid "Data saved but unable to repost to Fediverse instance." +msgid "Data saved but unable to crosspost to Fediverse instance." msgstr "數據已保存但未能轉發到聯邦實例。" #: journal/views/common.py:35 @@ -2802,7 +2799,7 @@ msgstr "播放" msgid "comment" msgstr "寫短評" -#: social/templates/activity/create_collection.html:16 takahe/utils.py:593 +#: social/templates/activity/create_collection.html:16 takahe/utils.py:600 msgid "created collection" msgstr "創建了收藏單" @@ -3195,39 +3192,39 @@ msgstr "登錄信息已更新" msgid "Account mismatch." msgstr "賬號信息不匹配。" -#: users/data.py:127 +#: users/data.py:131 msgid "Generating exports." msgstr "正在生成導出文件。" -#: users/data.py:139 +#: users/data.py:143 msgid "Export file expired. Please export again." msgstr "導出文件已失效,請重新導出" -#: users/data.py:150 +#: users/data.py:154 msgid "Sync in progress." msgstr "正在同步。" -#: users/data.py:164 +#: users/data.py:168 msgid "Settings saved." msgstr "設置已保存" -#: users/data.py:175 +#: users/data.py:179 msgid "Reset completed." msgstr "重置已完成。" -#: users/data.py:184 +#: users/data.py:188 msgid "Import in progress." msgstr "正在導出" -#: users/data.py:186 +#: users/data.py:190 msgid "Invalid URL." msgstr "無效網址。" -#: users/data.py:200 users/data.py:225 users/data.py:240 +#: users/data.py:204 users/data.py:229 users/data.py:244 msgid "File is uploaded and will be imported soon." msgstr "文件已上傳,等待後臺導入。" -#: users/data.py:203 users/data.py:243 +#: users/data.py:207 users/data.py:247 msgid "Invalid file." msgstr "無效文件。" @@ -3625,15 +3622,15 @@ msgid "local, this site only" msgstr "僅本站" #: users/templates/users/preferences.html:96 -msgid "Turn on repost to timeline by default" +msgid "Turn on crosspost to timeline by default" msgstr "發表時默認轉發到時間軸" #: users/templates/users/preferences.html:104 -msgid "Method for reposting to timeline" +msgid "Method for crossposting to timeline" msgstr "轉發到時間軸的方式" #: users/templates/users/preferences.html:118 -msgid "repost as new post" +msgid "create a new post" msgstr "另發新帖文" #: users/templates/users/preferences.html:119 diff --git a/users/templates/users/preferences.html b/users/templates/users/preferences.html index fec1b58f..9a0e3793 100644 --- a/users/templates/users/preferences.html +++ b/users/templates/users/preferences.html @@ -93,7 +93,7 @@ {% if request.user.mastodon_acct %}
- {% trans "Method for reposting to timeline" %} + {% trans "Method for crossposting to timeline" %} - +
{% endif %}