Commit 78c5e723 authored by Erik Huelsmann's avatar Erik Huelsmann

Revert "Merge branch 'zacl+aserve' into 'master'"

This reverts merge request !57
parent 90f96d12
# Emacs autosave
*~
\#*\#
*.elc
......@@ -11,4 +11,3 @@ system-index.txt
content/newsbox.html
content/about.html
*.dx64fsl
*.fasl
all: build
serve: static favicon
sbcl --load build.lisp
serve:
cd output; python ../server.py
static:
mkdir -p output/static
cp -rf content/static/* output/static/
# cp -rf content/static/* output/static
favicon:
cp content/favicon.ico output/
......@@ -16,8 +16,3 @@ build: static favicon
clean:
rm -rf output
mkdir output
# Python server - kept around for compatibility & benchmark testing:
pyserve:
cd output; python ../server.py
......@@ -49,8 +49,7 @@ in `layout/static/` takes precedence.
## Execution
### From command line
### From command line (recommended)
Using Make.
......@@ -59,47 +58,38 @@ The Makefile contains various useful commands.
Among them:
* `make` - to generate the site.
* `make serve` - to run a simple site server on port 8008 or subsequent (currently needs Allegro CL, SBCL, or CCL)
* `make serve` - to run a simple site server (needs python)
* `make clean` - to remove the generated files from output directory
* `make pyserve` - to run a secondary (python) server on port 8000 (crashes if 8000 is busy).
### From Lisp
### From Lisp ###
(The following assumes you have a reasonably recent Quicklisp loaded)
* Either (in one fell swoop):
(load ".../cl-site/build.lisp") ;; replace with your actual path to cl-site/
This will also start serving the site on port 8008 (or subsequent port
numbers, if 8008 is busy). So you can visit the site to test it at:
`http://localhost:8008`
Either (in one fell swoop):
* Or (step by step):
(load ".../cl-site/build.lisp") ;; replace with your actual path to cl-site/
First, make sure your `cl-site/` directory (the directory containing
this file) is pushed onto `ql:*local-project-directories*` or you
have this directory moved or linked under your
`quicklisp/local-projects/` directory (see `build.lisp` for example
of how to push onto `ql:*local-project-directories*`).
Then, load the system with this command:
Or (step by step):
(ql:quickload :cl-site)
First, make sure your `cl-site/` directory (the directory containing
this file) is pushed onto `ql:*local-project-directories*` or you have
this directory moved or linked under your `quicklisp/local-projects/`
directory (see `build.lisp` for example of how to push onto
`ql:*local-project-directories*`).
To generate the site:
Then, load the system with this command:
(cl-site:make-site)
(ql:quickload :cl-site)
The output files will be generated in the `output/` directory.
To generate the site:
To clean any old files from output/ directory:
(cl-site:make-site)
(cl-site:make-clean)
The output files will be generated in the `output/` directory.
To clean any old files from output/ directory:
(cl-site:make-clean)
(in-package :cl-user)
(push (make-pathname :defaults *load-truename* :name nil :type nil)
quicklisp:*local-project-directories*)
(ql:register-local-projects) ;; for good measure
(ql:quickload :cl-site)
(cl-site::make-site)
;;
;; Start aserve, publish site directory & pages, set default package.
;;
(cl-site:start-aserve)
(cl-site:publish-cl-site)
(setq *package* (find-package :cl-site))
......@@ -8,7 +8,7 @@
:author "C. Yang & Common-Lisp.Net maintainers"
:licence "TBD"
:description "Static site generator for common-lisp.net, written in CL"
:depends-on (:cl-mustache :plump :markdown.cl :closer-mop :cl-who :cl-yaml :aserve)
:depends-on (:cl-mustache :plump :markdown.cl :closer-mop :cl-who :cl-yaml)
:components ((:module source
:pathname ""
:serial t
......@@ -16,8 +16,8 @@
:components ((:file "globals")
(:file "helpers")
(:file "process")
(:file "main")
(:file "publish")))
(:file "main")))
(:module package
:pathname ""
:components ((:file "package"))))
......
......@@ -33,6 +33,3 @@
capture output when compile/loading any lispy html content files
wrapped with calls to add-content. Global value should always be
nil.")
(defvar *aserve-port* 8008)
(defvar *aserve-listeners* 5)
(defpackage #:cl-site
(:use :cl)
(:export #:make-site #:make-clean #:add-content #:wmd :with-cl-who-string
#:start-aserve :publish-cl-site))
(:export #:make-site #:make-clean #:add-content #:wmd :with-cl-who-string))
(defpackage #:cl-site-content
......
(in-package :cl-site)
(defun publish-cl-site ()
(dolist (file (directory (make-pathname :defaults *OUTPUT-DIR* :name :wild :type "html")))
(dolist (format-string (list "/~a" "/~a.htm" "/~a.html"))
(net.aserve:publish-file :path (format nil format-string (pathname-name file))
:file (namestring file))))
(net.aserve:publish-directory :prefix "/"
:destination (namestring *output-dir*)))
;;
;; FLAG -- below utility functions borrowed from Gendl Remove when/if
;; Gendl is included in cl-site. On the other hand, these are a bit
;; of a mess and any feedback is welcome, to clean them up before
;; blindly :use'ing them as-is from Gendl.
;;
(defun client-test (port)
"Check if a port is busy" ;; FLAG there must be a better way to check for
;; a busy port than this...
#-ccl
(multiple-value-bind (result error)
(ignore-errors
(bt:with-timeout (2)
(net.aserve.client:do-http-request (format nil "http://127.0.0.1:~a" port))))
(declare (ignore result))
(when (typep error 'error)
port))
;;
;; CCL has socket problems after calling do-http-request within an
;; ignore-errors, when it throws an error. So we do something
;; different. But this different thing apparently doesn't work so
;; reliably on non-CCL.
;;
#+ccl
(let* ((result
(handler-case
(let ((sock (usocket:socket-listen "127.0.0.1" port)))
(usocket:socket-close sock))
(usocket:address-in-use-error (e) (declare (ignore e)) :in-use)
(t (e) (declare (ignore e)) :unknown))))
(unless (or (member result '(:in-use :unknown))
#+windows-host
(ignore-errors
(net.aserve.client:do-http-request
(format nil "http://127.0.0.1:~a" port)))) port)))
(defun start-aserve (&key (port *aserve-port*) (listeners *aserve-listeners*)
;;
;; FLAG -- figure out correct external-format for the other Lisps.
;;
(external-format #+allegro :utf8-base #-allegro :utf8) aserve-start-args)
(net.aserve:shutdown)
(let ((wait-time 1))
(block :outer
(do () (nil)
(let ((port port))
(block :inner
(do ((port-free? (client-test port) (client-test port)))
(port-free?
(format t (if (> wait-time 1) "~&Retrying aserve on ~a...~%"
"~&Trying to start aserve on ~a...~%") port)
(if (ignore-errors
(apply #'net.aserve:start
:port port :listeners listeners
:external-format external-format
aserve-start-args))
(return-from :outer port)
(progn (sleep (random wait-time)) (return-from :inner))))
(incf port))))
(incf wait-time 0.1)))))
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