master
Aevann1 2021-07-27 23:35:50 +02:00
parent 2747d41c5a
commit f73362cab2
13 changed files with 88 additions and 143 deletions

1
.github/FUNDING.yml vendored
View File

@ -1,3 +1,2 @@
github: Aevann1 github: Aevann1
patreon: Aevann
custom: ["https://rdrama.gumroad.com/l/tfcvri"] custom: ["https://rdrama.gumroad.com/l/tfcvri"]

View File

@ -384,20 +384,19 @@ def api_comment(v):
) )
g.db.add(c) g.db.add(c)
g.db.flush() g.db.flush()
if v.dramacoins >= 0: if request.files.get("file"):
if request.files.get("file"): file=request.files["file"]
file=request.files["file"] if not file.content_type.startswith('image/'):
if not file.content_type.startswith('image/'): return jsonify({"error": "That wasn't an image!"}), 400
return jsonify({"error": "That wasn't an image!"}), 400
name = f'comment/{c.base36id}/{secrets.token_urlsafe(8)}'
name = f'comment/{c.base36id}/{secrets.token_urlsafe(8)}' url = upload_file(name, file)
url = upload_file(name, file)
body = request.form.get("body") + f"\n![]({url})"
body = request.form.get("body") + f"\n![]({url})" body = body.replace("\n", "\n\n")
body = body.replace("\n", "\n\n") with CustomRenderer(post_id=parent_id) as renderer:
with CustomRenderer(post_id=parent_id) as renderer: body_md = renderer.render(mistletoe.Document(body))
body_md = renderer.render(mistletoe.Document(body)) body_html = sanitize(body_md, linkgen=True)
body_html = sanitize(body_md, linkgen=True)
c_aux = CommentAux( c_aux = CommentAux(
id=c.id, id=c.id,
@ -738,35 +737,34 @@ def edit_comment(cid, v):
g.db.commit() g.db.commit()
return jsonify({"error": "Too much spam!"}), 403 return jsonify({"error": "Too much spam!"}), 403
if v.dramacoins >= 0: if request.files.get("file"):
if request.files.get("file"): file=request.files["file"]
file=request.files["file"] if not file.content_type.startswith('image/'):
if not file.content_type.startswith('image/'): return jsonify({"error": "That wasn't an image!"}), 400
return jsonify({"error": "That wasn't an image!"}), 400
name = f'comment/{c.base36id}/{secrets.token_urlsafe(8)}'
name = f'comment/{c.base36id}/{secrets.token_urlsafe(8)}' url = upload_file(name, file)
url = upload_file(name, file)
body += f"\n![]({url})" body += f"\n![]({url})"
body = body.replace("\n", "\n\n") body = body.replace("\n", "\n\n")
with CustomRenderer(post_id=c.parent_submission) as renderer: with CustomRenderer(post_id=c.parent_submission) as renderer:
body_md = renderer.render(mistletoe.Document(body)) body_md = renderer.render(mistletoe.Document(body))
body_html = sanitize(body_md, linkgen=True) body_html = sanitize(body_md, linkgen=True)
# #csam detection
# def del_function():
# delete_file(name)
# c.is_banned=True
# g.db.add(c)
# g.db.commit()
# #csam detection # csam_thread=threading.Thread(target=check_csam_url,
# def del_function(): # args=(f"https://s3.eu-central-1.amazonaws.com/i.ruqqus.ga/{name}",
# delete_file(name) # v,
# c.is_banned=True # del_function
# g.db.add(c) # )
# g.db.commit() # )
# csam_thread.start()
# csam_thread=threading.Thread(target=check_csam_url,
# args=(f"https://s3.eu-central-1.amazonaws.com/i.ruqqus.ga/{name}",
# v,
# del_function
# )
# )
# csam_thread.start()
c.body = body c.body = body
c.body_html = body_html c.body_html = body_html

View File

@ -867,10 +867,6 @@ def submit_post(v):
# check for embeddable video # check for embeddable video
domain = parsed_url.netloc domain = parsed_url.netloc
if request.files.get('file') and not v.dramacoins >= 0:
abort(403)
new_post = Submission( new_post = Submission(
private=bool(request.form.get("private","")), private=bool(request.form.get("private","")),
author_id=v.id, author_id=v.id,

View File

@ -324,45 +324,37 @@ def settings_log_out_others(v):
@auth_required @auth_required
@validate_formkey @validate_formkey
def settings_images_profile(v): def settings_images_profile(v):
if v.dramacoins >= 0:
if request.content_length > 16 * 1024 * 1024: if request.content_length > 16 * 1024 * 1024:
g.db.rollback() g.db.rollback()
abort(413) abort(413)
v.profileurl = None v.profileurl = None
imageurl = upload_file(name=f"profile.gif", file=request.files["profile"], resize=(100, 100)) imageurl = upload_file(name=f"profile.gif", file=request.files["profile"], resize=(100, 100))
if imageurl: if imageurl:
v.profileurl = imageurl v.profileurl = imageurl
g.db.add(v) g.db.add(v)
return render_template("settings_profile.html", return render_template("settings_profile.html",
v=v, msg="Profile picture successfully updated.") v=v, msg="Profile picture successfully updated.")
return render_template("settings_profile.html", v=v,
msg="Avatars require +0 dramacoins.")
@app.route("/settings/images/banner", methods=["POST"]) @app.route("/settings/images/banner", methods=["POST"])
@auth_required @auth_required
@validate_formkey @validate_formkey
def settings_images_banner(v): def settings_images_banner(v):
if v.dramacoins >= 0: if request.content_length > 16 * 1024 * 1024:
if request.content_length > 16 * 1024 * 1024: g.db.rollback()
g.db.rollback() abort(413)
abort(413)
v.bannerurl = None v.bannerurl = None
imageurl = upload_file(name=f"banner.gif", file=request.files["banner"]) imageurl = upload_file(name=f"banner.gif", file=request.files["banner"])
if imageurl: if imageurl:
v.bannerurl = imageurl v.bannerurl = imageurl
g.db.add(v) g.db.add(v)
return render_template("settings_profile.html", return render_template("settings_profile.html",
v=v, msg="Banner successfully updated.") v=v, msg="Banner successfully updated.")
return render_template("settings_profile.html", v=v,
msg="Banners require +0 dramacoins.")
@app.route("/settings/delete/profile", methods=["POST"]) @app.route("/settings/delete/profile", methods=["POST"])

View File

@ -192,7 +192,7 @@
<strong style="color: #999b2e;"><i class="far fa-fw fa-flag"></i> Reported by:</strong> <strong style="color: #999b2e;"><i class="far fa-fw fa-flag"></i> Reported by:</strong>
<ul style="margin-bottom: 0;"> <ul style="margin-bottom: 0;">
{% for f in c.flags %} {% for f in c.flags %}
<li><a href="{{ f.user.url }}">@{{ f.user.username }}</a>: "{{f.reason}}"</li> <li><a href="{{ f.user.url }}">@{{ f.user.username }}</a>: {{f.reason}}</li>
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>

View File

@ -14,8 +14,6 @@
<h1 class="h5">401 Not Authorized</h1> <h1 class="h5">401 Not Authorized</h1>
<p class="text-muted">You have 0 ban awards (they're a patron perk):</p> <p class="text-muted">You have 0 ban awards (they're a patron perk):</p>
<a href="https://rdrama.gumroad.com/l/tfcvri">https://rdrama.gumroad.com/l/tfcvri</a> <a href="https://rdrama.gumroad.com/l/tfcvri">https://rdrama.gumroad.com/l/tfcvri</a>
<br>
<a href="https://patreon.com/Aevann">https://patreon.com/Aevann</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -14,8 +14,6 @@
<h1 class="h5">401 Not Authorized</h1> <h1 class="h5">401 Not Authorized</h1>
<p class="text-muted">This page is only available to patrons:</p> <p class="text-muted">This page is only available to patrons:</p>
<a href="https://rdrama.gumroad.com/l/tfcvri">https://rdrama.gumroad.com/l/tfcvri</a> <a href="https://rdrama.gumroad.com/l/tfcvri">https://rdrama.gumroad.com/l/tfcvri</a>
<br>
<a href="https://patreon.com/Aevann">https://patreon.com/Aevann</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -107,7 +107,6 @@
<a class="dropdown-item" href="/changelog"><i class="fas fa-clipboard fa-fw text-left mr-3"></i>Changelog</a> <a class="dropdown-item" href="/changelog"><i class="fas fa-clipboard fa-fw text-left mr-3"></i>Changelog</a>
<a class="dropdown-item" href="https://github.com/Aevann1/Drama"><i class="fab fa-github fa-fw text-left mr-3"></i>Source code</a> <a class="dropdown-item" href="https://github.com/Aevann1/Drama"><i class="fab fa-github fa-fw text-left mr-3"></i>Source code</a>
<a class="dropdown-item" href="/discord"><i class="fab fa-discord fa-fw text-left mr-3"></i>Discord</a> <a class="dropdown-item" href="/discord"><i class="fab fa-discord fa-fw text-left mr-3"></i>Discord</a>
<a class="dropdown-item" href="https://patreon.com/Aevann"><i class="fab fa-patreon fa-fw text-left mr-3"></i>Patreon</a>
<a class="dropdown-item" href="https://rdrama.gumroad.com/l/tfcvri"><i class="fas fa-dollar-sign fa-fw text-left mr-3"></i>Gumroad</a> <a class="dropdown-item" href="https://rdrama.gumroad.com/l/tfcvri"><i class="fas fa-dollar-sign fa-fw text-left mr-3"></i>Gumroad</a>
<a class="dropdown-item" href="/archives"><i class="fas fa-book fa-fw text-left mr-3"></i>Subreddit Archives</a> <a class="dropdown-item" href="/archives"><i class="fas fa-book fa-fw text-left mr-3"></i>Subreddit Archives</a>
<a class="dropdown-item" href="/contact"><i class="fas fa-file-signature fa-fw text-left mr-3"></i>Contact us</a> <a class="dropdown-item" href="/contact"><i class="fas fa-file-signature fa-fw text-left mr-3"></i>Contact us</a>
@ -163,7 +162,6 @@
<li class="nav-item"><a class="nav-link" href="/post/1xq/posting-guidelines-policies-legal-shit"><i class="fas fa-balance-scale fa-fw mr-3"></i>Rules</a></li> <li class="nav-item"><a class="nav-link" href="/post/1xq/posting-guidelines-policies-legal-shit"><i class="fas fa-balance-scale fa-fw mr-3"></i>Rules</a></li>
<li class="nav-item"><a class="nav-link" href="https://github.com/Aevann1/Drama"><i class="fab fa-github fa-fw mr-3"></i>Source code</a></li> <li class="nav-item"><a class="nav-link" href="https://github.com/Aevann1/Drama"><i class="fab fa-github fa-fw mr-3"></i>Source code</a></li>
<li class="nav-item"><a class="nav-link" href="/discord"><i class="fab fa-discord fa-fw mr-3"></i>Discord</a></li> <li class="nav-item"><a class="nav-link" href="/discord"><i class="fab fa-discord fa-fw mr-3"></i>Discord</a></li>
<li class="nav-item"><a class="nav-link" href="https://patreon.com/Aevann"><i class="fab fa-patreon fa-fw mr-3"></i>Patreon</a></li>
<li class="nav-item"><a class="nav-link" href="https://rdrama.gumroad.com/l/tfcvri"><i class="fas fa-dollar-sign fa-fw mr-3"></i>Gumroad</a></li> <li class="nav-item"><a class="nav-link" href="https://rdrama.gumroad.com/l/tfcvri"><i class="fas fa-dollar-sign fa-fw mr-3"></i>Gumroad</a></li>
<li class="nav-item"><a class="nav-link" href="/archives"><i class="fas fa-book fa-fw mr-3"></i>Subreddit Archives</a></li> <li class="nav-item"><a class="nav-link" href="/archives"><i class="fas fa-book fa-fw mr-3"></i>Subreddit Archives</a></li>
<li class="nav-item"><a class="nav-link" href="/contact"><i class="fas fa-file-signature fa-fw mr-3"></i>Contact us</a></li> <li class="nav-item"><a class="nav-link" href="/contact"><i class="fas fa-file-signature fa-fw mr-3"></i>Contact us</a></li>

View File

@ -84,8 +84,6 @@
<div> <div>
{% if v.dramacoins >= 0 %}
<form action="/settings/images/profile" method="post" enctype="multipart/form-data"> <form action="/settings/images/profile" method="post" enctype="multipart/form-data">
<input type="hidden" name="formkey" value="{{v.formkey}}"> <input type="hidden" name="formkey" value="{{v.formkey}}">
<label class="btn btn-secondary text-capitalize mr-2 mb-0"> <label class="btn btn-secondary text-capitalize mr-2 mb-0">
@ -93,12 +91,6 @@
</label> </label>
</form> </form>
{% else %}
<div class="text-muted">You can add a custom avatar after earning 30 Dramacoins.{% if request.headers.get("cf-ipcountry")=="T1" and not v.is_activated %} Additionally, you must have a verified email address to upload images via Tor.{% endif %}</div>
{% endif %}
</div> </div>
{% if v.profileurl %} {% if v.profileurl %}
@ -112,12 +104,8 @@
</div> </div>
{% if v.dramacoins >= 0 %}
<div class="text-small-extra text-muted mt-3">JPG, PNG, GIF files are supported. Max file size is 16 MB.</div> <div class="text-small-extra text-muted mt-3">JPG, PNG, GIF files are supported. Max file size is 16 MB.</div>
{% endif %}
</div> </div>
</div> </div>
@ -139,8 +127,6 @@
<div> <div>
{% if v.dramacoins >= 0 %}
<form action="/settings/images/banner" method="post" enctype="multipart/form-data"> <form action="/settings/images/banner" method="post" enctype="multipart/form-data">
<input type="hidden" name="formkey" value="{{v.formkey}}"> <input type="hidden" name="formkey" value="{{v.formkey}}">
<label class="btn btn-secondary text-capitalize mr-2 mb-0"> <label class="btn btn-secondary text-capitalize mr-2 mb-0">
@ -148,12 +134,6 @@
</label> </label>
</form> </form>
{% else %}
<div class="text-muted">You can add a custom banner after earning 30 Dramacoins.{% if request.headers.get("cf-ipcountry")=="T1" and not v.is_activated %} Additionally, you must have a verified email address to upload images via Tor.{% endif %}</div>
{% endif %}
</div> </div>
<div> <div>
@ -168,12 +148,8 @@
</div> </div>
{% if v.dramacoins >= 0 %}
<div class="text-small-extra text-muted mt-3">JPG, PNG, GIF files are supported. Max file size is 16 MB.</div> <div class="text-small-extra text-muted mt-3">JPG, PNG, GIF files are supported. Max file size is 16 MB.</div>
{% endif %}
</div> </div>
</div> </div>

View File

@ -494,7 +494,7 @@
<strong style="color: #999b2e;"><i class="far fa-fw fa-flag"></i> Reported by:</strong> <strong style="color: #999b2e;"><i class="far fa-fw fa-flag"></i> Reported by:</strong>
<ul style="margin-bottom: 0;"> <ul style="margin-bottom: 0;">
{% for f in p.flags %} {% for f in p.flags %}
<li><a href="{{ f.user.url }}">@{{ f.user.username }}</a>: "{{f.reason}}"</li> <li><a href="{{ f.user.url }}">@{{ f.user.username }}</a>: {{f.reason}}</li>
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>
@ -549,7 +549,7 @@
<label class="btn btn-secondary format d-inline-block m-0" for="emoji-reply-btn-{{p.fullname}}"> <label class="btn btn-secondary format d-inline-block m-0" for="emoji-reply-btn-{{p.fullname}}">
<div id="emoji-reply-btn-{{p.fullname}}" onclick="loadEmojis('reply-form-body-{{p.fullname}}')" aria-hidden="true" data-toggle="modal" data-target="#emojiModal" data-toggle="tooltip" data-placement="bottom" title="Add Emoji"><i class="fas fa-smile-beam"></i></div> <div id="emoji-reply-btn-{{p.fullname}}" onclick="loadEmojis('reply-form-body-{{p.fullname}}')" aria-hidden="true" data-toggle="modal" data-target="#emojiModal" data-toggle="tooltip" data-placement="bottom" title="Add Emoji"><i class="fas fa-smile-beam"></i></div>
</label> </label>
<label class="format btn btn-secondary m-0 ml-1 {% if v and v.dramacoins >= 0 %}d-inline-block{% else %}d-none{% endif %}" for="file-upload-reply-{{p.fullname}}"> <label class="format btn btn-secondary m-0 ml-1 {% if v %}d-inline-block{% else %}d-none{% endif %}" for="file-upload-reply-{{p.fullname}}">
<div id="filename-show-reply-{{p.base36id}}"><i class="far fa-image"></i></div> <div id="filename-show-reply-{{p.base36id}}"><i class="far fa-image"></i></div>
<input id="file-upload-reply-{{p.fullname}}" type="file" name="file" accept="image/*" onchange="document.getElementById('filename-show-reply-{{p.base36id}}').innerHTML='image';" hidden> <input id="file-upload-reply-{{p.fullname}}" type="file" name="file" accept="image/*" onchange="document.getElementById('filename-show-reply-{{p.base36id}}').innerHTML='image';" hidden>
</label> </label>

View File

@ -333,7 +333,7 @@
<strong style="color: #999b2e;"><i class="far fa-fw fa-flag"></i> Reported by:</strong> <strong style="color: #999b2e;"><i class="far fa-fw fa-flag"></i> Reported by:</strong>
<ul style="margin-bottom: 0;"> <ul style="margin-bottom: 0;">
{% for f in p.flags %} {% for f in p.flags %}
<li><a href="{{ f.user.url }}">@{{ f.user.username }}</a>: "{{f.reason}}"</li> <li><a href="{{ f.user.url }}">@{{ f.user.username }}</a>: {{f.reason}}</li>
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>

View File

@ -322,9 +322,6 @@
<small class="form-text text-muted">To post an image, use a direct image link such as i.imgur.com</small> <small class="form-text text-muted">To post an image, use a direct image link such as i.imgur.com</small>
</div> </div>
<div {% if not v.dramacoins >= 0 %} class="d-none"{% else %} ondrop="event.preventDefault();let input=document.getElementById('file-upload');input.files=event.dataTransfer.files;input.onchange();" ondragover="event.preventDefault();"{% endif %}>
{% if v.dramacoins >= 0 %}
<div id="image-upload-block"> <div id="image-upload-block">
<div><label class="mt-3">Image Upload</label></div> <div><label class="mt-3">Image Upload</label></div>
@ -335,18 +332,6 @@
<small class="form-text text-muted">Images uploaded will be public. Optional if you have text.</small> <small class="form-text text-muted">Images uploaded will be public. Optional if you have text.</small>
</div> </div>
{% else %}
<div id="image-upload-block">
<div><label class="mt-3">Image Upload</label></div>
<label class="btn btn-secondary m-0" for="file-upload">
<div id="filename-show">Select Image</div>
<input id="file-upload" type="file" accept="image/*" hidden disabled>
</label>
<small class="form-text text-muted">You can upload images directly at 1000 Dramacoins.{% if request.headers.get("cf-ipcountry")=="T1" and not v.is_activated %} Additionally, you must have a verified email address to upload images via Tor.{% endif %}</small>
</div>
{% endif %}
</div> </div>
<label for="body" class="mt-3">Text<i class="fas fa-info-circle text-gray-400 ml-1" data-toggle="tooltip" data-placement="top" title="Uses markdown. Limited to 10000 characters."></i></label> <label for="body" class="mt-3">Text<i class="fas fa-info-circle text-gray-400 ml-1" data-toggle="tooltip" data-placement="top" title="Uses markdown. Limited to 10000 characters."></i></label>
@ -447,24 +432,30 @@
}); });
</script> </script>
{% if v.dramacoins >= 0 %}
<script> <script>
document.onpaste = function(event) { var items = (event.clipboardData || event.originalEvent.clipboardData).items;
f=document.getElementById('file-upload');
f.files = event.clipboardData.files;
$('#filename-show').text(f.files[0].name);
$('#urlblock').addClass('d-none');
var fileReader = new FileReader(); for (var item in items)
fileReader.readAsDataURL(f.files[0]); {
fileReader.addEventListener("load", function () { if (items[item].kind === "file")
$('#image-preview').attr('src', this.result); {
}); f=document.getElementById('file-upload');
f.files = event.clipboardData.files;
$('#file-upload').attr('required', false); $('#filename-show').text(f.files[0].name);
$('#urlblock').addClass('d-none');
checkForRequired();
var fileReader = new FileReader();
fileReader.readAsDataURL(f.files[0]);
fileReader.addEventListener("load", function () {
$('#image-preview').attr('src', this.result);
});
$('#file-upload').attr('required', false);
checkForRequired();
break;
}
} }
$('#file-upload').on('change', function(e){ $('#file-upload').on('change', function(e){
@ -481,7 +472,6 @@
checkForRequired(); checkForRequired();
}) })
</script> </script>
{% endif %}
</body> </body>

View File

@ -1,3 +1,6 @@
cd D:\1
git pull
sass ./drama/assets/style/dark.scss D:/#D/drama/assets/style/dark_ff66ac.css sass ./drama/assets/style/dark.scss D:/#D/drama/assets/style/dark_ff66ac.css
sass ./drama/assets/style/light.scss D:/#D/drama/assets/style/light_ff66ac.css sass ./drama/assets/style/light.scss D:/#D/drama/assets/style/light_ff66ac.css
sass ./drama/assets/style/coffee.scss D:/#D/drama/assets/style/coffee_ff66ac.css sass ./drama/assets/style/coffee.scss D:/#D/drama/assets/style/coffee_ff66ac.css
@ -6,7 +9,4 @@ sass ./drama/assets/style/4chan.scss D:/#D/drama/assets/style/4chan_ff66ac.css
python ./compilecss.py python ./compilecss.py
git add . git add .
git commit -m "css" git commit -m "css"
git push git push
cd D:\1
git pull