just some random stuff

This commit is contained in:
liquidex 2023-08-27 18:47:57 +02:00
parent d794e88bdc
commit e43d612e3d
5 changed files with 63 additions and 2 deletions

View file

@ -1,5 +1,10 @@
% id = "treehouse" % id = "treehouse"
- # liquidex's treehouse - # liquidex's treehouse
<span class="oops-you-seem-to-have-gotten-stuck">
<strong>achievement unlocked: <i>I don't want anything to do with this bullshit</i><br></strong>
…either that, or you folded the entire tree by accident.<br>
feel free to go back any time by clicking here.
</span>
% id = "01H8V556P1PND8DQ73XBTZZJH7" % id = "01H8V556P1PND8DQ73XBTZZJH7"
- welcome! make yourself at home - welcome! make yourself at home

View file

@ -219,6 +219,7 @@ pub fn regenerate(paths: &Paths<'_>) -> anyhow::Result<()> {
info!("loading config"); info!("loading config");
let mut config = Config::load(paths.config_file)?; let mut config = Config::load(paths.config_file)?;
config.site = std::env::var("TREEHOUSE_SITE").unwrap_or(config.site); config.site = std::env::var("TREEHOUSE_SITE").unwrap_or(config.site);
config.autopopulate_emoji(&paths.static_dir.join("emoji"))?;
info!("cleaning target directory"); info!("cleaning target directory");
let _ = std::fs::remove_dir_all(paths.target_dir); let _ = std::fs::remove_dir_all(paths.target_dir);

View file

@ -1,7 +1,8 @@
use std::{collections::HashMap, path::Path}; use std::{collections::HashMap, ffi::OsStr, path::Path};
use anyhow::Context; use anyhow::Context;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use walkdir::WalkDir;
#[derive(Debug, Clone, Deserialize, Serialize)] #[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Config { pub struct Config {
@ -28,4 +29,31 @@ impl Config {
let string = std::fs::read_to_string(path).context("cannot read config file")?; let string = std::fs::read_to_string(path).context("cannot read config file")?;
toml_edit::de::from_str(&string).context("error in config file") toml_edit::de::from_str(&string).context("error in config file")
} }
fn is_emoji_file(path: &Path) -> bool {
path.extension() == Some(OsStr::new("png")) || path.extension() == Some(OsStr::new("svg"))
}
pub fn autopopulate_emoji(&mut self, dir: &Path) -> anyhow::Result<()> {
for file in WalkDir::new(dir) {
let entry = file?;
if entry.file_type().is_file() && Self::is_emoji_file(entry.path()) {
if let Some(emoji_name) = entry.path().file_stem() {
let emoji_name = emoji_name.to_string_lossy();
if !self.emoji.contains_key(emoji_name.as_ref()) {
self.emoji.insert(
emoji_name.into_owned(),
entry
.path()
.strip_prefix(dir)
.unwrap_or(entry.path())
.to_string_lossy()
.into_owned(),
);
}
}
}
}
Ok(())
}
} }

View file

@ -244,3 +244,31 @@ img.emoji {
max-height: 1.375em; max-height: 1.375em;
vertical-align: bottom; vertical-align: bottom;
} }
/* Funny joke */
@keyframes hello-there {
0% {
opacity: 0%;
}
70% {
opacity: 0%;
}
100% {
opacity: 70%;
}
}
.oops-you-seem-to-have-gotten-stuck {
margin-top: 16px;
display: none;
position: absolute;
opacity: 0%;
}
#index\:treehouse>details:not([open])>summary .oops-you-seem-to-have-gotten-stuck {
display: inline;
animation: 4s hello-there forwards;
}

View file

@ -9,4 +9,3 @@ author = "liquidex"
"dawd3/repo" = "https://github.com/liquidev/dawd3" "dawd3/repo" = "https://github.com/liquidev/dawd3"
[emoji] [emoji]
hueh = "hueh.png"