From 0839077838c62d6267facfb6676f61b35d7c2d4e Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 3 Sep 2022 04:48:27 +0200 Subject: [PATCH 1/3] fix pup mask --- files/templates/comments.html | 2 +- files/templates/hats.html | 6 +++--- files/templates/header.html | 2 +- files/templates/submission.html | 2 +- files/templates/submission_listing.html | 2 +- files/templates/userpage.html | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/files/templates/comments.html b/files/templates/comments.html index 6becccb6a..0d47e1cb7 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -212,7 +212,7 @@
{% if c.author.hat_active -%} - + {%- endif %}
{{c.author_name}} diff --git a/files/templates/hats.html b/files/templates/hats.html index 0bae58539..a31d976ab 100644 --- a/files/templates/hats.html +++ b/files/templates/hats.html @@ -8,7 +8,7 @@ {% block Banner %}
- hats banner + hats banner
Number of hats you bought: {{v.num_of_hats_bought}}
Number of hats you designed: {{v.num_of_hats_designed}}
Coins you spent on hats: {{v.coins_spent_on_hats}}
@@ -36,7 +36,7 @@ {% for hat, user in owned %} - {{hat.name}} + {{hat.name}} {{hat.name}} {{hat.description}} {% if SITE == 'rdrama.net' %} @@ -55,7 +55,7 @@ {% for hat, user in not_owned %} - {{hat.name}} + {{hat.name}} {{hat.name}} {{hat.description}} {% if SITE == 'rdrama.net' %} diff --git a/files/templates/header.html b/files/templates/header.html index ded1d93d2..4ae237a95 100644 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -207,7 +207,7 @@
{% if v.hat_active -%} - + {%- endif %}
diff --git a/files/templates/submission.html b/files/templates/submission.html index 9df272d75..22f2c243c 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -677,7 +677,7 @@
{% if p.author.hat_active -%} - + {%- endif %}
{{p.author_name}} diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index 4638e8807..ab0d6eb4e 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -213,7 +213,7 @@
{% if p.author.hat_active -%} - + {%- endif %}
{{p.author_name}} diff --git a/files/templates/userpage.html b/files/templates/userpage.html index 9db8149df..bffed2dcb 100644 --- a/files/templates/userpage.html +++ b/files/templates/userpage.html @@ -42,7 +42,7 @@ {% if u.hat_active -%} - + {%- endif %}
@@ -407,7 +407,7 @@ {% if u.hat_active -%} - + {%- endif %} From 48affb53e658c02f73dc112003bf5b01d347f4e7 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 3 Sep 2022 05:04:51 +0200 Subject: [PATCH 2/3] more hat shit --- files/assets/css/main.css | 2 +- files/classes/hats.py | 7 +++++++ files/templates/admins.html | 4 ++-- files/templates/badges.html | 6 +++--- files/templates/hats.html | 11 +++++++++-- files/templates/poll_votes.html | 4 ++-- files/templates/shop.html | 3 ++- files/templates/sub/subs.html | 2 +- files/templates/util/assetcache.html | 2 +- files/templates/votes.html | 8 ++++---- 10 files changed, 32 insertions(+), 17 deletions(-) diff --git a/files/assets/css/main.css b/files/assets/css/main.css index e9c98483d..3ceb797b0 100644 --- a/files/assets/css/main.css +++ b/files/assets/css/main.css @@ -4876,7 +4876,7 @@ code { .noshadow { box-shadow: none !important; } -[role="button"] { +[role="button"], [onclick] { cursor: pointer !important; } diff --git a/files/classes/hats.py b/files/classes/hats.py index 8729707bd..25fcbb45c 100644 --- a/files/classes/hats.py +++ b/files/classes/hats.py @@ -1,6 +1,8 @@ from sqlalchemy import * from sqlalchemy.orm import relationship from files.__main__ import Base +from files.helpers.lazy import lazy +from flask import g class HatDef(Base): __tablename__ = "hat_defs" @@ -13,6 +15,11 @@ class HatDef(Base): author = relationship("User", primaryjoin="HatDef.author_id == User.id") + @property + @lazy + def number_sold(self): + return g.db.query(Hat).filter_by(hat_id=self.id).count() + class Hat(Base): __tablename__ = "hats" diff --git a/files/templates/admins.html b/files/templates/admins.html index c530ead5f..1411a61db 100644 --- a/files/templates/admins.html +++ b/files/templates/admins.html @@ -13,8 +13,8 @@ # Name - Truescore - Mod actions + Truescore + Mod actions diff --git a/files/templates/badges.html b/files/templates/badges.html index 44208ec8b..fdb21ad1e 100644 --- a/files/templates/badges.html +++ b/files/templates/badges.html @@ -14,12 +14,12 @@ - + - - + + diff --git a/files/templates/hats.html b/files/templates/hats.html index a31d976ab..3b21583d3 100644 --- a/files/templates/hats.html +++ b/files/templates/hats.html @@ -27,8 +27,12 @@ {% if SITE == 'rdrama.net' %} + + + {% else %} + + {% endif %} - @@ -42,6 +46,7 @@ {% if SITE == 'rdrama.net' %} {% endif %} + {% endif %} + - - + + diff --git a/files/templates/shop.html b/files/templates/shop.html index 3412656a7..59683e3ac 100644 --- a/files/templates/shop.html +++ b/files/templates/shop.html @@ -38,7 +38,7 @@ - + @@ -80,4 +80,5 @@ + {% endblock %} diff --git a/files/templates/sub/subs.html b/files/templates/sub/subs.html index 1b942b11d..9761e19f9 100644 --- a/files/templates/sub/subs.html +++ b/files/templates/sub/subs.html @@ -12,7 +12,7 @@ - + diff --git a/files/templates/util/assetcache.html b/files/templates/util/assetcache.html index 19b3376fe..5dca5ebe1 100644 --- a/files/templates/util/assetcache.html +++ b/files/templates/util/assetcache.html @@ -1,6 +1,6 @@ {%- set CACHE_VER = { - 'css/main.css': 502, + 'css/main.css': 503, 'css/catalog.css': 2, 'css/4chan.css': 61, diff --git a/files/templates/votes.html b/files/templates/votes.html index fbaad1b38..6970411f9 100644 --- a/files/templates/votes.html +++ b/files/templates/votes.html @@ -31,8 +31,8 @@ - - + + @@ -59,8 +59,8 @@ - - + + From 2398cf45f72a1bd3e7953694c75cd7592464ecf6 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 3 Sep 2022 05:10:14 +0200 Subject: [PATCH 3/3] refactor archive.org --- files/helpers/actions.py | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/files/helpers/actions.py b/files/helpers/actions.py index b5e613297..aedfd579c 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -30,7 +30,20 @@ def badge_grant(user, badge_id, description=None, url=None): def archiveorg(url): x = requests.get(f'https://web.archive.org/save/{url}', headers={'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}, timeout=100) - print(x, flush=True) + +def archive_url(url): + if url.startswith(SITE_FULL): return + + gevent.spawn(archiveorg, url) + + if url.startswith('https://twitter.com/'): + url = url.replace('https://twitter.com/', 'https://nitter.42l.fr/') + gevent.spawn(archiveorg, url) + + if url.startswith('https://instagram.com/'): + url = newposturl.replace('https://instagram.com/', 'https://imginn.com/') + gevent.spawn(archiveorg, url) + def execute_snappy(post, v): snappy = get_account(SNAPPY_ID) @@ -95,15 +108,7 @@ def execute_snappy(post, v): newposturl = post.url if newposturl.startswith('/'): newposturl = f"{SITE_FULL}{newposturl}" body += f"Snapshots:\n\n{rev}* [archive.org](https://web.archive.org/{newposturl})\n* [archive.ph](https://archive.ph/?url={quote(newposturl)}&run=1) (click to archive)\n* [ghostarchive.org](https://ghostarchive.org/search?term={quote(newposturl)}) (click to archive)\n\n" - gevent.spawn(archiveorg, newposturl) - - if newposturl.startswith('https://twitter.com/'): - newposturl = newposturl.replace('https://twitter.com/', 'https://nitter.42l.fr/') - gevent.spawn(archiveorg, newposturl) - - if newposturl.startswith('https://instagram.com/'): - newposturl = newposturl.replace('https://instagram.com/', 'https://imginn.com/') - gevent.spawn(archiveorg, newposturl) + archive_url(newposturl) captured = [] body_for_snappy = post.body_html.replace(' data-src="', ' src="') @@ -137,15 +142,7 @@ def execute_snappy(post, v): addition += f'* [ghostarchive.org](https://ghostarchive.org/search?term={quote(href)}) (click to archive)\n\n' if len(f'{body}{addition}') > 10000: break body += addition - gevent.spawn(archiveorg, href) - - if href.startswith('https://twitter.com/'): - href = href.replace('https://twitter.com/', 'https://nitter.42l.fr/') - gevent.spawn(archiveorg, href) - - if href.startswith('https://instagram.com/'): - href = href.replace('https://instagram.com/', 'https://imginn.com/') - gevent.spawn(archiveorg, href) + archive_url(href) body = body.strip() body_html = sanitize(body)
## Name Image Description#Rarity#Rarity
DescriptionAuthorNumber SoldPriceNumber SoldPricePrice Actions
{{user.username}}{{hat.number_sold}} {{hat.price}} {% if hat.id == v.equipped_hat.id %} @@ -61,6 +66,7 @@ {% if SITE == 'rdrama.net' %} {{user.username}}{{hat.number_sold}} {{hat.price}} Buy @@ -84,4 +90,5 @@ -{% endblock %} + +{% endblock %} \ No newline at end of file diff --git a/files/templates/poll_votes.html b/files/templates/poll_votes.html index 2b8e508f0..41bad6367 100644 --- a/files/templates/poll_votes.html +++ b/files/templates/poll_votes.html @@ -19,8 +19,8 @@
UserUser TruescoreVote TimeUser TruescoreVote Time
Icon Title PriceOwnedOwned Buy Description
# NamePostsPosts
UserUser TruescoreVote TimeUser TruescoreVote Time
UserUser TruescoreVote TimeUser TruescoreVote Time