forked from cadar/lithium
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathweb_viewsource.lfe
33 lines (27 loc) · 1.05 KB
/
web_viewsource.lfe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(define-module web_viewsource
(export all))
(include-file "lfeweb/wf.lfe")
(include-file "lfeweb/helpers.lfe")
(defun path () '"/home/cadar/myproject/lfeweb/examples/")
(defun replacements
((()) '())
(((60 . t)) `(38 108 116 59 . ,(replacements t)))
(((9 . t)) `(32 32 . ,(replacements t)))
(((h . t)) `(,h . ,(replacements t))))
(defun get-source
((module-arg)
(let* ((compilerinfo (call-str module-arg 'module_info 'compile))
;; Source not used! Compilerinfo do not have right value.
(source (: proplists get_value 'source compilerinfo))
((tuple 'ok b) (: file read_file (++ (path) (++ module-arg '".lfe")))))
(list '"<!-- " source '" -->"
'"<pre>"
(replacements (binary_to_list b))
'"</pre>"))))
(defun main ()
(let* ((module (hd (: wf q 'module)))
((tuple module1 _) (case module
((119 101 98 95 . es) (: wf_utils path_to_module module))
(_ (tuple 'undefined 'undefined)))))
(get-source module)))
(defun event (_) 'ok)