Browse Source

initial steps for /storage/management defroute.

This is an end-of-session commit. I've got the route up and running
with the /user/storage HTML template rendering in the browser and
listing out the files in storage. I could do with adding a model and
storing the files meta-data in the database. This page could do with
rendering the images and placeholders (E.G.generic text file icon) for
non-image files.
stable
Craig Oates 2 years ago
parent
commit
015eda2b0a
  1. 17
      src/web.lisp
  2. 2
      templates/user/dashboard.html
  3. 27
      templates/user/storage.html

17
src/web.lisp

@ -780,6 +780,7 @@
(utils:set-alert "No files provided.")
(redirect "/dashboard"))
(t (loop :for item :in files :do
;; TODO: ADD FILES TO DATABASE (IMAGE-TYPE FILE NAME ETC.)
(storage:store-file
"" "media"
(utils:slugify (caddr item)) (cdr item)))
@ -790,6 +791,22 @@
(utils:set-alert "You are not authorised to view this page.")
(redirect "/login")))))))
(defroute ("/storage/manage" :method :GET) ()
(hermetic:auth (:logged-in)
;; Authorised
(let ((alert (utils:get-and-reset-alert)))
(render #P"/user/storage.html"
(append (auth:auth-user-data)
`(:alert ,alert
:files ,(storage:get-file-names
(storage:get-files-in-directory
"" "media"))
:system-data ,(nera:system-data)))))
;; Not Authorised
(progn (utils:set-alert "You are not logged in.")
(redirect "/login"))))
;;
;; Error pages

2
templates/user/dashboard.html

@ -5,7 +5,7 @@
<div>
<a href="/create/page">Create Page</a>
<a href="/user/pages">Manage Pages</a>
<a href="/storage/files">Manage Files</a>
<a href="/storage/manage">Manage Files</a>
{% if roles.administrator %}
<a href="/users">Manage Users</a>
{% endif %}

27
templates/user/storage.html

@ -0,0 +1,27 @@
{% extends "layouts/default.html" %}
{% block title %}Manage you archive.{% endblock %}
{% block content %}
<h1>Storage</h1>
{% for item in files %}
{{item}}
{% endfor %}
<div>
<h2>File Upload</h2>
<form action="/storage/upload" method="POST" enctype="multipart/form-data">
<input required type="hidden" name="AUTHENTICITY-TOKEN" value="{{token}}">
<label>Single File Upload</label>
<input required type="file" name="STORAGE-FILE">
<input type="submit" value="Upload File"/>
</form>
<form action="/storage/multi-upload" method="POST" enctype="multipart/form-data">
<input required type="hidden" name="AUTHENTICITY-TOKEN" value="{{token}}">
<label>Multi-File Upload</label>
<input required type="file" name="STORAGE-FILES" multiple>
<input type="submit" value="Upload Files"/>
</form>
</div>
{% endblock %}
Loading…
Cancel
Save