@ -1045,7 +1045,7 @@
( defroute ( "/create/archive-entry" :method :POST ) ( )
( defroute ( "/create/archive-entry" :method :POST ) ( )
( destructuring-bind
( destructuring-bind
( &key title keywords thumbnail-file page-content
( &key title month year keywords thumbnail-file page-content
authenticity-token &allow-other-keys )
authenticity-token &allow-other-keys )
( utils:request-params
( utils:request-params
( lack.request:request-body-parameters ningle:*request* ) )
( lack.request:request-body-parameters ningle:*request* ) )
@ -1054,7 +1054,7 @@
( t ( hermetic:auth
( t ( hermetic:auth
( :logged-in )
( :logged-in )
;; Authorised
;; Authorised
( cond ( ( find t ( mapcar #' utils:string-is-nil-or-empty? ` ( , title , keywords ) ) )
( cond ( ( find t ( mapcar #' utils:string-is-nil-or-empty? ` ( , title , month , year ) ) )
( render
( render
"/user/create-archive.html"
"/user/create-archive.html"
( append ( auth:auth-user-data )
( append ( auth:auth-user-data )
@ -1064,6 +1064,8 @@
"sherlock-cat.png"
"sherlock-cat.png"
"Data is missing. Unable to create entry." )
"Data is missing. Unable to create entry." )
:title , title
:title , title
:month , month
:year , year
:keywords , keywords
:keywords , keywords
:data , page-content ) ) ) )
:data , page-content ) ) ) )
@ -1077,6 +1079,8 @@
"confused-cat.png"
"confused-cat.png"
"Entry with that title already exists. Unable to create entry." )
"Entry with that title already exists. Unable to create entry." )
:title , title
:title , title
:month , month
:year , year
:keywords , keywords
:keywords , keywords
:data , page-content ) ) ) )
:data , page-content ) ) ) )
@ -1088,9 +1092,11 @@
` ( :alert
` ( :alert
, ( utils:build-alert-string
, ( utils:build-alert-string
"invalid-data"
"invalid-data"
"confused-cat- png"
"confused-cat. png"
"File uploaded is not an image. Entry not created." )
"File uploaded is not an image. Entry not created." )
:title , title
:title , title
:month , month
:year , year
:keywords , keywords
:keywords , keywords
:data , page-content ) ) ) )
:data , page-content ) ) ) )
@ -1100,6 +1106,8 @@
title
title
search-id
search-id
( format nil "~a.html" ( utils:slugify title ) )
( format nil "~a.html" ( utils:slugify title ) )
month
year
( utils:format-filename ( cadr thumbnail-file ) ) ; File Name
( utils:format-filename ( cadr thumbnail-file ) ) ; File Name
( caddr thumbnail-file ) ; File Type
( caddr thumbnail-file ) ; File Type
( utils:format-keywords keywords ) )
( utils:format-keywords keywords ) )
@ -1112,7 +1120,8 @@
( utils:slugify title ) )
( utils:slugify title ) )
( format nil "storage/thumb/archive/~a.html"
( format nil "storage/thumb/archive/~a.html"
( utils:slugify title ) )
( utils:slugify title ) )
( local-time:now )
month
year
( utils:format-keywords keywords ) ) )
( utils:format-keywords keywords ) ) )
;; Storage File Entry
;; Storage File Entry
( storage:store-text
( storage:store-text
@ -1242,7 +1251,8 @@
( format nil
( format nil
"storage/thumb/archive/~a.html"
"storage/thumb/archive/~a.html"
( utils:slugify new-title ) )
( utils:slugify new-title ) )
( mito.dao.mixin:object-created-at archive-entry )
( archive::month-of archive-entry )
( archive::year-of archive-entry )
( archive::keywords-of archive-entry ) ) )
( archive::keywords-of archive-entry ) ) )
( utils:set-alert "Archive entry updated." "success" )
( utils:set-alert "Archive entry updated." "success" )
( redirect
( redirect
@ -1256,6 +1266,54 @@
"error" )
"error" )
( redirect "/login" ) ) ) ) ) ) )
( redirect "/login" ) ) ) ) ) ) )
( defroute ( "/edit/archive-publish-date" :method :POST ) ( )
( destructuring-bind
( &key archive-slug authenticity-token month year &allow-other-keys )
( utils:request-params ( lack.request:request-body-parameters ningle:*request* ) )
( cond ( ( not ( string= authenticity-token ( auth:csrf-token ) ) )
` ( , +forbidden+ ( :content-type "text/plain" ) ( "Denied" ) ) )
( t ( hermetic:auth
( :administrator )
;; Authorised
( cond ( ( find t ( mapcar #' utils:string-is-nil-or-empty?
` ( , archive-slug , month , year ) ) )
( utils:set-alert "Full date not provided. Not updated."
"missing-data" )
( redirect "/user/archive" ) )
( ( null ( nera:get-archive-entry :slug archive-slug ) )
( utils:set-alert
"Cannot file archive entry. Keywords not updated."
"invalid-data" )
( redirect "/user/archive" ) )
( t ( let ( ( archive-entry
( nera:get-archive-entry :slug archive-slug ) ) )
( nera:update-archive-entry-property
:slug archive-slug
:property 'archive::month-of
:value month )
( nera:update-archive-entry-property
:slug archive-slug
:property 'archive::year-of
:value year )
( search:submit-entry
( search:build-payload
( archive::search-id-of archive-entry )
( archive::title-of archive-entry )
( format nil "view/archive/~a"
( archive::slug-of archive-entry ) )
( format nil "storage/thumb/archive/~a"
( archive::slug-of archive-entry ) )
month
year
( archive::keywords-of archive-entry ) ) )
( utils:set-alert "Archive entry updated." "success" )
( redirect ( format nil "/edit/archive/~a" archive-slug ) ) ) ) )
;; Not Authorised
( progn ( utils:set-alert
"You are not authorised to delete this archive entry."
"error" )
( redirect "/login" ) ) ) ) ) ) )
( defroute ( "/edit/archive-keywords" :method :POST ) ( )
( defroute ( "/edit/archive-keywords" :method :POST ) ( )
( destructuring-bind
( destructuring-bind
( &key archive-slug new-keywords authenticity-token &allow-other-keys )
( &key archive-slug new-keywords authenticity-token &allow-other-keys )
@ -1289,7 +1347,8 @@
( archive::slug-of archive-entry ) )
( archive::slug-of archive-entry ) )
( format nil "storage/thumb/archive/~a"
( format nil "storage/thumb/archive/~a"
( archive::slug-of archive-entry ) )
( archive::slug-of archive-entry ) )
( mito.dao.mixin:object-created-at archive-entry )
( archive::month-of archive-entry )
( archive::year-of archive-entry )
keywords ) )
keywords ) )
( utils:set-alert "Archive entry updated." "success" )
( utils:set-alert "Archive entry updated." "success" )
( redirect ( format nil "/edit/archive/~a" archive-slug ) ) ) ) )
( redirect ( format nil "/edit/archive/~a" archive-slug ) ) ) ) )