Gopher RSS feed with gopher links - cl-yag - Common Lisp Yet Another website Generator HTML git clone git://bitreich.org/cl-yag/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/cl-yag/ DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit e187e771f1bad099c9f9ac8d98085aefa8998af9 DIR parent b8e92c61d9ff8d0a7e7fd65c33b0fd26c9741e68 HTML Author: Solene Rapenne <solene@perso.pw> Date: Tue, 17 Apr 2018 08:06:04 +0200 Gopher RSS feed with gopher links Diffstat: M generator.lisp | 36 +++++++++++++++++++++----------- M templates/gopher_head.tpl | 2 ++ M templates/layout.tpl | 1 + 3 files changed, 27 insertions(+), 12 deletions(-) --- DIR diff --git a/generator.lisp b/generator.lisp @@ -248,7 +248,7 @@ collect (create-article article :tiny t)))) ;; xml generation of the items for the rss -(defun generate-rss-item() +(defun generate-rss-item(&key (gopher nil)) (apply #'concatenate 'string (loop for article in *articles* 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) :monthname) 0 3))) (template "%%Url%%" - (format nil "~d~d-~d.html" - (getf *config* :url) - (date-format "%Year-%MonthNumber-%DayNumber" - (article-date article)) - (article-id article))))))) + (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" + (getf *config* :url) + (date-format "%Year-%MonthNumber-%DayNumber" + (article-date article)) + (article-id article)))))))) + ;; Generate the rss xml data -(defun generate-rss() +(defun generate-rss(&key (gopher nil)) (prepare "templates/rss.tpl" (template "%%Description%%" (getf *config* :description)) (template "%%Title%%" (getf *config* :title)) (template "%%Url%%" (getf *config* :url)) - (template "%%Items%%" (generate-rss-item)))) + (template "%%Items%%" (generate-rss-item :gopher gopher)))) ;; We do all the website (defun create-html-site() @@ -302,13 +309,20 @@ (loop for tag in (articles-by-tag) do (generate (format nil "output/html/tag-~d.html" (getf tag :NAME)) (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) (save-file "output/html/rss.xml" (generate-rss))) ;; we do all the gopher hole (defun create-gopher-hole() + ;;(generate-file-rss) + (save-file "output/gopher/rss.xml" (generate-rss :gopher t)) + ;; produce the gophermap file (save-file (concatenate 'string "output/gopher/" (getf *config* :gopher-index)) (let ((output (load-file "templates/gopher_head.tpl"))) @@ -340,9 +354,7 @@ (with-converter (let ((id (article-id article))) (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 DIR diff --git a/templates/gopher_head.tpl b/templates/gopher_head.tpl @@ -1,5 +1,7 @@ Hello, this is the head of your gophermap page, you can customize it how you want ! +[0|RSS Feed|/~me/rss.xml|server|port] + ----------------------------------------------------------------- DIR diff --git a/templates/layout.tpl b/templates/layout.tpl @@ -7,6 +7,7 @@ <title>%%Title%%</title> <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 Gopher" href="rss-gopher.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" /> </head>