Commit graph

15731 commits

Author SHA1 Message Date
TLSM
a9090b01e2 fix: duplicated notification header text
Seems to be a simple accidental duplication of the message left in
during the rewrite.
2023-03-16 11:12:24 -05:00
Ben Rog-Wilhelm
79b49342ba Fix: Generating permalinks for comments 500's if the associated post isn't loaded. 2023-03-16 11:12:08 -05:00
TLSM
a060f5840c fix: comment score regression
PR #547 introduced a UI bug where the comment score tooltip would
show the wrong values (and in fact, the displayed score was also
wrong, though this was not originally noticed).

Specifically, a comment with e.g. +4 | -1 would display in the tooltip
as being +4 | -4 and display a score of 4. The desired behavior would
be +4 | -1 and score of 3. Precisely, the upvote value was displayed
for each of upvotes, downvotes, and net score.

Root cause was the `@lazy` decorator at:
`files.classes.comment._score_context_str(⋅)`

`@lazy` is very dumb. I don't entirely know why we don't just use
`functools.cache`, but we use `@lazy` everywhere. It is entirely
ignorant of the parameters to a function--not a substitute for
memoization.

comments.html contains the following snippet:

    {%- set ups = c.upvotes_str(render_ctx) -%}
    {%- set score = c.score_str(render_ctx) -%}
    {%- set downs = c.downvotes_str(render_ctx) -%}

