Skip to content

Commit

Permalink
make re: s not compound
Browse files Browse the repository at this point in the history
  • Loading branch information
trinkey committed Nov 28, 2024
1 parent dd34404 commit 6a5f5d6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
14 changes: 7 additions & 7 deletions smiggins/backend/templating.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,19 +245,19 @@ def post(request, post_id: int) -> HttpResponse:

post_json = get_post_json(post_id, user.user_id if user is not None else 0)
lang = get_lang(user)

mentions = find_mentions(post.content + " @" + post.creator.username, exclude_users=[user.username if user else ""])
cw = post.content_warning or ""

return get_HTTP_response(
request, "post.html", lang, user=user,

DISPLAY_NAME = creator.display_name,
LOGGED_IN = str(user is not None).lower(),
POST_ID = str(post_id),
COMMENT = "false",
POST_ID = str(post_id),
COMMENT = "false",
POST_JSON = json.dumps(post_json),
CONTENT = (post.content_warning or post.content) + ("\n" + lang["home"]["quote_poll"] if post.poll else "\n" + lang["home"]["quote_recursive"] if post.quote else ""),
C_WARNING = (post.content_warning or "")[:MAX_CONTENT_WARNING_LENGTH - 4:],
CONTENT = (post.content_warning or post.content) + ("\n" + lang["home"]["quote_poll"] if post.poll else "\n" + lang["home"]["quote_recursive"] if post.quote else ""),
C_WARNING = cw[:MAX_CONTENT_WARNING_LENGTH] if cw.startswith("re: ") else f"re: {cw[:MAX_CONTENT_WARNING_LENGTH - 4]}",
EMBED_TITLE = lang["user_page"]["user_on_smiggins"].replace("%t", SITE_NAME).replace("%s", creator.display_name),

LIKES = lang["post_page"]["likes"].replace("%s", str(post_json["likes"])),
Expand Down Expand Up @@ -296,8 +296,8 @@ def comment(request, comment_id: int) -> HttpResponse:

comment_json = get_post_json(comment_id, user.user_id if user is not None else 0, True)
lang = get_lang(user if user is not None else None)

mentions = find_mentions(comment.content + " @" + comment.creator.username, exclude_users=[user.username if user else ""])
cw = comment.content_warning or ""

return get_HTTP_response(
request, "post.html", lang, user=user,
Expand All @@ -308,7 +308,7 @@ def comment(request, comment_id: int) -> HttpResponse:
COMMENT = "true",
POST_JSON = json.dumps(comment_json),
CONTENT = comment.content_warning or comment.content,
C_WARNING = (comment.content_warning or "")[:MAX_CONTENT_WARNING_LENGTH - 4:],
C_WARNING = cw[:MAX_CONTENT_WARNING_LENGTH] if cw.startswith("re: ") else f"re: {cw[:MAX_CONTENT_WARNING_LENGTH - 4]}",
EMBED_TITLE = lang["user_page"]["user_on_smiggins"].replace("%t", SITE_NAME).replace("%s", creator.display_name),

LIKES = lang["post_page"]["likes"].replace("%s", str(comment_json["likes"])),
Expand Down
2 changes: 1 addition & 1 deletion smiggins/templates/js/timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function addQuote(postID, isComment) {
<label for="default-private-${globalIncrement}">${lang.post.type_followers_only}:</label>
<input id="default-private-${globalIncrement}" type="checkbox" ${defaultPrivate ? "checked" : ""}><br>
</div>
${ENABLE_CONTENT_WARNINGS ? `<input class="c-warning" ${originalCW ? `value="re: ${escapeHTML(originalCW.slice(0, MAX_CONTENT_WARNING_LENGTH - 4))}"` : ""} maxlength="${MAX_CONTENT_WARNING_LENGTH}" placeholder="${lang.home.c_warning_placeholder}"><br>` : ""}
${ENABLE_CONTENT_WARNINGS ? `<input class="c-warning" ${originalCW ? `value="${escapeHTML(originalCW.startsWith("re: ") ? originalCW.slice(0, MAX_CONTENT_WARNING_LENGTH) : "re: " + originalCW.slice(0, MAX_CONTENT_WARNING_LENGTH - 4))}"` : ""} maxlength="${MAX_CONTENT_WARNING_LENGTH}" placeholder="${lang.home.c_warning_placeholder}"><br>` : ""}
<textarea class="post-text" maxlength="${MAX_POST_LENGTH}" placeholder="${lang.home.quote_placeholders[Math.floor(Math.random() * lang.home.quote_placeholders.length)]}"></textarea><br>
<button class="post-button inverted">${lang.generic.post}</button>
<button class="cancel-button inverted">${lang.generic.cancel}</button>
Expand Down
3 changes: 2 additions & 1 deletion smiggins/templates/post.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

{% extends "base.html" %}
{% load static %}

Expand Down Expand Up @@ -38,7 +39,7 @@
<input id="default-private" type="checkbox" {% if DEFAULT_PRIVATE == "true" %}checked{% endif %}><br>

{% if ENABLE_CONTENT_WARNINGS == 'true' %}
<input id="c-warning" {% if C_WARNING %}value="re: {{ C_WARNING }}"{% endif %} maxlength="{{ MAX_CONTENT_WARNING_LENGTH }}" placeholder="{{ lang.home.c_warning_placeholder }}"><br>
<input id="c-warning" {% if C_WARNING %}value="{{ C_WARNING }}"{% endif %} maxlength="{{ MAX_CONTENT_WARNING_LENGTH }}" placeholder="{{ lang.home.c_warning_placeholder }}"><br>
{% endif %}

<textarea id="post-text" maxlength="{{ MAX_POST_LENGTH }}" placeholder="{{ lang.post_page.comment_input_placeholder }}">{{ mentions }}</textarea><br>
Expand Down
2 changes: 1 addition & 1 deletion smiggins/ts/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function addQuote(postID: number, isComment: boolean): void {
<label for="default-private-${globalIncrement}">${ lang.post.type_followers_only }:</label>
<input id="default-private-${globalIncrement}" type="checkbox" ${defaultPrivate ? "checked" : ""}><br>
</div>
${ENABLE_CONTENT_WARNINGS ? `<input class="c-warning" ${originalCW ? `value="re: ${escapeHTML(originalCW.slice(0, MAX_CONTENT_WARNING_LENGTH - 4))}"` : ""} maxlength="${MAX_CONTENT_WARNING_LENGTH}" placeholder="${lang.home.c_warning_placeholder}"><br>` : ""}
${ENABLE_CONTENT_WARNINGS ? `<input class="c-warning" ${originalCW ? `value="${escapeHTML(originalCW.startsWith("re: ") ? originalCW.slice(0, MAX_CONTENT_WARNING_LENGTH) : "re: " + originalCW.slice(0, MAX_CONTENT_WARNING_LENGTH - 4))}"` : ""} maxlength="${MAX_CONTENT_WARNING_LENGTH}" placeholder="${lang.home.c_warning_placeholder}"><br>` : ""}
<textarea class="post-text" maxlength="${MAX_POST_LENGTH}" placeholder="${lang.home.quote_placeholders[Math.floor(Math.random() * lang.home.quote_placeholders.length)]}"></textarea><br>
<button class="post-button inverted">${lang.generic.post}</button>
<button class="cancel-button inverted">${lang.generic.cancel}</button>
Expand Down

0 comments on commit 6a5f5d6

Please sign in to comment.