@ -3,7 +3,8 @@
( :use #:cl
#:caveman2
#:log4cl
#:app-constants )
#:app-constants
#:storage )
( :export #:i18n-load
#:_
#:parse-iso-date
@ -19,7 +20,9 @@
#:get-image-dimensions
#:run-bash-command
#:create-thumbnail
#:create-timestamp-id )
#:create-timestamp-id
#:format-filename
#:format-keywords )
( :documentation "Utilities that do not depend on models." ) )
( in-package #:utils )
@ -31,6 +34,19 @@
"Turns a string of text into a slug."
( str:downcase ( slug:slugify string ) ) )
( defun format-filename ( string )
" Changes the filename into the system 's standard.
Replaces whitespace with '- ' and changes everything to lowecase. "
( str:replace-all " " "-" ( asciify string ) ) )
( defun format-keywords ( string )
" Formats the keywords used in the ` ARCHIVE-ENTRY ' class.
This is mostly just over-prep 'ing the keywords assuming the user
enters them in the incorrect format. Meilisearch exects something like
'art,welding,green paint,ritherdon '. The comma is the seperator which
allows each 'keyword ' to have ( white- ) spaces. "
( str:replace-all ", " "," ( asciify string ) ) )
( defun request-params ( request )
( loop :for ( key . value ) :in request
:collect ( let ( ( *package* ( find-package :keyword ) ) )
@ -103,17 +119,19 @@ The `FILEPATH' must be already merged with
:ignore-error-status t
:error-output :string ) )
( defun create-thumbnail ( storage-sub-directory file-name )
( defun create-thumbnail ( storage-sub-directory file-name &optional ( overwrite t ) )
" Runs a Bash command to convert a file to a thumbnail in /storage/media dir.
The file is reduced to 512x512 pixels if bigger than that. A new file
is then created with a 'thumbnail- ' pre-fix. This process relies on
Image Magick. So, it must be installed on the system for this function
to operate properly. "
( run-bash-command
( format nil "convert ~a -resize 512x512\\> ~a"
( storage:file-exists-p "" storage-sub-directory file-name )
( storage:make-path "" storage-sub-directory
( format nil "thumbnail-~a" file-name ) ) ) ) )
( format nil "convert ~a -resize 512x512\\> ~a"
( storage:file-exists-p "" storage-sub-directory file-name )
( if ( eq overwrite t )
( storage:file-exists-p "" storage-sub-directory file-name )
( storage:make-path "" storage-sub-directory
( format nil "thumbnail-~a" file-name ) ) ) ) ) )
( defun create-timestamp-id ( )
"Creates a integer based on time the function is called, in YYYYMMDD format."