publish fix

remotes/1693045480750635534/spooky-22
Aevann1 2022-03-18 21:05:54 +02:00
parent 2ae41be28e
commit 397dca9a83
15 changed files with 33 additions and 32 deletions

View File

@ -348,7 +348,7 @@ class Comment(Base):
if v.teddit: body = body.replace("old.reddit.com", "teddit.net")
elif not v.oldreddit: body = body.replace("old.reddit.com", "reddit.com")
if v.nitter and not '/i/' in body: body = body.replace("www.twitter.com", "nitter.net").replace("twitter.com", "nitter.net")
if v.nitter and not '/i/' in body and '/retweets' not in body: body = body.replace("www.twitter.com", "nitter.net").replace("twitter.com", "nitter.net")
if v and v.controversial:
captured = []

View File

@ -354,7 +354,7 @@ class Submission(Base):
if v.controversial: url += "&sort=controversial"
return url
elif self.url:
if v and v.nitter and not '/i/' in self.url: return self.url.replace("www.twitter.com", "nitter.net").replace("twitter.com", "nitter.net")
if v and v.nitter and '/i/' not in self.url and '/retweets' not in self.url: return self.url.replace("www.twitter.com", "nitter.net").replace("twitter.com", "nitter.net")
if self.url.startswith('/'): return SITE_FULL + self.url
return self.url
else: return ""
@ -370,7 +370,7 @@ class Submission(Base):
if v.teddit: body = body.replace("old.reddit.com", "teddit.net")
elif not v.oldreddit: body = body.replace("old.reddit.com", "reddit.com")
if v.nitter and not '/i/' in body: body = body.replace("www.twitter.com", "nitter.net").replace("twitter.com", "nitter.net")
if v.nitter and '/i/' not in body and '/retweets' not in body: body = body.replace("www.twitter.com", "nitter.net").replace("twitter.com", "nitter.net")
if v and v.shadowbanned and v.id == self.author_id and 86400 > time.time() - self.created_utc > 20:
ti = max(int((time.time() - self.created_utc)/60), 1)
@ -436,7 +436,7 @@ class Submission(Base):
if v.teddit: body = body.replace("old.reddit.com", "teddit.net")
elif not v.oldreddit: body = body.replace("old.reddit.com", "reddit.com")
if v.nitter and not '/i/' in body: body = body.replace("www.twitter.com", "nitter.net").replace("twitter.com", "nitter.net")
if v.nitter and '/i/' not in body and '/retweets' not in body: body = body.replace("www.twitter.com", "nitter.net").replace("twitter.com", "nitter.net")
return body

View File

@ -276,7 +276,7 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
sanitized = re.sub(f'(?<!"):{i.group(1).lower()}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{old}:" title=":{old}:" class="{classes}" src="/e/{emoji}.webp">', sanitized, flags=re.I|re.A)
if comment: marseys_used.add(emoji)
sanitized = sanitized.replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("m.wikipedia.org", "wikipedia.org").replace("https://m.youtube", "https://youtube").replace("https://www.youtube", "https://youtube")
sanitized = sanitized.replace("nitter.net", "twitter.com").replace("old.reddit.com/gallery", "reddit.com/gallery").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("m.wikipedia.org", "wikipedia.org").replace("https://m.youtube", "https://youtube").replace("https://www.youtube", "https://youtube").replace("https://www.twitter", "https://twitter")
if "https://youtube.com/watch?v=" in sanitized: sanitized = sanitized.replace("?t=", "&t=")
@ -302,8 +302,6 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
for rd in ["://reddit.com", "://new.reddit.com", "://www.reddit.com", "://redd.it", "://libredd.it"]:
sanitized = sanitized.replace(rd, "://old.reddit.com")
sanitized = sanitized.replace("old.reddit.com/gallery", "reddit.com/gallery")
sanitized = unlinked_regex.sub(r'\1<a href="\2" rel="nofollow noopener noreferrer" target="_blank">\2</a>', sanitized)

View File

@ -98,7 +98,7 @@ def publish(pid, v):
g.db.commit()
return redirect(p.permalink)
return redirect(post.permalink)
@app.get("/submit")
@app.get("/h/<sub>/submit")
@ -839,6 +839,8 @@ def submit_post(v, sub=None):
embed = None
if url:
url = url.replace("nitter.net", "twitter.com").replace("old.reddit.com/gallery", "reddit.com/gallery").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("m.wikipedia.org", "wikipedia.org").replace("https://m.youtube", "https://youtube").replace("https://www.youtube", "https://youtube").replace("https://www.twitter", "https://twitter")
if "/i.imgur.com/" in url: url = url.replace(".png", ".webp").replace(".jpg", ".webp").replace(".jpeg", ".webp")
elif "/media.giphy.com/" in url or "/c.tenor.com/" in url: url = url.replace(".gif", ".webp")
elif "/i.ibb.com/" in url: url = url.replace(".png", ".webp").replace(".jpg", ".webp").replace(".jpeg", ".webp").replace(".gif", ".webp")
@ -846,8 +848,6 @@ def submit_post(v, sub=None):
for rd in ("://reddit.com", "://new.reddit.com", "://www.reddit.com", "://redd.it", "://libredd.it", "://teddit.net"):
url = url.replace(rd, "://old.reddit.com")
url = url.replace("nitter.net", "twitter.com").replace("old.reddit.com/gallery", "reddit.com/gallery").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("m.wikipedia.org", "wikipedia.org").replace("https://m.youtube", "https://youtube").replace("https://www.youtube", "https://youtube")
if url.startswith("https://streamable.com/") and not url.startswith("https://streamable.com/e/"): url = url.replace("https://streamable.com/", "https://streamable.com/e/")
parsed_url = urlparse(url)