Each of those three functions internally calls to `_score_context_str`
but with different arguments. The first call to upvotes gets cached by
`@lazy` and the two subsequent calls get the upvotes string, rather than
what they wanted. It's a cheap enough operation that it's not really
worth memoizing, so we just remove the decorator.
2023-03-15 01:58:15 -05:00
Ben Rog-Wilhelm
1bd1eadefe Fix: Typo in comment refactor. 2023-03-14 13:50:42 -05:00
justcool393
a5c8741efa
fix /pp/ route (#542) 2023-03-14 13:33:48 -05:00
justcool393
82e4982261 fix base import 2023-03-14 13:32:47 -05:00
justcool393
9b94e524bb fix MovedIn20Warning
shouldn't actually cause any issues currently since SQLAlchemy is (to my annoyance)
import *ed everywhere but.
2023-03-14 13:32:47 -05:00
justcool393
e61e35226d disallow url() 2023-03-14 13:32:02 -05:00
justcool393
71406da834 security: disallow import statements in CSS 2023-03-14 13:32:02 -05:00
justcool393
92bd7d50fa
performance: add performance monitor 2023-03-14 13:31:04 -05:00
Ben Rog-Wilhelm
d9fa06585c
Merge pull request #547 from justcool393/enhancement-refactor-comments-html
comments.html: refactor so that something can be sanely changed in it
2023-03-14 13:28:47 -05:00
justcool393
8acddebb93 actually set is_notification_page
apparently this has just been a bug for over a year on rdrama
2023-03-14 13:10:26 -05:00
justcool393
e58e3f7719
Merge branch 'frost' into enhancement-refactor-comments-html 2023-03-14 10:54:01 -07:00
Ben Rog-Wilhelm
86fe498138
Merge pull request #549 from justcool393/fix-leaking-deleted-content
fix leak of deleted content
2023-03-14 12:48:55 -05:00
justcool393
8e62f1440b make this also work for not logged in users 2023-03-14 12:15:52 -05:00
justcool393
d09e1d4eb8 let users see their own content 2023-03-14 12:11:12 -05:00
justcool393
24af1b4433 fix leak of deleted content 2023-03-14 12:05:25 -05:00
justcool393
c670518a5e components: move around a bit 2023-03-12 07:38:27 -05:00
justcool393
8240ddcc43 organize modals 2023-03-11 03:16:55 -06:00
justcool393
b32d32a658 Don't duplicate view more button code 2023-03-11 03:04:29 -06:00
justcool393
54fdfd1559 sticky api url 2023-03-11 03:03:41 -06:00
justcool393
fde6d8a67a fix bug and move render context partly to model 2023-03-09 07:22:01 -06:00
justcool393
9895fa1bba comments.html: refactor so that something can be sanely
changed in it

the comments.html template (along with submission.html) has numerous
undesirable properties which i will describe now. unless you are very
familiar with the codebase, it can be extremely difficult to grok.

this is pretty insane as there is nothing fundamentally complex about
the goal of comments.html: return a component that shows a username
and info, reports if any, comment content, and actions a user can
take.

this behemeoth was initially 886 lines in the old version of this
codebase, and this is with awards and a lot of other cruft removed.
anyway, the maintainability of this file is about on par with some
legacy application that keels over and dies if you sneeze vaguely
in its direction.

the nicest thing i can say about it is that it isn't currently
crashing.

anyway some of the problems include:

* large, splittable components, are not split into separate files.

this makes it incredibly difficult to find or make changes across
the template and makes it nearly impossible to find or change a
specific thing.

this is most easily exemplified in the modals, which should by all
accounts be separate templates, just inlined into comments.html.

* the nesting is oftentimes incorrect.

inexplicably, probably out of laziness from when the code was first
written, things will end up fully left aligned, while multiple layers
deep into a nesting context.

if an if statement or an endif is changed, it is *incredibly*
difficult to figure out where the error was. you can't trust the
nesting.

* multiple repeated checks for things that are always true.

this is probably a symptom of the above two problems but it's very
noticeable once you fix the nesting. for example there is a block
near the very top of the actions bar which checks for
parent_submission which effectively checks "is this in a post" (this
commit won't complain about parent_submission checks but i do have
opinions on those).

all of the action buttons further down the chain also check for
parent_submission, or even check inconsistently (by using if c.post)
within this context this is a completely unnecessary check in this
context.

while it is potentially useful (and in fact because #251 requires we
dismantle the assumption a little bit) to have these checks now, the
fact that they were initially added shows that when the code was all
initial written, there was little care into thinking about comment
state.

* mobile actions are duplicated and duplicated inline.

i actually do find it probably pretty hard to support this normally
given the codebase's DOM so whatever, duplicate the things, *but* if
we're going to do that, inlining it into the middle of an incredibly
long template is really difficult to comprehend as a design decision.

...anyway yeah this PR intends to fix these problems and enable work
to be done on #251. this is a "perfect is the enemy of good" commit.
it doesn't change much fundamental and is not intended to erase the
sins of the original file, but at least make it maintainable.

this also fixes a minor bug with #473 where the GIF modal was left
in by accident.
2023-03-09 06:59:56 -06:00
justcool393
4c6c375215 Comments: indent actions in a less insane way 2023-03-09 03:13:45 -06:00
justcool393
fb65cf0416
privatize user CSS (fixes #273)
implements issue comment: https://github.com/themotte/rDrama/issues/273#issuecomment-1240543608
2023-02-25 04:51:06 -06:00
justcool393
d0ba568738 classes: use self.__class__.__name__ in __repr__ 2023-02-25 04:21:33 -06:00
justcool393
bfe8fb70f6
support infinite length posts and comments (fixes #229) 2023-02-25 04:18:30 -06:00
justcool393
44919507e9
leaderboard refactor (#526) 2023-02-24 06:31:17 -06:00
justcool393
22ad4f5d23
sanitize: sanitize raw content (fixes #214) 2023-02-24 06:00:19 -06:00
justcool393
ce04999fb2
remove more auth desireds on some routes
no need for the user at all here
2023-02-24 05:57:35 -06:00
justcool393
ff09ba4209 SQLA migration: fix RemovedIn20Warnings 2023-02-24 05:54:56 -06:00
justcool393
449e2557d0 fix unstickying 2023-02-20 18:10:40 -06:00
justcool393
872d9c613b
videos: remove video uploads lol 2023-02-17 21:26:40 -06:00
justcool393
0f10e1ea16 SQLA2 migration: default SQLALCHEMY_WARN_20 to 1 2023-02-17 17:50:11 -06:00
justcool393
f155578633 fix missing import used by error handler 2023-02-17 14:43:04 -06:00
justcool393
9f7e7ef980 oauth: fix length constraints 2023-02-17 14:42:37 -06:00
justcool393
a8013f1089 fix api comments (fixes #512) 2023-02-17 14:42:06 -06:00
justcool393
50b6e06f62 Modmail: constantify missed magic numbers 2023-02-17 14:41:41 -06:00
justcool393
1574c46d0a modmail: constantify user ID and fix bug where users can bypass modmail route checks
the random c.sentto == 2 magic numbers in the code is... pretty
unmaintainable and unless you were aware of who "2" was, it's hard to
know what's going on.

in addition, we force modmail to go through the modmail path instead of
letting users bypass validation checks.
2023-02-17 14:41:41 -06:00
justcool393
81cfc09fed simplify seed_db 2023-02-17 14:41:06 -06:00
Ben Rog-Wilhelm
860eea7ba8
Merge pull request #517 from justcool393/comment-reply-sort
Sorting: add comments sort for comments and constantify sorts
2023-02-17 14:39:34 -06:00
justcool393
6c2876ea6b no t 2023-02-17 01:00:38 -06:00
justcool393
340644a3ae default 2023-02-17 00:49:04 -06:00
justcool393
009918f954 Remove <pre></pre> bs 2023-02-17 00:44:21 -06:00
justcool393
7e93ea6361 fix indentation and logic error 2023-02-17 00:40:17 -06:00
justcool393
e8d2f2bce2 missing %endif% 2023-02-17 00:33:36 -06:00
justcool393
d8c12ff794 translate transformY 2023-02-17 00:30:08 -06:00
justcool393
9ca1fa6935 ccmode 2023-02-17 00:23:57 -06:00
justcool393
97359602b4 fix braindead mistake 2023-02-16 23:59:35 -06:00
justcool393
22741fce1f remove unnecessary classes and ids 2023-02-16 23:56:23 -06:00