1
0
mirror of https://github.com/Tygs/0bin.git synced 2023-08-10 21:13:00 +03:00

Delete paste in admin

This commit is contained in:
ksamuel 2020-08-12 15:39:07 +02:00
parent b6732d7348
commit e5faaac077
3 changed files with 26 additions and 19 deletions

View File

@ -75,15 +75,19 @@ def admin():
if paste_id: if paste_id:
try: try:
if "/paste/" in paste_id: if "/paste/" in paste_id:
paste_id = urlparse(paste_id).path.split("/path/")[-1] paste_id = urlparse(paste_id).path.split("/paste/")[-1]
paste = Paste.load(paste_id) paste = Paste.load(paste_id)
paste.delete() paste.delete()
except (TypeError, ValueError, FileNotFoundError): except (TypeError, ValueError, FileNotFoundError):
return {"status": "error", "message": f"Cannot find paste '{paste_id}'"} return {
"status": "error",
"message": f"Cannot find paste '{paste_id}'",
**GLOBAL_CONTEXT,
}
return {"status": "ok", "message": "Paste deleted"} return {"status": "ok", "message": "Paste deleted", **GLOBAL_CONTEXT}
return {"status": "ok", **GLOBAL_CONTEXT} return {"status": "ok", "message": "" ** GLOBAL_CONTEXT}
@app.get(ADMIN_LOGIN_URL) @app.get(ADMIN_LOGIN_URL)

View File

@ -1,9 +1,14 @@
<form action="./delete/" method="post"> <form action="." method="post">
%if status == "error": %if status == "error":
<div class="alert alert-danger" role="alert alert-danger"> <div class="alert alert-danger" role="alert alert-danger">
{{message}} {{message}}
</div> </div>
%end %end
%if status == "ok" and message:
<div class="alert alert-success" role="alert">
{{message}}
</div>
%end
<div> <div>
<div class="form-group"> <div class="form-group">
<label>Paste to delete</label> <label>Paste to delete</label>

View File

@ -26,7 +26,7 @@
<div id="app"> <div id="app">
<div class="topnav"> <div class="topnav" @mouseleave="openPreviousPastesMenu =false">
<a class="brand" href="/"><span>ø</span>bin<em>.net</em></a> <a class="brand" href="/"><span>ø</span>bin<em>.net</em></a>
<span class="tagline">"A client side encrypted PasteBin"<br><span>All pastes are AES256 encrypted, we cannot know <span class="tagline">"A client side encrypted PasteBin"<br><span>All pastes are AES256 encrypted, we cannot know
what you paste...</span> what you paste...</span>
@ -36,8 +36,7 @@
<ul> <ul>
<li class="submenu"><a href="#" @click.prevent="openPreviousPastesMenu = !openPreviousPastesMenu">Previous <li class="submenu"><a href="#" @click.prevent="openPreviousPastesMenu = !openPreviousPastesMenu">Previous
pastes v</a> pastes v</a>
<ul class="previous-pastes" id="topmenu" v-if="openPreviousPastesMenu" <ul class="previous-pastes" id="topmenu" v-if="openPreviousPastesMenu">
@mouseleave="openPreviousPastesMenu =false">
<li class="item active" v-if="previousPastes.length === 0"> <li class="item active" v-if="previousPastes.length === 0">
<a href="#">No paste yet</a> <a href="#">No paste yet</a>
</li> </li>
@ -64,19 +63,18 @@
<footer class="footer"> <footer class="footer">
<ul> <ul>
%for i, entry in enumerate(settings.MENU): %for i, entry in enumerate(settings.MENU):
<li> <li>
%if "mailto:" in entry[1]: %if "mailto:" in entry[1]:
<span :title='formatEmail(`{{ entry[1].replace("mailto:", "").replace("@", "__AT__") }}`)' <span :title='formatEmail(`{{ entry[1].replace("mailto:", "").replace("@", "__AT__") }}`)' class="email-link">
class="email-link" > {{ entry[0] }}
{{ entry[0] }} </span>
</span> %else:
%else: <a href="{{ entry[1] }}">{{ entry[0] }}</a>
<a href="{{ entry[1] }}">{{ entry[0] }}</a> %end
%end </li>
</li>
%end %end
</ul> </ul>
%if settings.DISPLAY_COUNTER: %if settings.DISPLAY_COUNTER:
<strong>{{ pastes_count }}</strong> pastes øbinned <strong>{{ pastes_count }}</strong> pastes øbinned
%end %end