Use feed::set_stylesheet instead of hack
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details

This was contributed in https://github.com/rust-syndication/atom/pull/68.

Closes #12.

Signed-off-by: Jacob Kiers <jacob@jacobkiers.net>
This commit is contained in:
Jacob Kiers 2022-12-13 20:32:07 +01:00
parent 31fda8bae2
commit 34d301590e
3 changed files with 6 additions and 5 deletions

3
Cargo.lock generated
View File

@ -29,8 +29,7 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]]
name = "atom_syndication"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21fb6a0b39c6517edafe46f8137e53c51742425a4dae1c73ee12264a37ad7541"
source = "git+https://github.com/jacobkiers/atom-syndication?rev=525c41508db23634c565ea312bfedb51b5bd3deb#525c41508db23634c565ea312bfedb51b5bd3deb"
dependencies = [
"chrono",
"derive_builder",

View File

@ -19,3 +19,6 @@ imap = { version = "^2.4.1", default-features = false }
mail-parser = "^0.8.0"
rustls-connector = { version = "^0.16.1", default-features = false, features = [ "webpki-roots-certs", "quic" ] }
sha2 = "^0.10.2"
[patch.crates-io]
atom_syndication = { git = "https://github.com/jacobkiers/atom-syndication", rev = "525c41508db23634c565ea312bfedb51b5bd3deb" }

View File

@ -109,9 +109,8 @@ fn build_feed(filename: &PathBuf, hostname: String, include_html: bool) -> Resul
feed.set_updated(Utc::now());
println!("Writing feed to {}", filename.display());
// TODO: Ugly hack because atom_syndication crate does not support style sheets.
let feed_str = feed.to_string().as_str().replace(">\n<feed", ">\n<?xml-stylesheet href=\"feed.xsl\" type=\"text/xsl\"?>\n<feed");
let _ = write_file(filename, feed_str)?;
feed.set_stylesheet(Some("feed.xsl".into()));
let _ = write_file(filename, feed.to_string())?;
let _ = write_file(dir.join("feed.xsl"), FEED_STYLESHEET)?;
// Another ugly hack, but I don't know how to do this better...