aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2022-02-13 19:19:03 -0500
committerB. Stack <bgstack15@gmail.com>2022-02-13 19:19:03 -0500
commit2e5ef31e697fbd01f7438c389edb40aac60839fc (patch)
tree5e6d478a5b4de6200fe201114a8593307852a4a8
parentadd admin page, delete function, and APPNAME var (diff)
downloadstackbin-2e5ef31e697fbd01f7438c389edb40aac60839fc.tar.gz
stackbin-2e5ef31e697fbd01f7438c389edb40aac60839fc.tar.bz2
stackbin-2e5ef31e697fbd01f7438c389edb40aac60839fc.zip
add redirects after delete, and simplify css calls
-rw-r--r--pastebin.py12
-rw-r--r--static/small.css6
-rw-r--r--static/style.css9
-rw-r--r--templates/layout.html2
4 files changed, 20 insertions, 9 deletions
diff --git a/pastebin.py b/pastebin.py
index 4c529f9..3851d01 100644
--- a/pastebin.py
+++ b/pastebin.py
@@ -48,6 +48,13 @@ def url_for_other_page(page):
app.jinja_env.globals['url_for_other_page'] = url_for_other_page
app.jinja_env.globals['appname'] = app.config['APPNAME']
+def refresh_string(delay,url):
+ """
+ Returns a string for html content for redirecting the user back after the
+ requested delay, to the requested url.
+ """
+ return f'<meta http-equiv="Refresh" content="{delay}; url={url}">'
+
@app.before_request
def check_user_status():
g.user = None
@@ -148,9 +155,10 @@ def delete_paste(paste_id):
try:
Paste.query.filter(Paste.id == paste.id).delete()
db.session.commit()
- return "OK",200 # WORKHERE: make this and the 500 redirect to admin/
+ message = refresh_string(1, url_for("admin")) + "OK"
+ return message,200
except:
- return "failure to delete object.",500
+ return f"failure to delete object. Select <a href='{url_for('admin')}'>here</a> to return to the admin panel.",500
def get_all_pastes():
"""
diff --git a/static/small.css b/static/small.css
deleted file mode 100644
index 7bba2a3..0000000
--- a/static/small.css
+++ /dev/null
@@ -1,6 +0,0 @@
-pre {
- font-size: 14px;
- line-height: 1.6em;
-}
-
-.page { margin: 20px auto; width: 100%; }
diff --git a/static/style.css b/static/style.css
index 1fc54ce..4507323 100644
--- a/static/style.css
+++ b/static/style.css
@@ -22,3 +22,12 @@ textarea { border: none; width: 780px; }
.pagination strong,
.pagination span.ellipsis,
.pagination a { border: 1px solid #d00; padding: 2px 6px; text-decoration: none; }
+
+/* trying to simplify the requests for style.css and small.css */
+@media only screen and (max-width: 800px) {
+ pre {
+ font-size: 14px;
+ line-height: 1.6em;
+ }
+ .page { margin: 20px auto; width: 100%; }
+}
diff --git a/templates/layout.html b/templates/layout.html
index fc2d8e5..3c6d8ab 100644
--- a/templates/layout.html
+++ b/templates/layout.html
@@ -5,7 +5,7 @@
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}">
-<link rel="stylesheet" media="screen and (max-width: 800px)" href="{{ url_for('static', filename='small.css') }}" />
+{#<link rel="stylesheet" media="screen and (max-width: 800px)" href="{{ url_for('static', filename='small.css') }}" />#}
<div class=page>
<ul class=nav>
<li><a href="{{ url_for('new_paste') }}">New Paste</a>
bgstack15