Navigation
-
"))
(defun end-navigation (str)
(format str "
~{~A~}
" lines)) (defun section (id title &rest line) (format nil "~{~A~}" lines)) (defun group (&rest items) (format nil "~{~A~}" items)) (defun footer (&rest line) (format nil "~{~A~}" line)) (let ((jours '("Lundi" "Mardi" "Mercredi" "Jeudi" "Vendredi" "Samedi" "Dimanche")) (mois '("Janvier" "Fevrier" "Mars" "Avril" "Mai" "Juin" "Juillet" "Aout" "Septembre" "Octobre" "Novembre" "Decembre")) (days '("Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday")) (months '("January" "February" "March" "April" "May" "June" "July" "August" "September" "October" "November" "December"))) (defun update-date (&optional (lang :us)) (multiple-value-bind (second minute hour date month year day) (get-decoded-time) (declare (ignore second minute hour)) (if (equal lang :fr) (format nil "Derniere mise a jour : ~A ~2,'0D ~A ~A" (nth day jours) date (nth (1- month) mois) year) (format nil "Last update: ~A ~A ~2,'0D ~A" (nth day days) (nth (1- month) months) date year))))) (defmacro with-html (() &body body) `(with-output-to-string (str) (header str (second ',(assoc 'title body))) (format str "~A" ,(assoc 'title body)) (format str "~A" ,(assoc 'subtitle body)) (prepare-navigation str) ,@(loop for b in body when (equal (first b) 'section) collect `(format str "~A~%" (section-nav ,@(rest b)))) (end-navigation str) ,@(loop for b in (remove (assoc 'footer body) (remove (assoc 'subtitle body) (remove (assoc 'title body) body))) collect `(format str "~A~%" ,b)) (do-footer str ,(assoc 'footer body)))) (defmacro html->file ((file) &body body) `(with-open-file (stream ,file :direction :output :if-exists :supersede) (format stream "~A" (with-html () ,@body)))) ;;(with-open-file (stream "test.html" :direction :output ;; :if-exists :supersede) ;; (format stream "~A" ;; (with-html () ;; (title "My title" " foo bar") ;; (subtitle "My full description" (br) ;; "Pouf pouf pouf") ;; (section "S1" "Section 1") ;; (p "A first paragraph ;;under many lines" (br) ;;"Return to the line begining") ;; (p "Another paragraph" ;; (br) ;; (a "http://hocwp.free.fr" "hocwp.free")) ;; (itemize "toto" ;; (group (a "http://google.fr" "Google") " a test with" " many things") ;; "plop" ;; "kdfslm" ;; "poidsf") ;; (code "(defun lisp () ;; (print 'toto))") ;; (section "S2" "Section 2") ;; (p "plop") ;; (footer "Last update : sat 11 apr 2009" (br) ;; (a "http://validator.w3.org/check?uri=referer" ;; (img "http://www.w3.org/Icons/valid-xhtml10" ;; 88 31 "Valid XHTML 1.0 Strict")))))) ;; ;; ;;(html->file ("test.html") ;; (title "My title" " foo bar") ;; (subtitle "My full description" (br) ;; "Pouf pouf pouf") ;; (section "S1" "Section 1") ;; (p "A first paragraph ;;under many lines" (br) ;;"Return to the line begining") ;; (p "Another paragraph" ;; (br) ;; (a "http://hocwp.free.fr" "hocwp.free")) ;; (itemize "toto" ;; (group (a "http://google.fr" "Google") " a test with" " many things") ;; "plop" ;; "kdfslm" ;; "poidsf") ;; (code "(defun lisp () ;; (print 'toto))") ;; (section "S2" "Section 2") ;; (p "plop") ;; (footer "Last update : sat 11 apr 2009" (br) ;; (a "http://validator.w3.org/check?uri=referer" ;; (img "http://www.w3.org/Icons/valid-xhtml10" ;; 88 31 "Valid XHTML 1.0 Strict"))))))