diff --git a/Cargo.toml b/Cargo.toml index a5b8768..b017d67 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sitewriter" -version = "0.4.0" +version = "0.4.1" authors = ["Edgar "] edition = "2018" description = "A sitemap writing library." @@ -13,13 +13,19 @@ categories = ["parsing"] [dependencies] chrono = "0.4.19" -derive_builder = "0.10.0" +derive_builder = "0.10.2" quick-xml = "0.22.0" -url = "2.2.1" +url = "2.2.2" [dev-dependencies] -criterion = { version = "0.3.4", features = ["html_reports"] } +criterion = { version = "0.3.5", features = ["html_reports"] } [[bench]] name = "benchmark" harness = false + +[profile.bench] +debug = true + +[profile.release] +debug = true diff --git a/README.md b/README.md index 6fdc50c..a0873f0 100644 --- a/README.md +++ b/README.md @@ -1,68 +1,69 @@ -# Sitewriter -[![Rust](https://github.com/edg-l/sitewriter/workflows/Rust/badge.svg)](https://github.com/edg-l/sitewriter/actions) -[![crates.io](http://meritbadge.herokuapp.com/sitewriter)](https://crates.io/crates/sitewriter) -[![License](https://img.shields.io/github/license/edg-l/sitewriter)](https://github.com/edg-l/sitewriter/blob/master/LICENSE) -[![codecov](https://codecov.io/gh/edg-l/sitewriter/branch/master/graph/badge.svg?token=JKOQCRSCZU)](https://codecov.io/gh/edg-l/sitewriter) +# sitewriter -A rust library to generate sitemaps. +### A library to generate sitemaps. + +[![Version](https://img.shields.io/crates/v/sitewriter)](https://crates.io/crates/sitewriter) +[![Downloads](https://img.shields.io/crates/d/sitewriter)](https://crates.io/crates/sitewriter) +[![License](https://img.shields.io/crates/l/sitewriter)](https://crates.io/crates/sitewriter) +![Rust](https://github.com/edg-l/sitewriter-rs/workflows/Rust/badge.svg) +[![Docs](https://docs.rs/sitewriter/badge.svg)](https://docs.rs/sitewriter) It uses the [quick-xml](https://github.com/tafia/quick-xml) so it should be fast. -## Example - -To run the examples use `cargo run --example gen_sitemap` +### Example ```rust - use chrono::prelude::*; - use sitewriter::*; +use chrono::prelude::*; +use sitewriter::*; -let urls = vec![ - UrlEntryBuilder::default() - .loc("https://edgarluque.com/projects".parse().unwrap()) - .build() - .unwrap(), - UrlEntry { - loc: "https://edgarluque.com/".parse().unwrap(), - changefreq: Some(ChangeFreq::Daily), - priority: Some(1.0), - lastmod: Some(Utc::now()), - }, - UrlEntry { - loc: "https://edgarluque.com/blog".parse().unwrap(), - changefreq: Some(ChangeFreq::Weekly), - priority: Some(0.8), - lastmod: Some(Utc::now()), - }, - UrlEntry { - loc: "https://edgarluque.com/blog/sitewriter".parse().unwrap(), - changefreq: Some(ChangeFreq::Never), - priority: Some(0.5), - lastmod: Some(Utc.ymd(2020, 11, 22).and_hms(15, 10, 15)), - }, - UrlEntry { - loc: "https://edgarluque.com/blog/some-future-post" - .parse() - .unwrap(), - changefreq: Some(ChangeFreq::Never), - priority: Some(0.5), - lastmod: Some( - Utc.from_utc_datetime(&Local.ymd(2020, 12, 5).and_hms(12, 30, 0).naive_utc()), - ), - }, - // Entity escaping - UrlEntry { - loc: "https://edgarluque.com/blog/test&id=''" - .parse() - .unwrap(), - changefreq: Some(ChangeFreq::Never), - priority: Some(0.5), - lastmod: Some( - Utc.from_utc_datetime(&Local.ymd(2020, 12, 5).and_hms(12, 30, 0).naive_utc()), - ), - }, -]; + let urls = vec![ + UrlEntryBuilder::default() + .loc("https://edgarluque.com/projects".parse().unwrap()) + .build() + .unwrap(), + UrlEntry { + loc: "https://edgarluque.com/".parse().unwrap(), + changefreq: Some(ChangeFreq::Daily), + priority: Some(1.0), + lastmod: Some(Utc::now()), + }, + UrlEntry { + loc: "https://edgarluque.com/blog".parse().unwrap(), + changefreq: Some(ChangeFreq::Weekly), + priority: Some(0.8), + lastmod: Some(Utc::now()), + }, + UrlEntry { + loc: "https://edgarluque.com/blog/sitewriter".parse().unwrap(), + changefreq: Some(ChangeFreq::Never), + priority: Some(0.5), + lastmod: Some(Utc.ymd(2020, 11, 22).and_hms(15, 10, 15)), + }, + UrlEntry { + loc: "https://edgarluque.com/blog/some-future-post" + .parse() + .unwrap(), + changefreq: Some(ChangeFreq::Never), + priority: Some(0.5), + lastmod: Some( + Utc.from_utc_datetime(&Local.ymd(2020, 12, 5).and_hms(12, 30, 0).naive_utc()), + ), + }, + // Entity escaping + UrlEntry { + loc: "https://edgarluque.com/blog/test&id=''" + .parse() + .unwrap(), + changefreq: Some(ChangeFreq::Never), + priority: Some(0.5), + lastmod: Some( + Utc.from_utc_datetime(&Local.ymd(2020, 12, 5).and_hms(12, 30, 0).naive_utc()), + ), + }, + ]; -let result = Sitemap::into_str(&urls).unwrap(); -println!("{}", result); + let result = Sitemap::generate_str(&urls).unwrap(); + println!("{}", result); ``` +License: MIT diff --git a/src/lib.rs b/src/lib.rs index 8b332c4..87424d9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,11 @@ //! ## A library to generate sitemaps. //! +//! [![Version](https://img.shields.io/crates/v/sitewriter)](https://crates.io/crates/sitewriter) +//! [![Downloads](https://img.shields.io/crates/d/sitewriter)](https://crates.io/crates/sitewriter) +//! [![License](https://img.shields.io/crates/l/sitewriter)](https://crates.io/crates/sitewriter) +//! ![Rust](https://github.com/edg-l/sitewriter-rs/workflows/Rust/badge.svg) +//! [![Docs](https://docs.rs/sitewriter/badge.svg)](https://docs.rs/sitewriter) +//! //! It uses the [quick-xml](https://github.com/tafia/quick-xml) so it should be fast. //! //! ## Example