@ -15,7 +15,8 @@
#:utils
#:utils
#:validation
#:validation
#:user
#:user
#:nera-db )
#:nera-db
#:files )
( :export #:*web* ) )
( :export #:*web* ) )
( in-package #:ritherdon-archive.web )
( in-package #:ritherdon-archive.web )
@ -738,14 +739,22 @@
( progn ( utils:set-alert "You are not authorised to delete page." )
( progn ( utils:set-alert "You are not authorised to delete page." )
( redirect "/login" ) ) ) ) ) ) )
( redirect "/login" ) ) ) ) ) ) )
;; TODO: Add condition branches for file-type.
;; This is working but I could do with adding content-types for images
;; and text so the browser doesn't always down the asset/media/file.
( defroute ( "/storage/view/:slug" :method :GET ) ( &key slug )
( defroute ( "/storage/view/:slug" :method :GET ) ( &key slug )
( if ( storage:file-exists-p "" "media" slug )
( if ( storage:file-exists-p "" "media" slug )
` ( 200 ( :content-type "octet/stream" )
` ( 200 ( :content-type
, ( storage:open-binary-file "" "media" slug ) )
, ( files::file-type-of
( on-exception *web* 404 ) ) )
( nera:get-storage-file :slug slug ) ) )
, ( storage:open-binary-file "" "media" slug ) )
( on-exception *web* 404 ) ) )
( defroute ( "/storage/thumb/:slug" :method :GET ) ( &key slug )
( if ( storage:file-exists-p "" "media" slug )
` ( 200 ( :content-type
, ( files::file-type-of
( nera:get-storage-file :slug slug ) ) )
, ( storage:open-binary-file "" "media"
( format nil "thumbnail-~a" slug ) ) )
( on-exception *web* 404 ) ) )
( defroute ( "/storage/manage" :method :GET ) ( )
( defroute ( "/storage/manage" :method :GET ) ( )
( hermetic:auth ( :logged-in )
( hermetic:auth ( :logged-in )
@ -782,6 +791,12 @@
( nera:add-storage-file file-name
( nera:add-storage-file file-name
( utils:slugify file-name )
( utils:slugify file-name )
( caddr storage-file ) )
( caddr storage-file ) )
( utils:run-bash-command
( format nil "convert ~a -resize 512x512\\> ~a"
( storage:file-exists-p "" "media" ( utils:slugify file-name ) )
( storage:make-path "" "media"
( format nil "thumbnail-~a"
( utils:slugify file-name ) ) ) ) )
( utils:set-alert "File uploaded." )
( utils:set-alert "File uploaded." )
( redirect "/storage/manage" ) ) )
( redirect "/storage/manage" ) ) )
;; Not Authorised
;; Not Authorised