Gopher RSS feed with gopher links

This commit is contained in:
Solene Rapenne 2018-04-17 08:06:04 +02:00
parent b8e92c61d9
commit e187e771f1
3 changed files with 27 additions and 12 deletions

View File

@ -248,7 +248,7 @@
collect (create-article article :tiny t)))) collect (create-article article :tiny t))))
;; xml generation of the items for the rss ;; xml generation of the items for the rss
(defun generate-rss-item() (defun generate-rss-item(&key (gopher nil))
(apply #'concatenate 'string (apply #'concatenate 'string
(loop for article in *articles* (loop for article in *articles*
for i from 1 to (min (length *articles*) (getf *config* :rss-item-number)) for i from 1 to (min (length *articles*) (getf *config* :rss-item-number))
@ -262,19 +262,26 @@
(subseq (getf (article-date article) :dayname) 0 3) (subseq (getf (article-date article) :dayname) 0 3)
(subseq (getf (article-date article) :monthname) 0 3))) (subseq (getf (article-date article) :monthname) 0 3)))
(template "%%Url%%" (template "%%Url%%"
(if gopher
(format nil "gopher://~a:~d/0~a/~a.txt"
(getf *config* :gopher-server)
(getf *config* :gopher-port)
(getf *config* :gopher-path)
(article-id article))
(format nil "~d~d-~d.html" (format nil "~d~d-~d.html"
(getf *config* :url) (getf *config* :url)
(date-format "%Year-%MonthNumber-%DayNumber" (date-format "%Year-%MonthNumber-%DayNumber"
(article-date article)) (article-date article))
(article-id article))))))) (article-id article))))))))
;; Generate the rss xml data ;; Generate the rss xml data
(defun generate-rss() (defun generate-rss(&key (gopher nil))
(prepare "templates/rss.tpl" (prepare "templates/rss.tpl"
(template "%%Description%%" (getf *config* :description)) (template "%%Description%%" (getf *config* :description))
(template "%%Title%%" (getf *config* :title)) (template "%%Title%%" (getf *config* :title))
(template "%%Url%%" (getf *config* :url)) (template "%%Url%%" (getf *config* :url))
(template "%%Items%%" (generate-rss-item)))) (template "%%Items%%" (generate-rss-item :gopher gopher))))
;; We do all the website ;; We do all the website
(defun create-html-site() (defun create-html-site()
@ -303,12 +310,19 @@
(generate (format nil "output/html/tag-~d.html" (getf tag :NAME)) (generate (format nil "output/html/tag-~d.html" (getf tag :NAME))
(generate-tag-mainpage (getf tag :VALUE)))) (generate-tag-mainpage (getf tag :VALUE))))
;; generate rss gopher in html folder if gopher is t
(when (getf *config* :gopher)
(save-file "output/html/rss-gopher.xml" (generate-rss :gopher t)))
;;(generate-file-rss) ;;(generate-file-rss)
(save-file "output/html/rss.xml" (generate-rss))) (save-file "output/html/rss.xml" (generate-rss)))
;; we do all the gopher hole ;; we do all the gopher hole
(defun create-gopher-hole() (defun create-gopher-hole()
;;(generate-file-rss)
(save-file "output/gopher/rss.xml" (generate-rss :gopher t))
;; produce the gophermap file ;; produce the gophermap file
(save-file (concatenate 'string "output/gopher/" (getf *config* :gopher-index)) (save-file (concatenate 'string "output/gopher/" (getf *config* :gopher-index))
(let ((output (load-file "templates/gopher_head.tpl"))) (let ((output (load-file "templates/gopher_head.tpl")))
@ -340,9 +354,7 @@
(with-converter (with-converter
(let ((id (article-id article))) (let ((id (article-id article)))
(save-file (format nil "output/gopher/article-~d.txt" id) (save-file (format nil "output/gopher/article-~d.txt" id)
(load-file (format nil "data/~d~d" id (converter-extension converter-object))))))) (load-file (format nil "data/~d~d" id (converter-extension converter-object))))))))
)
;; This is function called when running the tool ;; This is function called when running the tool

View File

@ -1,5 +1,7 @@
Hello, this is the head of your gophermap page, you can Hello, this is the head of your gophermap page, you can
customize it how you want ! customize it how you want !
[0|RSS Feed|/~me/rss.xml|server|port]
----------------------------------------------------------------- -----------------------------------------------------------------

View File

@ -7,6 +7,7 @@
<title>%%Title%%</title> <title>%%Title%%</title>
<link rel="stylesheet" type="text/css" href="static/css/style.css" media="screen" /> <link rel="stylesheet" type="text/css" href="static/css/style.css" media="screen" />
<link rel="alternate" type="application/rss+xml" title="%%Title%% RSS Feed" href="rss.xml" /> <link rel="alternate" type="application/rss+xml" title="%%Title%% RSS Feed" href="rss.xml" />
<link rel="alternate" type="application/rss+xml" title="%%Title%% RSS Feed Gopher" href="rss-gopher.xml" />
<!-- <link rel="alternate" type="application/atom+xml" title="%%Title%% Atom Feed" href="atom.xml" /> --> <!-- <link rel="alternate" type="application/atom+xml" title="%%Title%% Atom Feed" href="atom.xml" /> -->
<link rel="icon" type="image/x-icon" href="static/img/clyagFav.ico" /> <link rel="icon" type="image/x-icon" href="static/img/clyagFav.ico" />
</head> </head>