diff --git a/files/assets/emojis.json b/files/assets/emojis.json index 6f4bb0a8c..8b79bbc61 100644 --- a/files/assets/emojis.json +++ b/files/assets/emojis.json @@ -187,6 +187,7 @@ {"name":"marseyflagnorway","class":"Marsey Flags"}, {"name":"marseyflagpakistan","class":"Marsey Flags"}, {"name":"marseyflagpalestine","class":"Marsey Flags"}, + {"name":"marseyflagperu","class":"Marsey Flags"}, {"name":"marseyflagphillipines","class":"Marsey Flags"}, {"name":"marseyflagpoland","class":"Marsey Flags"}, {"name":"marseyflagportugal","class":"Marsey Flags"}, diff --git a/files/assets/images/emojis/marseycharlesiii.webp b/files/assets/images/emojis/marseycharlesiii.webp new file mode 100644 index 000000000..f14552491 Binary files /dev/null and b/files/assets/images/emojis/marseycharlesiii.webp differ diff --git a/files/assets/images/emojis/marseyfuntriptime.webp b/files/assets/images/emojis/marseyfuntriptime.webp new file mode 100644 index 000000000..248624706 Binary files /dev/null and b/files/assets/images/emojis/marseyfuntriptime.webp differ diff --git a/files/assets/images/emojis/marseygrapes.webp b/files/assets/images/emojis/marseygrapes.webp new file mode 100644 index 000000000..74788ae8e Binary files /dev/null and b/files/assets/images/emojis/marseygrapes.webp differ diff --git a/files/assets/images/emojis/marseyjannymini.webp b/files/assets/images/emojis/marseyjannymini.webp new file mode 100644 index 000000000..64228760c Binary files /dev/null and b/files/assets/images/emojis/marseyjannymini.webp differ diff --git a/files/assets/images/emojis/marseyoperaphantom.webp b/files/assets/images/emojis/marseyoperaphantom.webp new file mode 100644 index 000000000..e98ebc430 Binary files /dev/null and b/files/assets/images/emojis/marseyoperaphantom.webp differ diff --git a/files/assets/images/emojis/marseypureevil.webp b/files/assets/images/emojis/marseypureevil.webp new file mode 100644 index 000000000..442e90d56 Binary files /dev/null and b/files/assets/images/emojis/marseypureevil.webp differ diff --git a/files/assets/images/emojis/marseyrussian.webp b/files/assets/images/emojis/marseyrussian.webp new file mode 100644 index 000000000..6bf009921 Binary files /dev/null and b/files/assets/images/emojis/marseyrussian.webp differ diff --git a/files/assets/images/emojis/marseytrain2.webp b/files/assets/images/emojis/marseytrain2.webp new file mode 100644 index 000000000..4e1b0bd17 Binary files /dev/null and b/files/assets/images/emojis/marseytrain2.webp differ diff --git a/files/assets/images/emojis/marseyupvote2.webp b/files/assets/images/emojis/marseyupvote2.webp new file mode 100644 index 000000000..483ef5187 Binary files /dev/null and b/files/assets/images/emojis/marseyupvote2.webp differ diff --git a/files/assets/images/hats/Attifet.webp b/files/assets/images/hats/Attifet.webp new file mode 100644 index 000000000..af8179ce5 Binary files /dev/null and b/files/assets/images/hats/Attifet.webp differ diff --git a/files/assets/images/hats/Condiment Top.webp b/files/assets/images/hats/Condiment Top.webp new file mode 100644 index 000000000..3f444c1f1 Binary files /dev/null and b/files/assets/images/hats/Condiment Top.webp differ diff --git a/files/assets/images/hats/Cthulhu Mask.webp b/files/assets/images/hats/Cthulhu Mask.webp new file mode 100644 index 000000000..628051e96 Binary files /dev/null and b/files/assets/images/hats/Cthulhu Mask.webp differ diff --git a/files/assets/images/hats/Escoffion.webp b/files/assets/images/hats/Escoffion.webp new file mode 100644 index 000000000..d0e9a937a Binary files /dev/null and b/files/assets/images/hats/Escoffion.webp differ diff --git a/files/assets/images/hats/French Fries.webp b/files/assets/images/hats/French Fries.webp new file mode 100644 index 000000000..7f24b38d6 Binary files /dev/null and b/files/assets/images/hats/French Fries.webp differ diff --git a/files/assets/images/hats/Generic Religious Figurehead.webp b/files/assets/images/hats/Generic Religious Figurehead.webp new file mode 100644 index 000000000..025af2c11 Binary files /dev/null and b/files/assets/images/hats/Generic Religious Figurehead.webp differ diff --git a/files/assets/images/hats/PLAYER 1.webp b/files/assets/images/hats/PLAYER 1.webp new file mode 100644 index 000000000..485c6826e Binary files /dev/null and b/files/assets/images/hats/PLAYER 1.webp differ diff --git a/files/assets/images/hats/Shroom head.webp b/files/assets/images/hats/Shroom head.webp new file mode 100644 index 000000000..a73678bde Binary files /dev/null and b/files/assets/images/hats/Shroom head.webp differ diff --git a/files/assets/images/hats/Top Hat (pentagram).webp b/files/assets/images/hats/Top Hat (pentagram).webp new file mode 100644 index 000000000..121d8e834 Binary files /dev/null and b/files/assets/images/hats/Top Hat (pentagram).webp differ diff --git a/files/assets/images/hats/bleh.webp b/files/assets/images/hats/bleh.webp new file mode 100644 index 000000000..78e3ef848 Binary files /dev/null and b/files/assets/images/hats/bleh.webp differ diff --git a/files/assets/images/hats/book.webp b/files/assets/images/hats/book.webp new file mode 100644 index 000000000..6184c46ed Binary files /dev/null and b/files/assets/images/hats/book.webp differ diff --git a/files/classes/comment.py b/files/classes/comment.py index 999e9f9d6..fc0434b9b 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -4,6 +4,7 @@ from urllib.parse import urlencode, urlparse, parse_qs from flask import * from sqlalchemy import * from sqlalchemy.orm import relationship +from sqlalchemy.dialects.postgresql import TSVECTOR from files.__main__ import Base from files.classes.votes import CommentVote from files.helpers.const import * @@ -59,6 +60,7 @@ class Comment(Base): realupvotes = Column(Integer, default=1) body = Column(String) body_html = Column(String) + body_ts = Column(TSVECTOR(), server_default=FetchedValue()) ban_reason = Column(String) wordle_result = Column(String) treasure_amount = Column(String) diff --git a/files/routes/search.py b/files/routes/search.py index 13bb77ed5..c96925feb 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -14,11 +14,10 @@ valid_params = [ 'author', 'domain', 'over18', - "post", - "before", - "after", - "title", - "exact", + 'post', + 'before', + 'after', + 'title', search_operator_hole, ] @@ -90,14 +89,7 @@ def searchposts(v): ) else: posts = posts.filter(Submission.author_id == author.id) - if 'exact' in criteria and 'full_text' in criteria: - regex_str = '[[:<:]]'+criteria['full_text']+'[[:>:]]' # https://docs.oracle.com/cd/E17952_01/mysql-5.5-en/regexp.html "word boundaries" - if 'title' in criteria: - words = [Submission.title.regexp_match(regex_str)] - else: - words = [or_(Submission.title.regexp_match(regex_str), Submission.body.regexp_match(regex_str))] - posts = posts.filter(*words) - elif 'q' in criteria: + if 'q' in criteria: if('title' in criteria): words = [or_(Submission.title.ilike('%'+x+'%')) \ for x in criteria['q']] @@ -183,9 +175,6 @@ def searchposts(v): @app.get("/search/comments") @auth_required def searchcomments(v): - - return {"error": "Searching comments is disabled temporarily."}, 403 - query = request.values.get("q", '').strip() try: page = max(1, int(request.values.get("page", 1))) @@ -217,14 +206,10 @@ def searchcomments(v): else: comments = comments.filter(Comment.author_id == author.id) - if 'exact' in criteria and 'full_text' in criteria: - regex_str = '[[:<:]]'+criteria['full_text']+'[[:>:]]' # https://docs.oracle.com/cd/E17952_01/mysql-5.5-en/regexp.html "word boundaries" - words = [Comment.body.regexp_match(regex_str)] - comments = comments.filter(*words) - elif 'q' in criteria: - words = [or_(Comment.body.ilike('%'+x+'%')) \ - for x in criteria['q']] - comments = comments.filter(*words) + if 'q' in criteria: + comments = comments.filter(Comment.body_ts.match( + ' & '.join(criteria['q']), + postgresql_regconfig='english')) if 'over18' in criteria: comments = comments.filter(Comment.over_18 == True) diff --git a/files/routes/static.py b/files/routes/static.py index 0c78e15e8..705a6681f 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -4,7 +4,7 @@ from files.helpers.alerts import * from files.helpers.const import * from files.helpers.actions import * from files.classes.award import AWARDS -from sqlalchemy import func +from sqlalchemy import func, nullslast import os from files.classes.mod_logs import ACTIONTYPES, ACTIONTYPES2 from files.classes.badges import BadgeDef @@ -25,8 +25,12 @@ def marseys(v): if SITE == 'rdrama.net': marseys = g.db.query(Marsey, User).join(User, Marsey.author_id == User.id).filter(Marsey.submitter_id==None) sort = request.values.get("sort", "usage") - if sort == "usage": marseys = marseys.order_by(Marsey.count.desc(), User.username).all() - else: marseys = marseys.order_by(User.username, Marsey.count.desc()).all() + if sort == "usage": + marseys = marseys.order_by(Marsey.count.desc(), User.username).all() + elif sort == "added": + marseys = marseys.order_by(nullslast(Marsey.created_utc.desc()), User.username).all() + else: # implied sort == "author" + marseys = marseys.order_by(User.username, Marsey.count.desc()).all() original = os.listdir("/asset_submissions/marseys/original") for marsey, user in marseys: @@ -150,6 +154,7 @@ def log(v): if admin_id: actions = actions.filter_by(user_id=admin_id) kinds = set([x.kind for x in actions]) + kinds.add(kind) types2 = {} for k,val in types.items(): if k in kinds: types2[k] = val diff --git a/files/templates/marseys.html b/files/templates/marseys.html index d287603cb..e79c1b919 100644 --- a/files/templates/marseys.html +++ b/files/templates/marseys.html @@ -13,6 +13,7 @@ Usage {% if SITE == 'rdrama.net' %} Author + Added Original File {% endif %} @@ -26,6 +27,7 @@ :#{{marsey.name}}: {{marsey.count}} {% include "user_in_table.html" %} + {% if marsey.og %} {{marsey.og}} diff --git a/files/templates/search.html b/files/templates/search.html index 66ca09709..27f0d361b 100644 --- a/files/templates/search.html +++ b/files/templates/search.html @@ -76,10 +76,6 @@ {% endif %} -
-
Exact Match Only:
- -

