mirror of
https://github.com/lxsang/antd-web-apps
synced 2025-07-26 18:49:47 +02:00
first antdoc version
This commit is contained in:
@ -1,4 +1,120 @@
|
||||
|
||||
<?lua
|
||||
echo(data)
|
||||
?>
|
||||
local get_next
|
||||
get_next = function(toc, cpath)
|
||||
if toc.path == cpath then
|
||||
if toc.entries and #toc.entries > 0 then return toc.entries[1] end
|
||||
if toc.parent and toc.parent.entries and #toc.parent.entries > 0 then
|
||||
local entries = toc.parent.entries
|
||||
if toc.id == #entries then
|
||||
local p = toc.parent
|
||||
while p and p.parent and p.parent.entries and #p.parent.entries > 0 do
|
||||
entries = p.parent.entries
|
||||
if p.id ~= #entries then
|
||||
return entries[p.id + 1]
|
||||
end
|
||||
p = p.parent
|
||||
end
|
||||
return nil
|
||||
else
|
||||
return entries[toc.id + 1]
|
||||
end
|
||||
else
|
||||
return nil
|
||||
end
|
||||
else
|
||||
if toc.entries then
|
||||
for i,v in pairs(toc.entries) do
|
||||
local ret = get_next(v, cpath)
|
||||
if ret then return ret end
|
||||
end
|
||||
return nil
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local get_prev
|
||||
get_prev = function(toc, cpath)
|
||||
if toc.path == cpath then
|
||||
if toc.id == 1 then
|
||||
return toc.parent
|
||||
end
|
||||
if toc.parent and toc.parent.entries and #toc.parent.entries > 0 then
|
||||
local entries = toc.parent.entries
|
||||
local c = entries[toc.id - 1]
|
||||
while c and c.entries and #c.entries > 0 do
|
||||
if c.entries then
|
||||
c = c.entries[#c.entries]
|
||||
end
|
||||
end
|
||||
return c
|
||||
else
|
||||
return nil
|
||||
end
|
||||
else
|
||||
if toc.entries then
|
||||
for i,v in pairs(toc.entries) do
|
||||
local ret = get_prev(v, cpath)
|
||||
if ret then return ret end
|
||||
end
|
||||
return nil
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
local prev_entry = nil
|
||||
local next_entry = nil
|
||||
if toc then
|
||||
prev_entry = get_prev(toc.data, toc.cpath)
|
||||
next_entry = get_next(toc.data, toc.cpath)
|
||||
end
|
||||
?>
|
||||
<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".." >")
|
||||
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".." >")
|
||||
echo(next_entry.name)
|
||||
echo("</a>")
|
||||
end
|
||||
?>
|
||||
</div>
|
||||
<div class = "md-content" id = "renderer">
|
||||
|
||||
</div>
|
||||
<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".." >")
|
||||
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".." >")
|
||||
echo(next_entry.name)
|
||||
echo("</a>")
|
||||
end
|
||||
?>
|
||||
</div>
|
||||
<script>
|
||||
window.addEventListener('load', (event) => {
|
||||
var markdown = `<?=std.b64encode(data)?>`;
|
||||
var converter = new showdown.Converter();
|
||||
var html = converter.makeHtml(atob(markdown));
|
||||
document.getElementById("renderer").innerHTML = html;
|
||||
// highlight and math display
|
||||
renderMathInElement(document.getElementById("renderer"));
|
||||
document.querySelectorAll("pre code").forEach(element => {
|
||||
hljs.highlightBlock(element);
|
||||
hljs.lineNumbersBlock(element);
|
||||
});
|
||||
});
|
||||
</script>
|
26
doc/views/default/index/search.ls
Normal file
26
doc/views/default/index/search.ls
Normal file
@ -0,0 +1,26 @@
|
||||
<div class = "md-content">
|
||||
<?lua
|
||||
if data then
|
||||
for file,arr in pairs(data) do
|
||||
local f = io.open(file, "r")
|
||||
io.input(f)
|
||||
local title = io.read()
|
||||
io.close()
|
||||
file = file:gsub(map.local_path, map.vfs_path)
|
||||
title = std.trim(std.trim(title, "#"), " ")
|
||||
echo("<div>")
|
||||
echo("<p class= 'result-header'><a href='"..HTTP_ROOT..'/'..controller..'/'..std.b64encode(file):gsub("=","")..'/'..title:gsub(" ", "_")..".md'>")
|
||||
echo(title)
|
||||
echo("</a></p>")
|
||||
for i,content in ipairs(arr) do
|
||||
echo("<p class= 'result-content'>")
|
||||
echo("..."..content.."...")
|
||||
echo("</p>")
|
||||
end
|
||||
echo("</div>")
|
||||
end
|
||||
else
|
||||
echo("<p>No search result found</p>")
|
||||
end
|
||||
?>
|
||||
</div>
|
Reference in New Issue
Block a user