mirror of
https://github.com/lxsang/antd-web-apps
synced 2025-07-26 10:39:46 +02:00
WIP: make code compatible with new SILK API
All checks were successful
gitea-sync/antd-web-apps/pipeline/head This commit looks good
All checks were successful
gitea-sync/antd-web-apps/pipeline/head This commit looks good
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
BaseController:subclass("IndexController")
|
||||
|
||||
function IndexController:index(...)
|
||||
local file = io.open("/home/mrsang/doc/library.md", "r")
|
||||
-- TODO: add description to router
|
||||
local file = io.open(DOC_COVER, "r")
|
||||
if file then
|
||||
local content = ""
|
||||
local md = require("md")
|
||||
|
@ -107,8 +107,8 @@ function DocController:loadTOC()
|
||||
if line then
|
||||
local file =
|
||||
{
|
||||
name = std.trim(
|
||||
std.trim(line, "#"), " "),
|
||||
name = ulib.trim(
|
||||
ulib.trim(line, "#"), " "),
|
||||
path = vf.path,
|
||||
tpath = vf.path,
|
||||
parent = section,
|
||||
@ -145,14 +145,14 @@ function DocController:index(...)
|
||||
if args[1] then
|
||||
local b64text = args[1]
|
||||
if b64text then
|
||||
local p = bytes.__tostring(std.b64decode(b64text .. "=="))
|
||||
local p = tostring(enc.b64decode(b64text .. "=="))
|
||||
if p then
|
||||
toc.cpath = p
|
||||
path = getpath(p, self)
|
||||
if path and ulib.exists(path) then
|
||||
self.template:set("url", HTTP_ROOT .. '/' .. self.name ..
|
||||
'/' ..
|
||||
std.b64encode(toc.cpath):gsub("=", ""))
|
||||
enc.b64encode(toc.cpath):gsub("=", ""))
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -188,7 +188,7 @@ function DocController:search(...)
|
||||
local arr = explode(query, " ")
|
||||
local patterns = {}
|
||||
for k, v in ipairs(arr) do
|
||||
local world = std.trim(v, " ")
|
||||
local world = ulib.trim(v, " ")
|
||||
if v and v ~= "" then
|
||||
cmd = cmd .. " -e '" .. v .. "' "
|
||||
table.insert(patterns, v:lower())
|
||||
|
@ -3,24 +3,27 @@
|
||||
-- should be something like this
|
||||
-- ^\/apps\/+(.*)$ = /apps/router.lua?r=<1>&<query>
|
||||
-- some global variables
|
||||
DIR_SEP = "/"
|
||||
package.path = _SERVER["LIB_DIR"].."/lua/?.lua"
|
||||
require("silk.api")
|
||||
-- crypto lib
|
||||
enc = require("enc")
|
||||
WWW_ROOT = __ROOT__.."/doc"
|
||||
DIR_SEP = "/"
|
||||
if HEADER.Host then
|
||||
HTTP_ROOT= "https://"..HEADER.Host
|
||||
else
|
||||
HTTP_ROOT = "https://doc.iohub.dev"
|
||||
end
|
||||
|
||||
-- class path: path.to.class
|
||||
BASE_FRW = ""
|
||||
-- class path: path.to.class
|
||||
CONTROLLER_ROOT = BASE_FRW.."doc.controllers"
|
||||
MODEL_ROOT = BASE_FRW.."doc.models"
|
||||
CONTROLLER_ROOT = ."doc.controllers"
|
||||
MODEL_ROOT = "doc.models"
|
||||
-- file path: path/to/file
|
||||
VIEW_ROOT = WWW_ROOT..DIR_SEP.."views"
|
||||
LOG_ROOT = WWW_ROOT..DIR_SEP.."logs"
|
||||
POST_LIMIT = 10
|
||||
-- require needed library
|
||||
require(BASE_FRW.."silk.api")
|
||||
|
||||
-- TODO change me
|
||||
DOC_DIR = "/home/mrsang/doc"
|
||||
DOC_COVER = DOC_DIR.."/library.md"
|
||||
|
||||
package.path = package.path..";"..__ROOT__.."/os/libs/?.lua"
|
||||
|
||||
@ -33,7 +36,7 @@ end
|
||||
-- registry object store global variables
|
||||
local REGISTRY = {}
|
||||
-- set logging level
|
||||
REGISTRY.logger = Logger:new{ levels = {INFO = false, ERROR = true, DEBUG = false}}
|
||||
REGISTRY.logger = Logger:new{ level = Logger.INFO}
|
||||
REGISTRY.layout = 'default'
|
||||
REGISTRY.fileaccess = true
|
||||
|
||||
|
@ -76,12 +76,12 @@
|
||||
<?lua
|
||||
|
||||
if prev_entry then
|
||||
echo("<a class = 'go_prev' href="..HTTP_ROOT..'/'..toc.controller..'/'..std.b64encode(prev_entry.path):gsub("=","")..'/'..prev_entry.name:gsub(" ", "_")..".md?show_toc=false".." >")
|
||||
echo("<a class = 'go_prev' href="..HTTP_ROOT..'/'..toc.controller..'/'..enc.b64encode(prev_entry.path):gsub("=","")..'/'..prev_entry.name:gsub(" ", "_")..".md?show_toc=false".." >")
|
||||
echo(prev_entry.name)
|
||||
echo("</a>")
|
||||
end
|
||||
if next_entry then
|
||||
echo("<a class = 'go_next' href="..HTTP_ROOT..'/'..toc.controller..'/'..std.b64encode(next_entry.path):gsub("=","")..'/'..next_entry.name:gsub(" ", "_")..".md?show_toc=false".." >")
|
||||
echo("<a class = 'go_next' href="..HTTP_ROOT..'/'..toc.controller..'/'..enc.b64encode(next_entry.path):gsub("=","")..'/'..next_entry.name:gsub(" ", "_")..".md?show_toc=false".." >")
|
||||
echo(next_entry.name)
|
||||
echo("</a>")
|
||||
end
|
||||
@ -108,12 +108,12 @@ The comment editor supports <b>Markdown</b> syntax. Your email is necessary to n
|
||||
<div class = "pagenav">
|
||||
<?lua
|
||||
if prev_entry then
|
||||
echo("<a class = 'go_prev' href="..HTTP_ROOT..'/'..toc.controller..'/'..std.b64encode(prev_entry.path):gsub("=","")..'/'..prev_entry.name:gsub(" ", "_")..".md?show_toc=false".." >")
|
||||
echo("<a class = 'go_prev' href="..HTTP_ROOT..'/'..toc.controller..'/'..enc.b64encode(prev_entry.path):gsub("=","")..'/'..prev_entry.name:gsub(" ", "_")..".md?show_toc=false".." >")
|
||||
echo(prev_entry.name)
|
||||
echo("</a>")
|
||||
end
|
||||
if next_entry then
|
||||
echo("<a class = 'go_next' href="..HTTP_ROOT..'/'..toc.controller..'/'..std.b64encode(next_entry.path):gsub("=","")..'/'..next_entry.name:gsub(" ", "_")..".md?show_toc=false".." >")
|
||||
echo("<a class = 'go_next' href="..HTTP_ROOT..'/'..toc.controller..'/'..enc.b64encode(next_entry.path):gsub("=","")..'/'..next_entry.name:gsub(" ", "_")..".md?show_toc=false".." >")
|
||||
echo(next_entry.name)
|
||||
echo("</a>")
|
||||
end
|
||||
|
@ -7,9 +7,9 @@
|
||||
local title = io.read()
|
||||
io.close()
|
||||
file = file:gsub(map.local_path, map.vfs_path)
|
||||
title = std.trim(std.trim(title, "#"), " ")
|
||||
title = ulib.trim(ulib.trim(title, "#"), " ")
|
||||
echo("<div>")
|
||||
echo("<p class= 'result-header'><a href='"..HTTP_ROOT..'/'..controller..'/'..std.b64encode(file):gsub("=","")..'/'..title:gsub(" ", "_")..".md'>")
|
||||
echo("<p class= 'result-header'><a href='"..HTTP_ROOT..'/'..controller..'/'..enc.b64encode(file):gsub("=","")..'/'..title:gsub(" ", "_")..".md'>")
|
||||
echo(title)
|
||||
echo("</a></p>")
|
||||
for i,content in ipairs(arr) do
|
||||
|
@ -20,7 +20,7 @@ gentree = function(data, controller, cpath)
|
||||
selected = "class = 'selected'"
|
||||
end
|
||||
end
|
||||
local markup = '<li '..selected..'>'..caret..'<a '..highlight..' href="'..HTTP_ROOT..'/'..controller..'/'..std.b64encode(data.path):gsub("=","")..'/'..data.name:gsub(" ", "_")..'.md">'..data.name.."</a>"
|
||||
local markup = '<li '..selected..'>'..caret..'<a '..highlight..' href="'..HTTP_ROOT..'/'..controller..'/'..enc.b64encode(data.path):gsub("=","")..'/'..data.name:gsub(" ", "_")..'.md">'..data.name.."</a>"
|
||||
if data.entries then
|
||||
markup = markup.."<ul class='nested "..active.."'>"
|
||||
for k,v in pairs(data.entries) do
|
||||
|
Reference in New Issue
Block a user