Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 54 lines (45 sloc) 1.647 kb
e95e59fb »
2008-11-20 initial commit
1 ;; orgserv.el --- serve/edit org-mode files through the web
2 ;;
3 ;; Author: Eric Schulte
4 ;;
5 (require 'org)
6 (require 'gnuserv)
7
8 (defvar orgserv-base
9 (file-name-as-directory
10 (expand-file-name "www" (file-name-directory (or load-file-name buffer-file-name))))
11 "base directory from which to serve/store/find web-pages")
12
13 (defun orgserv-file-to-html (path)
14 "Return the supplied org-mode file as html"
15 (let ((default-directory orgserv-base))
16 (when (find-file path)
17 (org-export-as-html nil t nil 'string))))
18
19 (defun orgserv-subtree-to-html (path id)
20 "Export the subtree located in the file at PATH with the id ID
21 to html and return the resulting string"
22 (let ((default-directory orgserv-base)
23 position html)
24 (save-excursion
25 (when (and (find-file path) (setf position (org-find-entry-with-id id)))
26 (goto-char position)
27 (org-narrow-to-subtree)
28 (setf html (org-export-as-html nil t nil 'string t))
29 (kill-buffer)))
30 ;; wrap the resulting html in AJAXyness
31
32 html
33
34 ))
35
36 (defun orgserv-org-string-to-html (string)
37 "Accept a org-mode formatted string, and return it as html."
38 (with-temp-buffer
39 (insert string)
40 (org-export-as-html nil t nil 'string)))
41
42 (defun orgserv-start ()
43 "attempting to implement a persistent loop that can accept
44 input through gnuclient, and return output there all in a
45 persistent process."
46 ;; may not be possible
47 )
48
49 ;;--------------------------------------------------------------------------------
50 ;; functions for serving subtrees independently
51
52 (defun orgserv-idify ()
53 "assign each subtree in the current file a uid"
54 (org-map-entries 'org-id-get-create))
Something went wrong with that request. Please try again.