1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2025-04-19 01:56:44 +02:00

support comments in odc

This commit is contained in:
lxsang 2020-09-22 17:58:37 +02:00
parent 1e5f2e7fee
commit 25e75badc1
4 changed files with 126 additions and 56 deletions

View File

@ -1,4 +1,5 @@
html,body{ html,
body {
margin: 0; margin: 0;
padding: 0; padding: 0;
font-family: "Ubuntu"; font-family: "Ubuntu";
@ -61,7 +62,8 @@ div.doc-name a {
color: #c9c9c9; color: #c9c9c9;
} }
a.x-link, a.x-link:hover { a.x-link,
a.x-link:hover {
text-decoration: none; text-decoration: none;
color: #c9c9c9; color: #c9c9c9;
padding-left: 15px; padding-left: 15px;
@ -187,7 +189,8 @@ div.pagenav {
width: 100%; width: 100%;
} }
div.pagenav a.go_next, div.pagenav a.go_prev { div.pagenav a.go_next,
div.pagenav a.go_prev {
display: block; display: block;
flex: 1; flex: 1;
text-decoration: none; text-decoration: none;
@ -199,13 +202,12 @@ div.pagenav a.go_next, div.pagenav a.go_prev {
padding-bottom: 3px; padding-bottom: 3px;
margin-bottom: 10px; margin-bottom: 10px;
} }
div.pagenav a.go_next:hover, div.pagenav a.go_prev:hover div.pagenav a.go_next:hover,
{ div.pagenav a.go_prev:hover {
background-color: #e6e8e8; background-color: #e6e8e8;
} }
div.pagenav a.go_next div.pagenav a.go_next {
{
padding-right: 5px; padding-right: 5px;
text-align: center; text-align: center;
} }
@ -308,3 +310,15 @@ model-viewer{
width: 100%; width: 100%;
height: 350px; height: 350px;
} }
.commentsec {
padding: 15px;
display: block;
}
.commentsec .comment-header {
text-align: center;
border-top: 1px dashed #3170b2;
color: #3170b2;
margin: 0;
padding-top: 10px;
padding-bottom: 0px;
}

View File

@ -9,7 +9,8 @@ local pre_process_md = function(str, obj)
local content = str local content = str
for capture in str:gmatch("(%[%[@book:image:[^\n%]]*%]%])") do for capture in str:gmatch("(%[%[@book:image:[^\n%]]*%]%])") do
local apath = capture:match("%[%[@book:image:([^\n%]]*)%]%]") local apath = capture:match("%[%[@book:image:([^\n%]]*)%]%]")
local pattern = capture:gsub("%[", "%%["):gsub("%]", "%%]"):gsub("%-", "%%-") local pattern = capture:gsub("%[", "%%["):gsub("%]", "%%]"):gsub("%-",
"%%-")
if apath then if apath then
apath = apath:gsub(" ", "%%%%20") apath = apath:gsub(" ", "%%%%20")
print(apath) print(apath)
@ -27,7 +28,8 @@ local post_process_md = function(str, obj)
-- 3D model -- 3D model
for capture in str:gmatch("(%[%[@book:3dmodel:[^\n%]]*%]%])") do for capture in str:gmatch("(%[%[@book:3dmodel:[^\n%]]*%]%])") do
local apath = capture:match("%[%[@book:3dmodel:([^\n%]]*)%]%]") local apath = capture:match("%[%[@book:3dmodel:([^\n%]]*)%]%]")
local pattern = capture:gsub("%[", "%%["):gsub("%]", "%%]"):gsub("%-", "%%-") local pattern = capture:gsub("%[", "%%["):gsub("%]", "%%]"):gsub("%-",
"%%-")
if apath then if apath then
-- apath = utils.urlencode(apath):gsub("%%", "%%%%") -- apath = utils.urlencode(apath):gsub("%%", "%%%%")
apath = apath:gsub(" ", "%%20") apath = apath:gsub(" ", "%%20")
@ -41,10 +43,12 @@ local post_process_md = function(str, obj)
-- Youtube video -- Youtube video
for capture in str:gmatch("(%[%[youtube:[^\n%]]*%]%])") do for capture in str:gmatch("(%[%[youtube:[^\n%]]*%]%])") do
local apath = capture:match("%[%[youtube:([^\n%]]*)%]%]") local apath = capture:match("%[%[youtube:([^\n%]]*)%]%]")
local pattern = capture:gsub("%[", "%%["):gsub("%]", "%%]"):gsub("%-", "%%-") local pattern = capture:gsub("%[", "%%["):gsub("%]", "%%]"):gsub("%-",
"%%-")
if apath then if apath then
content = content:gsub(pattern, content = content:gsub(pattern,
"<iframe style='width:100%%;height: auto;min-height: 400px;' src=\"https://www.youtube.com/embed/"..apath.."\"> </iframe>") "<iframe style='width:100%%;height: auto;min-height: 400px;' src=\"https://www.youtube.com/embed/" ..
apath .. "\"> </iframe>")
end end
end end
@ -146,6 +150,11 @@ function DocController:index(...)
if p then if p then
toc.cpath = p toc.cpath = p
path = getpath(p, self) path = getpath(p, self)
if path and ulib.exists(path) then
self.template:set("url", HTTP_ROOT .. '/' .. self.name ..
'/' ..
std.b64encode(toc.cpath):gsub("=", ""))
end
end end
end end
else else

View File

@ -92,6 +92,19 @@
echo(data) echo(data)
?> ?>
</div> </div>
<?lua
if url then
?>
<div class = "commentsec">
<h3 class = "comment-header">Comments</h1>
<div>
The comment editor supports <b>Markdown</b> document format. Your email is necessary to notify you of further updates on the discussion. It will be hidden from the public.
</div>
<div id="quick_talk_comment_thread"></div>
</div>
<?lua
end
?>
<div class = "pagenav"> <div class = "pagenav">
<?lua <?lua
if prev_entry then if prev_entry then

View File

@ -2,6 +2,7 @@
local tocdata = __main__:get("toc") local tocdata = __main__:get("toc")
local elinks = __main__:get("elinks") local elinks = __main__:get("elinks")
local has_3d = __main__:get("has_3d") local has_3d = __main__:get("has_3d")
local url = __main__:get("url")
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
@ -14,6 +15,7 @@ local has_3d = __main__:get("has_3d")
rel="stylesheet" rel="stylesheet"
type="text/css" type="text/css"
href="<?=HTTP_ROOT?>/rst/katex/katex.min.css" /> href="<?=HTTP_ROOT?>/rst/katex/katex.min.css" />
<script src="<?=HTTP_ROOT?>/rst/gscripts/jquery-3.2.1.min.js"> </script>
<?lua <?lua
if has_3d then if has_3d then
?> ?>
@ -28,7 +30,19 @@ local has_3d = __main__:get("has_3d")
<script <script
src="<?=HTTP_ROOT?>/rst/hljs/highlightjs-line-numbers.min.js" src="<?=HTTP_ROOT?>/rst/hljs/highlightjs-line-numbers.min.js"
></script> ></script>
<?lua
if url then
?>
<link rel="stylesheet" type="text/css" href="https://chat.iohub.dev/assets/quicktalk.css" />
<script src="https://chat.iohub.dev/assets/quicktalk.js"> </script>
<?lua
else
?>
<script>hljs.initHighlightingOnLoad();</script> <script>hljs.initHighlightingOnLoad();</script>
<?lua
end
?>
<script <script
src="<?=HTTP_ROOT?>/rst/katex/katex.min.js" src="<?=HTTP_ROOT?>/rst/katex/katex.min.js"
></script> ></script>
@ -128,7 +142,27 @@ local has_3d = __main__:get("has_3d")
if( val === "" || val == "\n") return false; if( val === "" || val == "\n") return false;
return true; return true;
} }
<?lua
if url then
?>
var options = {
target: "quick_talk_comment_thread",
api_uri: "https://chat.iohub.dev/comment",
uri: "<?=url?>",
onload: function(){
renderMathInElement($("#book")[0]);
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
hljs.lineNumbersBlock(block);
}); });
}
};
new QuickTalk(options);
<?lua
end
?>
});
</script> </script>
</body> </body>
</html> </html>