Put media in correct place for export

main
Ashelyn Dawn 1 year ago
parent b57c05a8f2
commit 76fb8e6c08

@ -13,5 +13,3 @@
</body> </body>
</html> </html>
<!-- Masto UI: Roboto Regular -->
<!-- Masto Body: Roboto Regular -->

@ -62,7 +62,7 @@ fn generate() -> Result<(), Ærror> {
{ {
let output_str = render_ssr(outbox, author, archive_time)?; let output_str = render_ssr(outbox, author, archive_time)?;
println!("{}", output_str); fs::write("out/index.html", output_str);
copy_items( copy_items(
&mut vec!["resources/"], &mut vec!["resources/"],
@ -76,10 +76,12 @@ fn generate() -> Result<(), Ærror> {
fn setup_dirs(args: &GeneratorOptions) -> Result<(), crate::error::Ærror> { fn setup_dirs(args: &GeneratorOptions) -> Result<(), crate::error::Ærror> {
let output_dir = Path::new(&args.output_dir); let output_dir = Path::new(&args.output_dir);
let media_dir = output_dir.join("media");
// Create output dir // Create output dir
if !output_dir.exists() { if !output_dir.exists() {
fs::create_dir(output_dir)?; fs::create_dir(output_dir)?;
fs::create_dir(media_dir)?;
} else if !output_dir.read_dir()?.next().is_none() && !args.overwrite { } else if !output_dir.read_dir()?.next().is_none() && !args.overwrite {
return Err(Ærror::new(format!( return Err(Ærror::new(format!(
"Output directory {} exists but --overwrite not given", "Output directory {} exists but --overwrite not given",
@ -88,6 +90,7 @@ fn setup_dirs(args: &GeneratorOptions) -> Result<(), crate::error::Ærror> {
} else { } else {
fs::remove_dir_all(output_dir)?; fs::remove_dir_all(output_dir)?;
fs::create_dir(output_dir)?; fs::create_dir(output_dir)?;
fs::create_dir(media_dir)?;
} }
Ok(()) Ok(())
@ -98,6 +101,8 @@ fn read_archive(
) -> Result<(String, String, DateTime<chrono::Utc>), crate::error::Ærror> { ) -> Result<(String, String, DateTime<chrono::Utc>), crate::error::Ærror> {
#[cfg(not(debug_assertions))] #[cfg(not(debug_assertions))]
let path = &args.archive_file; let path = &args.archive_file;
let output_dir = Path::new(&args.output_dir);
let media_dir = output_dir.join("media");
let tar; let tar;
@ -151,11 +156,11 @@ fn read_archive(
"avatar.png" => { "avatar.png" => {
#[cfg(not(debug_assertions))] #[cfg(not(debug_assertions))]
file.unpack_in(&args.output_dir)?; file.unpack_in(&media_dir)?;
} }
"header.png" => { "header.png" => {
#[cfg(not(debug_assertions))] #[cfg(not(debug_assertions))]
file.unpack_in(&args.output_dir)?; file.unpack_in(&media_dir)?;
} }
_ => (), _ => (),
}; };

@ -1,6 +1,6 @@
use chrono::DateTime; use chrono::DateTime;
use futures::executor; use futures::executor;
use yew::{function_component, html, Html, Renderer, ServerRenderer, AttrValue}; use yew::{function_component, html, AttrValue, Html, Renderer, ServerRenderer};
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
use console_error_panic_hook::set_once as set_panic_hook; use console_error_panic_hook::set_once as set_panic_hook;
@ -25,9 +25,13 @@ pub fn render_ssr(
author: Person, author: Person,
archive_time: DateTime<chrono::Utc>, archive_time: DateTime<chrono::Utc>,
) -> Result<String, Ærror> { ) -> Result<String, Ærror> {
let output_template = include_str!("../index.html");
let output_string = executor::block_on(render_async(outbox, author, archive_time)); let output_string = executor::block_on(render_async(outbox, author, archive_time));
Ok(output_string) Ok(output_template.replace(
"<link data-trunk rel=\"rust\" href=\"Cargo.toml\" />",
&output_string,
))
} }
#[cfg(debug_assertions)] #[cfg(debug_assertions)]

Loading…
Cancel
Save