diff --git a/files/assets/js/gif_modal.js b/files/assets/js/gif_modal.js deleted file mode 100644 index 94746bf09..000000000 --- a/files/assets/js/gif_modal.js +++ /dev/null @@ -1,85 +0,0 @@ -let commentFormID; - -function commentForm(form) { - commentFormID = form; -}; - -async function getGif(searchTerm) { - - if (searchTerm !== undefined) { - document.getElementById('gifSearch').value = searchTerm; - } - else { - document.getElementById('gifSearch').value = null; - } - - var loadGIFs = document.getElementById('gifs-load-more'); - - var noGIFs = document.getElementById('no-gifs-found'); - - var container = document.getElementById('GIFs'); - - var backBtn = document.getElementById('gifs-back-btn'); - - var cancelBtn = document.getElementById('gifs-cancel-btn'); - - container.innerHTML = ''; - - if (searchTerm == undefined) { - container.innerHTML = '
Agree
Laugh
Confused
Sad
Happy
Awesome
Yes
No
Love
Please
Scared
Angry
Awkward
Cringe
OMG
Why
Gross
Meh
' - - backBtn.innerHTML = null; - - cancelBtn.innerHTML = null; - - noGIFs.innerHTML = null; - - loadGIFs.innerHTML = null; - } - else { - backBtn.innerHTML = ''; - - cancelBtn.innerHTML = ''; - - let response = await fetch("/giphy?searchTerm=" + searchTerm + "&limit=48"); - let data = await response.json() - var max = data.data?.length === undefined ? 0 : data.data.length - 1 - data = data.data - var gifURL = []; - - if (max <= 0) { - noGIFs.innerHTML = '

Aw shucks. No GIFs found...

'; - container.innerHTML = null; - loadGIFs.innerHTML = null; - } - else { - for (var i = 0; i < 48; i++) { - gifURL[i] = "https://media.giphy.com/media/" + data[i].id + "/giphy.webp"; - if (data[i].username==''){ - container.innerHTML += ('
'); - } - else { - container.innerHTML += ('
'); - } - noGIFs.innerHTML = null; - loadGIFs.innerHTML = '

Thou've reached the end of the list!

'; - } - } - } -} - -function insertGIF(url,form) { - - // https://github.com/themotte/rDrama/issues/139 - // when MULTIMEDIA_EMBEDDING_ENABLED == False, we want to insert an anchor, NOT an img - //var gif = "\n\n![](" + url +")"; - var gif = '\n\n[' + url + '](' + url + ')'; - - var commentBox = document.getElementById(form); - - var old = commentBox.value; - - commentBox.value = old + gif; - - if (typeof checkForRequired === "function") checkForRequired(); -} diff --git a/files/classes/comment.py b/files/classes/comment.py index d90893473..88f5df1db 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -1,7 +1,7 @@ from os import environ import re import time -from typing import Optional +from typing import Literal, Optional from urllib.parse import urlencode, urlparse, parse_qs from flask import * from sqlalchemy import * @@ -16,6 +16,8 @@ from random import randint from .votes import CommentVote from math import floor +CommentRenderContext = Literal['comments', 'volunteer'] + class Comment(Base): __tablename__ = "comments" @@ -87,10 +89,33 @@ class Comment(Base): comment_age_seconds = int(time.time()) - self.created_utc comment_age_hours = comment_age_seconds / (60*60) return comment_age_hours < app.config['SCORE_HIDING_TIME_HOURS'] + + @lazy + def _score_context_str(self, score_type:Literal['score', 'upvotes', 'downvotes'], + context:CommentRenderContext) -> str: + if self.is_message: return '' # don't show scores for messages + if context == 'volunteer': return '' # volunteer: hide scores + if self.should_hide_score: return '' # hide scores for new comments + + if score_type == 'upvotes': return str(self.upvotes) + if score_type == 'score': return str(self.score) + if score_type == 'downvotes': return str(self.downvotes) + + @lazy + def upvotes_str(self, context:CommentRenderContext) -> str: + return self._score_context_str('upvotes', context) + + @lazy + def score_str(self, context:CommentRenderContext) -> str: + return self._score_context_str('score', context) + + @lazy + def downvotes_str(self, context:CommentRenderContext) -> str: + return self._score_context_str('downvotes', context) @property @lazy - def top_comment(self): + def top_comment(self) -> Optional["Comment"]: return g.db.query(Comment).filter_by(id=self.top_comment_id).one_or_none() @lazy @@ -385,20 +410,121 @@ class Comment(Base): @lazy def collapse_for_user(self, v, path): if v and self.author_id == v.id: return False - if path == '/admin/removed/comments': return False - if self.over_18 and not (v and v.over_18) and not (self.post and self.post.over_18): return True - if self.is_banned: return True - if v and v.filter_words and self.body and any(x in self.body for x in v.filter_words): return True - return False @property @lazy - def is_op(self): return self.author_id==self.post.author_id + def is_op(self): + return self.author_id == self.post.author_id + + @property + @lazy + def is_comment(self) -> bool: + ''' + Returns whether this is an actual comment (i.e. not a private message) + ''' + return bool(self.parent_submission) + + @property + @lazy + def is_message(self) -> bool: + ''' + Returns whether this is a private message or modmail + ''' + return not self.is_comment + + @property + @lazy + def is_strict_message(self) -> bool: + ''' + Returns whether this is a private message or modmail + but is not a notification + ''' + return self.is_message and not self.is_notification + + @property + @lazy + def is_modmail(self) -> bool: + ''' + Returns whether this is a modmail message + ''' + if not self.is_message: return False + if self.sentto == MODMAIL_ID: return True + + top_comment: Optional["Comment"] = self.top_comment + return bool(top_comment.sentto == MODMAIL_ID) + + @property + @lazy + def is_notification(self) -> bool: + ''' + Returns whether this is a notification + ''' + return self.is_message and not self.sentto + + @lazy + def header_msg(self, v, is_notification_page:bool, reply_count:int) -> str: + ''' + Returns a message that is in the header for a comment, usually for + display on a notification page. + ''' + if self.post: + post_html:str = f"{self.post.realtitle(v)}" + if v: + if v.id == self.author_id and reply_count: + text = f"Comment {'Replies' if reply_count != 1 else 'Reply'}" + elif v.id == self.post.author_id and self.level == 1: + text = "Post Reply" + elif self.parent_submission in v.subscribed_idlist(): + text = "Subscribed Thread" + else: + text = "Username Mention" + if is_notification_page: + return f"{text}: {post_html}" + return post_html + elif self.author_id in {AUTOJANNY_ID, NOTIFICATIONS_ID}: + return "Notification" + elif self.sentto == MODMAIL_ID: + return "Sent to admins" + else: + return f"Sent to @{self.senttouser.username}" + + @lazy + def voted_display(self, v) -> int: + ''' + Returns data used to modify how to show the vote buttons. + + :returns: A number between `-2` and `1`. `-2` is returned if `v` is + `None`. `1` is returned if the user is the comment author. + Otherwise, a value of `-1` (downvote),` 0` (no vote or no data), or `1` + (upvote) is returned. + ''' + if not v: return -2 + if v.id == self.author_id: return 1 + return getattr(self, 'voted', 0) @lazy - def active_flags(self, v): return len(self.flags(v)) + def sticky_api_url(self, v) -> Optional[str]: + ''' + Returns the API URL used to sticky this comment. + :returns: Currently `None` always. Stickying comments was disabled + UI-side on TheMotte. + ''' + return None + if not self.is_comment: return None + if not v: return None + if v.admin_level >= 2: + return 'sticky_comment' + if v.id == self.post.author_id: + return 'pin_comment' + if self.post.sub and v.mods(self.post.sub): + return 'mod_pin' + return None + + @lazy + def active_flags(self, v): + return len(self.flags(v)) diff --git a/files/templates/comments.html b/files/templates/comments.html index 0f9a14b8b..21501901b 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -1,69 +1,19 @@ -{% if not ajax %} - {% if comment_info and not request.full_path.endswith('#context') %} - - {% endif %} - - - - {% include 'usernote.html' %} -{% endif %} +{%- include "component/comment/usernote_header.html" -%} {# "level" represents the nested level in this call; always starts at 1 #} {# this is distinct from "comment.level", which is the global depth of this comment #} {% macro single_comment(c, level) %} + {%- if render_ctx is not defined -%} + {% set render_ctx = 'comments' %} + {%- endif -%} + {%- set ups = c.upvotes_str(render_ctx) -%} + {%- set score = c.score_str(render_ctx) -%} + {%- set downs = c.downvotes_str(render_ctx) -%} +{%- set replies = c.replies(v) -%} +{%- set is_notification_page = request.path.startswith('/notifications') -%} -{% if should_hide_score or c.should_hide_score %} - {% set ups="" %} - {% set downs="" %} - {% set score="" %} -{% else %} - {% set ups=c.upvotes %} - {% set downs=c.downvotes %} - {% set score=c.score %} -{% endif %} - -{% if v and (v.shadowbanned or v.admin_level > 1) %} - {% set replies=c.replies_ignoring_shadowbans %} -{% else %} - {% set replies=c.replies(v) %} -{% endif %} - -{% if (c.is_banned or c.deleted_utc or c.is_blocking) and not (v and v.admin_level > 1) and not (v and v.id==c.author_id) %} +{% if (c.is_banned or c.deleted_utc or c.is_blocking) and not (v and v.admin_level >= 2) and not (v and v.id==c.author_id) %}
@@ -86,7 +36,7 @@ {{single_comment(reply, level=level+1)}} {% endfor %}
- {% elif replies and "notifications" in request.path %} + {% elif replies and is_notification_page %}
{% set standalone=False %} {% for reply in replies %} @@ -106,56 +56,21 @@
- {% else %} -{% if v %} - {% set voted=c.voted %} - {% if not voted and v.id == c.author_id %} - {% set voted=1 %} - {% endif %} -{% else %} - {% set voted=-2 %} -{% endif %} +{%- set voted = c.voted_display(v) -%} {% if standalone and level==1 %} -
+
{% if c.post and c.post.over_18 %}+18{% endif %} + {{c.header_msg(v, is_notification_page, replies | length) | safe}} - {% if c.post %} - {% if c.author_id==v.id and replies and is_notification_page%} - Comment {{'Replies' if (replies | length)>1 else 'Reply'}}: {{c.post.realtitle(v) | safe}} - {% elif c.post.author_id==v.id and c.level == 1 and is_notification_page%} - Post Reply: {{c.post.realtitle(v) | safe}} - {% elif is_notification_page and c.parent_submission in v.subscribed_idlist() %} - Subscribed Thread: {{c.post.realtitle(v) | safe}} - {% elif is_notification_page %} - Username Mention: {{c.post.realtitle(v) | safe}} - {% else %} - {{c.post.realtitle(v) | safe}} - {% endif %} - - {% if c.post.sub %} - in /h/{{c.post.sub}} - {% endif %} - {% elif c.author_id==NOTIFICATIONS_ID or c.author_id==AUTOJANNY_ID %} - Notification - {% else %} - {% if c.sentto == MODMAIL_ID %} - Sent to admins - {% else %} - Sent to @{{c.senttouser.username}} - {% endif %} - {% endif %} - + {{c.header_msg(v, is_notification_page, replies | length) | safe}} +
{% endif %} -{% if not standalone and c.parent_comment and c.parent_comment.sentto %} - {% set isreply = True %} -{% else %} - {% set isreply = False %} -{% endif %} +{% set isreply = not standalone and c.parent_comment and c.parent_comment.sentto %}
{% if not isreply %} @@ -164,89 +79,12 @@
{% endif %} -
- - {% if c.ghost %} - 👻 - {% else %} - {% if c.author.verified %} - {% endif %} - {% if not should_hide_username %} - {{c.author_name}} - {% endif %} - {% if v and v.admin_level > 1 %} - U - {% endif %} - {% if c.author.customtitle and not should_hide_username -%} -   {{c.author.customtitle | safe}} - {%- endif %} - {% endif %} - - {% if FEATURES['AWARDS'] %} - {% for a in c.awards|reverse %} - - {% endfor %} - {% endif %} - - {% if c.post %} - {% set sub = c.post.sub %} - {% if sub and c.author.exiled_from(sub) %} - - {% endif %} - {% endif %} - - {% if c.bannedfor %} - - {% endif %} - {% if v and c.filter_state == 'reported' and v.can_manage_reports() %}{{c.active_flags(v)}} Reports{% endif %} - {% if c.over_18 %}+18{% endif %} - {% if v and v.admin_level > 1 and c.author.shadowbanned %}{% endif %} - {% if c.is_pinned %} - - {% endif %} - {% if c.distinguish_level and not c.ghost %}{% endif %} - {% if c.is_op %}{% endif %} - {% if c.is_bot %}{% endif %} - {% if c.is_blocking %}{% endif %} - {% if c.is_blocked %}{% endif %} - - {% if c.parent_comment_id and not standalone and level != 1 %}{{c.parent_comment.author_name}}{% endif %} - - {% if c.notif_utc %} -  {{c.age_string}} - {% elif c.created_utc %} -  {{c.age_string}} - {% endif %} - - {% if c.edited_utc %} - · Edited {{c.edited_string}} - {% endif %} -
+ {%- include 'component/comment/user_info.html' -%}
-
- - - {% if v and c.filter_state == 'reported' and v.can_manage_reports() %} -
- Reports: - Approve - Approve and Ignore - Remove -

-				
    - {% for f in c.flags(v) %} -
  • {{f.user.username}}{% if f.reason %}: {{f.realreason(v) | safe}}{% endif %}
  • - {% endfor %} -
-
- {% endif %} - - {% if c.is_banned and c.ban_reason %} + {%- include 'component/comment/reports.html'-%} + {% if c.is_banned and c.ban_reason %} {# TODO: shouldn't be visible. See #359 #}
removed by @{{c.ban_reason}}
{% endif %} @@ -254,550 +92,90 @@ {{c.realbody(v) | safe}}
{% if c.parent_submission %} - - {% if v and v.id==c.author_id %} - - {% endif %} + {%- include 'component/comment/editbox_comment.html' -%}
- - -
    -
  • - {% if v and v.admin_level > 1 %} - - - - {% endif %} -
  • - + {% if v and v.admin_level >= 2 %} +
  • + +
  • + {% endif %} {% if v %} {% endif %}
  • - - - +
  • - - {% if v and request.path.startswith('/@') and v.admin_level < 2 %} -
  • - {% if voted==1 %} - - {% endif %} - - {{score}} - - {% if voted==-1 %} - - {% endif %} -
  • - {% elif v %} -
  • - - - - - {{score}} - - - - -
  • - {% else %} -
  • - - - - - {{score}} - - - - -
  • - {% endif %} -
-
-
- - - - - - - - - - -
  • - {% if v and request.path.startswith('/@') and v.admin_level < 2%} - {% if voted==1 %} - - {% endif %} - {% elif v %} - - - - {% else %} - - - {% endif %} - - - - {% if v and request.path.startswith('/@') and v.admin_level < 2 %} - {% if voted==-1 %} -
  • - {% endif %} - {% elif v %} - - - {% else %} - - - - {% endif %} - - {% if v and v.admin_level >= 2 %}Votes{% endif %} - - Context - - - - {% if v %} - - - - - - - - {% endif %} - - {% if c.parent_submission %} - {% if v and c.author_id == v.id %} - - - - - - {% elif v and c.body %} - - {% endif %} - {% endif %} - - {% if v and v.admin_level > 1 and c.filter_state == 'filtered' %} - - - {% endif %} - - {% if v %} - - - {% endif %} +
+
+ +
{% endif %} - - - {% if v and v.id != c.author_id and c.body %} - - {% endif %} - - -
- -
- - - {% if render_replies %} - {% if level <= RENDER_DEPTH_LIMIT - 1 or request.path == '/notifications' %} -
- {% for reply in replies %} - {{single_comment(reply, level=level+1)}} - {% endfor %} -
- {% elif replies %} -
- - More comments -
- {% endif %} - - {% if request.path == '/notifications' and c.level == 1 and c.sentto and not c.parent_submission and c.author_id not in (NOTIFICATIONS_ID, AUTOJANNY_ID) %} - Reply -
- -
- {% endif %} + + {% if v and v.id != c.author_id and c.body %} + + {% endif %} + + {%- include 'component/comment/replybox_comment.html' -%} + + {% if render_replies %} + {% if level <= RENDER_DEPTH_LIMIT - 1 or is_notification_page %} +
+ {% for reply in replies %} + {{single_comment(reply, level=level+1)}} + {% endfor %} +
+ {% elif replies %} +
+ + More comments +
+ {% endif %} + + {% if is_notification_page and c.level == 1 and c.sentto and not c.parent_submission and c.author_id not in (NOTIFICATIONS_ID, AUTOJANNY_ID) %} + {%- include 'components/comment/replybox_message.html' -%} + {% endif %} {% else %} -
+
{% endif %} +{%- include 'component/comment/actions_mobile.html' -%} - - - - - - - -{% if v and v.admin_level > 1 %} - +{% if v and v.admin_level >= 2 %} + {%- include 'component/comment/actions_mobile_admin.html' -%} {% endif %} - {% endif %} - {% endmacro %} {% for comment in comments %} - - {% if parent_level %} - {% set parent_level = parent_level | int %} - {% else %} - {% set parent_level = 0 %} - {% endif %} - - {{ single_comment(comment, level = parent_level + 1) }} - + {%- set parent_level = parent_level | int if parent_level else 0 -%} + {{single_comment(comment, level = parent_level + 1)}} {% endfor %} -{% if offset %} - {% if p %} - {% set pid = p.id %} - {% endif %} -
-
- -
-{% endif %} +{%- include 'component/comment/view_more_button.html' -%} {% if not ajax %} {% if v %} - {% include "gif_modal.html" %} - {% if v.admin_level > 1 %} - {% include "ban_modal.html" %} + {% if v.admin_level >= 2 %} + {% include "component/modal/ban.html" %} {% endif %} - - - - + {%- include 'component/modal/delete_comment.html' -%} + {%- include 'component/modal/report_comment.html' -%} {% endif %} {% if v %} @@ -812,14 +190,16 @@ - {% if v and v.admin_level > 1 %} - - {% if v.admin_level > 1 %} + {% if v %} + {% if v.admin_level >= 2 %} + + {% endif %} + {% if v.admin_level >= 2 %} {% endif %} {% endif %} - {% include "expanded_image_modal.html" %} + {% include "component/modal/expanded_image.html" %} @@ -842,7 +222,7 @@ {% if p and not (request.values and ('context' in request.values)) %} collapsedCommentStorageInit('post_{{p.id}}'); - {% elif request.path == '/notifications' or request.path.startswith('/@') %} + {% elif is_notification_page or request.path.startswith('/@') %} collapsedCommentStorageInit('{{request.path}}'); {% endif %} if (document.readyState === "complete" || @@ -888,5 +268,3 @@ } {% endif %} - - diff --git a/files/templates/component/comment/actions_desktop.html b/files/templates/component/comment/actions_desktop.html new file mode 100644 index 000000000..8400745c0 --- /dev/null +++ b/files/templates/component/comment/actions_desktop.html @@ -0,0 +1,80 @@ +{% if v and v.admin_level >= 2 %} + Votes +{% endif %} + Context + +{% if v %} + + + + +{% endif %} +{% if c.parent_submission %} +{% if v and c.author_id == v.id %} + + + +{% elif v and c.body %} + +{% endif %} +{% endif %} + +{% if v and v.admin_level >= 2 and c.filter_state == 'filtered' %} + + +{% endif %} + +{% if v %} + + +{% endif %} diff --git a/files/templates/component/comment/actions_mobile.html b/files/templates/component/comment/actions_mobile.html new file mode 100644 index 000000000..4944dec2c --- /dev/null +++ b/files/templates/component/comment/actions_mobile.html @@ -0,0 +1,71 @@ + diff --git a/files/templates/component/comment/actions_mobile_admin.html b/files/templates/component/comment/actions_mobile_admin.html new file mode 100644 index 000000000..568bfc8d8 --- /dev/null +++ b/files/templates/component/comment/actions_mobile_admin.html @@ -0,0 +1,45 @@ + diff --git a/files/templates/component/comment/editbox_comment.html b/files/templates/component/comment/editbox_comment.html new file mode 100644 index 000000000..b983e10dc --- /dev/null +++ b/files/templates/component/comment/editbox_comment.html @@ -0,0 +1,27 @@ +{% if v and v.id==c.author_id %} + +{% endif %} diff --git a/files/templates/component/comment/replybox_comment.html b/files/templates/component/comment/replybox_comment.html new file mode 100644 index 000000000..6f9577636 --- /dev/null +++ b/files/templates/component/comment/replybox_comment.html @@ -0,0 +1,29 @@ +
+ +
diff --git a/files/templates/component/comment/replybox_message.html b/files/templates/component/comment/replybox_message.html new file mode 100644 index 000000000..c3efb6ceb --- /dev/null +++ b/files/templates/component/comment/replybox_message.html @@ -0,0 +1,20 @@ +Reply +
+ +
diff --git a/files/templates/component/comment/reports.html b/files/templates/component/comment/reports.html new file mode 100644 index 000000000..ffdb38775 --- /dev/null +++ b/files/templates/component/comment/reports.html @@ -0,0 +1,14 @@ +{%- if v and c.filter_state == 'reported' and v.can_manage_reports() -%} +
+ Reports: + Approve + Approve and Ignore + Remove +

+		
+	
+{%- endif -%} diff --git a/files/templates/component/comment/user_info.html b/files/templates/component/comment/user_info.html new file mode 100644 index 000000000..b0174136f --- /dev/null +++ b/files/templates/component/comment/user_info.html @@ -0,0 +1,60 @@ +
+ {% if c.ghost %} + 👻 + {% else %} + {% if c.author.verified %} + {% endif %} + {% if not should_hide_username %} + {{c.author_name}} + {% endif %} + {% if v and v.admin_level >= 2 %} + U + {% endif %} + {% if c.author.customtitle and not should_hide_username -%} +   {{c.author.customtitle | safe}} + {%- endif %} + {% endif %} + + {% if FEATURES['AWARDS'] %} + {% for a in c.awards|reverse %} + + {% endfor %} + {% endif %} + + {% if c.post %} + {% set sub = c.post.sub %} + {% if sub and c.author.exiled_from(sub) %} + + {% endif %} + {% endif %} + + {% if c.bannedfor %} + + {% endif %} + {% if v and c.filter_state == 'reported' and v.can_manage_reports() %}{{c.active_flags(v)}} Reports{% endif %} + {% if c.over_18 %}+18{% endif %} + {% if v and v.admin_level >= 2 and c.author.shadowbanned %}{% endif %} + {% if c.is_pinned %} + + {% endif %} + {% if c.distinguish_level and not c.ghost %}{% endif %} + {% if c.is_op %}{% endif %} + {% if c.is_bot %}{% endif %} + {% if c.is_blocking %}{% endif %} + {% if c.is_blocked %}{% endif %} + + {% if c.parent_comment_id and not standalone and level != 1 %}{{c.parent_comment.author_name}}{% endif %} + + {% if c.notif_utc %} +  {{c.age_string}} + {% elif c.created_utc %} +  {{c.age_string}} + {% endif %} + + {% if c.edited_utc %} + · Edited {{c.edited_string}} + {% endif %} +
diff --git a/files/templates/component/comment/usernote_header.html b/files/templates/component/comment/usernote_header.html new file mode 100644 index 000000000..60f6a0e25 --- /dev/null +++ b/files/templates/component/comment/usernote_header.html @@ -0,0 +1,43 @@ +{% if not ajax %} + {% if comment_info and not request.full_path.endswith('#context') %} + + {% endif %} + + + + {% include 'usernote.html' %} +{% endif %} diff --git a/files/templates/component/comment/view_more_button.html b/files/templates/component/comment/view_more_button.html new file mode 100644 index 000000000..00f298b0c --- /dev/null +++ b/files/templates/component/comment/view_more_button.html @@ -0,0 +1,9 @@ +{% if offset %} + {% if p %} + {% set pid = p.id %} + {% endif %} +
+
+ +
+{% endif %} diff --git a/files/templates/component/comment/voting_desktop.html b/files/templates/component/comment/voting_desktop.html new file mode 100644 index 000000000..11bb0d499 --- /dev/null +++ b/files/templates/component/comment/voting_desktop.html @@ -0,0 +1,28 @@ +{# upvote #} +{%- if v and request.path.startswith('/@') and v.admin_level < 2 -%} + {% if voted==1 %} + + {% endif %} +{% elif v %} + +{% else %} + +{% endif %} + +{# score #} + + +{# downvote #} +{%- if v and request.path.startswith('/@') and v.admin_level < 2 -%} + {% if voted == -1 %} +
  • + {% endif %} +{%- elif environ.get('DISABLE_DOWNVOTES') == '1' -%} + {# downvotes not allowed, nop #} +{%- elif v -%} + +{%- else -%} + +{%- endif %} diff --git a/files/templates/component/comment/voting_mobile.html b/files/templates/component/comment/voting_mobile.html new file mode 100644 index 000000000..685ccae6e --- /dev/null +++ b/files/templates/component/comment/voting_mobile.html @@ -0,0 +1,28 @@ +{% if v and request.path.startswith('/@') and v.admin_level < 2 %} {# only admins can vote on user pages #} +
  • + {% if voted==1 %} + + {% endif %} + + {{score}} + {% if voted==-1 %} + + {% endif %} +
  • +{% elif v %} +
  • + + {{score}} + +
  • +{% else %} +
  • + + + + {{score}} + + + +
  • +{% endif %} diff --git a/files/templates/award_modal.html b/files/templates/component/modal/award.html similarity index 100% rename from files/templates/award_modal.html rename to files/templates/component/modal/award.html diff --git a/files/templates/ban_modal.html b/files/templates/component/modal/ban.html similarity index 100% rename from files/templates/ban_modal.html rename to files/templates/component/modal/ban.html diff --git a/files/templates/component/modal/delete_comment.html b/files/templates/component/modal/delete_comment.html new file mode 100644 index 000000000..56510e32e --- /dev/null +++ b/files/templates/component/modal/delete_comment.html @@ -0,0 +1,22 @@ + diff --git a/files/templates/delete_post_modal.html b/files/templates/component/modal/delete_post.html similarity index 99% rename from files/templates/delete_post_modal.html rename to files/templates/component/modal/delete_post.html index 442d73ad0..597348a26 100644 --- a/files/templates/delete_post_modal.html +++ b/files/templates/component/modal/delete_post.html @@ -10,19 +10,13 @@ diff --git a/files/templates/expanded_image_modal.html b/files/templates/component/modal/expanded_image.html similarity index 100% rename from files/templates/expanded_image_modal.html rename to files/templates/component/modal/expanded_image.html diff --git a/files/templates/component/modal/report_comment.html b/files/templates/component/modal/report_comment.html new file mode 100644 index 000000000..0d64a4d04 --- /dev/null +++ b/files/templates/component/modal/report_comment.html @@ -0,0 +1,29 @@ + diff --git a/files/templates/report_post_modal.html b/files/templates/component/modal/report_post.html similarity index 100% rename from files/templates/report_post_modal.html rename to files/templates/component/modal/report_post.html diff --git a/files/templates/post_actions.html b/files/templates/component/post/actions.html similarity index 100% rename from files/templates/post_actions.html rename to files/templates/component/post/actions.html diff --git a/files/templates/post_admin_actions_mobile.html b/files/templates/component/post/actions_admin_mobile.html similarity index 100% rename from files/templates/post_admin_actions_mobile.html rename to files/templates/component/post/actions_admin_mobile.html diff --git a/files/templates/post_actions_mobile.html b/files/templates/component/post/actions_mobile.html similarity index 100% rename from files/templates/post_actions_mobile.html rename to files/templates/component/post/actions_mobile.html diff --git a/files/templates/formatting.html b/files/templates/formatting.html index 02fb96e26..f6954df19 100644 --- a/files/templates/formatting.html +++ b/files/templates/formatting.html @@ -461,6 +461,6 @@ line breaks
    Comment Commands
    -{% include "expanded_image_modal.html" %} +{% include "component/modal/expanded_image.html" %} {% endblock %} diff --git a/files/templates/gif_modal.html b/files/templates/gif_modal.html deleted file mode 100644 index 43efffdeb..000000000 --- a/files/templates/gif_modal.html +++ /dev/null @@ -1,29 +0,0 @@ - - - diff --git a/files/templates/settings_profile.html b/files/templates/settings_profile.html index bfe98536d..259587ab6 100644 --- a/files/templates/settings_profile.html +++ b/files/templates/settings_profile.html @@ -467,11 +467,5 @@ - - - -{% include "gif_modal.html" %} - {% endblock %} - diff --git a/files/templates/submission.html b/files/templates/submission.html index 44209d9f7..f8d419bfd 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -114,7 +114,7 @@ {% endif %} - {% include "post_actions_mobile.html" %} + {% include "component/post/actions_mobile.html" %} @@ -123,7 +123,7 @@ {% endif %} {% if v and v.admin_level > 1 %} - {% include "post_admin_actions_mobile.html" %} + {% include "component/post/actions_admin_mobile.html" %} {% endif %} {% endblock %} @@ -338,7 +338,7 @@ View source {% endif %} - {% include 'post_actions.html' %} + {% include 'component/post/actions.html' %} @@ -553,11 +553,11 @@ {% if v and v.id==p.author_id %} - {% include "delete_post_modal.html" %} + {% include "component/modal/delete_post.html" %} {% endif %} {% if v %} - {% include "report_post_modal.html" %} + {% include "component/modal/report_post.html" %} {% endif %} {% if v and (v.id == p.author_id or v.admin_level > 1 and v.admin_level > 2) %} diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index b6163b459..41289bea1 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -243,7 +243,7 @@ {% if p.realbody(v) %} {% endif %} - {% include 'post_actions.html' %} + {% include 'component/post/actions.html' %} @@ -292,7 +292,7 @@ @@ -311,7 +311,7 @@ {% if v and v.admin_level > 1 %} - {% include "post_admin_actions_mobile.html" %} + {% include "component/post/actions_admin_mobile.html" %} {% endif %} @@ -407,13 +407,13 @@ {% endfor %} {% if v %} - {% include "delete_post_modal.html" %} - {% include "report_post_modal.html" %} + {% include "component/modal/delete_post.html" %} + {% include "component/modal/report_post.html" %} {% if v.admin_level > 1 %} - {% include "ban_modal.html" %} + {% include "component/modal/ban.html" %} {% endif %} {% endif %} -{% include "expanded_image_modal.html" %} +{% include "component/modal/expanded_image.html" %} diff --git a/files/templates/submit.html b/files/templates/submit.html index dc28fe5af..94873d86e 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -105,9 +105,7 @@   - -   - +