fddf
This commit is contained in:
parent
de880f14ba
commit
709598ebfb
11 changed files with 21 additions and 45 deletions
|
@ -19,7 +19,6 @@ class Domain(Base):
|
||||||
can_submit = Column(Boolean, default=True)
|
can_submit = Column(Boolean, default=True)
|
||||||
can_comment = Column(Boolean, default=True)
|
can_comment = Column(Boolean, default=True)
|
||||||
reason = Column(Integer, default=0)
|
reason = Column(Integer, default=0)
|
||||||
show_thumbnail = Column(Boolean, default=False)
|
|
||||||
embed_function = Column(String(64))
|
embed_function = Column(String(64))
|
||||||
embed_template = Column(String(32))
|
embed_template = Column(String(32))
|
||||||
|
|
||||||
|
|
|
@ -410,7 +410,7 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_image(self):
|
def is_image(self):
|
||||||
if self.url: return self.url.endswith('jpg') or self.url.endswith('png') or self.url.endswith('.gif') or self.url.endswith('jpeg') or self.url.endswith('?maxwidth=9999') or self.url.endswith('?maxwidth=8888')
|
if self.url: return self.url.lower().endswith('jpg') or self.url.lower().endswith('png') or self.url.lower().endswith('.gif') or self.url.lower().endswith('jpeg') or self.ur.lower()l.endswith('?maxwidth=9999') or self.url.lower().endswith('?maxwidth=8888')
|
||||||
else: return False
|
else: return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -123,26 +123,24 @@ def sanitize(text, linkgen=False, flair=False):
|
||||||
netloc = urlparse(url).netloc
|
netloc = urlparse(url).netloc
|
||||||
|
|
||||||
domain = get_domain(netloc)
|
domain = get_domain(netloc)
|
||||||
if not(netloc) or (domain and domain.show_thumbnail):
|
if "profile-pic-20" not in tag.get("class", ""):
|
||||||
|
#print(tag.get('class'))
|
||||||
|
# set classes and wrap in link
|
||||||
|
|
||||||
if "profile-pic-20" not in tag.get("class", ""):
|
tag["rel"] = "nofollow"
|
||||||
#print(tag.get('class'))
|
tag["style"] = "max-height: 100px; max-width: 100%;"
|
||||||
# set classes and wrap in link
|
tag["class"] = "in-comment-image rounded-sm my-2"
|
||||||
|
|
||||||
tag["rel"] = "nofollow"
|
link = soup.new_tag("a")
|
||||||
tag["style"] = "max-height: 100px; max-width: 100%;"
|
link["href"] = tag["src"]
|
||||||
tag["class"] = "in-comment-image rounded-sm my-2"
|
link["rel"] = "nofollow noopener"
|
||||||
|
link["target"] = "_blank"
|
||||||
|
|
||||||
link = soup.new_tag("a")
|
link["onclick"] = f"expandDesktopImage('{tag['src']}');"
|
||||||
link["href"] = tag["src"]
|
link["data-toggle"] = "modal"
|
||||||
link["rel"] = "nofollow noopener"
|
link["data-target"] = "#expandImageModal"
|
||||||
link["target"] = "_blank"
|
|
||||||
|
|
||||||
link["onclick"] = f"expandDesktopImage('{tag['src']}');"
|
tag.wrap(link)
|
||||||
link["data-toggle"] = "modal"
|
|
||||||
link["data-target"] = "#expandImageModal"
|
|
||||||
|
|
||||||
tag.wrap(link)
|
|
||||||
else:
|
else:
|
||||||
# non-whitelisted images get replaced with links
|
# non-whitelisted images get replaced with links
|
||||||
new_tag = soup.new_tag("a")
|
new_tag = soup.new_tag("a")
|
||||||
|
|
|
@ -931,7 +931,6 @@ def admin_ban_domain(v):
|
||||||
can_submit=False,
|
can_submit=False,
|
||||||
can_comment=False,
|
can_comment=False,
|
||||||
reason=reason,
|
reason=reason,
|
||||||
show_thumbnail=False,
|
|
||||||
embed_function=None,
|
embed_function=None,
|
||||||
embed_template=None
|
embed_template=None
|
||||||
)
|
)
|
||||||
|
|
|
@ -264,7 +264,7 @@ def api_comment(v):
|
||||||
|
|
||||||
if not body and not request.files.get('file'): return jsonify({"error":"You need to actually write something!"}), 400
|
if not body and not request.files.get('file'): return jsonify({"error":"You need to actually write something!"}), 400
|
||||||
|
|
||||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif))', body, re.MULTILINE): body = body.replace(i.group(1), f'})')
|
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif))', body.lower(), re.MULTILINE): body = body.replace(i.group(1), f'})')
|
||||||
body = body.replace("\n", "\n\n")
|
body = body.replace("\n", "\n\n")
|
||||||
with CustomRenderer(post_id=parent_id) as renderer: body_md = renderer.render(mistletoe.Document(body))
|
with CustomRenderer(post_id=parent_id) as renderer: body_md = renderer.render(mistletoe.Document(body))
|
||||||
body_html = sanitize(body_md, linkgen=True)
|
body_html = sanitize(body_md, linkgen=True)
|
||||||
|
@ -649,7 +649,7 @@ def edit_comment(cid, v):
|
||||||
if c.is_banned or c.deleted_utc > 0: abort(403)
|
if c.is_banned or c.deleted_utc > 0: abort(403)
|
||||||
|
|
||||||
body = request.form.get("body", "")[0:10000]
|
body = request.form.get("body", "")[0:10000]
|
||||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif))', body, re.MULTILINE): body = body.replace(i.group(1), f'})')
|
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif))', body.lower(), re.MULTILINE): body = body.replace(i.group(1), f'})')
|
||||||
body = body.replace("\n", "\n\n")
|
body = body.replace("\n", "\n\n")
|
||||||
with CustomRenderer(post_id=c.post.base36id) as renderer: body_md = renderer.render(mistletoe.Document(body))
|
with CustomRenderer(post_id=c.post.base36id) as renderer: body_md = renderer.render(mistletoe.Document(body))
|
||||||
body_html = sanitize(body_md, linkgen=True)
|
body_html = sanitize(body_md, linkgen=True)
|
||||||
|
|
|
@ -260,7 +260,7 @@ def edit_post(pid, v):
|
||||||
abort(403)
|
abort(403)
|
||||||
|
|
||||||
body = request.form.get("body", "")
|
body = request.form.get("body", "")
|
||||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif))', body, re.MULTILINE): body = body.replace(i.group(1), f'})')
|
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif))', body.lower(), re.MULTILINE): body = body.replace(i.group(1), f'})')
|
||||||
body = body.replace("\n", "\n\n")
|
body = body.replace("\n", "\n\n")
|
||||||
with CustomRenderer() as renderer:
|
with CustomRenderer() as renderer:
|
||||||
body_md = renderer.render(mistletoe.Document(body))
|
body_md = renderer.render(mistletoe.Document(body))
|
||||||
|
@ -794,7 +794,7 @@ def submit_post(v):
|
||||||
}
|
}
|
||||||
|
|
||||||
# render text
|
# render text
|
||||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif))', body, re.MULTILINE): body = body.replace(i.group(1), f'})')
|
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif))', body.lower(), re.MULTILINE): body = body.replace(i.group(1), f'})')
|
||||||
body = body.replace("\n", "\n\n")
|
body = body.replace("\n", "\n\n")
|
||||||
with CustomRenderer() as renderer:
|
with CustomRenderer() as renderer:
|
||||||
body_md = renderer.render(mistletoe.Document(body))
|
body_md = renderer.render(mistletoe.Document(body))
|
||||||
|
|
|
@ -69,7 +69,7 @@ def settings_profile_post(v):
|
||||||
v=v,
|
v=v,
|
||||||
error="You didn't change anything")
|
error="You didn't change anything")
|
||||||
|
|
||||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif))', bio, re.MULTILINE): bio = bio.replace(i.group(1), f'})')
|
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif))', bio.lower(), re.MULTILINE): bio = bio.replace(i.group(1), f'})')
|
||||||
bio = bio.replace("\n", "\n\n")
|
bio = bio.replace("\n", "\n\n")
|
||||||
with CustomRenderer() as renderer:
|
with CustomRenderer() as renderer:
|
||||||
bio_html = renderer.render(mistletoe.Document(bio))
|
bio_html = renderer.render(mistletoe.Document(bio))
|
||||||
|
|
|
@ -206,21 +206,6 @@ def settings_security(v):
|
||||||
msg=request.args.get("msg") or None
|
msg=request.args.get("msg") or None
|
||||||
)
|
)
|
||||||
|
|
||||||
@app.route("/imagehosts", methods=["GET"])
|
|
||||||
def info_image_hosts():
|
|
||||||
|
|
||||||
sites = g.db.query(Domain).filter_by(
|
|
||||||
show_thumbnail=True).order_by(
|
|
||||||
Domain.domain.asc()).all()
|
|
||||||
|
|
||||||
sites = [x.domain for x in sites]
|
|
||||||
|
|
||||||
text = "\n".join(sites)
|
|
||||||
|
|
||||||
resp = make_response(text)
|
|
||||||
resp.mimetype = "text/plain"
|
|
||||||
return resp
|
|
||||||
|
|
||||||
@app.route("/dismiss_mobile_tip", methods=["POST"])
|
@app.route("/dismiss_mobile_tip", methods=["POST"])
|
||||||
def dismiss_mobile_tip():
|
def dismiss_mobile_tip():
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,6 @@
|
||||||
<h3 class="h5 pt-2">reason</h3>
|
<h3 class="h5 pt-2">reason</h3>
|
||||||
<p>{{domain.reason_text}}</p>
|
<p>{{domain.reason_text}}</p>
|
||||||
|
|
||||||
<h3 class="h5 pt-2">show_thumbnail</h3>
|
|
||||||
<p>{{domain.show_thumbnail}}</p>
|
|
||||||
|
|
||||||
<h3 class="h5 pt-2">embed_function</h3>
|
<h3 class="h5 pt-2">embed_function</h3>
|
||||||
<p>{{domain.embed_function}}</p>
|
<p>{{domain.embed_function}}</p>
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@
|
||||||
|
|
||||||
<div class="row no-gutters mb-3 d-block d-md-none">
|
<div class="row no-gutters mb-3 d-block d-md-none">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<a target="_blank" href="{{p.url}}">{% if p.is_image and p.domain_obj and p.domain_obj.show_thumbnail %}<img src="{{p.url}}" class="img-fluid" alt="Unable to anonymously load image">
|
<a target="_blank" href="{{p.url}}">{% if p.is_image %}<img src="{{p.url}}" class="img-fluid" alt="Unable to anonymously load image">
|
||||||
<div class="post-img-overlay d-block d-md-none">{{p.domain|truncate(30, True)}}<i class="fas fa-external-link-alt text-small ml-2"></i></div>
|
<div class="post-img-overlay d-block d-md-none">{{p.domain|truncate(30, True)}}<i class="fas fa-external-link-alt text-small ml-2"></i></div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -59,8 +59,6 @@ On Drama, you can use Markdown formatting.
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<p class="text-small">* We have customized image embeds to add pop-overs and operate on a whitelist system. Embeds from known safe image hosts will use a pop-up display as demonstrated here. Attempted embeds to non-whitelisted sites will be converted into a link. The whitelist may be viewed <a href="/info/image_hosts" target="_blank">here</a>.</p>
|
|
||||||
|
|
||||||
{% filter markdown %}
|
{% filter markdown %}
|
||||||
|
|
||||||
## Block formatting
|
## Block formatting
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue