From 5b027d08aee87e9caed9de58d1f1bd878d23e86b Mon Sep 17 00:00:00 2001 From: Chris Wong <lambda.fairy@gmail.com> Date: Mon, 25 Mar 2019 20:36:23 +1300 Subject: [PATCH] Remove `maud_extras` crate (#168) I don't think the examples in this crate are very useful, or demonstrate how to best use the library. --- .travis.yml | 2 +- Cargo.toml | 1 - docs/content/traits.md | 3 +- maud_extras/Cargo.toml | 15 ---- maud_extras/README.md | 12 --- maud_extras/lib.rs | 193 ----------------------------------------- 6 files changed, 2 insertions(+), 224 deletions(-) delete mode 100644 maud_extras/Cargo.toml delete mode 100644 maud_extras/README.md delete mode 100644 maud_extras/lib.rs diff --git a/.travis.yml b/.travis.yml index 9ef1c44..b45243c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ script: - | if $RUN_CLIPPY; then CLIPPY_STATUS=0 - for package in maud_htmlescape maud_macros maud maud_extras; do + for package in maud_htmlescape maud_macros maud; do (cd $package && cargo clippy -- -D warnings) || CLIPPY_STATUS=$? done (exit $CLIPPY_STATUS) diff --git a/Cargo.toml b/Cargo.toml index 0b4badd..bd48ff0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,6 @@ members = [ "maud_htmlescape", "maud_macros", "maud", - "maud_extras", ] exclude = [ "benchmarks", diff --git a/docs/content/traits.md b/docs/content/traits.md index 4c5983b..344eafb 100644 --- a/docs/content/traits.md +++ b/docs/content/traits.md @@ -4,7 +4,7 @@ By default, a `(splice)` is rendered using the [`std::fmt::Display`][Display] tr To change this behavior, implement the [`Render`][Render] trait for your type. Then, when a value of this type is used in a template, Maud will call your custom code instead. -Below are some examples of using `Render`. Feel free to use these snippets in your own project! For more examples, take a look at the [`maud_extras`][maud_extras] crate. +Below are some examples of using `Render`. Feel free to use these snippets in your own project! ## Example: a shorthand for including CSS stylesheets @@ -75,7 +75,6 @@ impl<T: AsRef<str>> Render for Markdown<T> { } ``` -[maud_extras]: https://github.com/lfairy/maud/tree/master/maud_extras [Debug]: https://doc.rust-lang.org/std/fmt/trait.Debug.html [Display]: https://doc.rust-lang.org/std/fmt/trait.Display.html [Render]: https://docs.rs/maud/*/maud/trait.Render.html diff --git a/maud_extras/Cargo.toml b/maud_extras/Cargo.toml deleted file mode 100644 index a733309..0000000 --- a/maud_extras/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] - -name = "maud_extras" -version = "0.0.0" -authors = ["Chris Wong <lambda.fairy@gmail.com>"] - -license = "CC0-1.0" -repository = "https://github.com/lfairy/maud" -description = "Extra bits and pieces for use in Maud templates." - -[dependencies] -maud = { path = "../maud", features = ["iron"] } - -[lib] -path = "lib.rs" diff --git a/maud_extras/README.md b/maud_extras/README.md deleted file mode 100644 index 2fd4ba6..0000000 --- a/maud_extras/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# maud\_extras - -This crate contains various bits and pieces that can be used in Maud templates. - -To use an item from this crate, simply copy-and-paste the code into your project. Depending on `maud_extras` directly is discouraged, since (a) it often receives breaking changes, and (b) it's unlikely that you'll need everything. - - -## Contributing - -Contributions are welcome! Please note that all code in this repository is placed in the public domain ([CC0]). - -[CC0]: https://creativecommons.org/publicdomain/zero/1.0/ diff --git a/maud_extras/lib.rs b/maud_extras/lib.rs deleted file mode 100644 index dd98577..0000000 --- a/maud_extras/lib.rs +++ /dev/null @@ -1,193 +0,0 @@ -#![feature(proc_macro_hygiene)] - -extern crate maud; - -use maud::{Markup, Render, html}; - -/// Links to an external stylesheet. -/// -/// # Example -/// -/// ```rust -/// # #![feature(proc_macro_hygiene)] -/// # extern crate maud; -/// # extern crate maud_extras; -/// # use maud::html; -/// # use maud_extras::*; -/// # fn main() { -/// let markup = html! { (Css("styles.css")) }; -/// assert_eq!(markup.into_string(), -/// r#"<link rel="stylesheet" href="styles.css">"#); -/// # } -/// ``` -pub struct Css<T: AsRef<str>>(pub T); - -impl<T: AsRef<str>> Render for Css<T> { - fn render(&self) -> Markup { - html! { - link rel="stylesheet" href=(self.0.as_ref()) / - } - } -} - -/// Links to an external script. -/// -/// # Example -/// -/// ```rust -/// # #![feature(proc_macro_hygiene)] -/// # -/// # extern crate maud; -/// # extern crate maud_extras; -/// # use maud::html; -/// # use maud_extras::*; -/// # fn main() { -/// let markup = html! { (Js("app.js")) }; -/// assert_eq!(markup.into_string(), -/// r#"<script src="app.js"></script>"#); -/// # } -/// ``` -pub struct Js<T: AsRef<str>>(pub T); - -impl<T: AsRef<str>> Render for Js<T> { - fn render(&self) -> Markup { - html! { - script src=(self.0.as_ref()) {} - } - } -} - -/// Generate a `<meta>` element. -/// -/// # Example -/// -/// ```rust -/// # #![feature(proc_macro_hygiene)] -/// # extern crate maud; -/// # extern crate maud_extras; -/// # use maud::html; -/// # use maud_extras::*; -/// # fn main() { -/// let markup = html! { (Meta("description", "test description")) }; -/// assert_eq!(markup.into_string(), -/// r#"<meta name="description" content="test description">"#); -/// # } -/// ``` -pub struct Meta<T: AsRef<str>, U: AsRef<str>>(pub T, pub U); - -impl<T: AsRef<str>, U: AsRef<str>> Render for Meta<T, U> { - fn render(&self) -> Markup { - html! { - meta name=(self.0.as_ref()) content=(self.1.as_ref()) / - } - } -} - -/// Generate a `<title>` element. -/// -/// # Example -/// -/// ```rust -/// # #![feature(proc_macro_hygiene)] -/// # extern crate maud; -/// # extern crate maud_extras; -/// # use maud::html; -/// # use maud_extras::*; -/// # fn main() { -/// let markup = html! { (Title("Maud")) }; -/// assert_eq!(markup.into_string(), -/// r#"<title>Maud</title>"#); -/// # } -/// ``` -pub struct Title<T: AsRef<str>>(pub T); - -impl<T: AsRef<str>> Render for Title<T> { - fn render(&self) -> Markup { - html! { - title { (self.0.as_ref()) } - } - } -} - -/// Generate a `<meta charset="...">` element. -/// -/// # Example -/// -/// ```rust -/// # #![feature(proc_macro_hygiene)] -/// # extern crate maud; -/// # extern crate maud_extras; -/// # use maud::html; -/// # use maud_extras::*; -/// # fn main() { -/// let markup = html! { (Charset("utf-8")) }; -/// assert_eq!(markup.into_string(), -/// r#"<meta charset="utf-8">"#); -/// # } -/// ``` -pub struct Charset<T: AsRef<str>>(pub T); - -impl<T: AsRef<str>> Render for Charset<T> { - fn render(&self) -> Markup { - html! { - meta charset=(self.0.as_ref()) / - } - } -} - -/// Generate a `<meta property>` element. -/// -/// # Example -/// -/// ```rust -/// # #![feature(proc_macro_hygiene)] -/// # extern crate maud; -/// # extern crate maud_extras; -/// # use maud::html; -/// # use maud_extras::*; -/// # fn main() { -/// let markup = html! { (MetaProperty("og:description", "test description")) }; -/// assert_eq!(markup.into_string(), -/// r#"<meta property="og:description" content="test description">"#); -/// # } -/// ``` -pub struct MetaProperty<T: AsRef<str>, U: AsRef<str>>(pub T, pub U); - -impl<T: AsRef<str>, U: AsRef<str>> Render for MetaProperty<T, U> { - fn render(&self) -> Markup { - html! { - meta property=(self.0.as_ref()) content=(self.1.as_ref()) / - } - } -} - -/// Generate a `<meta robots>` element. -/// -/// # Example -/// -/// ```rust -/// # #![feature(proc_macro_hygiene)] -/// # extern crate maud; -/// # extern crate maud_extras; -/// # use maud::html; -/// # use maud_extras::*; -/// # fn main() { -/// let markup = html! { (MetaRobots { index: true, follow: false }) }; -/// assert_eq!(markup.into_string(), -/// r#"<meta name="robots" content="index,nofollow">"#); -/// # } -/// ``` -pub struct MetaRobots { - pub index: bool, - pub follow: bool, -} - -impl Render for MetaRobots { - fn render(&self) -> Markup { - let index = if self.index { "index" } else { "noindex" }; - let follow = if self.follow { "follow" } else { "nofollow" }; - html! { - meta name="robots" content={ (index) "," (follow) } / - } - } -}