Browse Source

add create-time-stamp-id function in utils package.

The only intended use for this function is to generate an Id. number
which will be used in the Meilisearch database and linking it to
Nera's database (I.E. this site's main database).
stable
Craig Oates 2 years ago
parent
commit
58b03ae8f2
  1. 17
      src/utils.lisp

17
src/utils.lisp

@ -18,7 +18,8 @@
#:slugify
#:get-image-dimensions
#:run-bash-command
#:create-thumbnail)
#:create-thumbnail
#:create-timestamp-id)
(:documentation "Utilities that do not depend on models."))
(in-package #:utils)
@ -102,7 +103,7 @@ The `FILEPATH' must be already merged with
:ignore-error-status t
:error-output :string))
(defun create-thumbnail (file-name)
(defun create-thumbnail (storage-sub-directory file-name)
"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
@ -110,5 +111,13 @@ 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 "" "media" file-name)
(storage:make-path "" "media" (format nil "thumbnail-~a" file-name)))))
(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."
(multiple-value-bind
(second minute hour day month year)
(get-decoded-time)
(format nil "~d~2,'0d~d~2,'0d~2,'0d~2,'0d" year month day hour minute second)))

Loading…
Cancel
Save