View File

@ -15,7 +15,7 @@
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=29">
<link rel="stylesheet" href="/static/assets/css/main.css?v=179"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=30">
{% if v.agendaposter %}
<style>
html {
@ -39,7 +39,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=29">
<link rel="stylesheet" href="/static/assets/css/main.css?v=179"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
{% endif %}
</head>

View File

@ -7,8 +7,8 @@
<script src="/static/assets/js/bootstrap.js?v=245"></script>
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=178">
<link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=29">
<link rel="stylesheet" href="/static/assets/css/main.css?v=179">
<link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=30">
{% if v.agendaposter %}
<style>
html {
@ -32,8 +32,8 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=178">
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=29">
<link rel="stylesheet" href="/static/assets/css/main.css?v=179">
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
{% endif %}
{% if sub and sub.css and not request.path.endswith('settings') %}

View File

@ -6,7 +6,7 @@
{% block content %}
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=29">
<link rel="stylesheet" href="/static/assets/css/main.css?v=179"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=30">
{% if v.agendaposter %}
<style>
html {
@ -30,7 +30,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=29">
<link rel="stylesheet" href="/static/assets/css/main.css?v=179"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
{% endif %}
<div class="row justify-content-around">

View File

@ -18,8 +18,8 @@
{% endblock %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=178">
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=29">
<link rel="stylesheet" href="/static/assets/css/main.css?v=179">
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
</head>

View File

@ -14,7 +14,7 @@
<title>2-Step Login - {{SITE_NAME}}</title>
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=29">
<link rel="stylesheet" href="/static/assets/css/main.css?v=179"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
</head>

View File

@ -1,13 +1,16 @@
{% if not p.ghost %}<a class="list-inline-item" href="/votes?link={{p.fullname}}"><i class="fas fa-arrows-v"></i>Votes</a>{% endif %}
{% if v and v.id==p.author_id %}
{% if p.private %}
<a class="list-inline-item" href='/publish/{{p.id}}'><i class="fas fa-globe"></i>Publish</a>
<form action="/publish/{{p.id}}" method="post">
<input type="hidden" name="formkey", value="{{v.formkey}}">
<button class="list-inline-item text-small p-0 m-0 mr-3 border-0 nobackground font-weight-bold" type="submit"><i class="fas fa-globe"></i>Publish</button>
</form>
{% endif %}
{% endif %}
{% if not p.ghost %}<a class="list-inline-item" href="/votes?link={{p.fullname}}"><i class="fas fa-arrows-v"></i>Votes</a>{% endif %}
{% if v %}
<a class="list-inline-item text-muted d-none d-md-inline-block" role="button" data-bs-toggle="modal" data-bs-target="#awardModal" onclick="awardModal('/award_post/{{p.id}}')"><i class="fas fa-gift fa-fw"></i>Give Award</a>
{% endif %}

View File

@ -34,7 +34,7 @@
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=29">
<link rel="stylesheet" href="/static/assets/css/main.css?v=179"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=30">
{% if v.agendaposter %}
<style>
html {

View File

@ -39,10 +39,10 @@
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=29">
<link rel="stylesheet" href="/static/assets/css/main.css?v=179"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=30">
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=29">
<link rel="stylesheet" href="/static/assets/css/main.css?v=179"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
{% endif %}
</head>

View File

@ -31,7 +31,7 @@
<title>{% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}Sign up - {{SITE_NAME}}{% endif %}</title>
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=29">
<link rel="stylesheet" href="/static/assets/css/main.css?v=179"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
</head>

View File

@ -32,7 +32,7 @@
<title>{% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}{{SITE_NAME}}{% endif %}</title>
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=29">
<link rel="stylesheet" href="/static/assets/css/main.css?v=179"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
</head>

View File

@ -26,7 +26,7 @@
{% block stylesheets %}
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=29">
<link rel="stylesheet" href="/static/assets/css/main.css?v=179"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=30">
{% if v.agendaposter %}
<style>
html {
@ -50,8 +50,8 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=178">
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=29">
<link rel="stylesheet" href="/static/assets/css/main.css?v=179">
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
{% endif %}
{% endblock %}