upgrade deps, version 0.4.1

This commit is contained in:
Edgar 2021-10-19 17:11:10 +02:00
parent 91a1ead43c
commit 5d93e6a617
No known key found for this signature in database
GPG key ID: 8731E6C0166EAA85
3 changed files with 75 additions and 62 deletions

View file

@ -1,6 +1,6 @@
[package] [package]
name = "sitewriter" name = "sitewriter"
version = "0.4.0" version = "0.4.1"
authors = ["Edgar <git@edgarluque.com>"] authors = ["Edgar <git@edgarluque.com>"]
edition = "2018" edition = "2018"
description = "A sitemap writing library." description = "A sitemap writing library."
@ -13,13 +13,19 @@ categories = ["parsing"]
[dependencies] [dependencies]
chrono = "0.4.19" chrono = "0.4.19"
derive_builder = "0.10.0" derive_builder = "0.10.2"
quick-xml = "0.22.0" quick-xml = "0.22.0"
url = "2.2.1" url = "2.2.2"
[dev-dependencies] [dev-dependencies]
criterion = { version = "0.3.4", features = ["html_reports"] } criterion = { version = "0.3.5", features = ["html_reports"] }
[[bench]] [[bench]]
name = "benchmark" name = "benchmark"
harness = false harness = false
[profile.bench]
debug = true
[profile.release]
debug = true

117
README.md
View file

@ -1,68 +1,69 @@
# Sitewriter # 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)
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. It uses the [quick-xml](https://github.com/tafia/quick-xml) so it should be fast.
## Example ### Example
To run the examples use `cargo run --example gen_sitemap`
```rust ```rust
use chrono::prelude::*; use chrono::prelude::*;
use sitewriter::*; use sitewriter::*;
let urls = vec![ let urls = vec![
UrlEntryBuilder::default() UrlEntryBuilder::default()
.loc("https://edgarluque.com/projects".parse().unwrap()) .loc("https://edgarluque.com/projects".parse().unwrap())
.build() .build()
.unwrap(), .unwrap(),
UrlEntry { UrlEntry {
loc: "https://edgarluque.com/".parse().unwrap(), loc: "https://edgarluque.com/".parse().unwrap(),
changefreq: Some(ChangeFreq::Daily), changefreq: Some(ChangeFreq::Daily),
priority: Some(1.0), priority: Some(1.0),
lastmod: Some(Utc::now()), lastmod: Some(Utc::now()),
}, },
UrlEntry { UrlEntry {
loc: "https://edgarluque.com/blog".parse().unwrap(), loc: "https://edgarluque.com/blog".parse().unwrap(),
changefreq: Some(ChangeFreq::Weekly), changefreq: Some(ChangeFreq::Weekly),
priority: Some(0.8), priority: Some(0.8),
lastmod: Some(Utc::now()), lastmod: Some(Utc::now()),
}, },
UrlEntry { UrlEntry {
loc: "https://edgarluque.com/blog/sitewriter".parse().unwrap(), loc: "https://edgarluque.com/blog/sitewriter".parse().unwrap(),
changefreq: Some(ChangeFreq::Never), changefreq: Some(ChangeFreq::Never),
priority: Some(0.5), priority: Some(0.5),
lastmod: Some(Utc.ymd(2020, 11, 22).and_hms(15, 10, 15)), lastmod: Some(Utc.ymd(2020, 11, 22).and_hms(15, 10, 15)),
}, },
UrlEntry { UrlEntry {
loc: "https://edgarluque.com/blog/some-future-post" loc: "https://edgarluque.com/blog/some-future-post"
.parse() .parse()
.unwrap(), .unwrap(),
changefreq: Some(ChangeFreq::Never), changefreq: Some(ChangeFreq::Never),
priority: Some(0.5), priority: Some(0.5),
lastmod: Some( lastmod: Some(
Utc.from_utc_datetime(&Local.ymd(2020, 12, 5).and_hms(12, 30, 0).naive_utc()), Utc.from_utc_datetime(&Local.ymd(2020, 12, 5).and_hms(12, 30, 0).naive_utc()),
), ),
}, },
// Entity escaping // Entity escaping
UrlEntry { UrlEntry {
loc: "https://edgarluque.com/blog/test&id='<test>'" loc: "https://edgarluque.com/blog/test&id='<test>'"
.parse() .parse()
.unwrap(), .unwrap(),
changefreq: Some(ChangeFreq::Never), changefreq: Some(ChangeFreq::Never),
priority: Some(0.5), priority: Some(0.5),
lastmod: Some( lastmod: Some(
Utc.from_utc_datetime(&Local.ymd(2020, 12, 5).and_hms(12, 30, 0).naive_utc()), Utc.from_utc_datetime(&Local.ymd(2020, 12, 5).and_hms(12, 30, 0).naive_utc()),
), ),
}, },
]; ];
let result = Sitemap::into_str(&urls).unwrap(); let result = Sitemap::generate_str(&urls).unwrap();
println!("{}", result); println!("{}", result);
``` ```
License: MIT

View file

@ -1,5 +1,11 @@
//! ## A 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. //! It uses the [quick-xml](https://github.com/tafia/quick-xml) so it should be fast.
//! //!
//! ## Example //! ## Example