Compare commits

..

No commits in common. "main" and "v0.1.0" have entirely different histories.
main ... v0.1.0

11 changed files with 49 additions and 48 deletions

36
Cargo.lock generated
View file

@ -115,6 +115,12 @@ dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "anyhow"
version = "1.0.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
[[package]]
name = "atom_syndication"
version = "0.12.6"
@ -1443,6 +1449,16 @@ dependencies = [
"redox_syscall",
]
[[package]]
name = "libyml"
version = "0.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3302702afa434ffa30847a83305f0a69d6abd74293b6554c18ec85c7ef30c980"
dependencies = [
"anyhow",
"version_check",
]
[[package]]
name = "linked-hash-map"
version = "0.5.6"
@ -2382,16 +2398,18 @@ dependencies = [
]
[[package]]
name = "serde_yaml_ng"
version = "0.10.0"
name = "serde_yml"
version = "0.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b4db627b98b36d4203a7b458cf3573730f2bb591b28871d916dfa9efabfd41f"
checksum = "59e2dd588bf1597a252c3b920e0143eb99b0f76e4e082f4c92ce34fbc9e71ddd"
dependencies = [
"indexmap",
"itoa 1.0.14",
"libyml",
"memchr",
"ryu",
"serde",
"unsafe-libyaml",
"version_check",
]
[[package]]
@ -2920,12 +2938,6 @@ version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
[[package]]
name = "unsafe-libyaml"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
[[package]]
name = "url"
version = "2.5.4"
@ -3094,7 +3106,7 @@ dependencies = [
[[package]]
name = "webdog"
version = "0.1.1"
version = "0.1.0"
dependencies = [
"clap",
"color-eyre",
@ -3115,7 +3127,7 @@ dependencies = [
"rayon",
"rss",
"serde",
"serde_yaml_ng",
"serde_yml",
"syntect",
"tera",
"time",

View file

@ -2,11 +2,11 @@
description = "static site generator fit for a dog"
edition = "2021"
homepage = "https://webdog.zyl.gay"
license = "AGPL-3.0-or-later"
license = "AGPLv2"
name = "webdog"
readme = "README.md"
repository = "https://github.com/zyllian/webdog"
version = "0.1.1"
version = "0.1.0"
[dependencies]
clap = {version = "4", features = ["derive"]}
@ -31,7 +31,7 @@ pulldown-cmark = {version = "0.12", default-features = false, features = [
rayon = "1"
rss = {version = "2", features = ["validation"]}
serde = {version = "1", features = ["derive"]}
serde_yaml_ng = "0.10"
serde_yml = "0.0.12"
syntect = "5"
tera = "1"
time = {version = "0.3", features = ["serde-human-readable"]}

View file

@ -3,7 +3,7 @@
webdog, the static site generator fit for a dog :3
```sh
cargo install webdog --locked
cargo install webdog
```
after installing, you can create your first site:

View file

@ -5,7 +5,7 @@ welcome to webdog, the static site generator fit for a dog :3
if you have [rust](https://rust-lang.org) installed, all you need to do to install webdog is run the following command:
```sh
cargo install webdog --locked
cargo install webdog --git https://github.com/zyllian/webdog
```
then you can make your first webdog site!

View file

@ -25,7 +25,7 @@ struct TemplateData<'a, T> {
/// Custom template data.
pub data: T,
/// Userdata supplied from the page.
pub userdata: serde_yaml_ng::Value,
pub userdata: serde_yml::Value,
}
/// Struct used to build the site.
@ -189,7 +189,7 @@ impl SiteBuilder {
let new_html = self.build_page_raw(
PageMetadata {
template: Some(template.to_string()),
userdata: serde_yaml_ng::to_value(attr_map)?,
userdata: serde_yml::to_value(attr_map)?,
is_partial: true,
..Default::default()
},
@ -267,8 +267,7 @@ impl SiteBuilder {
#[allow(clippy::single_match)]
match command {
"cdn" => {
new_src =
self.site.config.cdn_url(&new_src)?.to_string();
new_src = self.site.config.cdn_url(&new_src)?.to_string();
}
_ => new_src = src,
}
@ -292,8 +291,7 @@ impl SiteBuilder {
)?;
}
"cdn" => {
new_href =
self.site.config.cdn_url(&new_href)?.to_string();
new_href = self.site.config.cdn_url(&new_href)?.to_string();
}
_ => {
new_href = href;

View file

@ -30,7 +30,7 @@ impl Extra {
match self {
Self::Basic => {
let data: BasicData = serde_yaml_ng::from_value(data.inner.clone())?;
let data: BasicData = serde_yml::from_value(data.inner.clone())?;
let content = builder.tera.render(&data.template, &tera::Context::new())?;
append_to(&page, &content, "main.page")
}
@ -46,7 +46,7 @@ pub struct ExtraData {
pub name: String,
/// The inner data for the extra.
#[serde(flatten)]
pub inner: serde_yaml_ng::Value,
pub inner: serde_yml::Value,
}
/// Gets the extra for the given value.
@ -90,7 +90,7 @@ fn resource_list_outside(
resources: Vec<ResourceTemplateData<'r>>,
}
let data: ResourceListData = serde_yaml_ng::from_value(data.inner.clone())?;
let data: ResourceListData = serde_yml::from_value(data.inner.clone())?;
let res_builder = builder
.resource_builders

View file

@ -32,7 +32,7 @@ where
pub fn parse(input: String) -> eyre::Result<Self> {
if input.starts_with("---\n") {
if let Some((frontmatter, content)) = input[3..].split_once("\n---\n") {
let data = serde_yaml_ng::from_str(frontmatter)?;
let data = serde_yml::from_str(frontmatter)?;
return Ok(Self {
content: content.to_string(),
data,
@ -56,7 +56,7 @@ where
if let Some(data) = &self.data {
output.push_str("---\n");
output.push_str(&serde_yaml_ng::to_string(data)?);
output.push_str(&serde_yml::to_string(data)?);
output.push_str("---\n\n");
}

View file

@ -100,9 +100,7 @@ impl SiteConfig {
if !config_path.exists() {
eyre::bail!("no site config found!");
}
Ok(serde_yaml_ng::from_str(&std::fs::read_to_string(
config_path,
)?)?)
Ok(serde_yml::from_str(&std::fs::read_to_string(config_path)?)?)
}
}
@ -131,7 +129,7 @@ pub struct PageMetadata {
pub extra: Option<ExtraData>,
/// Custom values passed to the base template.
#[serde(default)]
pub userdata: serde_yaml_ng::Value,
pub userdata: serde_yml::Value,
/// Whether this page being rendered is a partial. Set by the builder, not your page metadata.
#[serde(skip)]
pub is_partial: bool,

View file

@ -135,7 +135,7 @@ fn main() -> eyre::Result<()> {
let config = SiteConfig::new(base_url.clone(), cdn_url.unwrap_or(base_url), title);
std::fs::write(
cli.site.join(SiteConfig::FILENAME),
serde_yaml_ng::to_string(&config)?,
serde_yml::to_string(&config)?,
)?;
DEFAULT_PROJECT.extract(&cli.site)?;
std::fs::create_dir(cli.site.join(webdog::ROOT_PATH))?;
@ -227,7 +227,7 @@ fn main() -> eyre::Result<()> {
config.resources.insert(id.clone(), resource_config);
std::fs::write(config_path, serde_yaml_ng::to_string(&config)?)?;
std::fs::write(config_path, serde_yml::to_string(&config)?)?;
let resource_path = cli.site.join(webdog::RESOURCES_PATH).join(&id);
std::fs::create_dir_all(&resource_path)?;
@ -240,7 +240,7 @@ fn main() -> eyre::Result<()> {
tags: vec!["first".to_string()],
cdn_file: None,
desc: Some(format!("This is the first {name} :)")),
inner: serde_yaml_ng::Value::Null,
inner: serde_yml::Value::Null,
draft: true,
},
)?;
@ -256,11 +256,7 @@ fn main() -> eyre::Result<()> {
title,
template,
} => {
let page_path = cli
.site
.join(webdog::PAGES_PATH)
.join(&id)
.with_extension("md");
let page_path = cli.site.join(webdog::PAGES_PATH).join(&id).with_extension("md");
let dir = page_path.parent().expect("should never fail");
if page_path.exists() {
eprintln!("page already exists!");
@ -314,7 +310,7 @@ fn main() -> eyre::Result<()> {
tags,
cdn_file: None,
desc: description,
inner: serde_yaml_ng::Value::Null,
inner: serde_yml::Value::Null,
draft: !skip_draft,
},
)?;

View file

@ -10,11 +10,8 @@ use serde::{Deserialize, Serialize};
use time::{format_description::well_known::Rfc2822, OffsetDateTime};
use crate::{
builder::SiteBuilder,
frontmatter::FrontMatterRequired,
link_list::Link,
util::{self, format_timestamp},
PageMetadata,
builder::SiteBuilder, frontmatter::FrontMatterRequired, link_list::Link,
util::{self, format_timestamp}, PageMetadata,
};
/// Metadata for resources.
@ -33,7 +30,7 @@ pub struct ResourceMetadata {
pub desc: Option<String>,
/// Extra resource data not included.
#[serde(flatten)]
pub inner: serde_yaml_ng::Value,
pub inner: serde_yml::Value,
/// Whether the resource is a draft. Drafts can be committed without being published to the live site.
#[serde(default)]
pub draft: bool,

View file

@ -95,7 +95,7 @@ fn create(
builder.build_all_resources()?;
}
} else if relative_path.display().to_string() == SiteConfig::FILENAME {
let new_config = serde_yaml_ng::from_str(&std::fs::read_to_string(path)?)?;
let new_config = serde_yml::from_str(&std::fs::read_to_string(path)?)?;
builder.site.config = new_config;
builder.reload()?;
builder.build_all()?;