diff --git a/index.html b/resources/index.html similarity index 61% rename from index.html rename to resources/index.html index e265963..962d635 100644 --- a/index.html +++ b/resources/index.html @@ -1,8 +1,12 @@ - Newsletters + + Newsletters + +

Newsletters 2 Web

+

The real feed can be found at feed.atom

Nothing to see here.

This is a public landing page for an instance of the Newsletters 2 Web diff --git a/src/main.rs b/src/main.rs index a47d049..ccacff8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,8 @@ use std::{ pub(crate) use message::Message; +const INDEX_HTML: & 'static str = include_str!("../resources/index.html"); + fn main() -> Result<(), Box> { let cli = cli::Cli::parse(); @@ -96,6 +98,8 @@ fn build_feed(filename: &PathBuf, hostname: String, include_html: bool) -> Resul write_file(&path, processed_html.as_bytes())?; } + write_file(dir.join("index.html"), INDEX_HTML)?; + feed::add_entry_to_feed(&mut feed, &msg, &processed_html, &hostname, include_html); } @@ -191,11 +195,12 @@ fn process_html(input: &str) -> Result { Ok(input.replace("src", "data-source")) } -fn write_file(html_path: &PathBuf, data: &[u8]) -> Result<(), std::io::Error> { +fn write_file, D: AsRef<[u8]>>(html_path: P, data: D) -> Result<(), std::io::Error> { + let path : PathBuf = html_path.into(); OpenOptions::new() .write(true) .create(true) - .open(&html_path) - .expect(format!("Could not open file '{}' for writing", &html_path.display()).as_str()) - .write_all(data) + .open(&path) + .expect(format!("Could not open file '{}' for writing", &path.display()).as_str()) + .write_all(data.as_ref()) } \ No newline at end of file