diff --git a/raincloud.py b/raincloud.py index 4be21c8..a01f616 100755 --- a/raincloud.py +++ b/raincloud.py @@ -67,20 +67,18 @@ app = Flask(__name__) @app.route("/", methods=["GET", "POST"]) @app.route("//", methods=["GET"]) -def files(directory, filename=None): +def directory(directory, filename=None): try: config = get_config(directory) if config["password"]: - authenticated = False - if directory in session and session[directory] == config["password"]: - authenticated = True + authenticated = True if directory in session and session[directory] == config["password"] else False if not authenticated: if request.method == "POST": if request.form["password"] == config["password"]: session[directory] = config["password"] - return redirect(url_for("files", directory=directory)) + return redirect(url_for("directory", directory=directory)) else: return render_template( "authenticate.html", cloud_name=cloud_name, config=config @@ -91,7 +89,7 @@ def files(directory, filename=None): if not filename: files = get_files(directory) return render_template( - "files.html", cloud_name=cloud_name, config=config, files=files + "directory.html", cloud_name=cloud_name, config=config, files=files ) # Download @@ -109,11 +107,8 @@ def files(directory, filename=None): if filename != "rc.toml": f.save(base_path / directory / filename) - # Return new file list - files = get_files(directory) - return render_template( - "files.html", cloud_name=cloud_name, config=config, files=files - ) + # Reload + return redirect(url_for("directory", directory=directory)) else: return "No upload allowed" diff --git a/static/style.css b/static/style.css index a9e96c4..cd962d0 100644 --- a/static/style.css +++ b/static/style.css @@ -9,13 +9,60 @@ body { } #header { - border: 1px solid green; + padding: 15px 30px; + border-bottom: 1px solid lightgray; + font-size: 20px; + display: flex; + justify-content: space-between; + align-items: center; } -#title { - font-size: 14pt; +#cloud-name { + +} + +#directory-name { + font-weight: bold; } #content { - border: 1px solid red; + margin: 50px 150px; +} + +.file { + border-bottom: 1px solid lightgrey; + padding: 5px 15px; + display: flex; + justify-content: space-between; + align-items: center; +} + +.button { + background-color: #28bcff; + border: none; + border-radius: 5px; + color: white; + padding: 12px 28px; + text-align: center; + text-decoration: none; + display: inline-block; + margin: 4px 2px; + font-size: 16px; + cursor: pointer; +} + +.button:hover { + background-color: #0cb3ff; +} + +input[type="file"] { + display: none; +} + +.upload { + background-color: #4bcd8f; +} + +.upload:hover { + background-color: #3bc885; } diff --git a/templates/base.html b/templates/base.html index 848ebaf..e55b4de 100644 --- a/templates/base.html +++ b/templates/base.html @@ -2,10 +2,13 @@ -{{ config["directory"] }} - {{ cloud_name }} +{{ cloud_name }} :: {{ config["directory"] }}
{% block content %}{% endblock %} diff --git a/templates/directory.html b/templates/directory.html new file mode 100644 index 0000000..4490bda --- /dev/null +++ b/templates/directory.html @@ -0,0 +1,23 @@ +{% extends "base.html" %} +{% block nav_content %} + {% if config["upload"] %} +
+
+ +
+
+ {% endif %} +{% endblock %} +{% block content %} + {% for f in files %} +
+

{{ f["name"] }}

+ {% if config["download"] %} + Download + {% endif %} +
+ {% endfor %} +{% endblock %} diff --git a/templates/files.html b/templates/files.html deleted file mode 100644 index 1a423f1..0000000 --- a/templates/files.html +++ /dev/null @@ -1,19 +0,0 @@ -{% extends "base.html" %} -{% block content %} - {% if config["upload"] %} -
- - -
- {% endif %} -
    - {% for f in files %} -
  • - {{ f["name"] }} - {% if config["download"] %} - Download - {% endif %} -
  • - {% endfor %} -
-{% endblock %}