From 0b9abc2d4a8cec4dd8b7b5c05d9dd20081f981f3 Mon Sep 17 00:00:00 2001 From: Marcus Kammer Date: Thu, 23 Jan 2025 16:06:39 +0100 Subject: [PATCH] Re-structure code and update the use of widgets --- index.lisp | 98 +++++++++++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 45 deletions(-) diff --git a/index.lisp b/index.lisp index 3aaaf33..1b560ef 100644 --- a/index.lisp +++ b/index.lisp @@ -13,7 +13,9 @@ (:import-from #:ml-sbt/navbar #:with-navbar) (:import-from #:ml-sbt/list-group - #:with-list-group) + #:list-group + #:with-list-group + #:with-list-group*) (:import-from #:ml-sbt/card #:with-card*) (:import-from #:ml-sbt/btn @@ -24,21 +26,21 @@ (defvar *lang* "en") (defparameter *active-projects* - '((:header "metalisp.sbt" - :items ("Library of Common Lisp Macros to generate HTML for Bootstrap CSS." "In Active Development" "Common Lisp") - :url "https://code.metalisp.dev/marcuskammer/dev.metalisp.sbt") - (:header "metalisp.survey" - :items ("Create questionnaires and analyze the results." "In Active Development" "Common Lisp") - :url "https://code.metalisp.dev/marcuskammer/dev.metalisp.survey") - (:header "metalisp.qmetrics" - :items ("Calculation engine for questionnaires." "In Active Development" "Common Lisp") - :url "https://code.metalisp.dev/marcuskammer/dev.metalisp.qmetrics") - (:header "metalisp.activitystreams" - :items ("ActivityStreams 2 library" "In Active Development" "Common Lisp") - :url "https://code.metalisp.dev/marcuskammer/dev.metalisp.activitystreams") - (:header "emacs dot files" - :items ("Personal emacs dot files." "In Active Development" "Emacs Lisp") - :url "https://code.metalisp.dev/marcuskammer/emacs.d"))) + '(("metalisp.sbt" + ("Library of Common Lisp Macros to generate HTML." "In Active Development" "Common Lisp") + "https://code.metalisp.dev/marcuskammer/dev.metalisp.sbt") + ("metalisp.survey" + ("Create questionnaires and analyze the results." "In Active Development" "Common Lisp") + "https://code.metalisp.dev/marcuskammer/dev.metalisp.survey") + ("metalisp.qmetrics" + ("Calculation engine for questionnaires." "In Active Development" "Common Lisp") + "https://code.metalisp.dev/marcuskammer/dev.metalisp.qmetrics") + ("metalisp.activitystreams" + ("ActivityStreams 2 library" "In Active Development" "Common Lisp") + "https://code.metalisp.dev/marcuskammer/dev.metalisp.activitystreams") + ("emacs dot files" + ("Personal emacs dot files." "In Active Development" "Emacs Lisp") + "https://code.metalisp.dev/marcuskammer/emacs.d"))) (defun md-to-html-string (markdown-string) (with-output-to-string (s) @@ -48,33 +50,39 @@ (with-output-to-string (s) (3bmd:parse-and-print-to-stream input-file s))) +(unless (uiop:directory-exists-p #P"public/") + (uiop:ensure-all-directories-exist '(#P"public/"))) + +(defparameter *index-html* + (with-page (:title "metalisp.dev projects") + (with-body-header nil "Crafting Software with the Power of Lisp" *lang* + (with-navbar nil "metalisp" "/" nil nil)) + (with-body-main nil + ;; Introduction + (with-section + (with-title-bar "About metalisp") + (:raw (md-file-to-html-string "introduction.md"))) + ;; News + (with-section + (with-title-bar "News") + (:raw (md-file-to-html-string "news.md"))) + ;; Active Projects + (with-section + (with-title-bar "Active Projects") + (with-section-row + (dolist (project *active-projects*) + (destructuring-bind (cheader citems curl) project + (with-card* + :card-header cheader + :card-items citems + :card-body (btn (:url curl) (t9n "view-details" *lang*))))))) + ;; Contact + (with-section + (with-title-bar "Contact") + (with-list-group nil + "email: post at metalisp.dev" + "jabber chatgroup: metalisp@conference.mailbox.org" + (:a :rel "me" :href "https://fosstodon.org/@metalisp" "Mastodon")))))) + (with-open-file (ofile "public/index.html" :direction :output :if-exists :supersede) - (let ((html (with-page (:title "metalisp.dev projects") - (with-body-header nil "Crafting Software with the Power of Lisp" *lang* - (with-navbar nil "metalisp" "/" nil nil)) - (with-body-main nil - ;; Introduction - (with-section - (with-title-bar "About metalisp") - (:raw (md-file-to-html-string "introduction.md"))) - ;; News - (with-section - (with-title-bar "News") - (:raw (md-file-to-html-string "news.md"))) - ;; Active Projects - (with-section - (with-title-bar "Active Projects") - (with-section-row - (dolist (project *active-projects*) - (with-card* - :card-header (getf project :header) - :card-items (getf project :items) - :card-body (btn (:url (getf project :url)) - (t9n "view-details" *lang*)))))) - ;; Contact - (with-section - (with-title-bar "Contact") - (with-list-group '(("email: post at metalisp.dev") - ("jabber groupchat: metalisp@conference.mailbox.org") - (:a :rel "me" :href "https://fosstodon.org/@metalisp" "Mastodon")))))))) - (princ html ofile))) + (princ *index-html* ofile))