From 68b4c603abe2c35fb0bbef2ba37e9835026dd531 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 13 Dec 2021 23:27:25 +0200 Subject: [PATCH] fsdfsd --- files/classes/submission.py | 9 --------- files/helpers/const.py | 4 ++-- files/routes/posts.py | 6 ++++-- files/routes/users.py | 10 +++++----- files/templates/settings_profile.html | 4 ++-- files/templates/userpage.html | 4 ++-- schema.sql | 1 - setup | 4 ++-- 8 files changed, 17 insertions(+), 25 deletions(-) diff --git a/files/classes/submission.py b/files/classes/submission.py index fb898fae7..681ba8d8e 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -32,7 +32,6 @@ class Submission(Base): views = Column(Integer, default=0) deleted_utc = Column(Integer, default=0) distinguish_level = Column(Integer, default=0) - created_str = Column(String) stickied = Column(String) is_pinned = Column(Boolean, default=False) private = Column(Boolean, default=False) @@ -60,14 +59,6 @@ class Submission(Base): awards = relationship("AwardRelationship", viewonly=True) def __init__(self, *args, **kwargs): - - if "created_utc" not in kwargs: - kwargs["created_utc"] = int(time.time()) - kwargs["created_str"] = time.strftime( - "%I:%M %p on %d %b %Y", time.gmtime( - kwargs["created_utc"])) - - super().__init__(*args, **kwargs) def __repr__(self): diff --git a/files/helpers/const.py b/files/helpers/const.py index 96b1f4c8b..416a878f4 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -106,7 +106,7 @@ Thank you.""" WELCOME_MSG = "Hi there! It's me, your soon-to-be favorite rDrama user @carpathianflorist here to give you a brief rundown on some of the sick features we have here. You'll probably want to start by following me, though. So go ahead and click my name and then smash that Follow button. This is actually really important, so go on. Hurry.\n\nThanks!\n\nNext up: If you're a member of the media, similarly just shoot me a DM and I'll set about verifying you and then we can take care of your sad journalism stuff.\n\n**FOR EVERYONE ELSE**\n\n Begin by navigating to [the settings page](https://rdrama.net/settings/profile) (we'll be prettying this up so it's less convoluted soon, don't worry) and getting some basic customization done.\n\n### Themes\n\nDefinitely change your theme right away, the default one (Midnight) is pretty enough, but why not use something *exotic* like Win98, or *flashy* like Tron? Even Coffee is super tasteful and way more fun than the default. More themes to come when we get around to it!\n\n### Avatar/pfp\n\nYou'll want to set this pretty soon; without uploading one, I put together a randomly-assigned selection of 180ish pictures of furries, ugly goths, mujahideen, anime girls, and My Little Ponys which are used by everyone who was too lazy to set a pfp. Set the banner too while you're at it. Your profile is important!\n\n### Flairs\n\nSince you're already on the settings page, you may as well set a flair, too. As with your username, you can - obviously - choose the color of this, either with a hex value or just from the preset colors. And also like your username, you can change this at any time. [Paypigs](https://marsey1.gumroad.com/l/tfcvri) can even further relive the glory days of 90s-00s internet and set obnoxious signatures.\n\n### PROFILE ANTHEMS\n\nSpeaking of profiles, hey, remember MySpace? Do you miss autoplaying music assaulting your ears every time you visited a friend's page? Yeah, we brought that back. Enter a YouTube URL, wait a few seconds for it to process, and then BAM! you've got a profile anthem which people cannot mute. Unless they spend 20,000 dramacoin in the shop for a mute button. Which you can then remove from your profile by spending 40,000 dramacoin on an unmuteable anthem. Get fucked poors!\n\n### Dramacoin?\n\nDramacoin is basically our take on the karma system. Except unlike the karma system, it's not gay and boring and stupid and useless. Dramacoin can be spent at [Marsey's Dramacoin Emporium](https://rdrama.net/shop) on upgrades to your user experience (many more coming than what's already listed there), and best of all on tremendously annoying awards to fuck with your fellow dramautists. We're always adding more, so check back regularly in case you happen to miss one of the announcement posts. Holiday-themed awards are currently unavailable while we resolve an internal dispute, but they **will** return, no matter what some other janitors insist.\n\nLike karma, dramacoin is obtained by getting upvotes on your threads and comments. *Unlike* karma, it's also obtained by getting downvotes on your threads and comments. Downvotes don't really do anything here - they pay the same amount of dramacoin and they increase thread/comment ranking just the same as an upvote. You just use them to express petty disapproval and hopefully start a fight. Because all votes are visible here. To hell with your anonymity.\n\nDramacoin can also be traded amongst users from their profiles. Note that there is a 3% transaction fee.\n\n**Dramacoin and shop items cannot be purchased with real money and this will not change.** Though we are notoriously susceptible to bribes, so definitely shoot your shot. It'll probably go well, honestly.\n\n### Badges\n\nRemember all those neat little metallic icons you saw on my profile when you were following me? If not, scroll back up and go have a look. And doublecheck to make sure you pressed the Follow button. Anyway, those are badges. You earn them by doing a variety of things. Some of them even offer benefits, like discounts at the shop. A [complete list of badges and their requirements can be found here](https://rdrama.net/badges), though I add more pretty regularly, so keep an eye on the changelog.\n\n### Other stuff\n\nWe're always adding new features, and we take a fun-first approach to development. If you have a suggestion for something that would be fun, funny, annoying - or best of all, some combination of all three - definitely make a thread about it. Or just DM me if you're shy. Weirdo. Anyway there's also the [leaderboards](https://rdrama.net/leaderboard), boring stuff like two-factor authentication you can toggle on somewhere in the settings page (psycho), the ability to save posts and comments, close to a thousand emojis already (several hundred of which are rDrama originals), and on and on and on and on. This is just the basics, mostly to help you get acquainted with some of the things you can do here to make it more easy on the eyes, customizable, and enjoyable. If you don't enjoy it, just go away! We're not changing things to suit you! Get out of here loser! And no, you can't delete your account :na:\n\nI love you.
*xoxo Carp* 💋" -if SITE == 'rdrama.net': +if 'rdrama.net' in SITE: BASEDBOT_ID = 0 KIPPY_ID = 7150 NOTIFICATIONS_ID = 1046 @@ -130,7 +130,7 @@ if SITE == 'rdrama.net': DONGER_ID = 541 FARTBINN_ID = 2256 BUG_THREAD = 18459 - EMOJI_THREAD = 22479 + EMOJI_THREAD = 16583 elif SITE == "pcmemes.net": BASEDBOT_ID = 800 KIPPY_ID = 1592 diff --git a/files/routes/posts.py b/files/routes/posts.py index 026ef0ba0..23d6ecd53 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -53,6 +53,7 @@ def publish(pid, v): post = get_post(pid) if not post.author_id == v.id: abort(403) post.private = False + post.created_utc = int(time.time()) g.db.add(post) notify_users = NOTIFY_USERS(f'{post.body_html}{post.title}', v.id) @@ -97,7 +98,7 @@ def post_id(pid, anything=None, v=None): try: pid = int(pid) except Exception as e: pass - if request.host == 'rdrama.net' and pid in [BUG_THREAD, EMOJI_THREAD]: defaultsortingcomments = 'new' + if 'rdrama.net' in request.host and pid in [BUG_THREAD, EMOJI_THREAD]: defaultsortingcomments = 'new' elif v: defaultsortingcomments = v.defaultsortingcomments else: defaultsortingcomments = "top" @@ -958,7 +959,8 @@ def submit_post(v): body_html=body_html, embed_url=embed, title=title[:500], - title_html=title_html + title_html=title_html, + created_utc=int(time.time()) ) g.db.add(new_post) diff --git a/files/routes/users.py b/files/routes/users.py index adc32dca1..07478a6d3 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -209,13 +209,13 @@ def transfer_coins(v, username): if not v.patron and not receiver.patron: tax = math.ceil(amount*0.03) tax_receiver = g.db.query(User).filter_by(id=TAX_RECEIVER_ID).first() - if request.host == 'rdrama.net': tax_receiver.coins += tax/3 + if 'rdrama.net' in request.host: tax_receiver.coins += tax/3 else: tax_receiver.coins += tax log_message = f"[@{v.username}]({v.url}) has transferred {amount} {app.config['COINS_NAME']} to [@{receiver.username}]({receiver.url})" send_notification(TAX_RECEIVER_ID, log_message) g.db.add(tax_receiver) - if request.host == 'rdrama.net': + if 'rdrama.net' in request.host: carp = g.db.query(User).filter_by(id=CARP_ID).first() carp.coins += tax/3 log_message = f"[@{v.username}]({v.url}) has transferred {amount} {app.config['COINS_NAME']} to [@{receiver.username}]({receiver.url})" @@ -493,7 +493,7 @@ def redditor_moment_redirect(username): @auth_required def followers(username, v): u = get_user(username, v=v) - # if request.host == 'rdrama.net' and u.id == 147: abort(404) + # if 'rdrama.net' in request.host and u.id == 147: abort(404) ids = [x[0] for x in g.db.query(Follow.user_id).filter_by(target_id=u.id).all()] users = g.db.query(User).filter(User.id.in_(ids)).all() return render_template("followers.html", v=v, u=u, users=users) @@ -502,7 +502,7 @@ def followers(username, v): @auth_required def following(username, v): u = get_user(username, v=v) - # if request.host == 'rdrama.net' and u.id == 147: abort(404) + # if 'rdrama.net' in request.host and u.id == 147: abort(404) ids = [x[0] for x in g.db.query(Follow.target_id).filter_by(user_id=u.id).all()] users = g.db.query(User).filter(User.id.in_(ids)).all() return render_template("following.html", v=v, u=u, users=users) @@ -510,7 +510,7 @@ def following(username, v): @app.get("/views") @auth_required def visitors(v): - if request.host == 'rdrama.net' and v.admin_level < 1 and not v.patron: return render_template("errors/patron.html", v=v) + if 'rdrama.net' in request.host and v.admin_level < 1 and not v.patron: return render_template("errors/patron.html", v=v) viewers=sorted(v.viewers, key = lambda x: x.last_view_utc, reverse=True) return render_template("viewers.html", v=v, viewers=viewers) diff --git a/files/templates/settings_profile.html b/files/templates/settings_profile.html index 4f847fa12..46c1bd670 100644 --- a/files/templates/settings_profile.html +++ b/files/templates/settings_profile.html @@ -523,7 +523,7 @@
- +
@@ -560,7 +560,7 @@
- +
diff --git a/files/templates/userpage.html b/files/templates/userpage.html index c30123eab..7361f718d 100644 --- a/files/templates/userpage.html +++ b/files/templates/userpage.html @@ -119,7 +119,7 @@ {% if u.bio_html %}

-					{% if request.host == 'rdrama.net' and u.id == 2050 %}
+					{% if 'rdrama.net' in request.host and u.id == 2050 %}
 						
{{u.friends_html | safe}}
{% else %}
{{u.bio_html | safe}}
@@ -130,7 +130,7 @@ {% if u.friends_html %}

Friends:

- {% if request.host == 'rdrama.net' and u.id == 2050 %} + {% if 'rdrama.net' in request.host and u.id == 2050 %} {{u.bio_html | safe}} {% else %} {{u.friends_html | safe}} diff --git a/schema.sql b/schema.sql index 61b39ebe5..20a46a1af 100644 --- a/schema.sql +++ b/schema.sql @@ -560,7 +560,6 @@ CREATE TABLE public.submissions ( is_banned boolean, over_18 boolean, distinguish_level integer, - created_str character varying(255), deleted_utc integer NOT NULL, domain_ref integer, is_approved integer NOT NULL, diff --git a/setup b/setup index 0b8f57be6..c3d2e569e 100644 --- a/setup +++ b/setup @@ -11,8 +11,8 @@ sudo apt -y install python3-pip sudo pip3 install -r requirements.txt sudo apt -y install gunicorn sudo apt -y install ffmpeg -mkdir /drama/songs -mkdir /drama/images +mkdir /songs +mkdir /images cp ./env /env . /env gunicorn files.__main__:app -k gevent -w 2 --reload -b localhost:80 --max-requests 1000 --max-requests-jitter 500 \ No newline at end of file