render gists inline

This commit is contained in:
realaravinth
2021-11-04 23:51:59 +05:30
parent 67a59fe38b
commit 9bf500f764
8 changed files with 113 additions and 160 deletions

View File

@ -1,18 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Gist</title>
</head>
<body>
<. for file in files {.>
<code> <.= file.get_html_content() .> </code>
<.}.>
<a href="<.= &html_url[1..html_url.len() -1] .>" target="_blank">See on GitHub</a>
</body>
<style>
<. include!("./main.css"); .>
</style>
</html>

View File

@ -1,14 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Gist</title>
</head>
<body>
Error
</body>
<style>
<. include!("./main.css"); .>
</style>
</html>

View File

@ -0,0 +1,8 @@
<. let gist_id = data.get_gist_id(&src); .>
<. let (_, gist)= gists.as_ref().unwrap().iter().find(|(id, _)| id == gist_id).as_ref().unwrap(); .>
<. for file in &gist.files {.>
<code> <.= file.get_html_content() .> </code>
<.}.>
<a href="<.= &gist.html_url .>" target="_blank"
>See gist on GitHub</a
>

View File

@ -63,9 +63,9 @@ code {
font-family: monospace;
font-size: 15px;
white-space: pre-wrap;
background-color: #888;
color: #fff;
display: block;
font-weight: 600;
line-height: 1rem;
}
iframe {

View File

@ -23,7 +23,7 @@
on <.= &date .> &#183; <.= data.reading_time.floor() as usize .> min read
</p>
<article>
<. let paragraphs = data.content.body_model.paragraphs; .>
<. let paragraphs = &data.content.body_model.paragraphs; .>
<. for (pindex, p) in paragraphs.iter().enumerate() {.>
<. if pindex == 0 && p.type_ == "H3" {.>
<. continue; .>
@ -45,8 +45,11 @@
<.} else if p.type_ == "IFRAME" {.>
<. let src = &p.iframe.as_ref().unwrap().media_resource.as_ref().unwrap().href; .>
<. if src.contains("gist.github.com"){.>
<iframe src="<.= crate::V1_API_ROUTES.proxy.get_gist(&src) .>" frameborder="0"></iframe>
<. include!("./gist_insert.html"); .>
<!--
<iframe src="<.#= crate::V1_API_ROUTES.proxy.get_gist(&src) .>" frameborder="0"></iframe>
<a href="<.= src .>">Click here to open gist on GitHub</a>
-->
<.} else {.>
<iframe src="<.= src .>" frameborder="0"></iframe>
<.}.>