Skip to content

Commit

Permalink
Fix lint issue
Browse files Browse the repository at this point in the history
  • Loading branch information
elocremarc committed Sep 5, 2023
1 parent bf353b8 commit 5c75775
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 28 deletions.
38 changes: 18 additions & 20 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use {
crate::templates::{
BlockHtml, ClockSvg, HomeHtml, InputHtml, InscriptionHtml, InscriptionJson,
InscriptionsBlockHtml, InscriptionsHtml, InscriptionsJson, OutputHtml, OutputJson, PageContent,
PageHtml, PreviewAudioHtml, PreviewImageHtml, PreviewModelHtml, PreviewPdfHtml, PreviewMarkdownHtml,
PreviewTextHtml, PreviewUnknownHtml, PreviewVideoHtml, RangeHtml, RareTxt, SatHtml, SatJson,
TransactionHtml,
PageHtml, PreviewAudioHtml, PreviewImageHtml, PreviewMarkdownHtml, PreviewModelHtml,
PreviewPdfHtml, PreviewTextHtml, PreviewUnknownHtml, PreviewVideoHtml, RangeHtml, RareTxt,
SatHtml, SatJson, TransactionHtml,
},
axum::{
body,
Expand Down Expand Up @@ -966,9 +966,9 @@ impl Server {
Media::Markdown => Ok(
(
[(
header::CONTENT_SECURITY_POLICY,
"script-src-elem 'self' https://cdn.jsdelivr.net",
)],
header::CONTENT_SECURITY_POLICY,
"script-src-elem 'self' https://cdn.jsdelivr.net",
)],
PreviewMarkdownHtml { inscription_id },
)
.into_response(),
Expand Down Expand Up @@ -2572,24 +2572,22 @@ mod tests {
fn markdown_preview() {
let server = TestServer::new_with_regtest();
server.mine_blocks(1);

let txid = server.bitcoin_rpc_server.broadcast_tx(TransactionTemplate {
inputs: &[(1, 0, 0)],
witness: inscription("text/markdown", "hello").to_witness(),
..Default::default()
});
let inscription_id = InscriptionId::from(txid);
inputs: &[(1, 0, 0)],
witness: inscription("text/markdown", "hello").to_witness(),
..Default::default()
});
let inscription_id = InscriptionId { txid, index: 0 };

server.mine_blocks(1);

server.assert_response_regex(
format!("/preview/{inscription_id}"),
StatusCode::OK,
format!(r".*<div data-inscription={inscription_id}></div>.*"),
);
format!("/preview/{inscription_id}"),
StatusCode::OK,
format!(r".*<div data-inscription={inscription_id}></div>.*"),
);
}



#[test]
fn image_preview() {
Expand Down
4 changes: 2 additions & 2 deletions src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ pub(crate) use {
output::{OutputHtml, OutputJson},
page_config::PageConfig,
preview::{
PreviewAudioHtml, PreviewImageHtml, PreviewModelHtml, PreviewPdfHtml, PreviewMarkdownHtml, PreviewTextHtml,
PreviewUnknownHtml, PreviewVideoHtml,
PreviewAudioHtml, PreviewImageHtml, PreviewMarkdownHtml, PreviewModelHtml, PreviewPdfHtml,
PreviewTextHtml, PreviewUnknownHtml, PreviewVideoHtml,
},
range::RangeHtml,
rare::RareTxt,
Expand Down
3 changes: 2 additions & 1 deletion static/preview-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { marked } from 'https://cdn.jsdelivr.net/npm/marked@8.0.0/+esm'
import DOMPurify from 'https://cdn.jsdelivr.net/npm/dompurify@3.0.5/+esm'

async function renderMarkdown() {
const contentDiv = document.getElementById('content');
const divElements = document.getElementsByTagName('div');
const contentDiv = divElements[0];

const inscriptionId = contentDiv.dataset.inscription;
const response = await fetch(`/content/${inscriptionId}`);
Expand Down
10 changes: 5 additions & 5 deletions templates/preview-markdown.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!doctype html>
<html lang="en">
<html lang=en>
<head>
<meta charset="utf-8">
<link rel=stylesheet href="/static/preview-markdown.css"></link>
<meta charset=utf-8>
<link rel=stylesheet href=/static/preview-markdown.css></link>
</head>
<body>
<div id="content" data-inscription="{{self.inscription_id}}"></div>
<script src="/static/preview-markdown.js" defer type="module"></script>
<div data-inscription={{self.inscription_id}}></div>
<script src=/static/preview-markdown.js defer type=module></script>
</body>
</html>

0 comments on commit 5c75775

Please sign in to comment.