fn render_feed(output_path: &Path, advisories: &[rustsec::Advisory]) {
    let mut entries: Vec<Entry> = vec![];
    let author = PersonBuilder::default().name("RustSec").build();

    // Used as latest update to feed
    let latest_advisory_date =
        advisories.first().unwrap().date().as_str().to_owned() + "T00:00:00+00:00";

    for advisory in advisories {
        let escaped_title_type = escape_str_attribute(&title_type(advisory)).into_owned();
        let escaped_title = escape_str_attribute(advisory.title()).into_owned();
        let date_time = advisory.date().as_str().to_owned() + "T00:00:00+00:00";
        let url = "https://rustsec.org/advisories/".to_owned() + advisory.id().as_str() + ".html";

        let link = LinkBuilder::default()
            .rel("alternate")
            .mime_type(Some("text/html".to_owned()))
            .title(escaped_title_type.clone())
            .href(url.clone())
            .build();

        let mut categories = vec![];
        for category in &advisory.metadata.categories {
            categories.push(
                CategoryBuilder::default()
                    .term(category.to_string())
                    .build(),
            );
        }

        let rendered_description =
            markdown_to_html(advisory.description(), &ComrakOptions::default());
        let rendered_title = markdown_to_html(advisory.title(), &ComrakOptions::default());
        let advisory_tmpl = AdvisoryContentTemplate {
            advisory,
            rendered_description,
            rendered_title,
        };
        let html = advisory_tmpl.render().unwrap();
        let content = ContentBuilder::default()
            .content_type(Some("html".to_owned()))
            .lang("en".to_owned())
            .value(Some(html))
            .build();

        let mut summary = Text::plain(escaped_title);
        summary.lang = Some("en".to_owned());

        let item = EntryBuilder::default()
            .id(url)
            .title(escaped_title_type)
            .summary(Some(summary))
            .links(vec![link])
            .categories(categories)
            .published(Some(FixedDateTime::from_str(&date_time).unwrap()))
            // required but we don't have precise data here
            .updated(FixedDateTime::from_str(&date_time).unwrap())
            .content(Some(content))
            .build();
        entries.push(item);
    }

    let self_url = "https://rustsec.org/feed.xml";
    let alternate_link = LinkBuilder::default()
        .href("https://rustsec.org/")
        .rel("alternate")
        .mime_type(Some("text/html".to_owned()))
        .build();
    let self_link = LinkBuilder::default()
        .href(self_url)
        .rel("self")
        .mime_type(Some("application/atom+xml".to_owned()))
        .build();

    let mut subtitle = Text::plain("Security advisories filed against Rust crates".to_owned());
    subtitle.lang = Some("en".to_owned());

    let feed = FeedBuilder::default()
        .id(self_url)
        .title("RustSec Advisories")
        .subtitle(Some(subtitle))
        .links(vec![self_link, alternate_link])
        .icon("https://rustsec.org/favicon.ico".to_owned())
        .entries(entries)
        .updated(FixedDateTime::from_str(&latest_advisory_date).unwrap())
        .authors(vec![author])
        .build();

    let file = File::create(&output_path).unwrap();
    feed.write_to(file).unwrap();
}
/// Renders an Atom feed of advisories
Renders an Atom feed of advisories
Renders an Atom feed of advisories
fn render_feed(output_path: &Path, advisories: &[rustsec::Advisory]) {
    let mut entries: Vec<Entry> = vec![];
    let author = PersonBuilder::default().name("RustSec").build();
    // Used as latest update to feed
    let latest_advisory_date =
        advisories.first().unwrap().date().as_str().to_owned() + "T00:00:00+00:00";
    for advisory in advisories {
        let escaped_title_type = escape_str_attribute(&title_type(advisory)).into_owned();
        let escaped_title = escape_str_attribute(advisory.title()).into_owned();
        let date_time = advisory.date().as_str().to_owned() + "T00:00:00+00:00";
        let url = "https://rustsec.org/advisories/".to_owned() + advisory.id().as_str() + ".html";
        let link = LinkBuilder::default()
            .rel("alternate")
            .mime_type(Some("text/html".to_owned()))
            .title(escaped_title_type.clone())
            .href(url.clone())
            .build();
        let mut categories = vec![];
        for category in &advisory.metadata.categories {
            categories.push(
                CategoryBuilder::default()
                    .term(category.to_string())
                    .build(),
            );
        }
        let rendered_description =
            markdown_to_html(advisory.description(), &ComrakOptions::default());
        let rendered_title = markdown_to_html(advisory.title(), &ComrakOptions::default());
        let advisory_tmpl = AdvisoryContentTemplate {
            advisory,
            rendered_description,
            rendered_title,
        };
        let html = advisory_tmpl.render().unwrap();
        let content = ContentBuilder::default()
            .content_type(Some("html".to_owned()))
            .lang("en".to_owned())
            .value(Some(html))
            .build();
        let mut summary = Text::plain(escaped_title);
        summary.lang = Some("en".to_owned());
        let item = EntryBuilder::default()
            .id(url)
            .title(escaped_title_type)
            .summary(Some(summary))
            .links(vec![link])
            .categories(categories)
            .published(Some(FixedDateTime::from_str(&date_time).unwrap()))
            // required but we don't have precise data here
            .updated(FixedDateTime::from_str(&date_time).unwrap())
            .content(Some(content))
            .build();
        entries.push(item);
    }
    let self_url = "https://rustsec.org/feed.xml";
    let alternate_link = LinkBuilder::default()
        .href("https://rustsec.org/")
        .rel("alternate")
        .mime_type(Some("text/html".to_owned()))
        .build();
    let self_link = LinkBuilder::default()
        .href(self_url)
        .rel("self")
        .mime_type(Some("application/atom+xml".to_owned()))
        .build();
    let mut subtitle = Text::plain("Security advisories filed against Rust crates".to_owned());
    subtitle.lang = Some("en".to_owned());
    let feed = FeedBuilder::default()
        .id(self_url)
        .title("RustSec Advisories")
        .subtitle(Some(subtitle))
        .links(vec![self_link, alternate_link])
        .icon("https://rustsec.org/favicon.ico".to_owned())
        .entries(entries)
        .updated(FixedDateTime::from_str(&latest_advisory_date).unwrap())
        .authors(vec![author])
        .build();
    let file = File::create(&output_path).unwrap();
    feed.write_to(file).unwrap();
}
fn render_feed ( output_path : & Path , advisories : & [ rustsec :: Advisory ] ) { let mut entries : Vec < Entry > = vec ! [ ] ; let author = PersonBuilder :: default ( ) . name ( " " ) . build ( ) ; // Used as latest update to feed let latest_advisory_date = advisories . first ( ) . unwrap ( ) . date ( ) . as_str ( ) . to_owned ( ) + " " ; for advisory in advisories { let escaped_title_type = escape_str_attribute ( & title_type ( advisory ) ) . into_owned ( ) ; let escaped_title = escape_str_attribute ( advisory . title ( ) ) . into_owned ( ) ; let date_time = advisory . date ( ) . as_str ( ) . to_owned ( ) + " " ; let url = " " . to_owned ( ) + advisory . id ( ) . as_str ( ) + " " ; let link = LinkBuilder :: default ( ) . rel ( " " ) . mime_type ( Some ( " " . to_owned ( ) ) ) . title ( escaped_title_type . clone ( ) ) . href ( url . clone ( ) ) . build ( ) ; let mut categories = vec ! [ ] ; for category in & advisory . metadata . categories { categories . push ( CategoryBuilder :: default ( ) . term ( category . to_string ( ) ) . build ( ) , ) ; } let rendered_description = markdown_to_html ( advisory . description ( ) , & ComrakOptions :: default ( ) ) ; let rendered_title = markdown_to_html ( advisory . title ( ) , & ComrakOptions :: default ( ) ) ; let advisory_tmpl = AdvisoryContentTemplate { advisory , rendered_description , rendered_title , } ; let html = advisory_tmpl . render ( ) . unwrap ( ) ; let content = ContentBuilder :: default ( ) . content_type ( Some ( " " . to_owned ( ) ) ) . lang ( " " . to_owned ( ) ) . value ( Some ( html ) ) . build ( ) ; let mut summary = Text :: plain ( escaped_title ) ; summary . lang = Some ( " " . to_owned ( ) ) ; let item = EntryBuilder :: default ( ) . id ( url ) . title ( escaped_title_type ) . summary ( Some ( summary ) ) . links ( vec ! [ link ] ) . categories ( categories ) . published ( Some ( FixedDateTime :: from_str ( & date_time ) . unwrap ( ) ) ) // required but we don't have precise data here . updated ( FixedDateTime :: from_str ( & date_time ) . unwrap ( ) ) . content ( Some ( content ) ) . build ( ) ; entries . push ( item ) ; } let self_url = " " ; let alternate_link = LinkBuilder :: default ( ) . href ( " " ) . rel ( " " ) . mime_type ( Some ( " " . to_owned ( ) ) ) . build ( ) ; let self_link = LinkBuilder :: default ( ) . href ( self_url ) . rel ( " " ) . mime_type ( Some ( " " . to_owned ( ) ) ) . build ( ) ; let mut subtitle = Text :: plain ( " " . to_owned ( ) ) ; subtitle . lang = Some ( " " . to_owned ( ) ) ; let feed = FeedBuilder :: default ( ) . id ( self_url ) . title ( " " ) . subtitle ( Some ( subtitle ) ) . links ( vec ! [ self_link alternate_link ] ) . icon ( " " . to_owned ( ) ) . entries ( entries ) . updated ( FixedDateTime :: from_str ( & latest_advisory_date ) . unwrap ( ) ) . authors ( vec ! [ author ] ) . build ( ) ; let file = File :: create ( & output_path ) . unwrap ( ) ; feed . write_to ( file ) . unwrap ( ) ; }
Renders an Atom feed of advisories
Renders an Atom feed of advisories
output_path
&Path
advisories
&[rustsec::Advisory]
output_path
&Path
advisories
&[rustsec::Advisory]