diff --git a/Cargo.lock b/Cargo.lock index 20cdb026..60fad3de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -324,6 +324,61 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "allocator-api2" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" + +[[package]] +name = "anstream" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "anstyle-parse" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +dependencies = [ + "anstyle", + "windows-sys 0.59.0", +] + [[package]] name = "anyhow" version = "1.0.93" @@ -409,6 +464,12 @@ dependencies = [ "serde", ] +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + [[package]] name = "byteorder" version = "1.5.0" @@ -467,6 +528,45 @@ dependencies = [ "inout", ] +[[package]] +name = "clap" +version = "4.5.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" +dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.5.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_lex" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" + +[[package]] +name = "codemap" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e769b5c8c8283982a987c6e948e540254f1058d5a74b8794914d4ef5fc2a24" + +[[package]] +name = "colorchoice" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" + [[package]] name = "colored" version = "2.1.0" @@ -649,6 +749,7 @@ name = "drust" version = "0.0.3" dependencies = [ "pagetop", + "pagetop-bootsier", ] [[package]] @@ -832,8 +933,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] @@ -871,6 +974,31 @@ dependencies = [ "regex-syntax 0.8.5", ] +[[package]] +name = "grass" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7a68216437ef68f0738e48d6c7bb9e6e6a92237e001b03d838314b068f33c94" +dependencies = [ + "clap", + "getrandom", + "grass_compiler", +] + +[[package]] +name = "grass_compiler" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d9e3df7f0222ce5184154973d247c591d9aadc28ce7a73c6cd31100c9facff6" +dependencies = [ + "codemap", + "indexmap", + "lasso", + "once_cell", + "phf", + "rand", +] + [[package]] name = "h2" version = "0.3.26" @@ -890,6 +1018,16 @@ dependencies = [ "tracing", ] +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "allocator-api2", +] + [[package]] name = "hashbrown" version = "0.15.1" @@ -1117,7 +1255,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.15.1", ] [[package]] @@ -1148,6 +1286,12 @@ dependencies = [ "unic-langid", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itoa" version = "1.0.11" @@ -1163,12 +1307,30 @@ dependencies = [ "libc", ] +[[package]] +name = "js-sys" +version = "0.3.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "language-tags" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" +[[package]] +name = "lasso" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e14eda50a3494b3bf7b9ce51c52434a761e383d7238ce1dd5dcec2fbc13e9fb" +dependencies = [ + "hashbrown 0.14.5", +] + [[package]] name = "lazy_static" version = "1.5.0" @@ -1355,6 +1517,7 @@ dependencies = [ "colored", "concat-string", "figlet-rs", + "fluent-bundle", "fluent-templates", "nom", "pagetop-macros", @@ -1371,10 +1534,30 @@ dependencies = [ "unic-langid", ] +[[package]] +name = "pagetop-aliner" +version = "0.0.1" +dependencies = [ + "pagetop", + "pagetop-build", + "static-files", +] + +[[package]] +name = "pagetop-bootsier" +version = "0.0.18" +dependencies = [ + "pagetop", + "pagetop-aliner", + "pagetop-build", + "static-files", +] + [[package]] name = "pagetop-build" version = "0.0.11" dependencies = [ + "grass", "static-files", ] @@ -1437,6 +1620,48 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[package]] +name = "phf" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +dependencies = [ + "phf_macros", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +dependencies = [ + "phf_shared", + "rand", +] + +[[package]] +name = "phf_macros" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "phf_shared" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +dependencies = [ + "siphasher", +] + [[package]] name = "pin-project" version = "1.1.7" @@ -1790,6 +2015,12 @@ dependencies = [ "libc", ] +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + [[package]] name = "slab" version = "0.4.9" @@ -1841,6 +2072,12 @@ dependencies = [ "path-slash", ] +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "substring" version = "1.4.5" @@ -2232,6 +2469,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "uuid" version = "1.11.0" @@ -2275,6 +2518,61 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index eb584dcc..39d7caaf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,8 +7,8 @@ members = [ # Packages "packages/pagetop", -# "packages/pagetop-bootsier", -# "packages/pagetop-macros", + "packages/pagetop-aliner", + "packages/pagetop-bootsier", # App "packages/drust", @@ -22,65 +22,18 @@ members = [ [workspace.package] homepage = "https://pagetop.cillero.es" repository = "https://github.com/manuelcillero/pagetop" -license = "MIT OR Apache-2.0" authors = ["Manuel Cillero "] +license = "MIT OR Apache-2.0" [workspace.dependencies] serde = { version = "1.0", features = ["derive"] } static-files = "0.2.4" +# Helpers pagetop-build = { version = "0.0", path = "helpers/pagetop-build" } pagetop-macros = { version = "0.0", path = "helpers/pagetop-macros" } +# Packages pagetop = { version = "0.0", path = "packages/pagetop" } - - - - -actix-web = "4" -actix-web-files = { package = "actix-files", version = "0.6" } -actix-web-static-files = "4.0" -actix-session = { version = "0.10", features = ["cookie-session"] } -fluent-templates = "0.11" -fluent-bundle = "0.15" -nom = "7.1" -substring = "1.4" -tracing = "0.1" -tracing-appender = "0.2" -tracing-subscriber = { version = "0.3", features = ["json", "env-filter"] } -tracing-actix-web = "0.7" -unic-langid = { version = "0.9", features = ["macros"] } - - -#[dependencies] -#chrono = "0.4.38" -#concat-string = "1.0.1" -#figlet-rs = "0.1.5" -#itoa = "1.0.11" -#nom = "7.1.3" -#paste = "1.0.15" -#substring = "1.4.5" -#terminal_size = "0.4.0" -#toml = "0.8.19" - -#tracing = "0.1.40" -#tracing-appender = "0.2.3" -#tracing-subscriber = { version = "0.3.18", features = ["json", "env-filter"] } -#tracing-actix-web = "0.7.14" - -#fluent-templates = "0.11.0" -#unic-langid = { version = "0.9.5", features = ["macros"] } - -#actix-web = "4" -#actix-session = { version = "0.10.1", features = ["cookie-session"] } - -#actix-web-files = { package = "actix-files", version = "0.6.6" } -#actix-web-static-files = "4.0.1" -#static-files = "0.2.4" - -#pagetop-macros = { version = "0.0", path = "helpers/pagetop-macros" } - -#serde = { version = "1.0", features = ["derive"] } - -#[build-dependencies] -#pagetop-build = { version = "0.0", path = "helpers/pagetop-build" } +pagetop-aliner = { version = "0.0", path = "packages/pagetop-aliner" } +pagetop-bootsier = { version = "0.0", path = "packages/pagetop-bootsier" } diff --git a/helpers/pagetop-build/Cargo.toml b/helpers/pagetop-build/Cargo.toml index cd6d7448..cd58a95d 100644 --- a/helpers/pagetop-build/Cargo.toml +++ b/helpers/pagetop-build/Cargo.toml @@ -3,15 +3,17 @@ name = "pagetop-build" version = "0.0.11" edition = "2021" -description = "Simplifies the process of embedding resources in PageTop app binaries." - +description = """\ + Simplifies the process of embedding resources in PageTop app binaries.\ +""" categories = ["development-tools::build-utils", "web-programming"] keywords = ["pagetop", "build", "assets", "resources", "static"] homepage = { workspace = true } repository = { workspace = true } -license = { workspace = true } authors = { workspace = true } +license = { workspace = true } [dependencies] -static-files.workspace = true +grass = "0.13.4" +static-files = { workspace = true } diff --git a/helpers/pagetop-build/src/lib.rs b/helpers/pagetop-build/src/lib.rs index a756ea55..0e36f2dc 100644 --- a/helpers/pagetop-build/src/lib.rs +++ b/helpers/pagetop-build/src/lib.rs @@ -1,57 +1,76 @@ -//! This function uses the [static_files](https://docs.rs/static-files/latest/static_files/) library -//! to embed at compile time a bundle of static files in your binary. +//! **`StaticFilesBundle`** uses [static_files](https://docs.rs/static-files/latest/static_files/) +//! to provide an easy way to embed static files or compiled SCSS files into your binary at compile +//! time. //! -//! Just create folder with static resources in your project (for example `static`): +//! ## Adding to your project //! -//! ```bash -//! cd project_dir -//! mkdir static -//! echo "Hello, world!" > static/hello -//! ``` -//! -//! Add to `Cargo.toml` the required dependencies: +//! Add the following to your `Cargo.toml`: //! //! ```toml //! [build-dependencies] //! pagetop-build = { ... } //! ``` //! -//! Add `build.rs` with call to bundle resources (*guides* will be the magic word in this example): +//! Next, create a `build.rs` file to configure how your static resources or SCSS files will be +//! bundled in your PageTop application, package, or theme. +//! +//! ## Usage examples +//! +//! ### 1. Embedding static files from a directory +//! +//! Include all files from a directory: //! //! ```rust#ignore //! use pagetop_build::StaticFilesBundle; //! //! fn main() -> std::io::Result<()> { -//! StaticFilesBundle::from_dir("./static") -//! .with_name("guides") -//! .build() +//! StaticFilesBundle::from_dir("./static", None) // Include all files. +//! .with_name("guides") // Name the generated module. +//! .build() // Build the bundle. //! } //! ``` //! -//! Optionally, you can pass a function to filter those files into the `./static` folder which -//! should be excluded in the resources bundle: +//! Apply a filter to include only specific files: //! //! ```rust#ignore //! use pagetop_build::StaticFilesBundle; +//! use std::path::Path; //! //! fn main() -> std::io::Result<()> { -//! StaticFilesBundle::from_dir("./static") -//! .with_name("guides") -//! .with_filter(except_css_dir) -//! .build() -//! } -//! -//! fn except_css_dir(p: &Path) -> bool { -//! if let Some(parent) = p.parent() { -//! !matches!(parent.to_str(), Some("/css")) +//! fn only_css_files(path: &Path) -> bool { +//! // Include only files with `.css` extension. +//! path.extension().map_or(false, |ext| ext == "css") //! } -//! true +//! +//! StaticFilesBundle::from_dir("./static", Some(only_css_files)) +//! .with_name("guides") +//! .build() //! } //! ``` //! -//! This will create a file called `guides.rs` in the standard directory +//! ### 2. Compiling SCSS files to CSS +//! +//! Compile a SCSS file into CSS and embed it: +//! +//! ```rust#ignore +//! use pagetop_build::StaticFilesBundle; +//! +//! fn main() -> std::io::Result<()> { +//! StaticFilesBundle::from_scss("./styles/main.scss", "main.css") +//! .with_name("main_styles") +//! .build() +//! } +//! ``` +//! +//! This compiles the `main.scss` file, including all imported SCSS files, into `main.css`. All +//! imports are resolved automatically, and the result is accessible within the binary file. +//! +//! ## Generated module +//! +//! `StaticFilesBundle` generates a file in the standard directory //! [OUT_DIR](https://doc.rust-lang.org/cargo/reference/environment-variables.html) where all -//! intermediate and output artifacts are placed during compilation. +//! intermediate and output artifacts are placed during compilation. For example, if you use +//! `with_name("guides")`, it generates a file named `guides.rs`: //! //! You don't need to access this file, just include it in your project using the builder name as an //! identifier: @@ -62,8 +81,7 @@ //! static_files!(guides); //! ``` //! -//! Also you can get the bundle as a static reference to the generated `HashMap` resources -//! collection: +//! Or, access the entire bundle as a static `HashMap`: //! //! ```rust#ignore //! use pagetop::prelude::*; @@ -73,13 +91,103 @@ //! //! You can build more than one resources file to compile with your project. +use grass::{from_path, Options, OutputStyle}; +use static_files::{resource_dir, ResourceDir}; + +use std::fs::{create_dir_all, remove_dir_all, File}; +use std::io::Write; use std::path::Path; -pub struct StaticFilesBundle(static_files::ResourceDir); +pub struct StaticFilesBundle { + resource_dir: ResourceDir, +} impl StaticFilesBundle { - pub fn from_dir(dir: &'static str) -> Self { - StaticFilesBundle(static_files::resource_dir(dir)) + /// Creates a bundle from a directory of static files, with an optional filter. + /// + /// # Arguments + /// + /// * `dir` - The directory containing the static files. + /// * `filter` - An optional function to filter files or directories to include. + pub fn from_dir(dir: &'static str, filter: Option bool>) -> Self { + let mut resource_dir = resource_dir(dir); + + // Apply the filter if provided. + if let Some(f) = filter { + resource_dir.with_filter(f); + } + + StaticFilesBundle { resource_dir } + } + + /// Creates a bundle starting from a SCSS file. + /// + /// # Arguments + /// + /// * `path` - The SCSS file to compile. + /// * `target_name` - The name for the CSS file in the bundle. + /// + /// This function will panic: + /// + /// * If the environment variable `OUT_DIR` is not set. + /// * If it is unable to create a temporary directory in the `OUT_DIR`. + /// * If the SCSS file cannot be compiled due to syntax errors in the SCSS file or missing + /// dependencies or import paths required for compilation. + /// * If it is unable to create the output CSS file in the temporary directory due to an invalid + /// `target_name` or insufficient permissions to create files in the temporary directory. + /// * If the function fails to write the compiled CSS content to the file. + pub fn from_scss

(path: P, target_name: &str) -> Self + where + P: AsRef, + { + // Create a temporary directory for the CSS file. + let out_dir = std::env::var("OUT_DIR").unwrap(); + let temp_dir = Path::new(&out_dir).join("from_scss_files"); + // Clean up the temporary directory from previous runs, if it exists. + if temp_dir.exists() { + remove_dir_all(&temp_dir).unwrap_or_else(|e| { + panic!( + "Failed to clean temporary directory `{}`: {e}", + temp_dir.display() + ); + }); + } + create_dir_all(&temp_dir).unwrap_or_else(|e| { + panic!( + "Failed to create temporary directory `{}`: {e}", + temp_dir.display() + ); + }); + + // Compile SCSS to CSS. + let css_content = from_path( + path.as_ref(), + &Options::default().style(OutputStyle::Compressed), + ) + .unwrap_or_else(|e| { + panic!( + "Failed to compile SCSS file `{}`: {e}", + path.as_ref().display(), + ) + }); + + // Write the compiled CSS to the temporary directory. + let css_path = temp_dir.join(target_name); + File::create(&css_path) + .expect(&format!( + "Failed to create CSS file `{}`", + css_path.display() + )) + .write_all(css_content.as_bytes()) + .expect(&format!( + "Failed to write CSS content to `{}`", + css_path.display() + )); + + // Initialize ResourceDir with the temporary directory. + StaticFilesBundle { + resource_dir: resource_dir(temp_dir.to_str().unwrap()), + } } /// Configures the name for the bundle of static files. @@ -88,16 +196,11 @@ impl StaticFilesBundle { /// /// This function will panic if the standard `OUT_DIR` environment variable is not set. pub fn with_name(mut self, name: &'static str) -> Self { - self.0.with_generated_filename( - Path::new(std::env::var("OUT_DIR").unwrap().as_str()).join(format!("{name}.rs")), - ); - self.0.with_module_name(format!("bundle_{name}")); - self.0.with_generated_fn(name); - self - } - - pub fn with_filter(mut self, filter: fn(p: &Path) -> bool) -> Self { - self.0.with_filter(filter); + let out_dir = std::env::var("OUT_DIR").unwrap(); + let filename = Path::new(&out_dir).join(format!("{name}.rs")); + self.resource_dir.with_generated_filename(filename); + self.resource_dir.with_module_name(format!("bundle_{name}")); + self.resource_dir.with_generated_fn(name); self } @@ -108,6 +211,6 @@ impl StaticFilesBundle { /// This function will return an error if there is an issue with I/O operations, such as failing /// to read or write to a file. pub fn build(self) -> std::io::Result<()> { - self.0.build() + self.resource_dir.build() } } diff --git a/helpers/pagetop-macros/Cargo.toml b/helpers/pagetop-macros/Cargo.toml index 9e9f3a3d..5fc12212 100644 --- a/helpers/pagetop-macros/Cargo.toml +++ b/helpers/pagetop-macros/Cargo.toml @@ -3,15 +3,16 @@ name = "pagetop-macros" version = "0.0.13" edition = "2021" -description = "A collection of macros that boost PageTop development." - +description = """\ + A collection of macros that boost PageTop development.\ +""" categories = ["development-tools::procedural-macro-helpers", "web-programming"] keywords = ["pagetop", "macros", "proc-macros", "codegen"] homepage = { workspace = true } repository = { workspace = true } -license = { workspace = true } authors = { workspace = true } +license = { workspace = true } [lib] proc-macro = true diff --git a/packages/drust/Cargo.toml b/packages/drust/Cargo.toml index 75b4dafd..2dd5751c 100644 --- a/packages/drust/Cargo.toml +++ b/packages/drust/Cargo.toml @@ -3,25 +3,22 @@ name = "drust" version = "0.0.3" edition = "2021" -description = "A modern web Content Management System to share your world." - +description = """\ + A modern web Content Management System to share your world.\ +""" homepage = { workspace = true } repository = { workspace = true } -license = { workspace = true } authors = { workspace = true } +license = { workspace = true } [dependencies] -pagetop.workspace = true - - +pagetop = { workspace = true } # Packages. +pagetop-bootsier = { workspace = true } #pagetop-admin = { version = "0.0", path = "../pagetop-admin" } #pagetop-user = { version = "0.0", path = "../pagetop-user" } #pagetop-node = { version = "0.0", path = "../pagetop-node" } -# Themes. -#pagetop-bootsier = { version = "0.0", path = "../pagetop-bootsier" } -#pagetop-bulmix = { version = "0.0", path = "../pagetop-bulmix" } #[features] #default = [ "mysql" ] diff --git a/packages/drust/config/default.toml b/packages/drust/config/default.toml index a7a99871..7e1da53b 100644 --- a/packages/drust/config/default.toml +++ b/packages/drust/config/default.toml @@ -1,5 +1,5 @@ [app] -theme = "Inception" +theme = "Aliner" #theme = "Bootsier" language = "es-ES" diff --git a/packages/drust/src/main.rs b/packages/drust/src/main.rs index 02856abc..709c5cfb 100644 --- a/packages/drust/src/main.rs +++ b/packages/drust/src/main.rs @@ -6,12 +6,10 @@ impl PackageTrait for Drust { fn dependencies(&self) -> Vec { vec![ // Packages. + &pagetop_bootsier::Bootsier, //&pagetop_admin::Admin, //&pagetop_user::User, //&pagetop_node::Node, - // Themes. - //&pagetop_bootsier::Bootsier, - //&pagetop_bulmix::Bulmix, ] } } diff --git a/packages/pagetop-aliner/Cargo.toml b/packages/pagetop-aliner/Cargo.toml new file mode 100644 index 00000000..3c5187b3 --- /dev/null +++ b/packages/pagetop-aliner/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "pagetop-aliner" +version = "0.0.1" +edition = "2021" + +description = """\ + PageTop default theme.\ +""" +categories = ["web-programming", "gui"] +keywords = ["pagetop", "theme", "css", "js"] + +homepage = { workspace = true } +repository = { workspace = true } +authors = { workspace = true } +license = { workspace = true } + +[dependencies] +pagetop = { workspace = true } +static-files = { workspace = true } + +[build-dependencies] +pagetop-build = { workspace = true } diff --git a/packages/pagetop-aliner/README.md b/packages/pagetop-aliner/README.md new file mode 100644 index 00000000..724f70eb --- /dev/null +++ b/packages/pagetop-aliner/README.md @@ -0,0 +1,37 @@ +

+ +

PageTop Bootsier

+ +

PageTop theme that uses Bootstrap framework for versatile styles and components.

+ +[![License](https://img.shields.io/badge/license-MIT%2FApache-blue.svg?style=for-the-badge)](#-license) +[![API Docs](https://img.shields.io/docsrs/pagetop-bootsier?label=API%20Docs&style=for-the-badge&logo=Docs.rs)](https://docs.rs/pagetop-bootsier) +[![Crates.io](https://img.shields.io/crates/v/pagetop-bootsier.svg?style=for-the-badge&logo=ipfs)](https://crates.io/crates/pagetop-bootsier) +[![Downloads](https://img.shields.io/crates/d/pagetop-bootsier.svg?style=for-the-badge&logo=transmission)](https://crates.io/crates/pagetop-bootsier) + +
+ +# 📦 About PageTop + +[PageTop](https://docs.rs/pagetop) is an opinionated web framework to build modular *Server-Side +Rendering* web solutions. + + +# 🚧 Warning + +**PageTop** framework is currently in active development. The API is unstable and subject to +frequent changes. Production use is not recommended until version **0.1.0**. + + +# 📜 License + +All code in this crate is dual-licensed under either: + + * MIT License + ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT) + + * Apache License, Version 2.0, + ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0) + +at your option. This means you can select the license you prefer! This dual-licensing approach is +the de-facto standard in the Rust ecosystem. diff --git a/packages/pagetop-aliner/_build.rs b/packages/pagetop-aliner/_build.rs new file mode 100644 index 00000000..fd9dc778 --- /dev/null +++ b/packages/pagetop-aliner/_build.rs @@ -0,0 +1,19 @@ +use pagetop_build::StaticFilesBundle; + +use std::env; +use std::path::Path; + +fn main() -> std::io::Result<()> { + StaticFilesBundle::from_scss("./static/bootstrap-5.3.3/bootstrap.scss", "bootstrap.css") + .with_name("bootsier") + .build()?; + StaticFilesBundle::from_dir("./static/js", Some(bootstrap_js_files)) + .with_name("bootsier-js") + .build() +} + +fn bootstrap_js_files(path: &Path) -> bool { + // No filtering during development, only on "release" compilation. + env::var("PROFILE").unwrap_or_else(|_| "release".to_string()) != "release" + || path.file_name().map_or(false, |n| n == "bootstrap.min.js") +} diff --git a/packages/pagetop-aliner/src/lib.rs b/packages/pagetop-aliner/src/lib.rs new file mode 100644 index 00000000..35276744 --- /dev/null +++ b/packages/pagetop-aliner/src/lib.rs @@ -0,0 +1,193 @@ +use pagetop::prelude::*; + +static_locales!(LOCALES_ALINER); + +//static_files!(bootsier); + +pub struct Aliner; + +impl PackageTrait for Aliner { + fn theme(&self) -> Option { + Some(&Aliner) + } + /* + fn actions(&self) -> Vec { + actions![ + action::theme::BeforePrepare::::new(&Self, before_prepare_icon), + action::theme::BeforePrepare::