Add per-tag browsing on gopher
This commit is contained in:
parent
4a5228a380
commit
142b84ab78
2
Makefile
2
Makefile
|
@ -3,7 +3,7 @@ LISP= ecl
|
||||||
all: dirs html
|
all: dirs html
|
||||||
|
|
||||||
html: $(HTML) css
|
html: $(HTML) css
|
||||||
$(LISP) -load generator.lisp
|
$(LISP) --load generator.lisp
|
||||||
|
|
||||||
dirs:
|
dirs:
|
||||||
mkdir -p "output/html/static"
|
mkdir -p "output/html/static"
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
:gopher-path "/user" ;; absolute path of your gopher directory
|
:gopher-path "/user" ;; absolute path of your gopher directory
|
||||||
:gopher-server "my.website" ;; hostname of the gopher server
|
:gopher-server "my.website" ;; hostname of the gopher server
|
||||||
:gopher-port "70" ;; tcp port of the gopher server, 70 usually
|
:gopher-port "70" ;; tcp port of the gopher server, 70 usually
|
||||||
:gopher-format "[0|~a|~a/article-~d.txt|~a|~a]~%~%" ;; menu format (geomyidae)
|
:gopher-format "[~d|~a|~a|~a|~a]~%" ;; menu format (geomyidae)
|
||||||
:gopher-index "index.gph" ;; menu file (geomyidae)
|
:gopher-index "index.gph" ;; menu file (geomyidae)
|
||||||
;; :gopher-format "0~a ~a/article-~d.txt ~a ~a~%~%" ;; menu format (gophernicus and others)
|
;; :gopher-format "~d~a ~a ~a ~a~%" ;; menu format (gophernicus and others)
|
||||||
;; :gopher-index "gophermap" ;; menu file (gophernicus and others)
|
;; :gopher-index "gophermap" ;; menu file (gophernicus and others)
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
|
@ -175,6 +175,30 @@
|
||||||
`(progn
|
`(progn
|
||||||
(save-file ,name (generate-layout ,@data))))
|
(save-file ,name (generate-layout ,@data))))
|
||||||
|
|
||||||
|
;; generate a gopher index file
|
||||||
|
(defun generate-gopher-index(articles)
|
||||||
|
(let ((output (load-file "templates/gopher_head.tpl")))
|
||||||
|
(dolist (article articles)
|
||||||
|
(setf output
|
||||||
|
(string
|
||||||
|
(concatenate 'string output
|
||||||
|
(format nil (getf *config* :gopher-format)
|
||||||
|
0 ;;;; gopher type, 0 for text files
|
||||||
|
;; here we create a 80 width char string with title on the left
|
||||||
|
;; and date on the right
|
||||||
|
;; we truncate the article title if it's too large
|
||||||
|
(let ((title (format nil "~80a"
|
||||||
|
(if (< 80 (length (article-title article)))
|
||||||
|
(subseq (article-title article) 0 80)
|
||||||
|
(article-title article)))))
|
||||||
|
(replace title (article-rawdate article) :start1 (- (length title) (length (article-rawdate article)))))
|
||||||
|
(concatenate 'string
|
||||||
|
(getf *config* :gopher-path) "/article-" (article-id article) ".txt")
|
||||||
|
(getf *config* :gopher-server)
|
||||||
|
(getf *config* :gopher-port)
|
||||||
|
)))))
|
||||||
|
output))
|
||||||
|
|
||||||
;; generate the list of tags
|
;; generate the list of tags
|
||||||
(defun articles-by-tag()
|
(defun articles-by-tag()
|
||||||
(let ((tag-list))
|
(let ((tag-list))
|
||||||
|
@ -325,28 +349,39 @@
|
||||||
|
|
||||||
;; 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))
|
||||||
|
(generate-gopher-index *articles*))
|
||||||
|
|
||||||
|
;; produce a tag list menu
|
||||||
|
(let* ((directory-path "output/gopher/_tags_/")
|
||||||
|
(index-path (concatenate 'string directory-path (getf *config* :gopher-index))))
|
||||||
|
(ensure-directories-exist directory-path)
|
||||||
|
(save-file index-path
|
||||||
(let ((output (load-file "templates/gopher_head.tpl")))
|
(let ((output (load-file "templates/gopher_head.tpl")))
|
||||||
(dolist (article *articles*)
|
(loop for tag in (articles-by-tag)
|
||||||
|
do
|
||||||
(setf output
|
(setf output
|
||||||
(string
|
(string
|
||||||
(concatenate 'string output
|
(concatenate
|
||||||
|
'string output
|
||||||
(format nil (getf *config* :gopher-format)
|
(format nil (getf *config* :gopher-format)
|
||||||
;; here we create a 80 width char string with title on the left
|
1 ;; gopher type, 1 for menus
|
||||||
;; and date on the right
|
(getf tag :NAME)
|
||||||
;; we truncate the article title if it's too large
|
(concatenate 'string
|
||||||
(let ((title (format nil "~80a"
|
(getf *config* :gopher-path) "/" (getf tag :NAME) "/")
|
||||||
(if (< 80 (length (article-title article)))
|
|
||||||
(subseq (article-title article) 0 80)
|
|
||||||
(article-title article)))))
|
|
||||||
(replace title (article-rawdate article) :start1 (- (length title) (length (article-rawdate article)))))
|
|
||||||
|
|
||||||
|
|
||||||
(getf *config* :gopher-path)
|
|
||||||
(article-id article)
|
|
||||||
(getf *config* :gopher-server)
|
(getf *config* :gopher-server)
|
||||||
(getf *config* :gopher-port)
|
(getf *config* :gopher-port)
|
||||||
)))))
|
)))))
|
||||||
output))
|
output)))
|
||||||
|
|
||||||
|
;; produce each tag gophermap index
|
||||||
|
(loop for tag in (articles-by-tag) do
|
||||||
|
(let* ((directory-path (concatenate 'string "output/gopher/" (getf tag :NAME) "/"))
|
||||||
|
(index-path (concatenate 'string directory-path (getf *config* :gopher-index)))
|
||||||
|
(articles-with-tag (loop for article in *articles*
|
||||||
|
when (member (article-id article) (getf tag :VALUE) :test #'equal)
|
||||||
|
collect article)))
|
||||||
|
(ensure-directories-exist directory-path)
|
||||||
|
(save-file index-path (generate-gopher-index articles-with-tag))))
|
||||||
|
|
||||||
;; produce each article file (only a copy/paste in fact)
|
;; produce each article file (only a copy/paste in fact)
|
||||||
(loop for article in *articles*
|
(loop for article in *articles*
|
||||||
|
|
|
@ -2,6 +2,7 @@ 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]
|
[0|RSS Feed|/~me/rss.xml|server|port]
|
||||||
|
[1|Browse by tag|/~me/_tags_/|server|port]
|
||||||
|
|
||||||
-----------------------------------------------------------------
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue