proxy github gists and render them on posts
This commit is contained in:
18
templates/gist.html
Normal file
18
templates/gist.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!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>
|
14
templates/gist_error.html
Normal file
14
templates/gist_error.html
Normal file
@ -0,0 +1,14 @@
|
||||
<!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>
|
@ -62,6 +62,17 @@ figcaption {
|
||||
code {
|
||||
font-family: monospace;
|
||||
font-size: 15px;
|
||||
white-space: pre-wrap;
|
||||
background-color: #888;
|
||||
color: #fff;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
iframe {
|
||||
width: 100%;
|
||||
display: block;
|
||||
margin: auto;
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1200px) {
|
||||
|
@ -44,7 +44,12 @@
|
||||
<h6><.= p.text .></h6>
|
||||
<.} 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>
|
||||
<a href="<.= src .>">Click here to open gist on GitHub</a>
|
||||
<.} else {.>
|
||||
<iframe src="<.= src .>" frameborder="0"></iframe>
|
||||
<.}.>
|
||||
<.}.>
|
||||
<.}.>
|
||||
</article>
|
||||
|
Reference in New Issue
Block a user