From 4d1d5308d3d83a23f9de2cd892c04874e6a231d2 Mon Sep 17 00:00:00 2001 From: zyl Date: Fri, 14 Jun 2024 22:01:05 -0700 Subject: [PATCH 01/35] implement support for directories in the static file structure --- src/builder.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index c470c8f..1a024b1 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -95,10 +95,16 @@ impl<'a> SiteBuilder<'a> { let root_path = self.site.site_path.join(ROOT_PATH); if root_path.exists() { - for entry in root_path.read_dir()? { + for entry in walkdir::WalkDir::new(&root_path) { let entry = entry?; let path = entry.path(); - std::fs::copy(&path, self.build_path.join(path.strip_prefix(&root_path)?))?; + if path.is_dir() { + continue; + } + let output_path = self.build_path.join(path.strip_prefix(&root_path)?); + let parent_path = output_path.parent().expect("should never fail"); + std::fs::create_dir_all(parent_path)?; + std::fs::copy(path, output_path)?; } } From 831a1486ee05d974a1726a3f96f218ae8ed20349 Mon Sep 17 00:00:00 2001 From: zyl Date: Fri, 14 Jun 2024 22:12:12 -0700 Subject: [PATCH 02/35] add support for custom scripts on a page --- site/templates/base.hbs | 3 +++ src/builder.rs | 3 +++ src/lib.rs | 3 +++ 3 files changed, 9 insertions(+) diff --git a/site/templates/base.hbs b/site/templates/base.hbs index b701d51..7c12ac4 100644 --- a/site/templates/base.hbs +++ b/site/templates/base.hbs @@ -7,6 +7,9 @@ {{title}} {{{head}}} + {{#each scripts}} + + {{/each}} diff --git a/src/builder.rs b/src/builder.rs index 1a024b1..c5888fb 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -21,6 +21,8 @@ struct TemplateData<'a, T> { pub page: &'a str, /// The page's title. pub title: &'a str, + /// The page's custom scripts. + pub scripts: &'a [String], /// Custom template data. #[serde(flatten)] pub extra_data: T, @@ -213,6 +215,7 @@ impl<'a> SiteBuilder<'a> { &TemplateData { page: page_html, title: &title, + scripts: &page_metadata.scripts, extra_data, }, )?; diff --git a/src/lib.rs b/src/lib.rs index 42714b8..9f24fe1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,6 +67,9 @@ pub struct PageMetadata { pub title: Option, /// The template to use for the page. If not specified, it defaults to "base". pub template: Option, + /// The page's custom scripts, if any. + #[serde(default)] + pub scripts: Vec, /// The extra stuff to run for the page, if any. pub extra: Option, } From f9b15aa9328de47bf1ead9bef474a1f256da4d38 Mon Sep 17 00:00:00 2001 From: zyl Date: Mon, 17 Jun 2024 13:16:39 -0700 Subject: [PATCH 03/35] add mime type and defer script loading --- site/templates/base.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/templates/base.hbs b/site/templates/base.hbs index 7c12ac4..2491216 100644 --- a/site/templates/base.hbs +++ b/site/templates/base.hbs @@ -8,7 +8,7 @@ {{title}} {{{head}}} {{#each scripts}} - + {{/each}} From 8d9866d04814ae753c1db22ee8f60e8b5e6bfd64 Mon Sep 17 00:00:00 2001 From: zyl Date: Mon, 17 Jun 2024 21:25:29 -0700 Subject: [PATCH 04/35] allow for injecting css scripts into pages --- site/templates/base.hbs | 3 +++ src/builder.rs | 3 +++ src/lib.rs | 3 +++ 3 files changed, 9 insertions(+) diff --git a/site/templates/base.hbs b/site/templates/base.hbs index 2491216..5d9fa17 100644 --- a/site/templates/base.hbs +++ b/site/templates/base.hbs @@ -10,6 +10,9 @@ {{#each scripts}} {{/each}} + {{#each styles}} + + {{/each}} diff --git a/src/builder.rs b/src/builder.rs index c5888fb..70ca44a 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -23,6 +23,8 @@ struct TemplateData<'a, T> { pub title: &'a str, /// The page's custom scripts. pub scripts: &'a [String], + /// the page's custom styles. + pub styles: &'a [String], /// Custom template data. #[serde(flatten)] pub extra_data: T, @@ -216,6 +218,7 @@ impl<'a> SiteBuilder<'a> { page: page_html, title: &title, scripts: &page_metadata.scripts, + styles: &page_metadata.styles, extra_data, }, )?; diff --git a/src/lib.rs b/src/lib.rs index 9f24fe1..e58ca49 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -70,6 +70,9 @@ pub struct PageMetadata { /// The page's custom scripts, if any. #[serde(default)] pub scripts: Vec, + /// the page's custom styles, if any. + #[serde(default)] + pub styles: Vec, /// The extra stuff to run for the page, if any. pub extra: Option, } From 9b517efed880acb591609e3cdff98de555a3062c Mon Sep 17 00:00:00 2001 From: zyl Date: Fri, 21 Jun 2024 11:58:15 -0700 Subject: [PATCH 05/35] initial pet progress --- site/config.yaml | 2 +- site/pages/pet.md | 25 ++++++ site/root/js/pet.js | 203 ++++++++++++++++++++++++++++++++++++++++++++ site/sass/pet.scss | 7 ++ 4 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 site/pages/pet.md create mode 100644 site/root/js/pet.js create mode 100644 site/sass/pet.scss diff --git a/site/config.yaml b/site/config.yaml index df17015..4427dce 100644 --- a/site/config.yaml +++ b/site/config.yaml @@ -1,7 +1,7 @@ base_url: "https://zyl.gay" title: zyl is gay description: "zyl's website." -sass_styles: [index.scss] +sass_styles: [index.scss, "pet.scss"] images_per_page: 10 blog_posts_per_page: 20 cdn_url: "https://i.zyl.gay" diff --git a/site/pages/pet.md b/site/pages/pet.md new file mode 100644 index 0000000..8c24bf6 --- /dev/null +++ b/site/pages/pet.md @@ -0,0 +1,25 @@ +--- +title: pet +scripts: ["js/pet.js"] +styles: ["pet.css"] +--- + +
+

--pet placeholder here--

+ +
+ +
+

whoa! you just found an egg somewhere! maybe you should watch it and see what happens..

+
+ + + +
+ +

LS: A: F: B: P:

+
diff --git a/site/root/js/pet.js b/site/root/js/pet.js new file mode 100644 index 0000000..125f176 --- /dev/null +++ b/site/root/js/pet.js @@ -0,0 +1,203 @@ +(function () { + "use strict"; + + /** the current pet version.. */ + const CURRENT_PET_VERSION = 1; + /** the max food a pet will eat */ + const MAX_FOOD = 100; + /** the amount of time it takes for a pet to have to GO */ + const POTTY_TIME = 100; + /** how fast a pet's food value decays */ + const FOOD_DECAY = 5; + /** the rate at which a pet ages */ + const AGING_RATE = 1; + /** how fast a pet's potty need decays */ + const POTTY_DECAY = 5; + + /** life stage for an egg */ + const LIFE_STAGE_EGG = 1; + /** life stage for a pup */ + const LIFE_STAGE_PUP = 2; + /** life stage for an adult */ + const LIFE_STAGE_ADULT = 3; + /** life stage for an elder pet */ + const LIFE_STAGE_ELDER = 4; + /** the time it takes for a pet to grow past the egg phase */ + const EGG_TIME = 2; + /** the time it takes for a pet to grow past the pup phase */ + const PUP_TIME = 300; + /** the time it takes for a pet to grow past the adult phase */ + const ADULT_TIME = 900; + /** the time it takes for a pet to grow past the elder phase */ + const ELDER_TIME = 300; + + const eggDiv = document.querySelector("div#egg"); + const petSetup = document.querySelector("div#pet-setup"); + const name = petSetup.querySelector("input[name=pet-name]"); + const nameItButton = petSetup.querySelector("button"); + const debug = document.querySelector("div#debug-section"); + const debugLifeStage = debug.querySelector("span[name=ls]"); + const debugAge = debug.querySelector("span[name=a]"); + const debugFood = debug.querySelector("span[name=f]"); + const debugBehavior = debug.querySelector("span[name=b]"); + const debugPotty = debug.querySelector("span[name=p]"); + const forceUpdateButton = debug.querySelector("button#force-update"); + + /** + * class containing information about a pet + */ + class Pet { + /** current pet version */ + version = CURRENT_PET_VERSION; + /** whether the pet can die or not */ + canDie = false; + /** whether the pet is alive or dead */ + alive = true; + /** whether the pet simulation is paused */ + paused = false; + /** the pet's current life stage */ + lifeStage = LIFE_STAGE_EGG; + /** the pet's name */ + name = ""; + /** how much food the pet has stored */ + food = MAX_FOOD; + /** the pet's age */ + age = 0; + /** the pet's behavior score */ + behavior = 0; + /** how long until the pet needs to go potty */ + pottyTimer = POTTY_TIME; + /** the time the pet was last updated */ + lastUpdate = Date.now(); + /** the time the egg was found */ + eggFound = Date.now(); + /** the time the egg hatched */ + hatched = Date.now(); + + /** + * updates a pet + */ + update() { + if (!this.alive || this.paused) { + return; + } + console.log("update"); + + this.age += AGING_RATE; + + if (this.lifeStage !== LIFE_STAGE_EGG) { + this.food -= FOOD_DECAY; + this.pottyTimer -= POTTY_DECAY; + + if (this.food < 0) { + if (this.canDie) { + // TODO: pet dies + } else { + this.food = 0; + } + } + + if (this.pottyTimer < 0) { + this.goPotty(); + } + } + + if (this.lifeStage === LIFE_STAGE_EGG && this.age >= EGG_TIME) { + this.paused = true; + this.lifeStage = LIFE_STAGE_PUP; + this.age = 0; + } else if (this.lifeStage === LIFE_STAGE_PUP && this.age >= PUP_TIME) { + this.paused = true; + this.lifeStage = LIFE_STAGE_ADULT; + this.age = 0; + } else if ( + this.lifeStage === LIFE_STAGE_ADULT && + this.age >= ADULT_TIME + ) { + this.paused = true; + this.lifeStage = LIFE_STAGE_ELDER; + this.age = 0; + } else if ( + this.lifeStage === LIFE_STAGE_ELDER && + this.age >= ELDER_TIME + ) { + this.paused = true; + this.alive = false; + // TODO: DEATH + } + this.updateDom(); + } + + /** + * updates the html dom + */ + updateDom() { + eggDiv.classList.add("hidden"); + petSetup.classList.add("hidden"); + + if (this.lifeStage === LIFE_STAGE_EGG) { + eggDiv.classList.remove("hidden"); + } else if (this.lifeStage === LIFE_STAGE_PUP) { + if (this.paused && this.name === "") { + petSetup.classList.remove("hidden"); + } + } else if (this.lifeStage === LIFE_STAGE_ADULT) { + } else if (this.lifeStage === LIFE_STAGE_ELDER) { + } + + debugLifeStage.innerText = this.lifeStage; + debugAge.innerText = this.age; + debugFood.innerText = this.food; + debugBehavior.innerText = this.behavior; + debugPotty.innerText = this.pottyTimer; + } + + /** + * feeds the pet + * @param {number} amount the amount to feed the pet by + */ + feed(amount) { + if (this.food > MAX_FOOD) { + return; + } + this.food += amount; + } + + /** + * makes the pet go potty + */ + goPotty() { + if (this.behavior > 15) { + // go potty properly + } else { + // make a mess of that shit + } + this.pottyTimer = POTTY_TIME; + } + } + + let pet = new Pet(); + pet.updateDom(); + + nameItButton.addEventListener("click", () => { + const newName = name.value; + console.log(newName); + if (newName.trim().length === 0) { + return; + } + pet.name = newName; + pet.paused = false; + pet.updateDom(); + }); + + const update = () => { + pet.update(); + }; + + // update the pet every 30 seconds? + setInterval(update, 30000); + + forceUpdateButton.addEventListener("click", update); + + console.log(pet); +})(); diff --git a/site/sass/pet.scss b/site/sass/pet.scss new file mode 100644 index 0000000..e7eb919 --- /dev/null +++ b/site/sass/pet.scss @@ -0,0 +1,7 @@ +.hidden { + display: none; +} + +#debug-section [name] { + font-weight: bold; +} From d0b9140da1ad5ffbed3e01a77d21e94b0335b268 Mon Sep 17 00:00:00 2001 From: zyl Date: Fri, 21 Jun 2024 13:52:19 -0700 Subject: [PATCH 06/35] fix bug in the link handler --- src/builder.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index 70ca44a..8ccf87b 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -143,7 +143,7 @@ impl<'a> SiteBuilder<'a> { }), element!("a", |el| { if let Some(mut href) = el.get_attribute("href") { - if let Some((command, new_href)) = href.split_once('$') { + if let Some((command, mut new_href)) = href.split_once('$') { #[allow(clippy::single_match)] match command { "me" => { @@ -152,7 +152,9 @@ impl<'a> SiteBuilder<'a> { &(el.get_attribute("rel").unwrap_or_default() + " me"), )?; } - _ => {} + _ => { + new_href = &href; + } } href = new_href.to_string(); el.set_attribute("href", &href)?; From f3a9662ca9cb50658a51360d9a92bb44ccfecf71 Mon Sep 17 00:00:00 2001 From: zyl Date: Fri, 21 Jun 2024 13:52:30 -0700 Subject: [PATCH 07/35] add a "pay me" page to the site --- site/pages/pay-me.md | 13 +++++++++++++ site/templates/base.hbs | 1 + 2 files changed, 14 insertions(+) create mode 100644 site/pages/pay-me.md diff --git a/site/pages/pay-me.md b/site/pages/pay-me.md new file mode 100644 index 0000000..f470236 --- /dev/null +++ b/site/pages/pay-me.md @@ -0,0 +1,13 @@ +--- +title: pay me!! +--- + +# pay me!! + +you should send trans people money. here's how you can send _me_ money: + +- **[\$zylpup](https://cash.app/$zylpup)** on cashapp **(preferred)** +- **z@zyl.gay** on apple cash **(preferred)** +- [github sponsors](https://github.com/sponsors/zyllian) +- [ko-fi](https://ko-fi.com/zylpup) +- [buy me a coffee](https://buymeacoffee.com/zylpup) diff --git a/site/templates/base.hbs b/site/templates/base.hbs index 5d9fa17..b89135b 100644 --- a/site/templates/base.hbs +++ b/site/templates/base.hbs @@ -24,6 +24,7 @@ blog | images | + pay me! | source
From 5e9a23d78984f77ee2b337e5e74280eef09c81c9 Mon Sep 17 00:00:00 2001 From: zyl Date: Fri, 21 Jun 2024 14:00:03 -0700 Subject: [PATCH 08/35] add utility for getting a current timestamp --- src/main.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main.rs b/src/main.rs index c228358..ba0813a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,11 +7,14 @@ use zyl_site::Site; enum Mode { Build, Serve, + Now, } #[cfg(feature = "serve")] #[tokio::main] async fn main() -> eyre::Result<()> { + use time::{format_description::well_known::Rfc3339, OffsetDateTime}; + #[cfg(feature = "color-eyre")] color_eyre::install()?; @@ -22,6 +25,9 @@ async fn main() -> eyre::Result<()> { if arg == "serve" { mode = Mode::Serve; break; + } else if arg == "now" { + mode = Mode::Now; + break; } } @@ -31,6 +37,14 @@ async fn main() -> eyre::Result<()> { site.build_once()? } Mode::Serve => site.serve().await?, + Mode::Now => { + let time = OffsetDateTime::now_utc(); + println!( + "{}", + time.format(&Rfc3339) + .expect("failed to format the current time") + ); + } } println!("Build complete!"); From 4e624a3afa1244f216e69023dbe52970fb6a6474 Mon Sep 17 00:00:00 2001 From: zyl Date: Fri, 21 Jun 2024 14:21:51 -0700 Subject: [PATCH 09/35] add blog post announcing the ability to Pay Me --- site/blog/send-trans-people-money.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 site/blog/send-trans-people-money.md diff --git a/site/blog/send-trans-people-money.md b/site/blog/send-trans-people-money.md new file mode 100644 index 0000000..5598919 --- /dev/null +++ b/site/blog/send-trans-people-money.md @@ -0,0 +1,12 @@ +--- +title: send trans people money. +timestamp: 2024-06-21T14:05:00.00Z +tags: [trans, money] +desc: you should send trans people money. i'm trans btw +header_image_file: 2024/06/gamecube.jpeg +header_image_alt: A photo of me holding a Cipon-branded Gamecube controller in my lap. +--- + +this is a pretty short post. i'm just here to say you should send trans people ([like me](/pay-me)) money. spare a few bucks and send it! sure you can find [one or two trans people](/pay-me) out there to send money to. surely. + +the picture is a gamecube controller i've been using recently since i started playing melee some :3 From 9285fc0974008619de5c05065e2e17eeda980802 Mon Sep 17 00:00:00 2001 From: zyl Date: Fri, 21 Jun 2024 14:27:19 -0700 Subject: [PATCH 10/35] fix builds without serve feature --- src/lib.rs | 2 +- src/serving.rs | 12 +----------- src/util.rs | 12 +++++++++++- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e58ca49..2e8358a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,8 +15,8 @@ use std::{ use eyre::Context; use serde::Deserialize; -use serving::get_name; use url::Url; +use util::get_name; use walkdir::WalkDir; use builder::SiteBuilder; diff --git a/src/serving.rs b/src/serving.rs index 177da73..09a6f53 100644 --- a/src/serving.rs +++ b/src/serving.rs @@ -18,7 +18,7 @@ use warp::{ Filter, }; -use crate::{Site, SiteBuilder, PAGES_PATH, ROOT_PATH, SASS_PATH, TEMPLATES_PATH}; +use crate::{util::get_name, Site, SiteBuilder, PAGES_PATH, ROOT_PATH, SASS_PATH, TEMPLATES_PATH}; fn with_build_path( build_path: PathBuf, @@ -26,16 +26,6 @@ fn with_build_path( warp::any().map(move || build_path.clone()) } -/// Helper to get the "name" of a path. -pub fn get_name(path: &Path) -> (PathBuf, String) { - let name = path.with_extension(""); - let name_str = name - .display() - .to_string() - .replace(std::path::MAIN_SEPARATOR, "/"); - (name, name_str) -} - /// Helper to make a path relative. fn rel(path: &Path, prefix: &Path) -> Result { Ok(path.strip_prefix(prefix)?.to_owned()) diff --git a/src/util.rs b/src/util.rs index faa4770..ed212ad 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,6 +1,6 @@ //! Module containing various utilities. -use std::path::Path; +use std::path::{Path, PathBuf}; /// Simple helper to remove the contents of a directory without removing the directory itself. pub fn remove_dir_contents(path: &Path) -> eyre::Result<()> { @@ -16,3 +16,13 @@ pub fn remove_dir_contents(path: &Path) -> eyre::Result<()> { Ok(()) } + +/// Helper to get the "name" of a path. +pub fn get_name(path: &Path) -> (PathBuf, String) { + let name = path.with_extension(""); + let name_str = name + .display() + .to_string() + .replace(std::path::MAIN_SEPARATOR, "/"); + (name, name_str) +} From 3234c0796812265d405cda663a8721d1fe8e29fc Mon Sep 17 00:00:00 2001 From: zyl Date: Fri, 21 Jun 2024 14:43:42 -0700 Subject: [PATCH 11/35] update site deployment? --- .github/workflows/main.yml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 842c79a..47bb604 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,6 +12,15 @@ on: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: false + env: CARGO_TERM_COLOR: always @@ -25,15 +34,19 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 # Runs a single command using the runners shell - name: Build site run: | cargo run --no-default-features --release - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./site/build + path: "build" + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 From da4131066afaa0b5775bf6aa2944841c5720df74 Mon Sep 17 00:00:00 2001 From: zyl Date: Fri, 21 Jun 2024 14:51:47 -0700 Subject: [PATCH 12/35] fix action? --- .github/workflows/main.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 47bb604..425b47e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -46,7 +46,15 @@ jobs: - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: - path: "build" - - name: Deploy to GitHub Pages + path: "./site/build/" + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to Github Pages id: deployment uses: actions/deploy-pages@v4 From 91c65fa01726696fa66ce65394c0ed402e092ee7 Mon Sep 17 00:00:00 2001 From: zyl Date: Fri, 21 Jun 2024 15:01:23 -0700 Subject: [PATCH 13/35] update youtube link --- site/pages/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/pages/index.md b/site/pages/index.md index ee1090c..196a6d3 100644 --- a/site/pages/index.md +++ b/site/pages/index.md @@ -6,7 +6,7 @@ extra: index hi! i'm zyl, a trans doggirlthing ΘΔ in the pnw. -if you want to see mostly stuff of my cat and some short game clips (most are unlisted in a public playlist) [i have a youtube over here](https://youtube.com/@zyllian) +if you're interested, check out [my youtube](me$https://youtube.com/@zylpup) to see what i've got going on there if you're an adult i have a couple socials floating around: From 35ac34b69c89d17c004cf98712f9b592c4e98cce Mon Sep 17 00:00:00 2001 From: zyl Date: Fri, 21 Jun 2024 15:01:38 -0700 Subject: [PATCH 14/35] change serde_yaml to serde_yml --- Cargo.lock | 73 ++++++++++++++++++++++++++++++++++++++++++-------- Cargo.toml | 2 +- src/lib.rs | 2 +- src/serving.rs | 2 +- 4 files changed, 65 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cdc96c1..e81f979 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -411,6 +411,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "extract-frontmatter" version = "4.1.1" @@ -427,6 +437,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "fastrand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" + [[package]] name = "file-id" version = "0.1.0" @@ -1071,6 +1087,18 @@ version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +[[package]] +name = "libyml" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e281a65eeba3d4503a2839252f86374528f9ceafe6fed97c1d3b52e1fb625c1" + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + [[package]] name = "litemap" version = "0.7.3" @@ -1708,6 +1736,19 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags 2.5.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + [[package]] name = "ryu" version = "1.0.18" @@ -1805,16 +1846,20 @@ dependencies = [ ] [[package]] -name = "serde_yaml" -version = "0.9.34+deprecated" +name = "serde_yml" +version = "0.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +checksum = "78ce6afeda22f0b55dde2c34897bce76a629587348480384231205c14b59a01f" dependencies = [ "indexmap", "itoa 1.0.11", + "libyml", + "log", + "memchr", "ryu", "serde", - "unsafe-libyaml", + "serde_json", + "tempfile", ] [[package]] @@ -1940,6 +1985,18 @@ dependencies = [ "syn 2.0.66", ] +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if", + "fastrand", + "rustix", + "windows-sys 0.52.0", +] + [[package]] name = "thin-slice" version = "0.1.1" @@ -2179,12 +2236,6 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[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.1" @@ -2619,7 +2670,7 @@ dependencies = [ "pulldown-cmark", "rss", "serde", - "serde_yaml", + "serde_yml", "time", "tokio", "url", diff --git a/Cargo.toml b/Cargo.toml index 7110fc6..6e3f9c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ pulldown-cmark = {version = "0.11", default-features = false, features = [ ]} rss = {version = "2", features = ["validation"]} serde = {version = "1", features = ["derive"]} -serde_yaml = "0.9" +serde_yml = "0.0.10" time = {version = "0.3", features = ["serde-human-readable"]} tokio = {version = "1.10", features = [ "macros", diff --git a/src/lib.rs b/src/lib.rs index 2e8358a..521d968 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -93,7 +93,7 @@ pub struct Site { impl Site { /// Creates a new site from the given path. pub fn new(site_path: &Path) -> eyre::Result { - let config: SiteConfig = serde_yaml::from_str( + let config: SiteConfig = serde_yml::from_str( &std::fs::read_to_string(site_path.join("config.yaml")) .wrap_err("Failed to read site config")?, ) diff --git a/src/serving.rs b/src/serving.rs index 09a6f53..a6c2a9b 100644 --- a/src/serving.rs +++ b/src/serving.rs @@ -61,7 +61,7 @@ fn create( builder.build_blog()?; } } else if relative_path.display().to_string() == "config.yaml" { - let new_config = serde_yaml::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.site.build_all_pages(builder)?; } else if let Ok(_sass_path) = relative_path.strip_prefix(SASS_PATH) { From 750c0c501f84415f9eb79635fe7f9db0ba426442 Mon Sep 17 00:00:00 2001 From: zyl Date: Fri, 21 Jun 2024 16:42:55 -0700 Subject: [PATCH 15/35] update embeds for the blog and add them to images --- src/blog.rs | 26 +++++++++++--------------- src/images.rs | 23 +++++++++++++++++++++-- src/resource.rs | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 17 deletions(-) diff --git a/src/blog.rs b/src/blog.rs index 7f41d68..abdf569 100644 --- a/src/blog.rs +++ b/src/blog.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - resource::{ResourceBuilderConfig, ResourceMetadata, ResourceMethods}, + resource::{EmbedMetadata, ResourceBuilderConfig, ResourceMetadata, ResourceMethods}, Site, SiteConfig, }; @@ -84,19 +84,15 @@ impl ResourceMethods for ResourceMetadata eyre::Result { - // TODO: update this so we're not just doing raw html injection lmao - Ok(format!( - r#" - - - - - - "#, - site_config.title, - self.title, - self.inner.get_header_image(site_config)?, - self.inner.desc, - )) + Ok(EmbedMetadata { + title: self.title.clone(), + site_name: &site_config.title, + description: Some(self.inner.desc.clone()), + image: Some(self.inner.get_header_image(site_config)?), + url: None, + theme_color: "rgb(255, 196, 252)".to_string(), + large_image: true, + } + .build()) } } diff --git a/src/images.rs b/src/images.rs index c09005c..6c92a90 100644 --- a/src/images.rs +++ b/src/images.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - resource::{ResourceBuilderConfig, ResourceMetadata, ResourceMethods}, + resource::{EmbedMetadata, ResourceBuilderConfig, ResourceMetadata, ResourceMethods}, Site, SiteConfig, }; @@ -37,6 +37,12 @@ pub struct ImageMetadata { pub file: String, } +impl ImageMetadata { + fn get_image_url(&self, site_config: &SiteConfig) -> eyre::Result { + Ok(site_config.cdn_url(&self.file)?.to_string()) + } +} + /// Template data for a specific image. #[derive(Debug, Serialize)] pub struct ImageTemplateData { @@ -55,7 +61,20 @@ impl ResourceMethods for ResourceMetadata { site_config: &SiteConfig, ) -> eyre::Result { Ok(ImageTemplateData { - src: site_config.cdn_url(&self.inner.file)?.to_string(), + src: self.inner.get_image_url(site_config)?, }) } + + fn get_head_data(&self, site_config: &SiteConfig) -> eyre::Result { + Ok(EmbedMetadata { + title: self.title.clone(), + site_name: &site_config.title, + description: self.inner.desc.clone(), + image: Some(self.inner.get_image_url(site_config)?), + url: None, + theme_color: "rgb(255, 196, 252)".to_string(), + large_image: true, + } + .build()) + } } diff --git a/src/resource.rs b/src/resource.rs index 7938cf7..6b198a4 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -79,6 +79,47 @@ where } } +/// struct for adding custom meta content embeds +#[derive(Debug)] +pub struct EmbedMetadata<'s> { + pub title: String, + pub site_name: &'s str, + pub description: Option, + pub url: Option, + pub image: Option, + pub theme_color: String, + pub large_image: bool, +} + +impl<'s> EmbedMetadata<'s> { + /// builds the embed html tags + pub fn build(self) -> String { + let mut s = format!(r#""#, self.title); + s = format!( + r#"{s}"#, + self.site_name + ); + if let Some(description) = self.description { + s = format!(r#"{s}"#); + } + if let Some(url) = self.url { + s = format!(r#"{s}"#); + } + if let Some(image) = self.image { + s = format!(r#"{s}"#); + } + s = format!( + r#"{s}"#, + self.theme_color + ); + if self.large_image { + s = format!(r#"{s}"#); + } + + s + } +} + #[derive(Debug, Serialize)] struct ResourceListTemplateData<'r, M, E> { resources: Vec<&'r ResourceTemplateData<'r, M, E>>, From 4fb1f2183d1f83944de71aadc5d961594805890d Mon Sep 17 00:00:00 2001 From: zyl Date: Fri, 21 Jun 2024 17:09:49 -0700 Subject: [PATCH 16/35] implement custom embeds for regular pages --- src/blog.rs | 2 +- src/builder.rs | 8 ++++++++ src/images.rs | 2 +- src/lib.rs | 4 ++++ src/resource.rs | 18 ++++++++++++++---- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/blog.rs b/src/blog.rs index abdf569..ff42808 100644 --- a/src/blog.rs +++ b/src/blog.rs @@ -86,7 +86,7 @@ impl ResourceMethods for ResourceMetadata eyre::Result { Ok(EmbedMetadata { title: self.title.clone(), - site_name: &site_config.title, + site_name: site_config.title.clone(), description: Some(self.inner.desc.clone()), image: Some(self.inner.get_header_image(site_config)?), url: None, diff --git a/src/builder.rs b/src/builder.rs index 8ccf87b..aab6768 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -21,6 +21,8 @@ struct TemplateData<'a, T> { pub page: &'a str, /// The page's title. pub title: &'a str, + /// Custom head data for the page. + pub head: Option, /// The page's custom scripts. pub scripts: &'a [String], /// the page's custom styles. @@ -214,11 +216,17 @@ impl<'a> SiteBuilder<'a> { _ => self.site.config.title.clone(), }; + let head = page_metadata.embed.map(|mut embed| { + embed.site_name.clone_from(&self.site.config.title); + embed.build() + }); + let out = self.reg.render( &page_metadata.template.unwrap_or_else(|| "base".to_string()), &TemplateData { page: page_html, title: &title, + head, scripts: &page_metadata.scripts, styles: &page_metadata.styles, extra_data, diff --git a/src/images.rs b/src/images.rs index 6c92a90..d0e7a22 100644 --- a/src/images.rs +++ b/src/images.rs @@ -68,7 +68,7 @@ impl ResourceMethods for ResourceMetadata { fn get_head_data(&self, site_config: &SiteConfig) -> eyre::Result { Ok(EmbedMetadata { title: self.title.clone(), - site_name: &site_config.title, + site_name: site_config.title.clone(), description: self.inner.desc.clone(), image: Some(self.inner.get_image_url(site_config)?), url: None, diff --git a/src/lib.rs b/src/lib.rs index 521d968..2b7703f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,6 +14,7 @@ use std::{ }; use eyre::Context; +use resource::EmbedMetadata; use serde::Deserialize; use url::Url; use util::get_name; @@ -67,6 +68,9 @@ pub struct PageMetadata { pub title: Option, /// The template to use for the page. If not specified, it defaults to "base". pub template: Option, + /// custom embed info for a template + #[serde(default)] + pub embed: Option, /// The page's custom scripts, if any. #[serde(default)] pub scripts: Vec, diff --git a/src/resource.rs b/src/resource.rs index 6b198a4..ca3502b 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -80,18 +80,24 @@ where } /// struct for adding custom meta content embeds -#[derive(Debug)] -pub struct EmbedMetadata<'s> { +#[derive(Debug, Deserialize)] +pub struct EmbedMetadata { pub title: String, - pub site_name: &'s str, + #[serde(default)] + pub site_name: String, + #[serde(default)] pub description: Option, + #[serde(default)] pub url: Option, + #[serde(default)] pub image: Option, + #[serde(default = "EmbedMetadata::default_theme_color")] pub theme_color: String, + #[serde(default)] pub large_image: bool, } -impl<'s> EmbedMetadata<'s> { +impl EmbedMetadata { /// builds the embed html tags pub fn build(self) -> String { let mut s = format!(r#""#, self.title); @@ -118,6 +124,10 @@ impl<'s> EmbedMetadata<'s> { s } + + fn default_theme_color() -> String { + "rgb(255, 196, 252)".to_string() + } } #[derive(Debug, Serialize)] From f6079f536f5864bd134229a1bc3e0a9f531c5647 Mon Sep 17 00:00:00 2001 From: zyl Date: Fri, 21 Jun 2024 17:09:58 -0700 Subject: [PATCH 17/35] add custom embed to the pay me page --- site/pages/pay-me.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/site/pages/pay-me.md b/site/pages/pay-me.md index f470236..48d9500 100644 --- a/site/pages/pay-me.md +++ b/site/pages/pay-me.md @@ -1,5 +1,9 @@ --- title: pay me!! +embed: + title: pay me!! + site_name: test + description: send trans people money. like me. --- # pay me!! From 333fb003d01b46500f19404811ebaacddb2ed7e0 Mon Sep 17 00:00:00 2001 From: zyl Date: Fri, 21 Jun 2024 17:14:14 -0700 Subject: [PATCH 18/35] update theme color --- src/blog.rs | 2 +- src/images.rs | 2 +- src/resource.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/blog.rs b/src/blog.rs index ff42808..34ea2ab 100644 --- a/src/blog.rs +++ b/src/blog.rs @@ -90,7 +90,7 @@ impl ResourceMethods for ResourceMetadata for ResourceMetadata { description: self.inner.desc.clone(), image: Some(self.inner.get_image_url(site_config)?), url: None, - theme_color: "rgb(255, 196, 252)".to_string(), + theme_color: EmbedMetadata::default_theme_color(), large_image: true, } .build()) diff --git a/src/resource.rs b/src/resource.rs index ca3502b..9379d1f 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -125,8 +125,8 @@ impl EmbedMetadata { s } - fn default_theme_color() -> String { - "rgb(255, 196, 252)".to_string() + pub fn default_theme_color() -> String { + "ffc4fc".to_string() } } From f64158d577a2c805a02265928fa645e96299f1ed Mon Sep 17 00:00:00 2001 From: zyl Date: Fri, 21 Jun 2024 17:27:27 -0700 Subject: [PATCH 19/35] fix theme color oops --- src/resource.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resource.rs b/src/resource.rs index 9379d1f..f16bde4 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -126,7 +126,7 @@ impl EmbedMetadata { } pub fn default_theme_color() -> String { - "ffc4fc".to_string() + "#ffc4fc".to_string() } } From 158257cd44d4434393a261f979502b0c188c7467 Mon Sep 17 00:00:00 2001 From: zyl Date: Mon, 24 Jun 2024 21:35:56 -0700 Subject: [PATCH 20/35] use lld on windows --- .cargo/config.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..13b29fe --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,3 @@ +[target.x86_64-pc-windows-msvc] +linker = "ld.lld.exe" +rustflags = ["-C", "link-arg=-fuse-ld=lld"] From 25c0fe81a1117504fc87a31d2447b6636b2a787f Mon Sep 17 00:00:00 2001 From: zyl Date: Mon, 24 Jun 2024 21:47:23 -0700 Subject: [PATCH 21/35] add pet page to the top bar --- site/templates/base.hbs | 1 + 1 file changed, 1 insertion(+) diff --git a/site/templates/base.hbs b/site/templates/base.hbs index b89135b..6abd31b 100644 --- a/site/templates/base.hbs +++ b/site/templates/base.hbs @@ -22,6 +22,7 @@ it/puppy(/she) + pet!! | blog | images | pay me! | From b43bcb8a7e46beb530f08f4ebbe9ff7470b4621e Mon Sep 17 00:00:00 2001 From: zyl Date: Mon, 24 Jun 2024 22:44:37 -0700 Subject: [PATCH 22/35] add debug class to body when serving --- src/builder.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/builder.rs b/src/builder.rs index aab6768..2cb1a0a 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -135,6 +135,10 @@ impl<'a> SiteBuilder<'a> { let mut rewriter = HtmlRewriter::new( Settings { element_content_handlers: vec![ + element!("body", |el| { + el.set_attribute("class", "debug")?; + Ok(()) + }), element!("head", |el| { el.prepend(r#""#, ContentType::Html); if self.serving { From fde22ee9c26396397fb8ad03932b190069be738b Mon Sep 17 00:00:00 2001 From: zyl Date: Mon, 24 Jun 2024 23:21:00 -0700 Subject: [PATCH 23/35] pet logic is implemented!! --- site/pages/pet.md | 42 ++++++-- site/root/js/pet.js | 255 ++++++++++++++++++++++++++++++++++++++++---- site/sass/pet.scss | 16 ++- 3 files changed, 279 insertions(+), 34 deletions(-) diff --git a/site/pages/pet.md b/site/pages/pet.md index 8c24bf6..7fa0eb4 100644 --- a/site/pages/pet.md +++ b/site/pages/pet.md @@ -4,22 +4,50 @@ scripts: ["js/pet.js"] styles: ["pet.css"] --- +
+
+

--pet placeholder here--

-

whoa! you just found an egg somewhere! maybe you should watch it and see what happens..

+

whoa! you just found a weird egg! maybe you should watch it and see what happens..

-
+ +
+ tips!! +
    +
  • pets need to be fed about once every eight hours!
  • +
  • the game (currently) doesn't simulate while the page is unloaded, so make sure to keep the page loaded for your pet to exist!
  • +
  • make sure to keep your pet clean!!
  • +
  • if your pet is turning grey, make sure you're giving them the attention they need!! pet's deserve happiness too :(
  • +
+
From 2906f17df1e64f128625d583e2e9de55b1e209cb Mon Sep 17 00:00:00 2001 From: zyl Date: Tue, 25 Jun 2024 00:19:59 -0700 Subject: [PATCH 29/35] remove outdated comment --- site/pages/pet.md | 1 - 1 file changed, 1 deletion(-) diff --git a/site/pages/pet.md b/site/pages/pet.md index f56193d..07b413c 100644 --- a/site/pages/pet.md +++ b/site/pages/pet.md @@ -9,7 +9,6 @@ styles: ["pet.css"]

-
From 63b43587431d492ee250bf3c45a5f2e56af7a565 Mon Sep 17 00:00:00 2001 From: zyl Date: Tue, 25 Jun 2024 00:42:10 -0700 Subject: [PATCH 30/35] add status messages --- site/pages/pet.md | 8 ++++++++ site/root/js/pet.js | 33 +++++++++++++++++++++++++++++++++ site/sass/pet.scss | 4 ++++ 3 files changed, 45 insertions(+) diff --git a/site/pages/pet.md b/site/pages/pet.md index 07b413c..962d653 100644 --- a/site/pages/pet.md +++ b/site/pages/pet.md @@ -9,6 +9,14 @@ styles: ["pet.css"]

+
+ + + + + + +
diff --git a/site/root/js/pet.js b/site/root/js/pet.js index ab7d3a4..f637d0f 100644 --- a/site/root/js/pet.js +++ b/site/root/js/pet.js @@ -73,6 +73,15 @@ const petDisplay = document.querySelector("#pet-display"); const thePet = petDisplay.querySelector(".the-pet"); + + const status = petDisplay.querySelector(".status"); + const statusHungry = status.querySelector("[name=hungry]"); + const statusStarving = status.querySelector("[name=starving]"); + const statusUnhappy = status.querySelector("[name=unhappy]"); + const statusMessy1 = status.querySelector("[name=messy-1]"); + const statusMessy2 = status.querySelector("[name=messy-2]"); + const statusMessy3 = status.querySelector("[name=messy-3]"); + const petName = document.querySelectorAll(".pet-name"); const eggDiv = document.querySelector("div#egg"); const petSetup = document.querySelector("#pet-setup"); @@ -231,6 +240,13 @@ thePet.classList.remove("elder"); thePet.classList.remove("dead"); + statusHungry.classList.add("hidden"); + statusStarving.classList.add("hidden"); + statusUnhappy.classList.add("hidden"); + statusMessy1.classList.add("hidden"); + statusMessy2.classList.add("hidden"); + statusMessy3.classList.add("hidden"); + let width = 0; let height = 0; @@ -280,6 +296,22 @@ thePet.classList.add("dead"); } else if (this.lifeStage !== LIFE_STAGE_EGG) { thePet.classList.add(this.type); + + if (this.food <= MAX_FOOD / 10) { + statusStarving.classList.remove("hidden"); + } else if (this.food <= MAX_FOOD / 2) { + statusHungry.classList.remove("hidden"); + } + if (this.happiness <= MAX_HAPPINESS / 3) { + statusUnhappy.classList.remove("hidden"); + } + if (this.messCounter >= MAX_MESS) { + statusMessy3.classList.remove("hidden"); + } else if (this.messCounter >= MAX_MESS / 2) { + statusMessy2.classList.remove("hidden"); + } else if (this.messCounter > 0) { + statusMessy1.classList.remove("hidden"); + } } if (this.paused) { @@ -488,6 +520,7 @@ if (document.body.classList.contains("debug")) { debug.classList.remove("hidden"); + document.pet = pet; } pet.updateDom(); diff --git a/site/sass/pet.scss b/site/sass/pet.scss index 3d3fa50..983f3d7 100644 --- a/site/sass/pet.scss +++ b/site/sass/pet.scss @@ -30,6 +30,10 @@ clip-path: polygon(50% 0, 100% 100%, 0 100%); } } + + .status { + font-style: italic; + } } #debug-section [name] { From 3c3e374fd550f6c8499e2eaa1543b22e59039a83 Mon Sep 17 00:00:00 2001 From: zyl Date: Tue, 25 Jun 2024 00:44:21 -0700 Subject: [PATCH 31/35] disable interaction buttons on cooldown --- site/root/js/pet.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/site/root/js/pet.js b/site/root/js/pet.js index f637d0f..7b02044 100644 --- a/site/root/js/pet.js +++ b/site/root/js/pet.js @@ -449,8 +449,10 @@ return; } canFeed = false; + feedButton.disabled = true; setTimeout(() => { canFeed = true; + feedButton.disabled = false; }, FEED_TIMER); pet.feed(38); @@ -461,8 +463,10 @@ return; } canPet = false; + petButton.disabled = true; setTimeout(() => { canPet = true; + petButton.disabled = false; }, PET_TIMER); pet.pet(); @@ -473,8 +477,10 @@ return; } canClean = false; + cleanButton.disabled = true; setTimeout(() => { canClean = true; + cleanButton.disabled = false; }, CLEAN_TIMER); pet.clean(); From f4a2f9f3734480dc86cfbe7e8986ad570fbf4ff5 Mon Sep 17 00:00:00 2001 From: zyl Date: Tue, 25 Jun 2024 00:44:55 -0700 Subject: [PATCH 32/35] make it harder to train a pet --- site/root/js/pet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/root/js/pet.js b/site/root/js/pet.js index 7b02044..bf30a1a 100644 --- a/site/root/js/pet.js +++ b/site/root/js/pet.js @@ -350,7 +350,7 @@ * makes the pet go potty */ goPotty() { - if (this.behavior > 15) { + if (this.behavior > 45) { // go potty properly } else { this.messCounter += 1; From f1c25ec896b96752ddfc007f152f8d1cb182dd2d Mon Sep 17 00:00:00 2001 From: zyl Date: Tue, 25 Jun 2024 00:45:33 -0700 Subject: [PATCH 33/35] add tip about potty training --- site/pages/pet.md | 1 + 1 file changed, 1 insertion(+) diff --git a/site/pages/pet.md b/site/pages/pet.md index 962d653..761b8fc 100644 --- a/site/pages/pet.md +++ b/site/pages/pet.md @@ -66,5 +66,6 @@ styles: ["pet.css"]
  • the game (currently) doesn't simulate while the page is unloaded, so make sure to keep the page loaded for your pet to exist!
  • make sure to keep your pet clean!!
  • if your pet is turning grey, make sure you're giving them the attention they need!! pet's deserve happiness too :(
  • +
  • if you take good enough care of your pet they'll stop going potty on the floor!
  • From 8f0a925a33f06f2c5a7e07163b4be828facece6f Mon Sep 17 00:00:00 2001 From: zyl Date: Tue, 25 Jun 2024 00:55:06 -0700 Subject: [PATCH 34/35] add the grayscale filter to the pet when unhappy --- site/root/js/pet.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/site/root/js/pet.js b/site/root/js/pet.js index bf30a1a..429004a 100644 --- a/site/root/js/pet.js +++ b/site/root/js/pet.js @@ -291,6 +291,18 @@ thePet.style.setProperty("--width", `${width}px`); thePet.style.setProperty("--height", `${height}px`); thePet.style.setProperty("--color", this.color); + let happinessFilter = 1 - this.happiness / MAX_HAPPINESS; + if (happinessFilter < 0.6) { + happinessFilter = 0; + } + happinessFilter = (happinessFilter - 0.6) * 2.5; + if (happinessFilter < 0) { + happinessFilter = 0; + } + thePet.style.setProperty( + "filter", + `grayscale(${happinessFilter * 100}%)` + ); if (!this.alive) { thePet.classList.add("dead"); From 0296c941862f226ef600679459f5df4fdcb80f5b Mon Sep 17 00:00:00 2001 From: zyl Date: Tue, 25 Jun 2024 00:56:05 -0700 Subject: [PATCH 35/35] change pet game name in top bar --- site/templates/base.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/templates/base.hbs b/site/templates/base.hbs index 6abd31b..c3e85df 100644 --- a/site/templates/base.hbs +++ b/site/templates/base.hbs @@ -22,7 +22,7 @@ it/puppy(/she) - pet!! | + creature | blog | images | pay me! |