Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 58 lines (46 sloc) 1.819 kb
65417db @nicferrier make new examples directory
authored
1 ;;; elnode-org.el
2
3 (require 'elnode)
4
5 (defun elnode-org-handler (httpcon)
6 (elnode-docroot-for "~/work/org"
7 with org-file
8 on httpcon
9 do (with-current-buffer (find-file-noselect org-file)
10 (let ((org-html
11 ;; This might throw errors so you could condition-case it
12 (org-export-as-html 3 nil nil 'string)))
13 (elnode-send-html httpcon org-html)))))
14
15 (defun elnode-org-update-handler (httpcon)
16 "Elnode handler to do org-mode updates.
17
18 Specify `file-name' for the file to update, `node-match' for an
19 org-agenda match, `in-node-match' to specify what will be
20 replaced in the node matched org line, `replace-match' for the
21 replacement."
22 (elnode-method httpcon
23 (POST
24 (let* ((file-name (elnode-http-param httpcon "file-name"))
25 (node-match (elnode-http-param httpcon "node-match"))
26 (in-node-match (elnode-http-param httpcon "in-node-match"))
27 (replace-match (elnode-http-param httpcon "replace-match")))
28 (elnode-org--update
29 file-name
30 node-match
31 in-node-match
32 replace-match)))))
33
34 (defun elnode-org--update (file-name node-match in-node-match replace-match)
35 "Update org-mode specified FILE-NAME.
36
37 NODE-MATCH specifies a match expression in the manner of org-agenda views.
38
39 IN-NODE-MATCH specifies a string match expression used with the
40 bounds of the matched node line.
41
42 REPLACE-MATCH specifies the replacement for the IN-NODE-MATCH."
43 (with-current-buffer (find-file-noselect file-name)
44 (org-map-entries
45 (lambda ()
46 (replace-regexp
47 in-node-match
48 replace-match
49 nil
50 (point)
51 (line-end-position)))
52 node-match)))
53
54 (elnode-start 'elnode-org-handler :port 8002)
55
56
57 ;;; elnode-org.el ends here
Something went wrong with that request. Please try again.