From 3ced625dffdc91bb68aba39a13a192a165035143 Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Mon, 19 May 2025 15:29:42 -0700 Subject: [PATCH] Add a Makefile --- Makefile | 6 ++++++ README.md | 9 +++++++++ routes.lua | 8 -------- routes.moon | 53 ----------------------------------------------------- site.moon | 3 ++- 5 files changed, 17 insertions(+), 62 deletions(-) create mode 100644 Makefile delete mode 100644 routes.lua delete mode 100644 routes.moon diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..30dc052 --- /dev/null +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index e071749..fc868af 100644 --- a/README.md +++ b/README.md @@ -52,10 +52,18 @@ $ docker run --rm -w /opt/app -v $PWD:/opt/app sitegen-openresty sitegen +or + + $ make build + ### start server $ docker run --rm -it --init -v $PWD:/opt/app -p 8080:8080 sitegen-openresty +or + + $ make + ### visit `localhost:8080` in web browser ### start watcher @@ -66,5 +74,6 @@ * page titles +* draft documents * treesitter highlighting for moonscript * penlight library diff --git a/routes.lua b/routes.lua deleted file mode 100644 index 0e6179a..0000000 --- a/routes.lua +++ /dev/null @@ -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 diff --git a/routes.moon b/routes.moon deleted file mode 100644 index a52a8a8..0000000 --- a/routes.moon +++ /dev/null @@ -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 "

hello

" --- 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 "

/posts

" - -- @to "/", "get" - -route diff --git a/site.moon b/site.moon index 4232c9c..6dff499 100644 --- a/site.moon +++ b/site.moon @@ -40,8 +40,9 @@ rootname = (str) -> result = string.gsub str, "%..+", "" result +-- TODO use split function from common split = (str, delimiter="/") -> - [capture for capture in string.gmatch str, "[^#{delimiter}]+"] + [capture for capture in str\gmatch "[^#{delimiter}]+"] last = (list) -> list[#list] join = (first, last, delimiter="/") -> table.concat { first, last }, delimiter