A => .gitignore +3 -0
@@ 1,3 @@
+# openresty nginx temporary directories
+*_temp
+server/*.lua<
\ No newline at end of file
A => .gitmodules +3 -0
@@ 1,3 @@
+[submodule "fennel"]
+ path = modules/fennel
+ url = git@github.com:bakpakin/fennel.git
A => conf/nginx.conf +15 -0
@@ 1,15 @@
+worker_processes 1;
+error_log logs/error.log;
+events {
+ worker_connections 1024;
+}
+http {
+ server {
+ listen 8090;
+ location / {
+ default_type text/html;
+ content_by_lua_file server/server.lua;
+ lua_code_cache off;
+ }
+ }
+}<
\ No newline at end of file
A => logs/.gitignore +2 -0
@@ 1,2 @@
+*
+!.gitignore<
\ No newline at end of file
A => makefile +15 -0
@@ 1,15 @@
+.PHONY: all
+all: server
+
+.PHONY: clean
+clean: clean-server
+
+.PHONY: server
+server: server/server.lua server/html.lua
+
+.PHONY: clean-server
+clean-server:
+ rm server/*.lua
+
+server/server.lua: server/server.fnl ; modules/fennel/fennel --compile $^ > $@
+server/html.lua: server/html.fnl ; modules/fennel/fennel --compile $^ > $@
A => modules/fennel +1 -0
@@ 1,1 @@
+Subproject commit 472deb1fc18f1e1f9021b2254e3060dcd82ac968
A => server/html.fnl +33 -0
@@ 1,33 @@
+;; borrowed from https://github.com/technomancy/fennel-lang.org/blob/3c5d70e2edf9434dc7b7582015b0457da448c87b/html.fnl
+
+;; A *very* basic HTML generation library.
+;; No escaping features; never use this on user input!
+
+(local map (fn [f tbl]
+ (let [out {}]
+ (each [i v (ipairs tbl)]
+ (tset out i (f v)))
+ out)))
+
+(local map-kv (fn [f tbl]
+ (let [out {}]
+ (each [k v (pairs tbl)]
+ (table.insert out (f k v)))
+ out)))
+
+(local to-attr (fn [k v]
+ (if (= v true) k
+ (.. k "=\"" v"\""))))
+
+(local tag (fn [tag-name attrs]
+ (assert (= (type attrs) "table") "Missing attrs table")
+ (let [attr-str (table.concat (map-kv to-attr attrs) " ")]
+ (.. "<" tag-name " " attr-str">"))))
+
+(fn html [doc]
+ (if (= (type doc) "string")
+ doc
+ (let [[tag-name attrs & body] doc]
+ (.. (tag tag-name attrs)
+ (table.concat (map html body) " ")
+"</" tag-name ">"))))
A => server/server.fnl +8 -0
@@ 1,8 @@
+(global ngx ngx)
+(local html (require :html))
+
+(local homepage
+ [:div {}
+ [:h1 {} "Hello, world!"]])
+
+(ngx.say (html homepage))