Commit 82a69835 authored by Dave Cooper's avatar Dave Cooper

Added ability to generate .html file in content/ from corresponding

lisp file containing lhtml and markdown.
parent 73cf1217
......@@ -8,3 +8,5 @@ auto-save-list
# Output files
output/
system-index.txt
content/newsbox.html
content/about.html
\ No newline at end of file
......@@ -4,12 +4,12 @@
(asdf:defsystem cl-site
:name "cl-site"
:version "0.0.1"
:maintainer "C. Yang"
:maintainer "common-lisp.net volunteers"
:author "C. Yang"
:licence "TBD"
:description "Static site generator for CLnet, written in CL"
:depends-on (:cl-mustache :plump :markdown.cl :closer-mop)
:depends-on (:cl-mustache :plump :cl-markdown :closer-mop :cl-who)
:components ((:module source
:pathname ""
......@@ -19,6 +19,7 @@
(:file "helpers")
(:file "process")
(:file "main")))
(:module package
:pathname ""
:components ((:file "package"))))
......
<h1><i class="far fa-question-circle"></i>&nbsp;About Common-Lisp.net</h1>
<p> Common-Lisp.net provides hosting for projects and user groups
related to the programming language Common Lisp.
</p>
<p>The site is run under the governance of the <a
href="http://www.cl-foundation.org/">Common Lisp Foundation</a> and
maintained mostly by a committee of volunteers. <a
href="/contribute">Please consider donating</a>.</p>
<p>Its source is hosted
on <a href="https://gitlab.common-lisp.net/clo/cl-site">gitlab.common-lisp.net</a>.
</p>
<p>If you want to request a project, <a href="/project-intro">read
this document</a>.</p>
<p>If you have questions, suggestions or comments about this site or
you simply wish to reach the current maintainers, <a
href="http://mailman.common-lisp.net/cgi-bin/mailman/listinfo/clo-devel">email
this mailinglist</a>.</p>
<p>The documentation, procedures, feature requests etc are located in
our Trac instance: <a href="http://trac.common-lisp.net/clo">clo's
Trac</a>.</p>
<h2>Maintainance</h2>
<p>Since many years <a href="/">Common-Lisp.net</a> has been run
by a number of volunteers.</p>
<h3>Currently active maintainers</h3>
<ul>
<li>Mark Evenson</li>
<li>Erik Huelsmann</li>
<li>Mariano Montone</li>
</ul>
<h3>Previous maintainers</h3>
<ul>
<li>Erik Enge</li>
<li>Drew Crampsie</li>
<li>Hans H&uuml;bner</li>
<li>Cheryl Yang</li>
<li>Mario S. Mommer</li>
</ul>
(in-package :cl-site)
(add-content
"about.html"
(with-cl-who-string (:indent t)
(:h1 ((:i :class "far fa-question-circle")) " About Common-Lisp.net")
(wmd "
Common-Lisp.net provides hosting for projects and user groups related to the programming language Common Lisp.
The site is run under the governance of the [Common Lisp
Foundation](http://www.cl-foundation.org) and maintained mostly by a
committee of volunteers. [Please consider donating](/contribute).
Its source is hosted on
[gitlab.common-lisp.net](https://gitlab.common-lisp.net/clo/cl-site).
If you want to request a project, read [this
document](/project-intro).
If you have questions, suggestions or comments about this site or you
simply wish to reach the current maintainers, email [this mailing
list](http://mailman.common-lisp.net/cgi-bin/mailman/listinfo/clo-devel).
The documentation, procedures, feature requests etc are located in our
Trac instance: [clo's Trac](http://trac.common-lisp.net/clo).")
(:h2 "Maintainance")
(wmd "
Since many years [Common-Lisp.net](/) has been run by a number of
volunteers.")
(:h3 "Currently active maintainers")
(wmd "
* Mark Evenson
* Erik Huelsmann
* Mariano Montone")
(:h3 "Previous maintainers")
(wmd "
* Erik Enge
* Drew Crampsie
* Hans H&uuml;bner
* Cheryl Yang
* Mario S. Mommer")))
......@@ -4,3 +4,5 @@
#:make-site))
(defpackage #:cl-site-content
(:use :cl))
......@@ -52,13 +52,41 @@
output-stream)))))
(defun process-pages ()
(format t "Processing pages..~%")
(format t "Processing pages...~%")
;;
;; Go through all the pages in *page-context* and look for
;; corresponding .lisp file. If it exists, it's assumed this is
;; using `add-content' (defined below) to generate an HTML string and
;; add it to the :content field of its entry in *page-context*. So
;; we compile/load this lisp file then write the content out to the
;; html file. Yes, this is turning into a goddamn Rube Goldberg
;; setup and at some point we will need to clean up and simplify
;; this whole process... But trying to get to where we can at least
;; experiment with using LHTML and markdown to author and maintain
;; page content.
;;
(dolist (page *page-context*)
(let* ((html-file (first page))
(lisp-file (probe-file (make-pathname :defaults *pages-dir*
:name (pathname-name html-file)
:type "lisp"))))
(when lisp-file
(format t "Compile/loading ~a and creating fresh ~a...~%" (file-namestring lisp-file) html-file)
(let ((fasl (compile-file lisp-file)))
(load fasl) (delete-file fasl))
(let ((content (page-content html-file)))
(with-open-file (out (merge-pathnames html-file *pages-dir*) :if-exists :supersede
:if-does-not-exist :create :direction :output)
(write-string content out))))))
(generate-news)
(let ((template-path (pathname (merge-pathnames *LAYOUT-DIR* *DEFAULT-PAGE-TEMPLATE*))))
(ensure-directories-exist *OUTPUT-DIR*)
(loop for page in *PAGES*
do
(format t "Generating ~A~%" (cdr (assoc :content page)))
(format t "Rendering ~A~%" (cdr (assoc :content page)))
(render-page page template-path))
(format t "Done.~%")))
......@@ -68,7 +96,8 @@
(defun generate-news ()
(let ((html
(markdown:parse-file (merge-pathnames "news.md" *PAGES-DIR*))))
(with-output-to-string (ss)
(cl-markdown:markdown (merge-pathnames "news.md" *PAGES-DIR*) :stream ss))))
(with-open-file (f (merge-pathnames "news.html" *PAGES-DIR*)
:direction :output
:if-does-not-exist :create
......@@ -144,3 +173,29 @@
;; else
(next-node)))))))
(plump:serialize news nil))))
(defmacro with-cl-who-string ((&rest args) &body body)
"Form. Sets up body to be evaluated with cl-who:with-html-output and return the resulting string instead
of writing to a stream."
(let ((ss (gensym)))
`(with-output-to-string (,ss)
(cl-who:with-html-output (,ss nil ,@args) ,@body))))
(defmacro wmd (string)
"Form suitable for inclusion in cl-who LHTML context. Returns an
`str` form after passing it through cl-markdown's markdown processor.
"
`(cl-who:str
(with-output-to-string (ss)
(cl-markdown:markdown ,string :stream ss))))
(defun add-content (page-name content-string)
(pushnew (cons :content content-string)
(first (rest (assoc page-name *page-context* :test #'string-equal)))))
(defun page-content (page-name)
(rest (assoc :content (page-context page-name))))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment