codedpedia

所属分类:前端开发
开发工具:Rust
文件大小:0KB
下载次数:0
上传日期:2023-06-19 01:13:36
上 传 者sh-1993
说明:  一个静态站点生成器,用于在Rust中编写和编程的静态百科全书。
(A static site generator for static encyclopedias that are written, programmed in Rust.)

文件列表:
Cargo.toml (156, 2023-09-08)
LICENSE (35149, 2023-09-08)
examples/ (0, 2023-09-08)
examples/assets/ (0, 2023-09-08)
examples/assets/styles/ (0, 2023-09-08)
examples/assets/styles/main.css (2605, 2023-09-08)
examples/simple_pedia.rs (4676, 2023-09-08)
src/ (0, 2023-09-08)
src/component.rs (2110, 2023-09-08)
src/component/ (0, 2023-09-08)
src/component/asset.rs (2922, 2023-09-08)
src/component/block.rs (2221, 2023-09-08)
src/component/block/ (0, 2023-09-08)
src/component/block/list.rs (10322, 2023-09-08)
src/component/block/media.rs (5274, 2023-09-08)
src/component/block/table.rs (19541, 2023-09-08)
src/component/block/text.rs (7737, 2023-09-08)
src/component/inline.rs (4925, 2023-09-08)
src/component/inline/ (0, 2023-09-08)
src/component/inline/media.rs (2504, 2023-09-08)
src/component/inline/text.rs (7878, 2023-09-08)
src/component/page.rs (14232, 2023-09-08)
src/component/section.rs (12749, 2023-09-08)
src/helpers.rs (369, 2023-09-08)
src/hseq.rs (7636, 2023-09-08)
src/hseq/ (0, 2023-09-08)
src/hseq/coproduct.rs (4386, 2023-09-08)
src/lib.rs (8187, 2023-09-08)
src/location.rs (17718, 2023-09-08)
src/render.rs (13161, 2023-09-08)
src/render/ (0, 2023-09-08)
src/render/combinators.rs (448, 2023-09-08)
src/render/common_text.rs (4053, 2023-09-08)
... ...

# Codedpedia Codedpedia is a static site generator designed for static encyclopedias that are programmed in Rust. The project can be resumed in a few items: - Components; - Component kinds; - Rendering formats; - Sites. Components implement the `Component` trait and have a `ComponentKind` associated with it that serves for the purpose of typing components. Codedpedia's builtin component kinds are: - `InlineComponent` - components inlined in text; - `BlockComponent` - components with blocks of their own; - `table::CellComponent` - cells of a table; - `table::RowComponent` - rows of a table; - `SectionComponent` - sections of an article/page; - `AssetComponent` - asset of an article/page; - `PageComponent` - the whole article/page. Rendering formats are a proxy to Rust's `fmt` which allows specific formatting e.g. in a specific context, such as in a nested list. More important than that is that they also are used to define what kind of output the rendering will produce. Builtin rendering formats are: - HTML; - Markdown; - Plaintext. Components can implement a trait named `Render` where `W` is a rendering format. For instance, if a component wants to render HTML, it must implement `Render`. Finally, a `Site` is a collection of pages structured in terms of in-memory directories. The build process consists of generating pages into actual directories, as well copying resources. Look at the function `static_site_main`. No JavaScript dependency required for the build output. # Documentation https://brunoczim.github.io/codedpedia/codedpedia/ # Example ```rust use codedpedia::{ component::{ asset::{AssetComponent, Stylesheet}, block::{list::UnorderedList, text::Paragraph, InlineBlock}, inline::text::Link, page::{Page, PageComponent}, section::Section, BlockComponent, }, harray, location::{Id, InternalPath, Location}, render::{DynFullComponent, FullRender, Html, Render}, site::{Entry, Site}, static_site_main, }; fn default_assets( ) -> impl Render + Send + Sync + 'static { [Stylesheet { location: Location::internal("styles/main.css") }] } fn banner() -> impl FullRender + Send + Sync + 'static { InlineBlock(Link { target: "Simple Pedia", location: Location::internal(""), }) } fn index() -> impl FullRender + Send + Sync + 'static { Page { banner: banner(), title: String::from("Simple Pedia"), assets: default_assets(), body: harray![ Paragraph( "This is the initial page of the simple pedia. You can dive \ down into the following:" ), UnorderedList(harray![ InlineBlock(Link { location: Location::internal("foo"), target: "Foo stuff", }), InlineBlock(Link { location: Location::internal("bar"), target: "Bar stiff", }), ]), ], children: harray![ Section { title: "Random Section", id: Some(Id::new("random").unwrap()), body: Paragraph("This is a random paragraph."), children: harray![ Section { title: "Randomly First", id: Some(Id::new("random-first").unwrap()), body: Paragraph( "This the first (really?) random paragraph." ), children: harray![], }, Section { title: "Randomly Second", id: Some(Id::new("random-second").unwrap()), body: Paragraph( "This the second (really??) random paragraph." ), children: harray![], } ], }, Section { title: "Weird Title", id: Some(Id::new("weird").unwrap()), body: Paragraph("Weird paragraph as an example"), children: harray![], } ], } } fn foo_page() -> impl FullRender + Send + Sync + 'static { Page { banner: banner(), title: String::from("Foo"), assets: default_assets(), body: harray![Paragraph("Foo is a metavariable."),], children: harray![], } } fn bar_page() -> impl FullRender + Send + Sync + 'static { Page { banner: banner(), title: String::from("Bar"), assets: default_assets(), body: harray![Paragraph(harray![ "Bar is a metavariable. ", Link { location: Location::internal("bar/baz"), target: "Baz" }, " is also a metavariable." ])], children: harray![], } } fn baz_page() -> impl FullRender + Send + Sync + 'static { Page { banner: banner(), title: String::from("Baz"), assets: default_assets(), body: harray![Paragraph(harray![ "Baz is a metavariable, similar to ", Link { location: Location::internal("bar"), target: "Bar" }, "." ])], children: harray![], } } fn simple_pedia_site() -> Site> { let mut site = Site::default(); site.root .insert_index(InternalPath::root(), Entry::Page(index().into_dyn())); site.root.insert_index( InternalPath::parse("foo").unwrap(), Entry::Page(foo_page().into_dyn()), ); site.root.insert_index( InternalPath::parse("bar").unwrap(), Entry::Page(bar_page().into_dyn()), ); site.root.insert_index( InternalPath::parse("bar/baz").unwrap(), Entry::Page(baz_page().into_dyn()), ); site.root.insert_path( &InternalPath::parse("styles/main.css").unwrap(), Entry::Resource, ); site } fn main() { let site = simple_pedia_site(); static_site_main(&site, &mut Html, "examples/build", "examples/assets"); } ```

近期下载者

相关文件


收藏者