eschulte pushed a commit to branch master in repository elpa. commit a8bd36926d7bf2992f594c17d326f50b53af9e93 Author: Eric Schulte <schulte.e...@gmail.com> Date: Sat Jan 11 11:06:59 2014 -0700
simpler handler in example --- examples/007-org-mode-file-server.el | 38 ++++++++++++++++----------------- 1 files changed, 18 insertions(+), 20 deletions(-) diff --git a/examples/007-org-mode-file-server.el b/examples/007-org-mode-file-server.el index 1bcfe10..d80b260 100644 --- a/examples/007-org-mode-file-server.el +++ b/examples/007-org-mode-file-server.el @@ -1,23 +1,21 @@ ;;; org-mode-file-server.el --- serve on-demand exported Org-mode files -(lexical-let ((docroot default-directory)) +(lexical-let ((docroot "/tmp/")) (ws-start - (list - (cons '(:GET . ".*") - (lambda (request) - (with-slots (process headers) request - (let ((path (ws-in-directory-p ; check if path is in docroot - docroot (substring (cdr (assoc :GET headers)) 1)))) - (unless path (ws-send-404 process)) ; send 404 if not in docroot - (let* ((base (file-name-sans-extension path)) - (type (case (intern (downcase (file-name-extension path))) - (html 'html) - (tex 'latex) - (txt 'ascii) - (t (ws-error process "%S export not supported" - (file-name-extension path))))) - (orig (concat base ".org"))) - (unless (file-exists-p orig) (ws-send-404 process)) - (save-window-excursion (find-file orig) - (org-export-to-file type path)) - (ws-send-file process path))))))) + (lambda (request) + (with-slots (process headers) request + (let ((path (ws-in-directory-p ; check if path is in docroot + docroot (substring (cdr (assoc :GET headers)) 1)))) + (unless path (ws-send-404 process)) ; send 404 if not in docroot + (let* ((base (file-name-sans-extension path)) + (type (case (intern (downcase (file-name-extension path))) + (html 'html) + (tex 'latex) + (txt 'ascii) + (t (ws-error process "%S export not supported" + (file-name-extension path))))) + (orig (concat base ".org"))) + (unless (file-exists-p orig) (ws-send-404 process)) + (save-window-excursion (find-file orig) + (org-export-to-file type path)) + (ws-send-file process path))))) 9007))