[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 92/119: simpler handler in example
From: |
Eric Schulte |
Subject: |
[elpa] 92/119: simpler handler in example |
Date: |
Mon, 10 Mar 2014 16:57:49 +0000 |
eschulte pushed a commit to branch master
in repository elpa.
commit a8bd36926d7bf2992f594c17d326f50b53af9e93
Author: Eric Schulte <address@hidden>
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))
- [elpa] 91/119: more tutorial, (continued)
- [elpa] 91/119: more tutorial, Eric Schulte, 2014/03/10
- [elpa] 94/119: example serving Org-mode files as JSON, Eric Schulte, 2014/03/10
- [elpa] 93/119: helper function to serve directory listings, Eric Schulte, 2014/03/10
- [elpa] 90/119: tutorials, Eric Schulte, 2014/03/10
- [elpa] 88/119: accept single-function handlers, Eric Schulte, 2014/03/10
- [elpa] 96/119: expand this example w/smart dir listings, Eric Schulte, 2014/03/10
- [elpa] 98/119: TODO chunked encoding, Eric Schulte, 2014/03/10
- [elpa] 99/119: serve files with htmlize Emacs fontification, Eric Schulte, 2014/03/10
- [elpa] 97/119: added ws-stop-all convenience function, Eric Schulte, 2014/03/10
- [elpa] 89/119: authorization helper, Eric Schulte, 2014/03/10
- [elpa] 92/119: simpler handler in example,
Eric Schulte <=
- [elpa] 102/119: updated content- transfer-encoding notes, Eric Schulte, 2014/03/10
- [elpa] 103/119: set Content-length when serving files, Eric Schulte, 2014/03/10
- [elpa] 95/119: better ws-send-directory-list, Eric Schulte, 2014/03/10
- [elpa] 106/119: TODO Content and Transfer encodings, Eric Schulte, 2014/03/10
- [elpa] 104/119: tweak notes, Eric Schulte, 2014/03/10
- [elpa] 108/119: test chunked/gzipped transfer/content encodings, Eric Schulte, 2014/03/10
- [elpa] 100/119: manual application of x-gzip content encoding, Eric Schulte, 2014/03/10
- [elpa] 101/119: manual application of chunked transfer encoding, Eric Schulte, 2014/03/10
- [elpa] 107/119: support for content and transfer encodings, Eric Schulte, 2014/03/10
- [elpa] 109/119: doc for new content/transfer encoding helpers, Eric Schulte, 2014/03/10