dfsfds
This commit is contained in:
parent
8340715364
commit
e5a5aa3ccf
4 changed files with 62 additions and 12 deletions
|
@ -307,6 +307,34 @@ class Comment(Base):
|
|||
|
||||
return body
|
||||
|
||||
def plainbody(self, v):
|
||||
if self.post and self.post.club and not (v and v.paid_dues): return "<p>COUNTRY CLUB ONLY</p>"
|
||||
|
||||
body = self.body
|
||||
|
||||
if not body: return ""
|
||||
|
||||
if not v or v.slurreplacer:
|
||||
for s, r in SLURS.items(): body = body.replace(s, r)
|
||||
|
||||
if v and not v.oldreddit: body = body.replace("old.reddit.com", "reddit.com")
|
||||
|
||||
if v and v.nitter: body = body.replace("www.twitter.com", "nitter.net").replace("twitter.com", "nitter.net")
|
||||
|
||||
if v and v.controversial:
|
||||
for i in re.finditer('(/comments/.*?)"', body):
|
||||
url = i.group(1)
|
||||
p = urlparse(url).query
|
||||
p = parse_qs(p)
|
||||
|
||||
if 'sort' not in p:
|
||||
p['sort'] = ['controversial']
|
||||
|
||||
url_noquery = url.split('?')[0]
|
||||
body = body.replace(url, f"{url_noquery}?{urlencode(p, True)}")
|
||||
|
||||
return body
|
||||
|
||||
@lazy
|
||||
def collapse_for_user(self, v):
|
||||
|
||||
|
|
|
@ -348,6 +348,18 @@ class Submission(Base):
|
|||
if v and v.nitter: body = body.replace("www.twitter.com", "nitter.net").replace("twitter.com", "nitter.net")
|
||||
return body
|
||||
|
||||
def plainbody(self, v):
|
||||
if self.club and not (v and v.paid_dues): return "COUNTRY CLUB ONLY"
|
||||
body = self.body
|
||||
|
||||
if not v or v.slurreplacer:
|
||||
for s,r in SLURS.items():
|
||||
body = body.replace(s, r)
|
||||
|
||||
if v and not v.oldreddit: body = body.replace("old.reddit.com", "reddit.com")
|
||||
if v and v.nitter: body = body.replace("www.twitter.com", "nitter.net").replace("twitter.com", "nitter.net")
|
||||
return body
|
||||
|
||||
@lazy
|
||||
def realtitle(self, v):
|
||||
if self.club and not (v and v.paid_dues) and not (v and v.admin_level == 6): return 'COUNTRY CLUB MEMBERS ONLY'
|
||||
|
@ -359,6 +371,16 @@ class Submission(Base):
|
|||
|
||||
return title
|
||||
|
||||
@lazy
|
||||
def plaintitle(self, v):
|
||||
if self.club and not (v and v.paid_dues) and not (v and v.admin_level == 6): return 'COUNTRY CLUB MEMBERS ONLY'
|
||||
else: title = self.title
|
||||
|
||||
if not v or v.slurreplacer:
|
||||
for s,r in SLURS.items(): title = title.replace(s, r)
|
||||
|
||||
return title
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def is_image(self):
|
||||
|
|
|
@ -83,15 +83,15 @@
|
|||
<meta property="og:type" content="article" />
|
||||
|
||||
{% if comment_info and not comment_info.is_banned and not linked_comment.deleted_utc > 0 %}
|
||||
<title>{{'@'+comment_info.author.username}} comments on "{{p.title}} - {{'SITE_NAME' | app_config}}"</title>
|
||||
<title>{{'@'+comment_info.author.username}} comments on "{{p.plaintitle(v)}} - {{'SITE_NAME' | app_config}}"</title>
|
||||
|
||||
|
||||
<meta property="og:article:author" content="{{'@'+comment_info.author.username}}" />
|
||||
<meta property="article:published_time" content="{{comment_info.created_datetime}}" />
|
||||
{% if comment_info.edited_utc %}<meta property="article:modified_time" content="{{comment_info.edited_string}}" />{% endif %}
|
||||
<meta property="og:description" name="description" content="{{comment_info.body}}" />
|
||||
<meta property="og:description" name="description" content="{{comment_info.plainbody(v)}}" />
|
||||
<meta property="og:author" name="author" content="{{'@'+comment_info.author.username}}" />
|
||||
<meta property="og:title" content="{{'@'+comment_info.author.username}} comments on {{p.title}} - {{'SITE_NAME' | app_config}}" />
|
||||
<meta property="og:title" content="{{'@'+comment_info.author.username}} comments on {{p.plaintitle(v)}} - {{'SITE_NAME' | app_config}}" />
|
||||
<meta property="og:image" content="{% if p.is_image %}{{p.realurl(v)}}{% elif p.has_thumb%}{{p.thumb_url}}{% else %}{{'SITE_NAME' | app_config}}/assets/images/{{'SITE_NAME' | app_config}}/preview.webp{% endif %}" />
|
||||
{% if p.url and p.url.lower().endswith('.mp4') %}
|
||||
<meta property="og:video" content="{{ p.realurl(v) }}" />
|
||||
|
@ -101,9 +101,9 @@
|
|||
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta name="twitter:site" content="{{request.host_url}}">
|
||||
<meta name="twitter:title" content="{{'@'+comment_info.author.username}} comments on {{p.title}} - {{'SITE_NAME' | app_config}}" />
|
||||
<meta name="twitter:title" content="{{'@'+comment_info.author.username}} comments on {{p.plaintitle(v)}} - {{'SITE_NAME' | app_config}}" />
|
||||
<meta name="twitter:creator" content="{{'@'+comment_info.author.username}}">
|
||||
<meta name="twitter:description" content="{{comment_info.body}}" />
|
||||
<meta name="twitter:description" content="{{comment_info.plainbody(v)}}" />
|
||||
<meta name="twitter:image" content="{% if p.is_image %}{{p.realurl(v)}}{% elif p.has_thumb%}{{p.thumb_url}}{% else %}{{'SITE_NAME' | app_config}}/assets/images/{{'SITE_NAME' | app_config}}/preview.webp{% endif %}" />
|
||||
<meta name="twitter:url" content="{{p.permalink | full_link}}" />
|
||||
|
||||
|
@ -112,15 +112,15 @@
|
|||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
<title>{{p.title}} - {{'SITE_NAME' | app_config}}</title>
|
||||
<title>{{p.plaintitle(v)}} - {{'SITE_NAME' | app_config}}</title>
|
||||
|
||||
|
||||
<meta property="og:article:author" content="{{'@'+p.author.username}}" />
|
||||
<meta property="article:published_time" content="{{p.created_datetime}}" />
|
||||
{% if p.edited_utc %}<meta property="article:modified_time" content="{{p.edited_string}}" />{% endif %}
|
||||
<meta property="og:description" name="description" content="{{p.body}}" />
|
||||
<meta property="og:description" name="description" content="{{p.plainbody(v)}}" />
|
||||
<meta property="og:author" name="author" content="{{'@'+p.author.username}}" />
|
||||
<meta property="og:title" content="{{p.title}} - {{'SITE_NAME' | app_config}}" />
|
||||
<meta property="og:title" content="{{p.plaintitle(v)}} - {{'SITE_NAME' | app_config}}" />
|
||||
<meta property="og:image" content="{% if p.is_image %}{{p.realurl(v)}}{% elif p.has_thumb%}{{p.thumb_url}}{% else %}{{'SITE_NAME' | app_config}}/assets/images/{{'SITE_NAME' | app_config}}/preview.webp{% endif %}" />
|
||||
{% if p.url and p.url.lower().endswith('.mp4') %}
|
||||
<meta property="og:video" content="{{ p.realurl(v) }}" />
|
||||
|
@ -130,9 +130,9 @@
|
|||
|
||||
<meta name="twitter:card" content="summary_large_image"/>
|
||||
<meta name="twitter:site" content="{{request.host_url}}">
|
||||
<meta name="twitter:title" content="{{p.title}} - {{'SITE_NAME' | app_config}}" />
|
||||
<meta name="twitter:title" content="{{p.plaintitle(v)}} - {{'SITE_NAME' | app_config}}" />
|
||||
<meta name="twitter:creator" content="{{'@'+p.author.username}}">
|
||||
<meta name="twitter:description" content="{{p.body}}" />
|
||||
<meta name="twitter:description" content="{{p.plainbody(v)}}" />
|
||||
<meta name="twitter:image" content="{% if p.is_image %}{{p.realurl(v)}}{% elif p.has_thumb %}{{p.thumb_url}}{% else %}{{'SITE_NAME' | app_config}}/assets/images/{{'SITE_NAME' | app_config}}/preview.webp{% endif %}" />
|
||||
<meta name="twitter:url" content="{{p.permalink | full_link}}" />
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
{% endif %}
|
||||
|
||||
{% block title %}
|
||||
<title>{{p.title}}</title>
|
||||
<title>{{p.plaintitle(v)}}</title>
|
||||
{% if p.is_banned %}
|
||||
<meta name="description" content="[removed by admins]">
|
||||
{% else %}
|
||||
|
@ -55,7 +55,7 @@
|
|||
<div id="post-{{p.id}}" class="card d-flex flex-row-reverse flex-nowrap justify-content-end border-0 p-0 {% if voted==1 %} upvoted{% elif voted==-1 %} downvoted{% endif %}">
|
||||
<div class="card-block my-md-auto{% if p.is_banned %} banned{% endif %}">
|
||||
<div class="post-meta text-left d-md-none mb-1">{% if p.over_18 %}<span class="badge badge-danger">+18</span> {% endif %}{% if p.is_banned %}[Removed by admins]{% else %}[Deleted by user]{% endif %}</div>
|
||||
<h5 class="card-title post-title text-left mb-0 mb-md-1">{{p.title}}</h5>
|
||||
<h5 class="card-title post-title text-left mb-0 mb-md-1">{{p.plaintitle(v)}}</h5>
|
||||
<div class="post-meta text-left d-none d-md-block">{% if p.over_18 %}<span class="badge badge-danger">+18</span> {% endif %}{% if p.is_banned %}[Removed by admins]{% else %}[Deleted by user]{% endif %}</div>
|
||||
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue