diff --git a/src/index/updater.rs b/src/index/updater.rs index 0828f156d3..d053e1bd8e 100644 --- a/src/index/updater.rs +++ b/src/index/updater.rs @@ -273,7 +273,7 @@ impl<'index> Updater<'_> { // There's no try_iter on tokio::sync::mpsc::Receiver like std::sync::mpsc::Receiver. // So we just loop until BATCH_SIZE doing try_recv until it returns None. let mut outpoints = vec![outpoint]; - for _ in 0..BATCH_SIZE-1 { + for _ in 0..BATCH_SIZE - 1 { let Ok(outpoint) = outpoint_receiver.try_recv() else { break; }; @@ -296,7 +296,10 @@ impl<'index> Updater<'_> { }; // Send all tx output values back in order for (i, tx) in txs.iter().flatten().enumerate() { - let Ok(_) = value_sender.send(tx.output[usize::try_from(outpoints[i].vout).unwrap()].value).await else { + let Ok(_) = value_sender + .send(tx.output[usize::try_from(outpoints[i].vout).unwrap()].value) + .await + else { log::error!("Value channel closed unexpectedly"); return; }; diff --git a/src/inscription.rs b/src/inscription.rs index 5506c5f361..a63d4f0d4f 100644 --- a/src/inscription.rs +++ b/src/inscription.rs @@ -44,7 +44,9 @@ impl Inscription { pub(crate) fn from_transaction(tx: &Transaction) -> Vec { let mut result = Vec::new(); for (index, tx_in) in tx.input.iter().enumerate() { - let Ok(inscriptions) = InscriptionParser::parse(&tx_in.witness) else { continue }; + let Ok(inscriptions) = InscriptionParser::parse(&tx_in.witness) else { + continue; + }; result.extend( inscriptions diff --git a/src/media.rs b/src/media.rs index c5ea8ac488..ff43ba40a2 100644 --- a/src/media.rs +++ b/src/media.rs @@ -9,6 +9,7 @@ pub(crate) enum Media { Audio, Iframe, Image, + Model, Pdf, Text, Unknown, @@ -31,7 +32,8 @@ impl Media { ("image/png", Media::Image, &["png"]), ("image/svg+xml", Media::Iframe, &["svg"]), ("image/webp", Media::Image, &["webp"]), - ("model/gltf-binary", Media::Unknown, &["glb"]), + ("model/gltf+json", Media::Model, &["gltf"]), + ("model/gltf-binary", Media::Model, &["glb"]), ("model/stl", Media::Unknown, &["stl"]), ("text/css", Media::Text, &["css"]), ("text/html", Media::Iframe, &[]), diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index 1f4f93453d..dd8d2189b7 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -10,8 +10,8 @@ use { crate::templates::{ BlockHtml, ClockSvg, HomeHtml, InputHtml, InscriptionHtml, InscriptionJson, InscriptionsHtml, InscriptionsJson, OutputHtml, OutputJson, PageContent, PageHtml, PreviewAudioHtml, - PreviewImageHtml, PreviewPdfHtml, PreviewTextHtml, PreviewUnknownHtml, PreviewVideoHtml, - RangeHtml, RareTxt, SatHtml, SatJson, TransactionHtml, + PreviewImageHtml, PreviewModelHtml, PreviewPdfHtml, PreviewTextHtml, PreviewUnknownHtml, + PreviewVideoHtml, RangeHtml, RareTxt, SatHtml, SatJson, TransactionHtml, }, axum::{ body, @@ -919,6 +919,16 @@ impl Server { ) .into_response(), ), + Media::Model => Ok( + ( + [( + header::CONTENT_SECURITY_POLICY, + "script-src-elem 'self' https://ajax.googleapis.com", + )], + PreviewModelHtml { inscription_id }, + ) + .into_response(), + ), Media::Pdf => Ok( ( [( diff --git a/src/templates.rs b/src/templates.rs index 145e4f679d..ab21051e3b 100644 --- a/src/templates.rs +++ b/src/templates.rs @@ -11,8 +11,8 @@ pub(crate) use { output::{OutputHtml, OutputJson}, page_config::PageConfig, preview::{ - PreviewAudioHtml, PreviewImageHtml, PreviewPdfHtml, PreviewTextHtml, PreviewUnknownHtml, - PreviewVideoHtml, + PreviewAudioHtml, PreviewImageHtml, PreviewModelHtml, PreviewPdfHtml, PreviewTextHtml, + PreviewUnknownHtml, PreviewVideoHtml, }, range::RangeHtml, rare::RareTxt, diff --git a/src/templates/preview.rs b/src/templates/preview.rs index ed9ee4a415..74cb0261dd 100644 --- a/src/templates/preview.rs +++ b/src/templates/preview.rs @@ -10,6 +10,11 @@ pub(crate) struct PreviewImageHtml { pub(crate) inscription_id: InscriptionId, } +#[derive(boilerplate::Boilerplate)] +pub(crate) struct PreviewModelHtml { + pub(crate) inscription_id: InscriptionId, +} + #[derive(boilerplate::Boilerplate)] pub(crate) struct PreviewPdfHtml { pub(crate) inscription_id: InscriptionId, diff --git a/templates/preview-model.html b/templates/preview-model.html new file mode 100644 index 0000000000..5386001130 --- /dev/null +++ b/templates/preview-model.html @@ -0,0 +1,17 @@ + + + + + + + + + + + diff --git a/tests/parse.rs b/tests/parse.rs index 1877c25ec7..a8f7cc381b 100644 --- a/tests/parse.rs +++ b/tests/parse.rs @@ -26,7 +26,7 @@ fn hash() { #[test] fn unrecognized_object() { CommandBuilder::new("parse A") - .stderr_regex(r#"error: .*: unrecognized object\n.*"#) + .stderr_regex(r"error: .*: unrecognized object\n.*") .expected_exit_code(2) .run_and_extract_stdout(); }