Add a Makefile
This commit is contained in:
parent
aebdf3d3f0
commit
521fcba66e
6
Makefile
Normal file
6
Makefile
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
run:
|
||||||
|
docker run --rm -it --init -v $(PWD):/opt/app -p 8080:8080 \
|
||||||
|
sitegen-openresty
|
||||||
|
|
||||||
|
build:
|
||||||
|
docker run --rm -w /opt/app -v $(PWD):/opt/app sitegen-openresty sitegen
|
@ -52,10 +52,18 @@
|
|||||||
|
|
||||||
$ docker run --rm -w /opt/app -v $PWD:/opt/app sitegen-openresty sitegen
|
$ docker run --rm -w /opt/app -v $PWD:/opt/app sitegen-openresty sitegen
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
$ make build
|
||||||
|
|
||||||
### start server
|
### start server
|
||||||
|
|
||||||
$ docker run --rm -it --init -v $PWD:/opt/app -p 8080:8080 sitegen-openresty
|
$ docker run --rm -it --init -v $PWD:/opt/app -p 8080:8080 sitegen-openresty
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
$ make
|
||||||
|
|
||||||
### visit `localhost:8080` in web browser
|
### visit `localhost:8080` in web browser
|
||||||
|
|
||||||
### start watcher
|
### start watcher
|
||||||
@ -66,5 +74,6 @@
|
|||||||
|
|
||||||
* page titles
|
* page titles
|
||||||
|
|
||||||
|
* draft documents
|
||||||
* treesitter highlighting for moonscript
|
* treesitter highlighting for moonscript
|
||||||
* penlight library
|
* penlight library
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
local route = require("resty.route").new()
|
|
||||||
route:get("=/posts/index.html", function(self)
|
|
||||||
return ngx.exec("/posts/index.html")
|
|
||||||
end)
|
|
||||||
route:get("=/posts/", function(self)
|
|
||||||
return ngx.req.set_uri("/posts/index.html", false)
|
|
||||||
end)
|
|
||||||
return route
|
|
53
routes.moon
53
routes.moon
@ -1,53 +0,0 @@
|
|||||||
route = require("resty.route").new!
|
|
||||||
|
|
||||||
-- flag = last: true, break: false
|
|
||||||
|
|
||||||
route\get "=/posts/index.html", =>
|
|
||||||
-- ngx.req.set_uri("/posts/index.html", false)
|
|
||||||
ngx.exec("/posts/index.html")
|
|
||||||
|
|
||||||
route\get "=/posts/", =>
|
|
||||||
-- ngx.req.set_uri("/posts/2023-08-03-recursively-list-all-files-in-a-directory-with-elixir.html", false)
|
|
||||||
-- ngx.exec("/posts/2023-08-03-recursively-list-all-files-in-a-directory-with-elixir.html")
|
|
||||||
-- ngx.say("resty-route " .. ngx.var.uri)
|
|
||||||
-- ngx.req.set_uri(ngx.var.uri, false)
|
|
||||||
-- @render "somecontent", @context
|
|
||||||
ngx.req.set_uri("/posts/index.html", false)
|
|
||||||
-- ngx.req.set_uri("/posts/2023-08-03-recursively-list-all-files-in-a-directory-with-elixir.html", true)
|
|
||||||
-- ngx.say ngx.var.uri
|
|
||||||
-- ngx.exec("/about.html")
|
|
||||||
-- ngx.exec("/posts/2023-08-03-recursively-list-all-files-in-a-directory-with-elixir.html")
|
|
||||||
|
|
||||||
-- route\get "#/posts/([%w%-%_]+)[.](%w+)", (file, ext) =>
|
|
||||||
-- ngx.req.set_uri("/posts")
|
|
||||||
-- ngx.say ngx.var.uri
|
|
||||||
-- ngx.exec "/posts/#{file}.#{ext}"
|
|
||||||
-- ngx.req.set_uri("/posts/2023-08-03-recursively-list-all-files-in-a-directory-with-elixir.html")
|
|
||||||
|
|
||||||
-- route\get "#/posts/([%w%-%_]+)", (id) =>
|
|
||||||
-- ngx.say "<p>hello</p>"
|
|
||||||
-- route\get "#/posts/(%w+)", (id) =>
|
|
||||||
-- ngx.say file
|
|
||||||
-- ngx.exec "/posts/2023-08-03-recursively-list-all-files-in-a-directory-with-elixir.html"
|
|
||||||
|
|
||||||
-- route\get "=/posts", =>
|
|
||||||
-- route\get "#/posts/([%w%-%_]+)", (id) =>
|
|
||||||
-- ngx.exec "/posts/2023-08-03-recursively-list-all-files-in-a-directory-with-elixir.html"
|
|
||||||
-- ngx.req.set_uri("/posts")
|
|
||||||
-- ngx.exec "/posts/2023-08-03-recursively-list-all-files-in-a-directory-with-elixir.html"
|
|
||||||
-- router\to "/about.html", "get"
|
|
||||||
-- require("moon").p route
|
|
||||||
-- { one: "two" }
|
|
||||||
-- ngx.say [k .. v for k, v in pairs { one: "two" }]
|
|
||||||
-- keys = [k .. "\n" for k,v in pairs @]
|
|
||||||
-- keys = [k .. "\n" for k,v in pairs @]
|
|
||||||
-- ngx.log(ngx.ERR, @)
|
|
||||||
|
|
||||||
-- ngx.say [k .. v for k, v in pairs route]
|
|
||||||
-- ngx.say type(route)
|
|
||||||
-- uri = "/posts/2023-08-03-recursively-list-all-files-in-a-directory-with-elixir.html"
|
|
||||||
-- ngx.req.set_uri("/about.html")
|
|
||||||
-- ngx.say "<p>/posts</p>"
|
|
||||||
-- @to "/", "get"
|
|
||||||
|
|
||||||
route
|
|
@ -40,8 +40,9 @@ rootname = (str) ->
|
|||||||
result = string.gsub str, "%..+", ""
|
result = string.gsub str, "%..+", ""
|
||||||
result
|
result
|
||||||
|
|
||||||
|
-- TODO use split function from common
|
||||||
split = (str, delimiter="/") ->
|
split = (str, delimiter="/") ->
|
||||||
[capture for capture in string.gmatch str, "[^#{delimiter}]+"]
|
[capture for capture in str\gmatch "[^#{delimiter}]+"]
|
||||||
|
|
||||||
last = (list) -> list[#list]
|
last = (list) -> list[#list]
|
||||||
join = (first, last, delimiter="/") -> table.concat { first, last }, delimiter
|
join = (first, last, delimiter="/") -> table.concat { first, last }, delimiter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user