Skip to content

Commit

Permalink
fix spoiler text when commenting episodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name authored and alphatownsman committed Apr 21, 2024
1 parent 50cd724 commit 8b0507f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion common/templates/_sidebar_anonymous.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h3>欢迎 🙋🏻‍♀️ 🙋🏻 🙋🏻‍♂️</h3>
<i class="fa-solid fa-circle-question"></i> &nbsp; 如果有任何问题或建议,欢迎通过<a href="https://mastodon.social/@neodb">联邦宇宙</a><a href="https://discord.gg/uprvcH8gqD">Discord</a>和我们联系。
</p>
<p>
<i class="fa-solid fa-door-open"></i> &nbsp; <a href="{% url 'users:login' %}">点击这里</a>登录
<i class="fa-solid fa-door-open"></i> &nbsp; <a href="{% url 'users:login' %}">点击这里</a>注册或登录
</p>
</article>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion locale/zh_Hans/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ msgstr "收藏单"

#: catalog/common/models.py:129 catalog/common/models.py:142
msgid "TV"
msgstr "电视"
msgstr "剧集"

#: catalog/common/models.py:130 catalog/common/models.py:143
#: common/templates/_header.html:37
Expand Down
15 changes: 11 additions & 4 deletions mastodon/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def detect_server_info(login_domain) -> tuple[str, str, str]:
response = get(url, headers={"User-Agent": USER_AGENT})
except Exception as e:
logger.warning(f"Error connecting {login_domain}: {e}")
raise Exception(f"无法连接 {login_domain}")
raise Exception(f"无法连接实例 {login_domain}")
if response.status_code != 200:
logger.warning(f"Error connecting {login_domain}: {response.status_code}")
raise Exception(f"实例 {login_domain} 返回错误,代码: {response.status_code}")
Expand Down Expand Up @@ -398,7 +398,7 @@ def get_or_create_fediverse_application(login_domain):
app_id=data["id"],
client_id=data["client_id"],
client_secret=data["client_secret"],
vapid_key=data["vapid_key"] if "vapid_key" in data else "",
vapid_key=data.get("vapid_key", ""),
)
return app

Expand Down Expand Up @@ -518,10 +518,11 @@ def share_comment(comment):
if user.preference.mastodon_append_tag
else ""
)
spoiler_text, txt = get_spoiler_text(comment.text or "", comment.item)
tpl = ShelfManager.get_action_template(ShelfType.PROGRESS, comment.item.category)
content = (
_(tpl).format(item=comment.item.display_title)
+ f"\n{comment.text}\n{comment.item.absolute_url}{tags}"
+ f"\n{txt}\n{comment.item.absolute_url}{tags}"
)
update_id = None
if comment.metadata.get(
Expand All @@ -532,7 +533,13 @@ def share_comment(comment):
) # might be re.match(r'.+/([^/]+)$', u) if Pleroma supports edit
update_id = r[1] if r else None
response = post_toot(
user.mastodon_site, content, visibility, user.mastodon_token, False, update_id
user.mastodon_site,
content,
visibility,
user.mastodon_token,
False,
update_id,
spoiler_text,
)
if response is not None and response.status_code in [200, 201]:
j = response.json()
Expand Down

0 comments on commit 8b0507f

Please sign in to comment.