- Date now computed from a format YYYYMMDD
- id attribute on <article>
This commit is contained in:
parent
52bd9a828b
commit
013ada82f3
|
@ -10,6 +10,7 @@
|
||||||
:description "Yet another website on the net"
|
:description "Yet another website on the net"
|
||||||
:url "https://my.website/~~user/" ;; the trailing slash is mandatory! RSS links will fail without it. Notice the '~~' to produce a literal '~'
|
:url "https://my.website/~~user/" ;; the trailing slash is mandatory! RSS links will fail without it. Notice the '~~' to produce a literal '~'
|
||||||
:rss-item-number 10 ;; limit total amount of items in RSS feed to 10
|
:rss-item-number 10 ;; limit total amount of items in RSS feed to 10
|
||||||
|
:date-format "%DayNumber %MonthName %Year" ;; format for date %DayNumber %DayName %MonthNumber %MonthName %Year
|
||||||
:html t ;; 't' to enable export to a html website / 'nil' to disable
|
:html t ;; 't' to enable export to a html website / 'nil' to disable
|
||||||
:gopher t ;; 't' to enable export to a gopher website / 'nil' to disable
|
:gopher t ;; 't' to enable export to a gopher website / 'nil' to disable
|
||||||
:gopher-path "/user" ;; absolute path of your gopher directory
|
:gopher-path "/user" ;; absolute path of your gopher directory
|
||||||
|
@ -41,15 +42,15 @@
|
||||||
|
|
||||||
;; CSS
|
;; CSS
|
||||||
(post :title "CSS For cl-yag"
|
(post :title "CSS For cl-yag"
|
||||||
:id "css" :date "02.12.2017" :tag "cl-yag"
|
:id "css" :date "20171202" :tag "cl-yag"
|
||||||
:author "lambda" :tiny "Read more")
|
:author "lambda" :tiny "Read more")
|
||||||
|
|
||||||
;; README
|
;; README
|
||||||
(post :title "README"
|
(post :title "README"
|
||||||
:id "README" :date "23.11.2017" :tag "cl-yag"
|
:id "README" :date "20171202" :tag "cl-yag"
|
||||||
:author "lambda" :tiny "Read cl-yag's README")
|
:author "lambda" :tiny "Read cl-yag's README")
|
||||||
|
|
||||||
;; 1
|
;; 1
|
||||||
(post :title "My first post"
|
(post :title "My first post"
|
||||||
:id "1" :date "29.04.2016" :tag "pony"
|
:id "1" :date "20160429" :tag "pony"
|
||||||
:tiny "This is the first message" :author "Solène")
|
:tiny "This is the first message" :author "Solène")
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
(defparameter *articles* '())
|
(defparameter *articles* '())
|
||||||
(defparameter *converters* '())
|
(defparameter *converters* '())
|
||||||
|
(defparameter *days* '("Monday" "Tuesday" "Wednesday" "Thursday"
|
||||||
|
"Friday" "Saturday" "Sunday"))
|
||||||
|
(defparameter *months* '("January" "February" "March" "April"
|
||||||
|
"May" "June" "July" "August" "September"
|
||||||
|
"October" "November" "December"))
|
||||||
|
|
||||||
;; structure to store links
|
;; structure to store links
|
||||||
(defstruct article title tag date id tiny author short)
|
(defstruct article title tag date id tiny author)
|
||||||
(defstruct converter name command extension)
|
(defstruct converter name command extension)
|
||||||
|
|
||||||
(defun post(&optional &key title tag date id (tiny nil) (author nil) (short nil))
|
(defun post(&optional &key title tag date id (tiny nil) (author nil))
|
||||||
(push (make-article :title title
|
(push (make-article :title title
|
||||||
:tag tag
|
:tag tag
|
||||||
:date date
|
:date date
|
||||||
:tiny tiny
|
:tiny tiny
|
||||||
:author author
|
:author author
|
||||||
:short short
|
|
||||||
:id id)
|
:id id)
|
||||||
*articles*))
|
*articles*))
|
||||||
|
|
||||||
|
@ -26,6 +30,31 @@
|
||||||
(setf *articles* (reverse *articles*))
|
(setf *articles* (reverse *articles*))
|
||||||
|
|
||||||
|
|
||||||
|
;; return the day of the week
|
||||||
|
(defun get-day-of-week(day month year)
|
||||||
|
(multiple-value-bind
|
||||||
|
(second minute hour date month year day-of-week dst-p tz)
|
||||||
|
(decode-universal-time (encode-universal-time 0 0 0 day month year))
|
||||||
|
(declare (ignore second minute hour date month year dst-p tz))
|
||||||
|
day-of-week))
|
||||||
|
|
||||||
|
;; parse the date to
|
||||||
|
(defun date-parse(date)
|
||||||
|
(if (= 8 (length date))
|
||||||
|
(let* ((year (parse-integer date :start 0 :end 4))
|
||||||
|
(monthnum (parse-integer date :start 4 :end 6))
|
||||||
|
(daynum (parse-integer date :start 6 :end 8))
|
||||||
|
(day (nth (get-day-of-week daynum monthnum year) *days*))
|
||||||
|
(month (nth (- monthnum 1) *months*)))
|
||||||
|
(list
|
||||||
|
:dayname day
|
||||||
|
:daynumber daynum
|
||||||
|
:monthname month
|
||||||
|
:monthnumber monthnum
|
||||||
|
:year year))
|
||||||
|
nil))
|
||||||
|
|
||||||
|
|
||||||
;; common-lisp don't have a replace string function natively
|
;; common-lisp don't have a replace string function natively
|
||||||
(defun replace-all (string part replacement &key (test #'char=))
|
(defun replace-all (string part replacement &key (test #'char=))
|
||||||
(with-output-to-string (out)
|
(with-output-to-string (out)
|
||||||
|
@ -82,6 +111,16 @@
|
||||||
`(progn
|
`(progn
|
||||||
(setf output (replace-all output ,before ,@after))))
|
(setf output (replace-all output ,before ,@after))))
|
||||||
|
|
||||||
|
;; format the date
|
||||||
|
(defun date-format(format date)
|
||||||
|
(let ((output format))
|
||||||
|
(template "%DayName" (getf date :dayname))
|
||||||
|
(template "%DayNumber" (write-to-string (getf date :daynumber)))
|
||||||
|
(template "%MonthName" (getf date :monthname))
|
||||||
|
(template "%MonthNumber" (write-to-string (getf date :monthnumber)))
|
||||||
|
(template "%Year" (write-to-string (getf date :year )))
|
||||||
|
output))
|
||||||
|
|
||||||
;; simplify the declaration of a new page type
|
;; simplify the declaration of a new page type
|
||||||
(defmacro prepare(template &body code)
|
(defmacro prepare(template &body code)
|
||||||
`(progn
|
`(progn
|
||||||
|
@ -129,9 +168,11 @@
|
||||||
(prepare "templates/article.tpl"
|
(prepare "templates/article.tpl"
|
||||||
(template "%%Author%%" (let ((author (article-author article)))
|
(template "%%Author%%" (let ((author (article-author article)))
|
||||||
(or author (getf *config* :webmaster))))
|
(or author (getf *config* :webmaster))))
|
||||||
(template "%%Date%%" (article-date article))
|
(template "%%Date%%" (date-format (getf *config* :date-format)
|
||||||
(template "%%Title%%" (article-title article))
|
(date-parse (article-date article))))
|
||||||
(template "%%Id%%" (article-id article))
|
(template "%%Raw-Date%%" (article-date article))
|
||||||
|
(template "%%Title%%" (article-title article))
|
||||||
|
(template "%%Id%%" (article-id article))
|
||||||
(template "%%Tags%%" (get-tag-list-article article))
|
(template "%%Tags%%" (get-tag-list-article article))
|
||||||
(template "%%Text%%" (if no-text
|
(template "%%Text%%" (if no-text
|
||||||
""
|
""
|
||||||
|
@ -166,7 +207,7 @@
|
||||||
(defun generate-rss-item()
|
(defun generate-rss-item()
|
||||||
(apply #'concatenate 'string
|
(apply #'concatenate 'string
|
||||||
(loop for article in *articles*
|
(loop for article in *articles*
|
||||||
for i from 1 to (if (> (length *articles*) (getf *config* :rss-item-number)) (getf *config* :rss-item-number) (length *articles*))
|
for i from 1 to (min (length *articles*) (getf *config* :rss-item-number))
|
||||||
collect
|
collect
|
||||||
(prepare "templates/rss-item.tpl"
|
(prepare "templates/rss-item.tpl"
|
||||||
(template "%%Title%%" (article-title article))
|
(template "%%Title%%" (article-title article))
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
<article>
|
<article id="%%Raw-Date%%">
|
||||||
<header>
|
<header>
|
||||||
<h1><a href="article-%%Id%%.html">%%Title%%</a></h1>
|
<h1><a href="article-%%Id%%.html">%%Title%%</a></h1>
|
||||||
<p>Written by <em>%%Author%%</em>, on %%Date%%.<br/>Tags: %%Tags%%</p>
|
<p>Written by <em>%%Author%%</em>, on %%Date%%.<br/>Tags: %%Tags%%</p>
|
||||||
|
|
Loading…
Reference in New Issue