From b36f9c05071ea549ed59e703270fcf223b60df03 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sun, 9 Apr 2017 09:02:09 +0200 Subject: Major rewrite to use jab/oauth. Highlights: - Uses the oauth branch of jab. - Changed design to use bootstrap. - Some minor changes to functionality in file uploading and listing. - API is currently disabled and incomplete. --- fbin/templates/base.html | 70 +++++++++++++++++++++++++++++++++++++++ fbin/templates/file-modals.html | 59 +++++++++++++++++++++++++++++++++ fbin/templates/files.html | 73 +++++++++++++++++++++++++++++++++++++++++ fbin/templates/help.html | 30 +++++++++++++++++ fbin/templates/images.html | 29 ++++++++++++++++ fbin/templates/modal.html | 17 ++++++++++ fbin/templates/upload.html | 25 ++++++++++++++ fbin/templates/uploaded.html | 14 ++++++++ 8 files changed, 317 insertions(+) create mode 100644 fbin/templates/base.html create mode 100644 fbin/templates/file-modals.html create mode 100644 fbin/templates/files.html create mode 100644 fbin/templates/help.html create mode 100644 fbin/templates/images.html create mode 100644 fbin/templates/modal.html create mode 100644 fbin/templates/upload.html create mode 100644 fbin/templates/uploaded.html (limited to 'fbin/templates') diff --git a/fbin/templates/base.html b/fbin/templates/base.html new file mode 100644 index 0000000..bab0f7b --- /dev/null +++ b/fbin/templates/base.html @@ -0,0 +1,70 @@ + + + + + + + {{ config.SITE_NAME }}{% if title %} — {{ title }}{% endif %} + + +{% block head %} +{% endblock %} + + + +
+{% if title %} + +{% endif %} +{% with messages = get_flashed_messages(with_categories = True) %} +{% for category, message in messages %} + +{% endfor %} +{% endwith %} +{% block content %} +{% endblock %} +
+ + + + +{% block scripts %} +{% endblock %} + + diff --git a/fbin/templates/file-modals.html b/fbin/templates/file-modals.html new file mode 100644 index 0000000..9e4d422 --- /dev/null +++ b/fbin/templates/file-modals.html @@ -0,0 +1,59 @@ + + diff --git a/fbin/templates/files.html b/fbin/templates/files.html new file mode 100644 index 0000000..cae04fa --- /dev/null +++ b/fbin/templates/files.html @@ -0,0 +1,73 @@ +{% extends "base.html" %} +{% block content %} +

You have {{ files|length() }} uploaded files totaling {{ total_size }}.

+ + + + + + + + + + + + {% for file in files %} + + + + + + + + {% else %} + + {% endfor %} + +
FileSizeDate
+ {{ file.filename }} + + + hash + {% if file.ext %} + – ext. + {% endif %} + + {{ file.formatted_size }}{{ file.formatted_date }} + + +
(No file uploads yet.)
+{% include "file-modals.html" %} +{% endblock %} +{% block scripts %} + +{% endblock %} diff --git a/fbin/templates/help.html b/fbin/templates/help.html new file mode 100644 index 0000000..899cd78 --- /dev/null +++ b/fbin/templates/help.html @@ -0,0 +1,30 @@ +{% extends "base.html" %} +{% block content %} +
+

+ + TODO: Update this page. +

+
+
+ + Everything below this point is outdated and should be disregarded until further notice. +
+ +

Usage: POST to $scheme://${host}${settings.virtual_root}u with filedata given to "file" and original filename to "filename". Login is done by generating a login token and sending it as the cookie "token".

+

cURL examples, get_token: +

$ curl $scheme://${host}${settings.virtual_root}a?method=get_token -F username=foo -F password=bar
+{"status": true, "message": null, "method": "get_token", "token": "cb42eb38eb516d9dfcaaa742d1da0b3ad454b2bd05a8b4daa6d01e9587d7c759"}
+Upload using the token: +
$ curl -b 'token=cb42eb38eb516d9dfcaaa742d1da0b3ad454b2bd05a8b4daa6d01e9587d7c759' -F 'file=@image.png' -F 'filename=image.png' -F 'api=1' $scheme://${host}${settings.virtual_root}u
+OK sjLUD
+To expire the current token: +
$ curl $scheme://${host}${settings.virtual_root}a?method=expire_token -F token=cb42eb38eb516d9dfcaaa742d1da0b3ad454b2bd05a8b4daa6d01e9587d7c759
+{"status": true, "message": null, "method": "expire_token"}
+If you get HTTP 417 responses, try adding:-H 'Expect:'.

+

By adding the key-value pair "api=1" you will get machine-readable responses in the form: response result where response is either ERROR or OK, +and result is the file hash in the case of OK, or an error message in the case of ERROR (see example above). +The hash can be used to construct URLs in which the paths begin with /f/hash where hash is the hash received.

+

Any file extension an be appended to the hash, and for convenience the original filename (or whatever filename you prefer) can be appended after an additional slash after the hash.

+
+{% endblock %} diff --git a/fbin/templates/images.html b/fbin/templates/images.html new file mode 100644 index 0000000..c4bfd8f --- /dev/null +++ b/fbin/templates/images.html @@ -0,0 +1,29 @@ +{% extends "base.html" %} +{% block content %} +

You have {{ files|length() }} uploaded images totaling {{ total_size }}.

+{% if files %} +
+ {% for file in files %} + + {% endfor %} +
+{% else %} +
(No image uploads yet.)
+{% endif %} +{% endblock %} +{% block scripts %} + +{% endblock %} diff --git a/fbin/templates/modal.html b/fbin/templates/modal.html new file mode 100644 index 0000000..ca9fb5a --- /dev/null +++ b/fbin/templates/modal.html @@ -0,0 +1,17 @@ + diff --git a/fbin/templates/upload.html b/fbin/templates/upload.html new file mode 100644 index 0000000..643e09d --- /dev/null +++ b/fbin/templates/upload.html @@ -0,0 +1,25 @@ +{% extends "base.html" %} +{% block content %} +{% if current_user.is_authenticated or config.ALLOW_ANONYMOUS_UPLOADS %} +
+
+ +
+
+ +
+
+{% else %} +
You must be logged in to upload files.
+{% endif %} +{% endblock %} +{% block scripts %} + +{% endblock %} diff --git a/fbin/templates/uploaded.html b/fbin/templates/uploaded.html new file mode 100644 index 0000000..84a541c --- /dev/null +++ b/fbin/templates/uploaded.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} +{% block content %} +

Your file has been uploaded:

+ +{% if current_user.is_authenticated %} +

Your file will also appear in your file list.

+{% else %} +

If you were logged in, your file would also appear in your file list.

+{% endif %} +{% endblock %} -- cgit v1.2.3