From 668a7ce2b0d79feb8330db566b34f5993d70aad7 Mon Sep 17 00:00:00 2001 From: Aevann Date: Thu, 23 May 2024 05:22:20 +0300 Subject: [PATCH] do this https://rdrama.net/h/slackernews/post/269704/open-source-maintainer-neurodivergentreact-gets-a/6417198#context --- files/helpers/config/const.py | 4 +++- files/routes/holes.py | 4 ++-- files/routes/jinja2.py | 3 +-- files/routes/settings.py | 4 ++-- files/templates/hole/settings.html | 4 ++-- files/templates/settings/advanced.html | 4 ++-- migrations/20240523-adjust-snappy-quotes-length.sql | 2 ++ 7 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 migrations/20240523-adjust-snappy-quotes-length.sql diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index b2cc2a340..2f8d7eadf 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -443,6 +443,8 @@ POST_SORTS = COMMENT_SORTS | { } COMMENT_SORTS = COMMENT_SORTS | {"saves": "save"} +USER_SNAPPY_QUOTES_LENGTH = 1000 + ################################################################################ ### COLUMN INFO ################################################################################ @@ -450,7 +452,7 @@ COMMENT_SORTS = COMMENT_SORTS | {"saves": "save"} HOLE_NAME_COLUMN_LENGTH = 25 HOLE_SIDEBAR_COLUMN_LENGTH = 10000 HOLE_SIDEBAR_HTML_COLUMN_LENGTH = 20000 -CUSTOM_SNAPPY_QUOTES_LENGTH = 20000 +HOLE_SNAPPY_QUOTES_LENGTH = 50000 HOLE_SIDEBAR_URL_COLUMN_LENGTH = 60 HOLE_BANNER_URL_COLUMN_LENGTH = 60 HOLE_MARSEY_URL_LENGTH = 60 diff --git a/files/routes/holes.py b/files/routes/holes.py index cdbb26d3d..b72d51236 100644 --- a/files/routes/holes.py +++ b/files/routes/holes.py @@ -953,8 +953,8 @@ def post_hole_snappy_quotes(v, hole): if snappy_quotes.endswith('[para]'): snappy_quotes = snappy_quotes[:-6].strip() - if len(snappy_quotes) > CUSTOM_SNAPPY_QUOTES_LENGTH: - abort(400, f"Quotes are too long (max {CUSTOM_SNAPPY_QUOTES_LENGTH} characters)") + if len(snappy_quotes) > HOLE_SNAPPY_QUOTES_LENGTH: + abort(400, f"Quotes are too long (max {HOLE_SNAPPY_QUOTES_LENGTH} characters)") hole.snappy_quotes = snappy_quotes g.db.add(hole) diff --git a/files/routes/jinja2.py b/files/routes/jinja2.py index 5a7301320..c5ecc645c 100644 --- a/files/routes/jinja2.py +++ b/files/routes/jinja2.py @@ -206,6 +206,5 @@ def inject_constants(): "CURSORMARSEY_DEFAULT":CURSORMARSEY_DEFAULT, "SNAPPY_ID":SNAPPY_ID, "ZOZBOT_ID":ZOZBOT_ID, "get_running_orgy":get_running_orgy, "bar_position":bar_position, "datetime":datetime, "CSS_LENGTH_LIMIT":CSS_LENGTH_LIMIT, "cache":cache, "emoji_count":emoji_count, "group_count":group_count, "user_count":user_count, - "HOLE_SIDEBAR_COLUMN_LENGTH":HOLE_SIDEBAR_COLUMN_LENGTH, "CUSTOM_SNAPPY_QUOTES_LENGTH":CUSTOM_SNAPPY_QUOTES_LENGTH, - "top_poster_of_the_day":top_poster_of_the_day, + "HOLE_SIDEBAR_COLUMN_LENGTH":HOLE_SIDEBAR_COLUMN_LENGTH, "HOLE_SNAPPY_QUOTES_LENGTH":HOLE_SNAPPY_QUOTES_LENGTH, "USER_SNAPPY_QUOTES_LENGTH":USER_SNAPPY_QUOTES_LENGTH, "top_poster_of_the_day":top_poster_of_the_day, } diff --git a/files/routes/settings.py b/files/routes/settings.py index cb1f8be18..f097588e1 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -457,8 +457,8 @@ def snappy_quotes(v): if snappy_quotes == v.snappy_quotes: abort(400, "You didn't change anything!") - if len(snappy_quotes) > CUSTOM_SNAPPY_QUOTES_LENGTH: - abort(400, f"Quotes are too long (max {CUSTOM_SNAPPY_QUOTES_LENGTH} characters)") + if len(snappy_quotes) > USER_SNAPPY_QUOTES_LENGTH: + abort(400, f"Quotes are too long (max {USER_SNAPPY_QUOTES_LENGTH} characters)") if not snappy_quotes: snappy_quotes = None diff --git a/files/templates/hole/settings.html b/files/templates/hole/settings.html index a572f5ce0..cbd1ec04f 100644 --- a/files/templates/hole/settings.html +++ b/files/templates/hole/settings.html @@ -84,9 +84,9 @@
- + Separate quotes with [para] -

Limit of {{CUSTOM_SNAPPY_QUOTES_LENGTH}} characters

+

Limit of {{HOLE_SNAPPY_QUOTES_LENGTH}} characters

diff --git a/files/templates/settings/advanced.html b/files/templates/settings/advanced.html index 5898faa5d..b3b22e4ba 100644 --- a/files/templates/settings/advanced.html +++ b/files/templates/settings/advanced.html @@ -213,8 +213,8 @@ Enter things you would like @Snappy to reply to your posts with. - Separate quotes with [para]. Limit of {{CUSTOM_SNAPPY_QUOTES_LENGTH}} characters + rows="3" name="snappy_quotes" form="snappy-quotes" maxlength="{{USER_SNAPPY_QUOTES_LENGTH}}">{% if v.snappy_quotes %}{{v.snappy_quotes}}{% endif %} + Separate quotes with [para]. Limit of {{USER_SNAPPY_QUOTES_LENGTH}} characters
diff --git a/migrations/20240523-adjust-snappy-quotes-length.sql b/migrations/20240523-adjust-snappy-quotes-length.sql new file mode 100644 index 000000000..77a29f73b --- /dev/null +++ b/migrations/20240523-adjust-snappy-quotes-length.sql @@ -0,0 +1,2 @@ +alter table users alter column snappy_quotes type varchar(1000); +alter table holes alter column snappy_quotes type varchar(50000);