[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 62/119: example serving Org-mode files exported on demand
From: |
Eric Schulte |
Subject: |
[elpa] 62/119: example serving Org-mode files exported on demand |
Date: |
Mon, 10 Mar 2014 16:57:29 +0000 |
eschulte pushed a commit to branch master
in repository elpa.
commit d693833dd903ee9c0dc599280cfde6da50cb4f1a
Author: Eric Schulte <address@hidden>
Date: Sat Jan 4 10:51:06 2014 -0700
example serving Org-mode files exported on demand
---
doc/web-server.texi | 15 +++++++++++++--
examples/7-org-mode-file-server.el | 23 +++++++++++++++++++++++
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/doc/web-server.texi b/doc/web-server.texi
index b93e4fa..0f5bb9a 100644
--- a/doc/web-server.texi
+++ b/doc/web-server.texi
@@ -159,6 +159,7 @@ These examples demonstrate usage.
* URL Parameter Echo:: Echo Parameters from a URL query string
* POST Echo:: Echo POST parameters back
* Basic Authentication:: BASIC HTTP Authentication
+* Org-mode Export Server:: Export files to HTML and Tex
@end menu
@node Hello World, Hello World UTF8, Usage Examples, Usage Examples
@@ -227,7 +228,8 @@ in a @code{POST} request.
@verbatiminclude ../examples/5-post-echo.el
address@hidden Basic Authentication, Function Index, POST Echo, Usage Examples
address@hidden Basic Authentication, Org-mode Export Server, POST Echo, Usage
Examples
address@hidden Basic Authentication
The following example demonstrates BASIC HTTP authentication. The
handler prompts an unauthenticated client for authentication by
@@ -248,10 +250,19 @@ Note: BASIC HTTP authentication passes user credentials
in plain text
between the client and the server and should generally only be used
with HTTPS network encryption. While the Emacs web server currently
doesn't support HTTPS network encryption it may be run behind an HTTPS
-proxy server (e.g., Apache) which does support HTTPS.
+proxy server (e.g., Apache or Nginx) with HTTPS support.
@verbatiminclude ../examples/6-basic-authentication.el
address@hidden Org-mode Export Server, Function Index, Basic Authentication,
Usage Examples
address@hidden Org-mode Export Server
+
+The following example exports a directory of Org-mode files as either
+text, HTML or LaTeX. The Org-mode export engine is used to export
+files on-demand as they are requested.
+
address@hidden ../examples/7-org-mode-file-server.el
+
@node Function Index, Copying, Usage Examples, Top
@chapter Function Index
@cindex function index
diff --git a/examples/7-org-mode-file-server.el
b/examples/7-org-mode-file-server.el
new file mode 100644
index 0000000..856634c
--- /dev/null
+++ b/examples/7-org-mode-file-server.el
@@ -0,0 +1,23 @@
+;;; file-server.el --- serve on-demand exported Org-mode files
+(lexical-let ((docroot default-directory))
+ (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)))))))
+ 9007))
- [elpa] 45/119: new request object, (continued)
- [elpa] 45/119: new request object, Eric Schulte, 2014/03/10
- [elpa] 56/119: fix ports in examples, Eric Schulte, 2014/03/10
- [elpa] 58/119: note: shouldn't use BASIC authentication w/o HTTPS, Eric Schulte, 2014/03/10
- [elpa] 59/119: notes about security & authentication options, Eric Schulte, 2014/03/10
- [elpa] 57/119: BASIC HTTP authentication, Eric Schulte, 2014/03/10
- [elpa] 61/119: fix deprecated file name in file example, Eric Schulte, 2014/03/10
- [elpa] 38/119: starting on documentation, Eric Schulte, 2014/03/10
- [elpa] 60/119: quick benchmarking, Eric Schulte, 2014/03/10
- [elpa] 52/119: changed prefix: ews -> ws, Eric Schulte, 2014/03/10
- [elpa] 63/119: autoload ws-start, Eric Schulte, 2014/03/10
- [elpa] 62/119: example serving Org-mode files exported on demand,
Eric Schulte <=
- [elpa] 64/119: fix file header, Eric Schulte, 2014/03/10
- [elpa] 65/119: handle POST file uploads w/example, Eric Schulte, 2014/03/10
- [elpa] 66/119: notes, Eric Schulte, 2014/03/10
- [elpa] 70/119: run all tests with "make check", Eric Schulte, 2014/03/10
- [elpa] 67/119: test large file upload (w/o network chunking), Eric Schulte, 2014/03/10
- [elpa] 69/119: refactoring no multiple concurrent header parsing, Eric Schulte, 2014/03/10
- [elpa] 71/119: updating notes and README text, Eric Schulte, 2014/03/10
- [elpa] 72/119: notes for running behind an Apache HTTPS proxy, Eric Schulte, 2014/03/10
- [elpa] 73/119: some more examples to implement, Eric Schulte, 2014/03/10
- [elpa] 68/119: no multiple concurrent entry of ws-parse-request, Eric Schulte, 2014/03/10