diff --git a/schema.sql b/schema.sql index d2c599b87..20cb4f743 100644 --- a/schema.sql +++ b/schema.sql @@ -391,7 +391,8 @@ CREATE TABLE public.comments ( slots_result character varying(36), blackjack_result character varying(860), treasure_amount character varying(10), - wordle_result character varying(115) + wordle_result character varying(115), + body_ts tsvector GENERATED ALWAYS AS (to_tsvector('english'::regconfig, (body)::text)) STORED ); @@ -1620,6 +1621,13 @@ CREATE INDEX comment_parent_index ON public.comments USING btree (parent_comment CREATE INDEX comment_post_id_index ON public.comments USING btree (parent_submission); +-- +-- Name: comments_body_ts_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX comments_body_ts_idx ON public.comments USING gin (body_ts); + + -- -- Name: comments_user_index; Type: INDEX; Schema: public; Owner: - -- diff --git a/seed-db.sql b/seed-db.sql index 61533ae2c..f5ea31363 100644 --- a/seed-db.sql +++ b/seed-db.sql @@ -249,10 +249,16 @@ INSERT INTO public.hat_defs VALUES (755, 'Ski-mask EYES', 'When 2 eyes isn''t en INSERT INTO public.hat_defs VALUES (757, 'Beanie baby tag', 'Now you''re a plush, into the jar with you-parx5', 2, 500, NULL, 1664602656); INSERT INTO public.hat_defs VALUES (758, 'Target', 'Bullseye!', 2, 500, NULL, 1664604233); INSERT INTO public.hat_defs VALUES (760, 'Foxy Grandpa', 'Goddamn you are one foxy grandpa-SalaciousWombat', 2, 500, NULL, 1664633035); - - - - +INSERT INTO public.hat_defs VALUES (764, 'Generic Religious Figurehead', 'Good morning', 2, 500, NULL, 1664640654); +INSERT INTO public.hat_defs VALUES (762, 'Cthulhu Mask', 'I would kiss that cutie.', 2, 500, NULL, 1664638109); +INSERT INTO public.hat_defs VALUES (763, 'Top Hat (pentagram)', 'mages vs matriarchy headgear', 2, 500, NULL, 1664638170); +INSERT INTO public.hat_defs VALUES (770, 'Shroom head', 'You really went so long without a shower mushrooms grew?', 2, 500, NULL, 1664658333); +INSERT INTO public.hat_defs VALUES (771, 'Escoffion', 'Look dark... AND STYLISH!', 2, 500, NULL, 1664658375); +INSERT INTO public.hat_defs VALUES (772, 'Attifet', 'You''re a European woman in the 1600s??', 2, 500, NULL, 1664658421); +INSERT INTO public.hat_defs VALUES (774, 'French Fries', 'Now your salty and tasty!', 2, 500, NULL, 1664658675); +INSERT INTO public.hat_defs VALUES (775, 'Condiment Top', 'Now you can squirt out tasty condiments!', 2, 500, NULL, 1664658867); +INSERT INTO public.hat_defs VALUES (767, 'bleh', 'froggy go “bleh”', 2, 500, NULL, 1664646019); +INSERT INTO public.hat_defs VALUES (768, 'PLAYER 1', 'you only have 2 lives left oop', 2, 500, NULL, 1664646508); INSERT INTO public.hat_defs VALUES (723, 'Hohol', 'Мій предок :)', 2, 500, NULL, 1663892328); INSERT INTO public.hat_defs VALUES (750, 'Cave Man', 'UNGA BUNGA UNGA BUNGA OOO OOO', 2, 500, NULL, 1664595865); @@ -263,6 +269,7 @@ INSERT INTO public.hat_defs VALUES (715, 'Inspector Gadget', '"Go go Gadget Brow INSERT INTO public.hat_defs VALUES (724, 'Spartan Helmet', 'THIS IS SPARTA!', 2, 500, NULL, 1663892367); INSERT INTO public.hat_defs VALUES (751, 'Butter', 'Southern-fried and full of love.', 2, 500, NULL, 1664595886); INSERT INTO public.hat_defs VALUES (754, 'Crusader helmet', 'RETAKE THE HOLY LAND!', 2, 500, NULL, 1664595954); +INSERT INTO public.hat_defs VALUES (766, 'book', 'i can read! heheh', 2, 500, NULL, 1664645746); INSERT INTO public.hat_defs VALUES (676, 'Kepi', 'Army cap for those unlucky enough to be French', 2, 500, NULL, 1663303083); INSERT INTO public.hat_defs VALUES (678, 'Turkroach', 'Come on Carp this one''s hilarious. It''s semi transparent to clarify', 2, 500, NULL, 1663305640); INSERT INTO public.hat_defs VALUES (679, 'Judge Dredd', 'THIS USER IS THE LAW', 2, 500, NULL, 1663309533); @@ -908,7 +915,7 @@ INSERT INTO public.hat_defs VALUES (504, 'Iron Crown of Lombardy', 'This isn''t -- Name: hat_defs_id_seq; Type: SEQUENCE SET; Schema: public; Owner: - -- -SELECT pg_catalog.setval('public.hat_defs_id_seq', 765, true); +SELECT pg_catalog.setval('public.hat_defs_id_seq', 777, true); -- @@ -1245,6 +1252,7 @@ INSERT INTO public.marseys (name, author_id, tags, created_utc) VALUES ('marseychad',2,'canthal tilt jaw hunter eyes',NULL), ('marseychadthundercock',2,'vvc virgin foid pimp hot player big dick huge cock ouch gigachad meme',NULL), ('marseychadyes',2,'based gigachad',NULL), +('marseycharlesiii',2,'king england britain royalty royal monarch',1664652665), ('marseycharlesmanson',2,'charlie manson charliemanson murderer killer swastika crazy psycho schizo helterskelter prison cult',NULL), ('marseychartbar',2,'stats statistics chart graph plot data bar column',NULL), ('marseychartgaussian',2,'stats statistics chart graph plot data gaussian normal bell distribution',NULL), @@ -1539,7 +1547,6 @@ INSERT INTO public.marseys (name, author_id, tags, created_utc) VALUES ('marseyfingergoodjob',2,'cute encourage positive respect k-pop thumbs up congrats gif animated congratulations nice ok great',NULL), ('marseyfingerhearts',2,'cute love k-pop',NULL), ('marseyfingerwords',2,'cute long tldr didnt read',NULL), -('marseyflagperu',2,'peru soccer south america latinx flag',1664491371), ('marseyflakes',2,'parsley seasoning salt pepper spice food seasoning',NULL), ('marseyflamethrower',2,'vietname soldier fire',NULL), ('marseyflamewar',2,'troll fight fire reaction gasoline',NULL), @@ -1573,6 +1580,7 @@ INSERT INTO public.marseys (name, author_id, tags, created_utc) VALUES ('marseyfugg',2,'spurdo sparde fugg',NULL), ('marseyfugg2',2,'spurdo sparde',NULL), ('marseyfunko',2,'action figure doll funko toy soy',NULL), +('marseyfuntriptime',2,'lsd drugs joy happy gay schizo',1664656681), ('marseyfuriosa',2,'mad max madmax imperator furryosa fury road furyroad post apocalyptic apocalypse australian australia',NULL), ('marseyfurry',2,'fursona furry fursuit kitsune',NULL), ('marseyfurry2',2,'furry fur degenerate sex',NULL), @@ -1625,6 +1633,7 @@ INSERT INTO public.marseys (name, author_id, tags, created_utc) VALUES ('marseygoose2',2,'goose geese kill cat bird death bite chomp',NULL), ('marseygossip',2,'tea rotary phone popcorn gabbing',NULL), ('marseygrad',2,'graduate graduation school degree diploma hat tassel animated college university',NULL), +('marseygrapes',2,'fat roman emperor fruit chubby snacking healthy',1664677557), ('marseygras',2,'mardi gras fat tuesday nola new orleans neworleans holiday louisiana mardigras carnival beads mask',NULL), ('marseygrass',2,'reaction outside touchgrass touch grass',NULL), ('marseygrilling',2,'barbecue bbq centrist boomer barbeque',NULL), @@ -1723,6 +1732,7 @@ INSERT INTO public.marseys (name, author_id, tags, created_utc) VALUES ('marseyjamming',2,'mp3 headphones beat ipod music happy',NULL), ('marseyjanny',2,'jannie unpaid volunteer administrator janitor free moderator',NULL), ('marseyjanny2',2,'jannie unpaid volunteer administrator janitor free moderator',NULL), +('marseyjannymini',2,'janny minigun gun clean gatling jannie animated',1664657815), ('marseyjapanese',2,'nippon rising sun weeb japan animated',NULL), ('marseyjason',2,'hockey mask horror halloween kill fridaythe13th knife stab voorheys friday the 13th evil monster holiday',NULL), ('marseyjavelin',2,'ukraine russia missile rocket rpg grenade launcher kyiv kiev kiyv zelensky putin tank',NULL), @@ -1997,6 +2007,7 @@ INSERT INTO public.marseys (name, author_id, tags, created_utc) VALUES ('marseyoldguard',2,'napoleon war soldier musket french france history europe reaction',NULL), ('marseyoldtimey',2,'cartoon disney vintage olde classic retro',NULL), ('marseyonacid',2,'tripping trippy drugs lcd animated',NULL), +('marseyoperaphantom',2,'phantom opera music incel mask',1664677165), ('marseyopossum',2,'possum trash',NULL), ('marseyoppenheimer',2,'scientist nuke bomb ww2 atomic nuclear mushroom cloud',NULL), ('marseyorca',2,'orca whale idate smoke smoking anime weeks sal',NULL), @@ -2127,6 +2138,7 @@ INSERT INTO public.marseys (name, author_id, tags, created_utc) VALUES ('marseypunished2',2,'punished venom snake metal gear solid kojima eyepatch drama',NULL), ('marseypunisher',2,'thin blue line rightoid police cops',NULL), ('marseypuppy',2,'dog dalle2 puppy',NULL), +('marseypureevil',2,'satan evil demon pointy horns',1664656928), ('marseypusheen',2,'grey gray',NULL), ('marseypussyhat',2,'feminist feminism activism activist protester protesting foid gussy woman birthing person roasty roastie thot slut whore',NULL), ('marseyputin',2,'vladimir russian kgb moscow ukraine dictator leader',NULL), @@ -2197,6 +2209,7 @@ INSERT INTO public.marseys (name, author_id, tags, created_utc) VALUES ('marseyrussel',2,'old pipe history',NULL), ('marseyrussiadolls',2,'toys ussr babushka matryoshka soviet',NULL), ('marseyrussiaglow',2,'animated russia red putin fsb kgb glow trump commie communist hat comrade',NULL), +('marseyrussian',2,'russian putin russia vodka adidas tracksuit vatnik ai alcohol beer drunk moscow',1664643821), ('marseyrustyventure',2,'dramamine venture bros brothers adult swim cartoon character glasses goattee goatee beard',NULL), ('marseysad',2,'concerned worried waiting prepared reaction',NULL), ('marseysad2',2,'reaction disappointed disappointment upset',NULL), @@ -2525,6 +2538,7 @@ INSERT INTO public.marseys (name, author_id, tags, created_utc) VALUES ('marseyupmarsey',2,'upvote vote upmarsey arrow reddit up animated',NULL), ('marseyupset',2,'marsey upset tears',1663697961), ('marseyupvote',2,'updoot upmarsey agree yes good based true',1664181430), +('marseyupvote2',2,'upvote reddit narwhal orangered updoot',1664658174), ('marseyusa',2,'burger patriot america freedom liberty justice love independence freedom guns trump biden state flag',NULL), ('marseyuwuw',2,'fursona furry fursuit',NULL), ('marseyvampire',2,'undead sanguine horror spooky halloween fangs holiday monster',NULL), diff --git a/sql/20221002-body-tsvector.sql b/sql/20221002-body-tsvector.sql new file mode 100644 index 000000000..1151ef682 --- /dev/null +++ b/sql/20221002-body-tsvector.sql @@ -0,0 +1,3 @@ +ALTER TABLE public.comments ADD COLUMN body_ts tsvector + GENERATED ALWAYS AS (to_tsvector('english', body)) STORED; +CREATE INDEX comments_body_ts_idx ON public.comments USING GIN (body_ts); diff --git a/ubuntu_setup.sh b/ubuntu_setup.sh index 1795291d9..3d930fc10 100644 --- a/ubuntu_setup.sh +++ b/ubuntu_setup.sh @@ -12,8 +12,10 @@ cp ./env /env sed -i 's/^/export /g;s/=/="/g;s/$/"/g' /env . /env -cp ./startup.sh /s -cp ./startup_chat.sh /s2 +mkdir /scripts +cp ./startup.sh /scripts/s +cp ./startup_chat.sh /scripts/s2 +chmod +x /scripts/* sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - @@ -79,4 +81,4 @@ echo "psql -U postgres" > /p echo "tmux -S /tmp/s a -t 0" > /c echo "tmux -S /tmp/s a -t 1" > /c2 echo "cd /rDrama && git pull" > /g -echo '{"Bots": true, "Fart mode": false, "Read-only mode": false, "Signups": true, "login_required": false}' > /site_settings.json \ No newline at end of file +echo '{"Bots": true, "Fart mode": false, "Read-only mode": false, "Signups": true, "login_required": false}' > /site_settings.json