Compare commits
1 Commits
2c2dc57453
...
testing
| Author | SHA1 | Date | |
|---|---|---|---|
| 7fbf8ae8c2 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1 @@
|
|||||||
fes
|
fes
|
||||||
*.tar.gz
|
|
||||||
/stuff/
|
|
||||||
|
|||||||
17
Dockerfile
17
Dockerfile
@@ -4,17 +4,24 @@ WORKDIR /src
|
|||||||
|
|
||||||
RUN apk add --no-cache git build-base
|
RUN apk add --no-cache git build-base
|
||||||
|
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN make
|
ENV CGO_ENABLED=0
|
||||||
|
ENV GOOS=linux
|
||||||
|
ENV GOARCH=amd64
|
||||||
|
|
||||||
FROM alpine:3.19
|
RUN go build -ldflags="-X fes/modules/version.gitCommit=$(git rev-parse --short HEAD) -s -w" -o fes
|
||||||
|
|
||||||
COPY --from=builder /src/fes /usr/local/bin/fes
|
FROM scratch
|
||||||
|
|
||||||
|
COPY --from=builder /src/fes /fes
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 8080
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/fes"]
|
ENTRYPOINT ["/fes"]
|
||||||
CMD ["run", "/app"]
|
CMD ["run", "/app"]
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
Pinnipeds [2] are the seals and their relatives, a group of semi-aquatic marine
|
|
||||||
mammals. The Pinnipedia is in the Order Carnivora. There are three seal
|
|
||||||
families: Odobenidae (walruses), Otariidae (eared seals, including sea lions
|
|
||||||
and fur seals), and Phocidae (true seals).[3]
|
|
||||||
|
|
||||||
Seals are sleek-bodied and barrel-shaped. Their bodies are well adapted to the
|
|
||||||
aquatic habitat where they spend most of their lives. Pinnipeds have flippers
|
|
||||||
for hands, big bulky bodies, doggish faces, and big eyes. Unlike cetaceans,
|
|
||||||
pinnipeds have their noses on their faces, and each nostril of the nose closes
|
|
||||||
when the pinniped goes underwater. Like cetaceans, pinnipeds have a thick layer
|
|
||||||
of blubber (fat) just under their skin: this blubber keeps them warm in cold
|
|
||||||
waters and keeps them fed during times when food is not easily found. When they
|
|
||||||
cannot find food, they live off the fat in the blubber.
|
|
||||||
|
|
||||||
Pinnipeds are carnivorous. This means they eat only meat (such as fish or
|
|
||||||
squid) and not plants. However, almost all pinnipeds can be eaten by polar
|
|
||||||
bears, sharks and killer whales.
|
|
||||||
|
|
||||||
Seals are often trained in zoos or aquariums to put on shows. However, in
|
|
||||||
Sweden, it is illegal to train a seal to balance a ball on its nose.[4]
|
|
||||||
|
|
||||||
From [Pinniped Wikipedia](https://simple.wikipedia.org/wiki/Pinniped)
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
local fes = require("fes")
|
|
||||||
local site = fes.fes()
|
|
||||||
|
|
||||||
site.copyright = fes.util.copyright("https://fsd.vxserver.dev/", "fSD")
|
|
||||||
|
|
||||||
site:extend("myext", {
|
|
||||||
shout = function(self, str) return self:g(str:upper()) end
|
|
||||||
})
|
|
||||||
|
|
||||||
site.myext:shout("hello world")
|
|
||||||
|
|
||||||
return site
|
|
||||||
|
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 1.8 MiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
4
go.mod
4
go.mod
@@ -11,7 +11,11 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
|
github.com/stretchr/testify v1.11.1 // indirect
|
||||||
golang.org/x/sys v0.25.0 // indirect
|
golang.org/x/sys v0.25.0 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
9
go.sum
9
go.sum
@@ -1,3 +1,5 @@
|
|||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
|
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
|
||||||
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
|
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
|
||||||
github.com/gomarkdown/markdown v0.0.0-20250810172220-2e2c11897d1a h1:l7A0loSszR5zHd/qK53ZIHMO8b3bBSmENnQ6eKnUT0A=
|
github.com/gomarkdown/markdown v0.0.0-20250810172220-2e2c11897d1a h1:l7A0loSszR5zHd/qK53ZIHMO8b3bBSmENnQ6eKnUT0A=
|
||||||
@@ -11,6 +13,10 @@ github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0
|
|||||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
|
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
|
||||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
|
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
|
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
|
||||||
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
|
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
@@ -18,3 +24,6 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
|
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
|
||||||
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||
28
lib/fes.lua
28
lib/fes.lua
@@ -1,5 +1,4 @@
|
|||||||
local std = require("lib.std")
|
local std = require("lib.std")
|
||||||
local symbol = require("lib.symbol")
|
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
M.__index = M
|
M.__index = M
|
||||||
@@ -319,30 +318,11 @@ em, i { font-style: italic; }
|
|||||||
return setmetatable(self, M)
|
return setmetatable(self, M)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:g(str)
|
function M:custom(str)
|
||||||
table.insert(self.parts, str)
|
table.insert(self.parts, str)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:extend(name, tbl)
|
|
||||||
if type(name) ~= "string" then
|
|
||||||
error("First argument to extend must be a string (namespace name)")
|
|
||||||
end
|
|
||||||
if type(tbl) ~= "table" then
|
|
||||||
error("Second argument to extend must be a table of functions")
|
|
||||||
end
|
|
||||||
self[name] = {}
|
|
||||||
for k, v in pairs(tbl) do
|
|
||||||
if type(v) ~= "function" then
|
|
||||||
error("Extension values must be functions, got " .. type(v) .. " for key " .. k)
|
|
||||||
end
|
|
||||||
self[name][k] = function(...)
|
|
||||||
return v(self, ...)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
for name, func in pairs(std) do
|
for name, func in pairs(std) do
|
||||||
if type(func) == "function" then
|
if type(func) == "function" then
|
||||||
M[name] = function(self, ...)
|
M[name] = function(self, ...)
|
||||||
@@ -360,11 +340,9 @@ function M:build()
|
|||||||
header = header:gsub(
|
header = header:gsub(
|
||||||
"{{FAVICON}}",
|
"{{FAVICON}}",
|
||||||
favicon_html
|
favicon_html
|
||||||
or
|
or [[<link rel="icon" href="data:image/svg+xml,<svg xmlns=%%22http://www.w3.org/2000/svg%%22 viewBox=%%220 0 100 100%%22><text y=%%22.9em%%22 font-size=%%2290%%22>🔥</text></svg>">]]
|
||||||
[[<link rel="icon" href="data:image/svg+xml,<svg xmlns=%%22http://www.w3.org/2000/svg%%22 viewBox=%%220 0 100 100%%22><text y=%%22.9em%%22 font-size=%%2290%%22>🔥</text></svg>">]]
|
|
||||||
)
|
)
|
||||||
local footer = self.footer:gsub("{{COPYRIGHT}}",
|
local footer = self.footer:gsub("{{COPYRIGHT}}", self.copyright or "© The Copyright Holder")
|
||||||
self.copyright or symbol.legal.copyright .. "The Copyright Holder")
|
|
||||||
return header .. table.concat(self.parts, "\n") .. footer
|
return header .. table.concat(self.parts, "\n") .. footer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
27
lib/site.lua
27
lib/site.lua
@@ -1,27 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
function M.name()
|
|
||||||
local fes_mod = package.loaded.fes
|
|
||||||
if fes_mod and fes_mod.config and fes_mod.config.site and fes_mod.config.site.name then
|
|
||||||
return fes_mod.config.site.name
|
|
||||||
end
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.version()
|
|
||||||
local fes_mod = package.loaded.fes
|
|
||||||
if fes_mod and fes_mod.config and fes_mod.config.site and fes_mod.config.site.version then
|
|
||||||
return fes_mod.config.site.version
|
|
||||||
end
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.authors()
|
|
||||||
local fes_mod = package.loaded.fes
|
|
||||||
if fes_mod and fes_mod.config and fes_mod.config.site and fes_mod.config.site.authors then
|
|
||||||
return fes_mod.config.site.authors
|
|
||||||
end
|
|
||||||
return {}
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
||||||
159
lib/std.lua
159
lib/std.lua
@@ -1,163 +1,155 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.element(tag, attrs, content)
|
function M.fes_version()
|
||||||
local out = { "<", tag }
|
local fes_mod = package.loaded.fes
|
||||||
|
if fes_mod and fes_mod.config and fes_mod.config.fes and fes_mod.config.fes.version then
|
||||||
if attrs then
|
return fes_mod.config.fes.version
|
||||||
for k, v in pairs(attrs) do
|
|
||||||
if v ~= false and v ~= nil then
|
|
||||||
if v == true then
|
|
||||||
out[#out + 1] = " " .. k
|
|
||||||
else
|
|
||||||
out[#out + 1] = " " .. k .. "=\"" .. tostring(v) .. "\""
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
|
||||||
if content == nil then
|
function M.site_version()
|
||||||
out[#out + 1] = " />"
|
local fes_mod = package.loaded.fes
|
||||||
return table.concat(out)
|
if fes_mod and fes_mod.config and fes_mod.config.site and fes_mod.config.site.version then
|
||||||
|
return fes_mod.config.site.version
|
||||||
end
|
end
|
||||||
|
return ""
|
||||||
out[#out + 1] = ">"
|
|
||||||
out[#out + 1] = tostring(content)
|
|
||||||
out[#out + 1] = "</"
|
|
||||||
out[#out + 1] = tag
|
|
||||||
out[#out + 1] = ">"
|
|
||||||
|
|
||||||
return table.concat(out)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.a(link, str)
|
function M.a(link, str)
|
||||||
link = link or "https://example.com"
|
link = link or "https://example.com"
|
||||||
str = str or link
|
str = str or link
|
||||||
return M.element("a", { href = link }, str)
|
return '<a href="' .. link .. '">' .. str .. "</a>"
|
||||||
end
|
|
||||||
|
|
||||||
function M.download(link, str, downloadName)
|
|
||||||
link = link or "."
|
|
||||||
str = str or link
|
|
||||||
return M.element("a", { href = link, download = downloadName }, str)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.ha(link, str)
|
function M.ha(link, str)
|
||||||
link = link or "https://example.com"
|
link = link or "https://example.com"
|
||||||
str = str or link
|
str = str or link
|
||||||
return M.element("a", { href = link, class = "hidden" }, str)
|
return '<a class="hidden" href="' .. link .. '">' .. str .. "</a>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.external(link, str)
|
function M.external(link, str)
|
||||||
return M.element("a", { href = link, target = "_blank" }, str)
|
return '<a target="_blank" href="' .. link .. '">' .. str .. "</a>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.note(str)
|
function M.note(str)
|
||||||
return M.element("div", { class = "note" }, str)
|
return '<div class="note">' .. str .. "</div>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.muted(str)
|
function M.muted(str)
|
||||||
return M.element("div", { class = "muted" }, str)
|
return '<div class="muted">' .. str .. "</div>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.callout(str)
|
function M.callout(str)
|
||||||
return M.element("div", { class = "callout" }, str)
|
return '<div class="callout">' .. str .. "</div>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.h1(str)
|
function M.h1(str)
|
||||||
return M.element("h1", nil, str or "")
|
return "<h1>" .. (str or "") .. "</h1>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.h2(str)
|
function M.h2(str)
|
||||||
return M.element("h2", nil, str or "")
|
return "<h2>" .. (str or "") .. "</h2>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.h3(str)
|
function M.h3(str)
|
||||||
return M.element("h3", nil, str or "")
|
return "<h3>" .. (str or "") .. "</h3>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.h4(str)
|
function M.h4(str)
|
||||||
return M.element("h4", nil, str or "")
|
return "<h4>" .. (str or "") .. "</h4>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.h5(str)
|
function M.h5(str)
|
||||||
return M.element("h5", nil, str or "")
|
return "<h5>" .. (str or "") .. "</h5>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.h6(str)
|
function M.h6(str)
|
||||||
return M.element("h6", nil, str or "")
|
return "<h6>" .. (str or "") .. "</h6>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.p(str)
|
function M.p(str)
|
||||||
return M.element("p", nil, str or "")
|
return "<p>" .. (str or "") .. "</p>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.pre(str)
|
function M.pre(str)
|
||||||
return M.element("pre", nil, str or "")
|
return "<pre>" .. (str or "") .. "</pre>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.code(str)
|
function M.code(str)
|
||||||
return M.element("pre", nil, M.element("code", nil, str or ""))
|
return "<pre><code>" .. (str or "") .. "</code></pre>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.ul(items)
|
function M.ul(items)
|
||||||
items = items or {}
|
items = items or {}
|
||||||
local out = {}
|
local html = "<ul>"
|
||||||
for _, item in ipairs(items) do
|
for _, item in ipairs(items) do
|
||||||
out[#out + 1] = M.element("li", nil, item)
|
html = html .. "<li>" .. tostring(item) .. "</li>"
|
||||||
end
|
end
|
||||||
return M.element("ul", nil, table.concat(out))
|
html = html .. "</ul>"
|
||||||
|
return html
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.ol(items)
|
function M.ol(items)
|
||||||
items = items or {}
|
items = items or {}
|
||||||
local out = {}
|
local html = "<ol>"
|
||||||
for _, item in ipairs(items) do
|
for _, item in ipairs(items) do
|
||||||
out[#out + 1] = M.element("li", nil, item)
|
html = html .. "<li>" .. tostring(item) .. "</li>"
|
||||||
end
|
end
|
||||||
return M.element("ol", nil, table.concat(out))
|
html = html .. "</ol>"
|
||||||
|
return html
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.tl(items)
|
function M.tl(items)
|
||||||
items = items or {}
|
items = items or {}
|
||||||
local out = {}
|
local html = '<ul class="tl">'
|
||||||
for _, item in ipairs(items) do
|
for _, item in ipairs(items) do
|
||||||
out[#out + 1] = M.element("li", nil, item)
|
html = html .. "<li>" .. tostring(item) .. "</li>"
|
||||||
end
|
end
|
||||||
return M.element("ul", { class = "tl" }, table.concat(out))
|
html = html .. "</ul>"
|
||||||
|
return html
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.blockquote(str)
|
function M.blockquote(str)
|
||||||
return M.element("blockquote", nil, str or "")
|
return "<blockquote>" .. (str or "") .. "</blockquote>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.hr()
|
function M.hr()
|
||||||
return M.element("hr")
|
return "<hr>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.img(src, alt)
|
function M.img(src, alt)
|
||||||
return M.element("img", { src = src or "", alt = alt or "" })
|
src = src or ""
|
||||||
|
alt = alt or ""
|
||||||
|
return '<img src="' .. src .. '" alt="' .. alt .. '">'
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.strong(str)
|
function M.strong(str)
|
||||||
return M.element("strong", nil, str or "")
|
return "<strong>" .. (str or "") .. "</strong>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.em(str)
|
function M.em(str)
|
||||||
return M.element("em", nil, str or "")
|
return "<em>" .. (str or "") .. "</em>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.br()
|
function M.br()
|
||||||
return M.element("br")
|
return "<br>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.div(content, class)
|
function M.div(content, class)
|
||||||
return M.element("div", class and { class = class } or nil, content or "")
|
content = content or ""
|
||||||
|
class = class or ""
|
||||||
|
local class_attr = class ~= "" and (' class="' .. class .. '"') or ""
|
||||||
|
return "<div" .. class_attr .. ">" .. content .. "</div>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.span(content, class)
|
function M.span(content, class)
|
||||||
return M.element("span", class and { class = class } or nil, content or "")
|
content = content or ""
|
||||||
|
class = class or ""
|
||||||
|
local class_attr = class ~= "" and (' class="' .. class .. '"') or ""
|
||||||
|
return "<span" .. class_attr .. ">" .. content .. "</span>"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- HTML escaping utility
|
||||||
function M.escape(str)
|
function M.escape(str)
|
||||||
str = tostring(str or "")
|
str = tostring(str or "")
|
||||||
str = str:gsub("&", "&")
|
str = str:gsub("&", "&")
|
||||||
@@ -168,28 +160,55 @@ function M.escape(str)
|
|||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Get site name from config
|
||||||
|
function M.site_name()
|
||||||
|
local fes_mod = package.loaded.fes
|
||||||
|
if fes_mod and fes_mod.config and fes_mod.config.site and fes_mod.config.site.name then
|
||||||
|
return fes_mod.config.site.name
|
||||||
|
end
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get site title from config
|
||||||
|
function M.site_title()
|
||||||
|
local fes_mod = package.loaded.fes
|
||||||
|
if fes_mod and fes_mod.config and fes_mod.config.site and fes_mod.config.site.title then
|
||||||
|
return fes_mod.config.site.title
|
||||||
|
end
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get site authors from config
|
||||||
|
function M.site_authors()
|
||||||
|
local fes_mod = package.loaded.fes
|
||||||
|
if fes_mod and fes_mod.config and fes_mod.config.site and fes_mod.config.site.authors then
|
||||||
|
return fes_mod.config.site.authors
|
||||||
|
end
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
function M.highlight(str)
|
function M.highlight(str)
|
||||||
return M.element("span", { class = "highlight" }, str or "")
|
return '<span class="highlight">' .. (str or "") .. "</span>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.banner(str)
|
function M.banner(str)
|
||||||
return M.element("div", { class = "banner" }, str or "")
|
return '<div class="banner">' .. (str or "") .. "</div>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.center(str)
|
function M.center(str)
|
||||||
return M.element("div", { class = "center" }, str or "")
|
return '<div class="center">' .. (str or "") .. "</div>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.nav(link, str)
|
function M.nav(link, str)
|
||||||
link = link or "example.com"
|
link = link or "example.com"
|
||||||
str = str or link
|
str = str or link
|
||||||
return M.element("a", { href = link, class = "nav" }, str)
|
return '<a class="nav" href="' .. link .. '">' .. str .. "</a>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.rl(r, l)
|
function M.rl(r, l)
|
||||||
return
|
r = r or ""
|
||||||
M.element("span", { class = "left" }, r or "") ..
|
l = l or ""
|
||||||
M.element("span", { class = "right" }, l or "")
|
return string.format('<span class="left">%s</span><span class="right">%s</span>', r, l)
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
@@ -1,75 +1,7 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local function get(s)
|
M.copyright = "©"
|
||||||
return "&" .. (s or "") .. ";"
|
M.registered_trademark = "®"
|
||||||
end
|
M.trademark = "™"
|
||||||
|
|
||||||
M.legal = {
|
|
||||||
copyright = get("copy"),
|
|
||||||
registered_trademark = get("reg"),
|
|
||||||
trademark = get("trade"),
|
|
||||||
}
|
|
||||||
|
|
||||||
M.currency = {
|
|
||||||
euro = get("euro"),
|
|
||||||
pound = get("pound"),
|
|
||||||
yen = get("yen"),
|
|
||||||
cent = get("cent"),
|
|
||||||
dollar = "$",
|
|
||||||
}
|
|
||||||
|
|
||||||
M.math = {
|
|
||||||
plus_minus = get("plusmn"),
|
|
||||||
multiply = get("times"),
|
|
||||||
divide = get("divide"),
|
|
||||||
not_equal = get("ne"),
|
|
||||||
less_equal = get("le"),
|
|
||||||
greater_equal = get("ge"),
|
|
||||||
infinity = get("infin"),
|
|
||||||
approx = get("asymp"),
|
|
||||||
}
|
|
||||||
|
|
||||||
M.arrows = {
|
|
||||||
left = get("larr"),
|
|
||||||
right = get("rarr"),
|
|
||||||
up = get("uarr"),
|
|
||||||
down = get("darr"),
|
|
||||||
left_right = get("harr"),
|
|
||||||
}
|
|
||||||
|
|
||||||
M.punctuation = {
|
|
||||||
left_double_quote = get("ldquo"),
|
|
||||||
right_double_quote = get("rdquo"),
|
|
||||||
left_single_quote = get("lsquo"),
|
|
||||||
right_single_quote = get("rsquo"),
|
|
||||||
ellipsis = get("hellip"),
|
|
||||||
em_dash = get("mdash"),
|
|
||||||
en_dash = get("ndash"),
|
|
||||||
}
|
|
||||||
|
|
||||||
M.whitespace = {
|
|
||||||
non_breaking = get("nbsp"),
|
|
||||||
thin = get("thinsp"),
|
|
||||||
}
|
|
||||||
|
|
||||||
M.symbols = {
|
|
||||||
degree = get("deg"),
|
|
||||||
micro = get("micro"),
|
|
||||||
section = get("sect"),
|
|
||||||
paragraph = get("para"),
|
|
||||||
check = get("check"),
|
|
||||||
cross = get("cross"),
|
|
||||||
bullet = get("bull"),
|
|
||||||
middle_dot = get("middot"),
|
|
||||||
broken_bar = get("brvbar"),
|
|
||||||
}
|
|
||||||
|
|
||||||
M.html = {
|
|
||||||
less_than = get("lt"),
|
|
||||||
greater_than = get("gt"),
|
|
||||||
ampersand = get("amp"),
|
|
||||||
double_quote = get("quot"),
|
|
||||||
single_quote = get("apos"),
|
|
||||||
}
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
27
lib/util.lua
27
lib/util.lua
@@ -3,33 +3,12 @@ local symbol = require("lib.symbol")
|
|||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.cc(tbl, sep)
|
function M.cc(tbl)
|
||||||
return table.concat(tbl, sep or "")
|
return table.concat(tbl)
|
||||||
end
|
|
||||||
|
|
||||||
function M.year(y)
|
|
||||||
return y or os.date("%Y")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.copyright(link, holder)
|
function M.copyright(link, holder)
|
||||||
return symbol.legal.copyright .. " " .. std.external(link, holder)
|
return symbol.copyright .. " " .. std.external(link, holder)
|
||||||
end
|
|
||||||
|
|
||||||
function M.license(name)
|
|
||||||
return symbol.legal.registered .. " " .. name
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.ls(dir)
|
|
||||||
local p = io.popen('ls -A -1 -- ' .. string.format('%q', dir))
|
|
||||||
if not p then
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
local t = {}
|
|
||||||
for line in p:lines() do
|
|
||||||
t[#t + 1] = line
|
|
||||||
end
|
|
||||||
p:close()
|
|
||||||
return t
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
28
main.go
28
main.go
@@ -6,7 +6,6 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
|
|
||||||
@@ -14,7 +13,6 @@ import (
|
|||||||
"fes/modules/doc"
|
"fes/modules/doc"
|
||||||
"fes/modules/new"
|
"fes/modules/new"
|
||||||
"fes/modules/server"
|
"fes/modules/server"
|
||||||
"fes/modules/ui"
|
|
||||||
"fes/modules/version"
|
"fes/modules/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -31,21 +29,18 @@ func init() {
|
|||||||
config.Docker = flag.Bool("docker", false, "Create a docker project")
|
config.Docker = flag.Bool("docker", false, "Create a docker project")
|
||||||
config.Lib = lib
|
config.Lib = lib
|
||||||
config.Doc = documentation
|
config.Doc = documentation
|
||||||
config.Verbose = flag.Bool("verbose", false, "Enable verbose logging")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var m runtime.MemStats
|
|
||||||
|
|
||||||
flag.Usage = func() {
|
flag.Usage = func() {
|
||||||
fmt.Fprintf(flag.CommandLine.Output(), "Usage: %s [options] <command> <project_dir>\n", os.Args[0])
|
fmt.Fprintf(flag.CommandLine.Output(), "Usage: %s [options] <command> <project_dir>\n", os.Args[0])
|
||||||
fmt.Fprintln(flag.CommandLine.Output(), "Commands:")
|
fmt.Fprintf(os.Stderr, "Commands:")
|
||||||
fmt.Fprintln(flag.CommandLine.Output(), " new <project_dir> Create a new project")
|
fmt.Fprintf(os.Stderr, " new <project_dir> Create a new project")
|
||||||
fmt.Fprintln(flag.CommandLine.Output(), " doc Open documentation")
|
fmt.Fprintf(os.Stderr, " doc Open documentation")
|
||||||
fmt.Fprintln(flag.CommandLine.Output(), " run <project_dir> Start the server")
|
fmt.Fprintf(os.Stderr, " run <project_dir> Start the server")
|
||||||
fmt.Fprintln(flag.CommandLine.Output(), "Options:")
|
fmt.Fprintf(os.Stderr, "Options:")
|
||||||
flag.PrintDefaults()
|
flag.PrintDefaults()
|
||||||
fmt.Fprintln(flag.CommandLine.Output(), "For bug reports, contact a developer and describe the issue. Provide the output of the `-V1` flag.")
|
fmt.Fprintf(os.Stderr, "For bug reports, contact a developer and describe the issue. Provide the output of the `-V1` flag.")
|
||||||
}
|
}
|
||||||
|
|
||||||
showVersion := flag.Bool("version", false, "Show version and exit")
|
showVersion := flag.Bool("version", false, "Show version and exit")
|
||||||
@@ -94,16 +89,7 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
case "run":
|
case "run":
|
||||||
if *config.Port == 3000 {
|
if _, err := server.Start(dir); err != nil {
|
||||||
ui.WARNING("Using default port, this may lead to conflicts with other services")
|
|
||||||
}
|
|
||||||
ui.Log("Fes is starting")
|
|
||||||
ui.Log("Fes version=%s, commit=%s, just started", version.VERSION, version.GetCommit())
|
|
||||||
|
|
||||||
runtime.ReadMemStats(&m)
|
|
||||||
ui.Log("FRE memory usage when created %v Mb", m.TotalAlloc/1024/1024)
|
|
||||||
|
|
||||||
if err := server.Start(dir); err != nil {
|
|
||||||
if errors.Is(err, os.ErrNotExist) {
|
if errors.Is(err, os.ErrNotExist) {
|
||||||
fmt.Fprintf(os.Stderr, "%s does not exist\n", dir)
|
fmt.Fprintf(os.Stderr, "%s does not exist\n", dir)
|
||||||
fmt.Fprintf(os.Stderr, "Try: fes new %s\n", dir)
|
fmt.Fprintf(os.Stderr, "Try: fes new %s\n", dir)
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ var Port *int
|
|||||||
var Color *bool
|
var Color *bool
|
||||||
var Static *bool
|
var Static *bool
|
||||||
var Docker *bool
|
var Docker *bool
|
||||||
var Verbose *bool
|
|
||||||
|
|
||||||
type AppConfig struct {
|
type AppConfig struct {
|
||||||
App struct {
|
App struct {
|
||||||
|
|||||||
@@ -118,12 +118,11 @@ Check out [Fes's docs](https://docs.vxserver.dev/static/fes.html).`, "$$", "`"),
|
|||||||
|
|
||||||
ui.Hint("you can run this with `fes run %s`", dir)
|
ui.Hint("you can run this with `fes run %s`", dir)
|
||||||
|
|
||||||
fmt.Println("Created new Fes project at", func () string {
|
fmt.Println("Created new Fes project at", func() string {
|
||||||
if cwd, err := os.Getwd(); err != nil {
|
if res, err := filepath.Abs(dir); err == nil {
|
||||||
return dir
|
return res
|
||||||
} else {
|
|
||||||
return cwd
|
|
||||||
}
|
}
|
||||||
|
return dir
|
||||||
}())
|
}())
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"context"
|
||||||
"fes/modules/config"
|
"fes/modules/config"
|
||||||
"fes/modules/ui"
|
"fes/modules/ui"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -286,25 +286,23 @@ func generateArchiveIndex(fsPath string, urlPath string) (string, error) {
|
|||||||
urlPath = basePath(strings.TrimPrefix(urlPath, "/archive"))
|
urlPath = basePath(strings.TrimPrefix(urlPath, "/archive"))
|
||||||
|
|
||||||
var b strings.Builder
|
var b strings.Builder
|
||||||
|
|
||||||
b.WriteString("<html>\n<head><title>Index of ")
|
b.WriteString("<html>\n<head><title>Index of ")
|
||||||
b.WriteString(template.HTMLEscapeString(urlPath))
|
b.WriteString(template.HTMLEscapeString(urlPath))
|
||||||
b.WriteString("</title></head>\n<body>\n<h1>Index of ")
|
b.WriteString("</title></head>\n<body>\n<h1>Index of ")
|
||||||
b.WriteString(template.HTMLEscapeString(urlPath))
|
b.WriteString(template.HTMLEscapeString(urlPath))
|
||||||
b.WriteString("</h1><hr><pre>")
|
b.WriteString("</h1><hr><pre>")
|
||||||
|
if urlPath != "/archive" && urlPath != "/archive/" {
|
||||||
if urlPath != "/" {
|
up := path.Dir(urlPath)
|
||||||
b.WriteString(
|
if up == "." {
|
||||||
`<a href="/archive` +
|
up = "/archive"
|
||||||
template.HTMLEscapeString(path.Dir(strings.TrimSuffix(urlPath, "/"))) +
|
}
|
||||||
`">../</a>` + "\n",
|
if !strings.HasSuffix(up, "/") {
|
||||||
)
|
up = "/archive" + filepath.Dir(up) + "/"
|
||||||
|
}
|
||||||
|
b.WriteString(`<a href="` + template.HTMLEscapeString(up) + `">../</a>` + "\n")
|
||||||
} else {
|
} else {
|
||||||
b.WriteString(
|
b.WriteString(`<a href="../">../</a>` + "\n")
|
||||||
`<a href="/">../</a>` + "\n",
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nameCol := 50
|
nameCol := 50
|
||||||
for _, ei := range list {
|
for _, ei := range list {
|
||||||
escapedName := template.HTMLEscapeString(ei.name)
|
escapedName := template.HTMLEscapeString(ei.name)
|
||||||
@@ -382,26 +380,18 @@ func loadDirs() map[string]string {
|
|||||||
|
|
||||||
/* helper to parse the Fes.toml and generate config */
|
/* helper to parse the Fes.toml and generate config */
|
||||||
func parseConfig() config.AppConfig {
|
func parseConfig() config.AppConfig {
|
||||||
defaultCfg := config.AppConfig{}
|
|
||||||
defaultCfg.App.Authors = []string{"unknown"}
|
|
||||||
defaultCfg.App.Name = "unknown"
|
|
||||||
defaultCfg.App.Version = "unknown"
|
|
||||||
|
|
||||||
tomlDocument, err := os.ReadFile("Fes.toml")
|
tomlDocument, err := os.ReadFile("Fes.toml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, os.ErrNotExist) {
|
ui.Error("failed to read Fes.toml", err)
|
||||||
ui.WARN("no config file found, using the default config. In order to specify a config file write to Fes.toml")
|
os.Exit(1)
|
||||||
return defaultCfg
|
|
||||||
} else {
|
|
||||||
ui.Error("failed to read Fes.toml", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
docStr := fixMalformedToml(string(tomlDocument))
|
docStr := fixMalformedToml(string(tomlDocument))
|
||||||
var cfg config.AppConfig
|
var cfg config.AppConfig
|
||||||
if err := toml.Unmarshal([]byte(docStr), &cfg); err != nil {
|
if err := toml.Unmarshal([]byte(docStr), &cfg); err != nil {
|
||||||
ui.Warning("failed to parse Fes.toml", err)
|
ui.Warning("failed to parse Fes.toml", err)
|
||||||
cfg = defaultCfg
|
cfg.App.Authors = []string{"unknown"}
|
||||||
|
cfg.App.Name = "unknown"
|
||||||
|
cfg.App.Version = "unknown"
|
||||||
}
|
}
|
||||||
return cfg
|
return cfg
|
||||||
}
|
}
|
||||||
@@ -421,12 +411,14 @@ func readArchive(w http.ResponseWriter, route string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* start the Fes server */
|
/* start the Fes server */
|
||||||
func Start(dir string) error {
|
func Start(dir string) (*http.Server, error) {
|
||||||
if err := os.Chdir(dir); err != nil {
|
if _, err := os.Stat(dir); os.IsNotExist(err) {
|
||||||
return ui.Error(fmt.Sprintf("failed to change directory to %s", dir), err)
|
return nil, fmt.Errorf("directory does not exist: %s", dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.Log("Running root=%s, port=%d.", filepath.Clean(dir), *config.Port)
|
if err := os.Chdir(dir); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to change directory to %s: %w", dir, err)
|
||||||
|
}
|
||||||
|
|
||||||
cfg := parseConfig()
|
cfg := parseConfig()
|
||||||
notFoundData := generateNotFoundData(&cfg)
|
notFoundData := generateNotFoundData(&cfg)
|
||||||
@@ -479,8 +471,24 @@ func Start(dir string) error {
|
|||||||
|
|
||||||
w.Write(data)
|
w.Write(data)
|
||||||
})
|
})
|
||||||
ui.Log("Server initialized")
|
|
||||||
|
|
||||||
ui.Log("Ready to accept connections tcp")
|
fmt.Printf("Server is running on http://localhost:%d\n", *config.Port)
|
||||||
return http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", *config.Port), nil)
|
|
||||||
|
srv := &http.Server{
|
||||||
|
Addr: fmt.Sprintf("0.0.0.0:%d", *config.Port),
|
||||||
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||||
|
ui.Error("Server failed: %v", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
return srv, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Stop(srv *http.Server) error {
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
return srv.Shutdown(ctx)
|
||||||
}
|
}
|
||||||
|
|||||||
1093
modules/server/server_test.go
Normal file
1093
modules/server/server_test.go
Normal file
File diff suppressed because it is too large
Load Diff
119
modules/ui/ui.go
119
modules/ui/ui.go
@@ -4,114 +4,75 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"fes/modules/config"
|
"fes/modules/config"
|
||||||
|
"fes/modules/version"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
hintColor = 0xbda02a
|
hint_color = 0xbda02a
|
||||||
)
|
)
|
||||||
|
|
||||||
func formatTimestamp() string {
|
/* print out the current path (route) and relevant error */
|
||||||
return time.Now().Format("02 Jan 2006 15:04")
|
func Path(path string, err error) {
|
||||||
}
|
path = strings.TrimPrefix(path, "/")
|
||||||
|
|
||||||
func logMessage(prefix string, msg string, args ...any) {
|
if path == "" {
|
||||||
formatted := fmt.Sprintf(msg, args...)
|
path = "(null)"
|
||||||
if prefix == "" {
|
}
|
||||||
fmt.Printf("%s * %s\n", formatTimestamp(), formatted)
|
|
||||||
|
fmt.Printf(" > %s ", path)
|
||||||
|
if err == nil {
|
||||||
|
OK("ok")
|
||||||
|
return
|
||||||
|
} else if errors.Is(err, config.ErrRouteMiss) {
|
||||||
|
WARN(config.ErrRouteMiss.Error())
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("%s * %s: %s\n", formatTimestamp(), prefix, formatted)
|
ERROR("bad")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generic log
|
/* print general system warning */
|
||||||
func Log(msg string, args ...any) {
|
func Warning(msg string, err error) error {
|
||||||
logMessage("", msg, args...)
|
fmt.Printf("%s: %s: %v\n", version.PROGRAM_NAME, color.MagentaString("warning"), err)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// OK message (green)
|
/* print general system error */
|
||||||
func OK(msg string, args ...any) {
|
func Error(msg string, err error) error {
|
||||||
formatted := fmt.Sprintf(msg, args...)
|
fmt.Printf("%s: %s: %v\n", version.PROGRAM_NAME, color.RedString("error"), err)
|
||||||
color.Green("%s * %s\n", formatTimestamp(), formatted)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warning message (magenta)
|
/* print fatality and panic */
|
||||||
func WARN(msg string, args ...any) {
|
func Fatal(msg string, err error) error {
|
||||||
formatted := fmt.Sprintf(msg, args...)
|
fmt.Printf("%s: %s: %v\n", version.PROGRAM_NAME, color.RedString("fatal"), err)
|
||||||
color.Magenta("%s # %s\n", formatTimestamp(), formatted)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warning message (magenta)
|
/* print a useful hint to the user */
|
||||||
func WARNING(msg string, args ...any) {
|
func Hint(format string, args ...any) {
|
||||||
formatted := fmt.Sprintf(msg, args...)
|
|
||||||
color.Magenta("%s # WARNING %s\n", formatTimestamp(), formatted)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Error message (red)
|
|
||||||
func ERROR(msg string, args ...any) {
|
|
||||||
formatted := fmt.Sprintf(msg, args...)
|
|
||||||
color.Red("%s ! %s\n", formatTimestamp(), formatted)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fatal message and panic
|
|
||||||
func FATAL(msg string, args ...any) {
|
|
||||||
formatted := fmt.Sprintf(msg, args...)
|
|
||||||
color.Red("%s % %s\n", formatTimestamp(), formatted)
|
|
||||||
panic(formatted)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hint message (custom color)
|
|
||||||
func Hint(msg string, args ...any) {
|
|
||||||
formatted := fmt.Sprintf(msg, args...)
|
|
||||||
color.RGB(func(hex int) (r, g, b int) {
|
color.RGB(func(hex int) (r, g, b int) {
|
||||||
r = (hex >> 16) & 0xFF
|
r = (hex >> 16) & 0xFF
|
||||||
g = (hex >> 8) & 0xFF
|
g = (hex >> 8) & 0xFF
|
||||||
b = hex & 0xFF
|
b = hex & 0xFF
|
||||||
return
|
return
|
||||||
}(hintColor)).Printf("hint: %s\n", formatted)
|
}(hint_color)).Printf("hint: %s\n", fmt.Sprintf(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Path logging: prints route and status
|
/* print message using the ok status color */
|
||||||
func Path(path string, err error) {
|
func OK(msg string) {
|
||||||
path = strings.TrimPrefix(path, "/")
|
color.Green(msg)
|
||||||
if path == "" {
|
|
||||||
path = "(null)"
|
|
||||||
}
|
|
||||||
|
|
||||||
if err == nil {
|
|
||||||
OK("Route: %s - ok", path)
|
|
||||||
} else if errors.Is(err, config.ErrRouteMiss) {
|
|
||||||
WARN("Route: %s - %s", path, config.ErrRouteMiss.Error())
|
|
||||||
} else {
|
|
||||||
ERROR("Route: %s - bad", path)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// System warning with prefix
|
/* print message using the warning status color */
|
||||||
func Warning(msg string, err error) error {
|
func WARN(msg string) {
|
||||||
WARN("%s: %v", msg, err)
|
color.Magenta(msg)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// System error with prefix
|
/* print message using the error status color */
|
||||||
func Error(msg string, err error) error {
|
func ERROR(msg string) {
|
||||||
ERROR("%s: %v", msg, err)
|
color.Red(msg)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fatal system error
|
|
||||||
func Fatal(msg string, err error) error {
|
|
||||||
FATAL("%s: %v", msg, err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Log on Verbose
|
|
||||||
func LogVerbose(msg string, args ...any) {
|
|
||||||
if *config.Verbose {
|
|
||||||
Log(msg, args...)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ var gitCommit string = "devel"
|
|||||||
|
|
||||||
const PROGRAM_NAME string = "fes"
|
const PROGRAM_NAME string = "fes"
|
||||||
const PROGRAM_NAME_LONG string = "fes/fSD"
|
const PROGRAM_NAME_LONG string = "fes/fSD"
|
||||||
const VERSION string = "0.3.1"
|
const VERSION string = "beta"
|
||||||
|
|
||||||
func Version() {
|
func Version() {
|
||||||
fmt.Printf("%s version %s\n", PROGRAM_NAME_LONG, VERSION)
|
fmt.Printf("%s version %s\n", PROGRAM_NAME_LONG, VERSION)
|
||||||
@@ -20,7 +20,3 @@ func FullVersion() {
|
|||||||
fmt.Printf("%s+%s\n", VERSION, gitCommit)
|
fmt.Printf("%s+%s\n", VERSION, gitCommit)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetCommit() string {
|
|
||||||
return gitCommit
|
|
||||||
}
|
|
||||||
|
|||||||
5
test/files/archive/Fes.toml
Normal file
5
test/files/archive/Fes.toml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
[app]
|
||||||
|
|
||||||
|
name = "archive"
|
||||||
|
version = "0.0.1"
|
||||||
|
authors = ["fSD"]
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
# extentions
|
# archive
|
||||||
|
|
||||||
```
|
```
|
||||||
fes new extentions
|
fes new archive
|
||||||
```
|
```
|
||||||
|
|
||||||
> **Know what you are doing?** Delete this file. Have fun!
|
> **Know what you are doing?** Delete this file. Have fun!
|
||||||
BIN
test/files/archive/archive/seal.png
Normal file
BIN
test/files/archive/archive/seal.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 MiB |
8
test/files/archive/www/index.lua
Normal file
8
test/files/archive/www/index.lua
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
local fes = require("fes")
|
||||||
|
local site = fes.fes()
|
||||||
|
|
||||||
|
-- site.copyright = fes.util.copyright("https://example.com", "vx-clutch")
|
||||||
|
|
||||||
|
site:h1("Hello, World!")
|
||||||
|
|
||||||
|
return site
|
||||||
5
test/files/lua-basic/Fes.toml
Normal file
5
test/files/lua-basic/Fes.toml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
[app]
|
||||||
|
|
||||||
|
name = "lua-basic"
|
||||||
|
version = "0.0.1"
|
||||||
|
authors = ["fSD"]
|
||||||
33
test/files/lua-basic/README.md
Normal file
33
test/files/lua-basic/README.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# lua-basic
|
||||||
|
|
||||||
|
```
|
||||||
|
fes new lua-basic
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Know what you are doing?** Delete this file. Have fun!
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
|
||||||
|
Inside your Fes project, you'll see the following directories and files:
|
||||||
|
|
||||||
|
```
|
||||||
|
.
|
||||||
|
├── Fes.toml
|
||||||
|
├── README.md
|
||||||
|
└── www
|
||||||
|
└── index.lua
|
||||||
|
```
|
||||||
|
|
||||||
|
Fes looks for `.lua` files in the `www/` directory. Each file is exposed as a route based on its file name.
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
All commands are run from the root of the project, from a terminal:
|
||||||
|
|
||||||
|
| Command | Action |
|
||||||
|
| :------------------------ | :----------------------------------------------- |
|
||||||
|
| `fes run .` | Runs the project at `.` |
|
||||||
|
|
||||||
|
## What to learn more?
|
||||||
|
|
||||||
|
Check out [Fes's docs](https://docs.vxserver.dev/static/fes.html).
|
||||||
8
test/files/lua-basic/www/index.lua
Normal file
8
test/files/lua-basic/www/index.lua
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
local fes = require("fes")
|
||||||
|
local site = fes.fes()
|
||||||
|
|
||||||
|
-- site.copyright = fes.util.copyright("https://example.com", "vx-clutch")
|
||||||
|
|
||||||
|
site:h1("Hello, World!")
|
||||||
|
|
||||||
|
return site
|
||||||
5
test/files/lua-error/Fes.toml
Normal file
5
test/files/lua-error/Fes.toml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
[app]
|
||||||
|
|
||||||
|
name = "lua-error"
|
||||||
|
version = "0.0.1"
|
||||||
|
authors = ["fSD"]
|
||||||
33
test/files/lua-error/README.md
Normal file
33
test/files/lua-error/README.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# lua-error
|
||||||
|
|
||||||
|
```
|
||||||
|
fes new lua-error
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Know what you are doing?** Delete this file. Have fun!
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
|
||||||
|
Inside your Fes project, you'll see the following directories and files:
|
||||||
|
|
||||||
|
```
|
||||||
|
.
|
||||||
|
├── Fes.toml
|
||||||
|
├── README.md
|
||||||
|
└── www
|
||||||
|
└── index.lua
|
||||||
|
```
|
||||||
|
|
||||||
|
Fes looks for `.lua` files in the `www/` directory. Each file is exposed as a route based on its file name.
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
All commands are run from the root of the project, from a terminal:
|
||||||
|
|
||||||
|
| Command | Action |
|
||||||
|
| :------------------------ | :----------------------------------------------- |
|
||||||
|
| `fes run .` | Runs the project at `.` |
|
||||||
|
|
||||||
|
## What to learn more?
|
||||||
|
|
||||||
|
Check out [Fes's docs](https://docs.vxserver.dev/static/fes.html).
|
||||||
6
test/files/lua-error/www/index.lua
Normal file
6
test/files/lua-error/www/index.lua
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
local fes = require("fes")
|
||||||
|
local site = fes.fes()
|
||||||
|
|
||||||
|
Hello, World!
|
||||||
|
|
||||||
|
return site
|
||||||
5
test/files/lua-include/Fes.toml
Normal file
5
test/files/lua-include/Fes.toml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
[app]
|
||||||
|
|
||||||
|
name = "lua-include"
|
||||||
|
version = "0.0.1"
|
||||||
|
authors = ["fSD"]
|
||||||
33
test/files/lua-include/README.md
Normal file
33
test/files/lua-include/README.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# lua-include
|
||||||
|
|
||||||
|
```
|
||||||
|
fes new lua-include
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Know what you are doing?** Delete this file. Have fun!
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
|
||||||
|
Inside your Fes project, you'll see the following directories and files:
|
||||||
|
|
||||||
|
```
|
||||||
|
.
|
||||||
|
├── Fes.toml
|
||||||
|
├── README.md
|
||||||
|
└── www
|
||||||
|
└── index.lua
|
||||||
|
```
|
||||||
|
|
||||||
|
Fes looks for `.lua` files in the `www/` directory. Each file is exposed as a route based on its file name.
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
All commands are run from the root of the project, from a terminal:
|
||||||
|
|
||||||
|
| Command | Action |
|
||||||
|
| :------------------------ | :----------------------------------------------- |
|
||||||
|
| `fes run .` | Runs the project at `.` |
|
||||||
|
|
||||||
|
## What to learn more?
|
||||||
|
|
||||||
|
Check out [Fes's docs](https://docs.vxserver.dev/static/fes.html).
|
||||||
7
test/files/lua-include/include/test.lua
Normal file
7
test/files/lua-include/include/test.lua
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
local test = {}
|
||||||
|
|
||||||
|
test.render = function(std)
|
||||||
|
return std.h2("Hello, World!")
|
||||||
|
end
|
||||||
|
|
||||||
|
return test
|
||||||
10
test/files/lua-include/www/index.lua
Normal file
10
test/files/lua-include/www/index.lua
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
local fes = require("fes")
|
||||||
|
local site = fes.fes()
|
||||||
|
|
||||||
|
-- site.copyright = fes.util.copyright("https://example.com", "vx-clutch")
|
||||||
|
|
||||||
|
site:h1("Hello, World!")
|
||||||
|
|
||||||
|
site:note(fes.app.test.render(fes.std))
|
||||||
|
|
||||||
|
return site
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
[app]
|
[app]
|
||||||
|
|
||||||
name = "extentions"
|
name = "markdown"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = ["vx-clutch"]
|
authors = ["vx-clutch"]
|
||||||
33
test/files/markdown/README.md
Normal file
33
test/files/markdown/README.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# markdown
|
||||||
|
|
||||||
|
```
|
||||||
|
fes new markdown
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Know what you are doing?** Delete this file. Have fun!
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
|
||||||
|
Inside your Fes project, you'll see the following directories and files:
|
||||||
|
|
||||||
|
```
|
||||||
|
.
|
||||||
|
├── Fes.toml
|
||||||
|
├── README.md
|
||||||
|
└── www
|
||||||
|
└── index.lua
|
||||||
|
```
|
||||||
|
|
||||||
|
Fes looks for `.lua` files in the `www/` directory. Each file is exposed as a route based on its file name.
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
All commands are run from the root of the project, from a terminal:
|
||||||
|
|
||||||
|
| Command | Action |
|
||||||
|
| :------------------------ | :----------------------------------------------- |
|
||||||
|
| `fes run .` | Runs the project at `.` |
|
||||||
|
|
||||||
|
## What to learn more?
|
||||||
|
|
||||||
|
Check out [Fes's docs](https://docs.vxserver.dev/static/fes.html).
|
||||||
310
test/files/markdown/www/index.md
Normal file
310
test/files/markdown/www/index.md
Normal file
@@ -0,0 +1,310 @@
|
|||||||
|
# Markdown: Syntax
|
||||||
|
|
||||||
|
* [Overview](#overview)
|
||||||
|
* [Philosophy](#philosophy)
|
||||||
|
* [Inline HTML](#html)
|
||||||
|
* [Automatic Escaping for Special Characters](#autoescape)
|
||||||
|
* [Block Elements](#block)
|
||||||
|
* [Paragraphs and Line Breaks](#p)
|
||||||
|
* [Headers](#header)
|
||||||
|
* [Blockquotes](#blockquote)
|
||||||
|
* [Lists](#list)
|
||||||
|
* [Code Blocks](#precode)
|
||||||
|
* [Horizontal Rules](#hr)
|
||||||
|
* [Span Elements](#span)
|
||||||
|
* [Links](#link)
|
||||||
|
* [Emphasis](#em)
|
||||||
|
* [Code](#code)
|
||||||
|
* [Images](#img)
|
||||||
|
* [Miscellaneous](#misc)
|
||||||
|
* [Backslash Escapes](#backslash)
|
||||||
|
* [Automatic Links](#autolink)
|
||||||
|
|
||||||
|
|
||||||
|
**Note:** This document is itself written using Markdown; you
|
||||||
|
can [see the source for it by adding '.text' to the URL](/projects/markdown/syntax.text).
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
### Philosophy
|
||||||
|
|
||||||
|
Markdown is intended to be as easy-to-read and easy-to-write as is feasible.
|
||||||
|
|
||||||
|
Readability, however, is emphasized above all else. A Markdown-formatted
|
||||||
|
document should be publishable as-is, as plain text, without looking
|
||||||
|
like it's been marked up with tags or formatting instructions. While
|
||||||
|
Markdown's syntax has been influenced by several existing text-to-HTML
|
||||||
|
filters -- including [Setext](http://docutils.sourceforge.net/mirror/setext.html), [atx](http://www.aaronsw.com/2002/atx/), [Textile](http://textism.com/tools/textile/), [reStructuredText](http://docutils.sourceforge.net/rst.html),
|
||||||
|
[Grutatext](http://www.triptico.com/software/grutatxt.html), and [EtText](http://ettext.taint.org/doc/) -- the single biggest source of
|
||||||
|
inspiration for Markdown's syntax is the format of plain text email.
|
||||||
|
|
||||||
|
## Block Elements
|
||||||
|
|
||||||
|
### Paragraphs and Line Breaks
|
||||||
|
|
||||||
|
A paragraph is simply one or more consecutive lines of text, separated
|
||||||
|
by one or more blank lines. (A blank line is any line that looks like a
|
||||||
|
blank line -- a line containing nothing but spaces or tabs is considered
|
||||||
|
blank.) Normal paragraphs should not be indented with spaces or tabs.
|
||||||
|
|
||||||
|
The implication of the "one or more consecutive lines of text" rule is
|
||||||
|
that Markdown supports "hard-wrapped" text paragraphs. This differs
|
||||||
|
significantly from most other text-to-HTML formatters (including Movable
|
||||||
|
Type's "Convert Line Breaks" option) which translate every line break
|
||||||
|
character in a paragraph into a `<br />` tag.
|
||||||
|
|
||||||
|
When you *do* want to insert a `<br />` break tag using Markdown, you
|
||||||
|
end a line with two or more spaces, then type return.
|
||||||
|
|
||||||
|
### Headers
|
||||||
|
|
||||||
|
Markdown supports two styles of headers, [Setext] [1] and [atx] [2].
|
||||||
|
|
||||||
|
Optionally, you may "close" atx-style headers. This is purely
|
||||||
|
cosmetic -- you can use this if you think it looks better. The
|
||||||
|
closing hashes don't even need to match the number of hashes
|
||||||
|
used to open the header. (The number of opening hashes
|
||||||
|
determines the header level.)
|
||||||
|
|
||||||
|
|
||||||
|
### Blockquotes
|
||||||
|
|
||||||
|
Markdown uses email-style `>` characters for blockquoting. If you're
|
||||||
|
familiar with quoting passages of text in an email message, then you
|
||||||
|
know how to create a blockquote in Markdown. It looks best if you hard
|
||||||
|
wrap the text and put a `>` before every line:
|
||||||
|
|
||||||
|
> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
|
||||||
|
> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
|
||||||
|
> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
|
||||||
|
>
|
||||||
|
> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
|
||||||
|
> id sem consectetuer libero luctus adipiscing.
|
||||||
|
|
||||||
|
Markdown allows you to be lazy and only put the `>` before the first
|
||||||
|
line of a hard-wrapped paragraph:
|
||||||
|
|
||||||
|
> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
|
||||||
|
consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
|
||||||
|
Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
|
||||||
|
|
||||||
|
> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
|
||||||
|
id sem consectetuer libero luctus adipiscing.
|
||||||
|
|
||||||
|
Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by
|
||||||
|
adding additional levels of `>`:
|
||||||
|
|
||||||
|
> This is the first level of quoting.
|
||||||
|
>
|
||||||
|
> > This is nested blockquote.
|
||||||
|
>
|
||||||
|
> Back to the first level.
|
||||||
|
|
||||||
|
Blockquotes can contain other Markdown elements, including headers, lists,
|
||||||
|
and code blocks:
|
||||||
|
|
||||||
|
> ## This is a header.
|
||||||
|
>
|
||||||
|
> 1. This is the first list item.
|
||||||
|
> 2. This is the second list item.
|
||||||
|
>
|
||||||
|
> Here's some example code:
|
||||||
|
>
|
||||||
|
> return shell_exec("echo $input | $markdown_script");
|
||||||
|
|
||||||
|
Any decent text editor should make email-style quoting easy. For
|
||||||
|
example, with BBEdit, you can make a selection and choose Increase
|
||||||
|
Quote Level from the Text menu.
|
||||||
|
|
||||||
|
|
||||||
|
### Lists
|
||||||
|
|
||||||
|
Markdown supports ordered (numbered) and unordered (bulleted) lists.
|
||||||
|
|
||||||
|
Unordered lists use asterisks, pluses, and hyphens -- interchangably
|
||||||
|
-- as list markers:
|
||||||
|
|
||||||
|
* Red
|
||||||
|
* Green
|
||||||
|
* Blue
|
||||||
|
|
||||||
|
is equivalent to:
|
||||||
|
|
||||||
|
+ Red
|
||||||
|
+ Green
|
||||||
|
+ Blue
|
||||||
|
|
||||||
|
and:
|
||||||
|
|
||||||
|
- Red
|
||||||
|
- Green
|
||||||
|
- Blue
|
||||||
|
|
||||||
|
Ordered lists use numbers followed by periods:
|
||||||
|
|
||||||
|
1. Bird
|
||||||
|
2. McHale
|
||||||
|
3. Parish
|
||||||
|
|
||||||
|
It's important to note that the actual numbers you use to mark the
|
||||||
|
list have no effect on the HTML output Markdown produces. The HTML
|
||||||
|
Markdown produces from the above list is:
|
||||||
|
|
||||||
|
If you instead wrote the list in Markdown like this:
|
||||||
|
|
||||||
|
1. Bird
|
||||||
|
1. McHale
|
||||||
|
1. Parish
|
||||||
|
|
||||||
|
or even:
|
||||||
|
|
||||||
|
3. Bird
|
||||||
|
1. McHale
|
||||||
|
8. Parish
|
||||||
|
|
||||||
|
you'd get the exact same HTML output. The point is, if you want to,
|
||||||
|
you can use ordinal numbers in your ordered Markdown lists, so that
|
||||||
|
the numbers in your source match the numbers in your published HTML.
|
||||||
|
But if you want to be lazy, you don't have to.
|
||||||
|
|
||||||
|
To make lists look nice, you can wrap items with hanging indents:
|
||||||
|
|
||||||
|
* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
||||||
|
Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
|
||||||
|
viverra nec, fringilla in, laoreet vitae, risus.
|
||||||
|
* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
|
||||||
|
Suspendisse id sem consectetuer libero luctus adipiscing.
|
||||||
|
|
||||||
|
But if you want to be lazy, you don't have to:
|
||||||
|
|
||||||
|
* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
||||||
|
Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
|
||||||
|
viverra nec, fringilla in, laoreet vitae, risus.
|
||||||
|
* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
|
||||||
|
Suspendisse id sem consectetuer libero luctus adipiscing.
|
||||||
|
|
||||||
|
List items may consist of multiple paragraphs. Each subsequent
|
||||||
|
paragraph in a list item must be indented by either 4 spaces
|
||||||
|
or one tab:
|
||||||
|
|
||||||
|
1. This is a list item with two paragraphs. Lorem ipsum dolor
|
||||||
|
sit amet, consectetuer adipiscing elit. Aliquam hendrerit
|
||||||
|
mi posuere lectus.
|
||||||
|
|
||||||
|
Vestibulum enim wisi, viverra nec, fringilla in, laoreet
|
||||||
|
vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
|
||||||
|
sit amet velit.
|
||||||
|
|
||||||
|
2. Suspendisse id sem consectetuer libero luctus adipiscing.
|
||||||
|
|
||||||
|
It looks nice if you indent every line of the subsequent
|
||||||
|
paragraphs, but here again, Markdown will allow you to be
|
||||||
|
lazy:
|
||||||
|
|
||||||
|
* This is a list item with two paragraphs.
|
||||||
|
|
||||||
|
This is the second paragraph in the list item. You're
|
||||||
|
only required to indent the first line. Lorem ipsum dolor
|
||||||
|
sit amet, consectetuer adipiscing elit.
|
||||||
|
|
||||||
|
* Another item in the same list.
|
||||||
|
|
||||||
|
To put a blockquote within a list item, the blockquote's `>`
|
||||||
|
delimiters need to be indented:
|
||||||
|
|
||||||
|
* A list item with a blockquote:
|
||||||
|
|
||||||
|
> This is a blockquote
|
||||||
|
> inside a list item.
|
||||||
|
|
||||||
|
To put a code block within a list item, the code block needs
|
||||||
|
to be indented *twice* -- 8 spaces or two tabs:
|
||||||
|
|
||||||
|
* A list item with a code block:
|
||||||
|
|
||||||
|
<code goes here>
|
||||||
|
|
||||||
|
### Code Blocks
|
||||||
|
|
||||||
|
Pre-formatted code blocks are used for writing about programming or
|
||||||
|
markup source code. Rather than forming normal paragraphs, the lines
|
||||||
|
of a code block are interpreted literally. Markdown wraps a code block
|
||||||
|
in both `<pre>` and `<code>` tags.
|
||||||
|
|
||||||
|
To produce a code block in Markdown, simply indent every line of the
|
||||||
|
block by at least 4 spaces or 1 tab.
|
||||||
|
|
||||||
|
This is a normal paragraph:
|
||||||
|
|
||||||
|
This is a code block.
|
||||||
|
|
||||||
|
Here is an example of AppleScript:
|
||||||
|
|
||||||
|
tell application "Foo"
|
||||||
|
beep
|
||||||
|
end tell
|
||||||
|
|
||||||
|
A code block continues until it reaches a line that is not indented
|
||||||
|
(or the end of the article).
|
||||||
|
|
||||||
|
Within a code block, ampersands (`&`) and angle brackets (`<` and `>`)
|
||||||
|
are automatically converted into HTML entities. This makes it very
|
||||||
|
easy to include example HTML source code using Markdown -- just paste
|
||||||
|
it and indent it, and Markdown will handle the hassle of encoding the
|
||||||
|
ampersands and angle brackets. For example, this:
|
||||||
|
|
||||||
|
<div class="footer">
|
||||||
|
© 2004 Foo Corporation
|
||||||
|
</div>
|
||||||
|
|
||||||
|
Regular Markdown syntax is not processed within code blocks. E.g.,
|
||||||
|
asterisks are just literal asterisks within a code block. This means
|
||||||
|
it's also easy to use Markdown to write about Markdown's own syntax.
|
||||||
|
|
||||||
|
```
|
||||||
|
tell application "Foo"
|
||||||
|
beep
|
||||||
|
end tell
|
||||||
|
```
|
||||||
|
|
||||||
|
## Span Elements
|
||||||
|
|
||||||
|
### Links
|
||||||
|
|
||||||
|
Markdown supports two style of links: *inline* and *reference*.
|
||||||
|
|
||||||
|
In both styles, the link text is delimited by [square brackets].
|
||||||
|
|
||||||
|
To create an inline link, use a set of regular parentheses immediately
|
||||||
|
after the link text's closing square bracket. Inside the parentheses,
|
||||||
|
put the URL where you want the link to point, along with an *optional*
|
||||||
|
title for the link, surrounded in quotes. For example:
|
||||||
|
|
||||||
|
This is [an example](http://example.com/) inline link.
|
||||||
|
|
||||||
|
[This link](http://example.net/) has no title attribute.
|
||||||
|
|
||||||
|
### Emphasis
|
||||||
|
|
||||||
|
Markdown treats asterisks (`*`) and underscores (`_`) as indicators of
|
||||||
|
emphasis. Text wrapped with one `*` or `_` will be wrapped with an
|
||||||
|
HTML `<em>` tag; double `*`'s or `_`'s will be wrapped with an HTML
|
||||||
|
`<strong>` tag. E.g., this input:
|
||||||
|
|
||||||
|
*single asterisks*
|
||||||
|
|
||||||
|
_single underscores_
|
||||||
|
|
||||||
|
**double asterisks**
|
||||||
|
|
||||||
|
__double underscores__
|
||||||
|
|
||||||
|
### Code
|
||||||
|
|
||||||
|
To indicate a span of code, wrap it with backtick quotes (`` ` ``).
|
||||||
|
Unlike a pre-formatted code block, a code span indicates code within a
|
||||||
|
normal paragraph. For example:
|
||||||
|
|
||||||
|
Use the `printf()` function.
|
||||||
5
test/files/minimal/Fes.toml
Normal file
5
test/files/minimal/Fes.toml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
[app]
|
||||||
|
|
||||||
|
name = "minimal"
|
||||||
|
version = "0.0.1"
|
||||||
|
authors = ["fSD"]
|
||||||
33
test/files/minimal/README.md
Normal file
33
test/files/minimal/README.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# minimal
|
||||||
|
|
||||||
|
```
|
||||||
|
fes new minimal
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Know what you are doing?** Delete this file. Have fun!
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
|
||||||
|
Inside your Fes project, you'll see the following directories and files:
|
||||||
|
|
||||||
|
```
|
||||||
|
.
|
||||||
|
├── Fes.toml
|
||||||
|
├── README.md
|
||||||
|
└── www
|
||||||
|
└── index.lua
|
||||||
|
```
|
||||||
|
|
||||||
|
Fes looks for `.lua` files in the `www/` directory. Each file is exposed as a route based on its file name.
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
All commands are run from the root of the project, from a terminal:
|
||||||
|
|
||||||
|
| Command | Action |
|
||||||
|
| :------------------------ | :----------------------------------------------- |
|
||||||
|
| `fes run .` | Runs the project at `.` |
|
||||||
|
|
||||||
|
## What to learn more?
|
||||||
|
|
||||||
|
Check out [Fes's docs](https://docs.vxserver.dev/static/fes.html).
|
||||||
1
test/files/minimal/www/index.lua
Normal file
1
test/files/minimal/www/index.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
return "Hello, World!"
|
||||||
Reference in New Issue
Block a user