mirror of
https://github.com/Noratrieb/website.git
synced 2026-01-15 01:15:02 +01:00
random name for back alley
This commit is contained in:
parent
9f9120dc27
commit
2d2c820510
6 changed files with 95 additions and 9 deletions
|
|
@ -11,6 +11,7 @@ use color_eyre::{eyre::Context, Result};
|
|||
use crate::Config;
|
||||
|
||||
pub fn assemble_website(
|
||||
rng: &mut rand::rngs::StdRng,
|
||||
config: &Config,
|
||||
statics: &Path,
|
||||
submodules: &Path,
|
||||
|
|
@ -24,7 +25,7 @@ pub fn assemble_website(
|
|||
)
|
||||
.wrap_err("building slides")?;
|
||||
|
||||
statics::build(&config.slides, statics, dist).wrap_err("building root files")?;
|
||||
statics::build(rng, &config.slides, statics, dist).wrap_err("building root files")?;
|
||||
|
||||
add_cname(dist)?;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use std::{fs, path::Path};
|
|||
|
||||
use askama::Template;
|
||||
use color_eyre::{eyre::WrapErr, Result};
|
||||
use rand::seq::SliceRandom;
|
||||
|
||||
use crate::{utils, SlidesConfig, Talk};
|
||||
|
||||
|
|
@ -13,9 +14,33 @@ struct Slides {
|
|||
talks: Vec<Talk>,
|
||||
}
|
||||
|
||||
pub fn build(config: &SlidesConfig, statics: &Path, dist: &Path) -> Result<()> {
|
||||
pub fn build(
|
||||
rng: &mut rand::rngs::StdRng,
|
||||
config: &SlidesConfig,
|
||||
statics: &Path,
|
||||
dist: &Path,
|
||||
) -> Result<()> {
|
||||
let back_alley_name = b"abcdefghijklmnopqrstuvwxyz"
|
||||
.choose_multiple(rng, 6)
|
||||
.map(|&c| char::from_u32(c.into()).unwrap())
|
||||
.collect::<String>();
|
||||
|
||||
let back_alley_name = format!("back-alley-{back_alley_name}.html");
|
||||
|
||||
utils::cp_content(&statics.join("root"), dist).wrap_err("copying root files")?;
|
||||
|
||||
let back_alley = dist.join("back-alley.html");
|
||||
std::fs::copy(&back_alley, dist.join(&back_alley_name)).wrap_err("copying back-alley.html")?;
|
||||
fs::remove_file(back_alley).wrap_err("deleting normal back-alley.html")?;
|
||||
|
||||
let index_html = dist.join("index.html");
|
||||
let index = fs::read_to_string(&index_html).wrap_err("reading index.html")?;
|
||||
fs::write(
|
||||
index_html,
|
||||
index.replace("back-alley.html", &back_alley_name),
|
||||
)
|
||||
.wrap_err("writing back index.html")?;
|
||||
|
||||
let slide_html = Slides {
|
||||
talks: config.talks.clone(),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue