From 20435e53cbe94aeed4c2c24239db6c32d764d2ae Mon Sep 17 00:00:00 2001 From: SilasMarvin <19626586+SilasMarvin@users.noreply.github.com> Date: Wed, 28 Feb 2024 14:24:39 -0800 Subject: [PATCH 1/2] Made search collection name use the cms hash --- pgml-dashboard/Cargo.toml | 3 +++ pgml-dashboard/build.rs | 19 +++++++++++++++++-- pgml-dashboard/src/utils/markdown.rs | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/pgml-dashboard/Cargo.toml b/pgml-dashboard/Cargo.toml index 19231db8b..71dbbcf4b 100644 --- a/pgml-dashboard/Cargo.toml +++ b/pgml-dashboard/Cargo.toml @@ -52,3 +52,6 @@ yaml-rust = "0.4" zoomies = { git="https://github.com/HyperparamAI/zoomies.git", branch="master" } ws = { package = "rocket_ws", git = "https://github.com/SergioBenitez/Rocket" } futures = "0.3.29" + +[build-dependencies] +glob = "*" diff --git a/pgml-dashboard/build.rs b/pgml-dashboard/build.rs index 89143fd57..004524e28 100644 --- a/pgml-dashboard/build.rs +++ b/pgml-dashboard/build.rs @@ -1,4 +1,7 @@ +use glob::glob; use std::fs::read_to_string; +use std::hash::Hasher; +use std::path::PathBuf; use std::process::Command; fn main() { @@ -27,9 +30,11 @@ fn main() { let css_version = read_to_string("static/css/.pgml-bundle").expect("failed to read .pgml-bundle"); let css_version = css_version.trim(); + println!("cargo:rustc-env=CSS_VERSION={css_version}"); let js_version = read_to_string("static/js/.pgml-bundle").expect("failed to read .pgml-bundle"); let js_version = js_version.trim(); + println!("cargo:rustc-env=JS_VERSION={js_version}"); let status = Command::new("cp") .arg("static/js/main.js") @@ -41,6 +46,16 @@ fn main() { panic!("failed to bundle main.js"); } - println!("cargo:rustc-env=CSS_VERSION={css_version}"); - println!("cargo:rustc-env=JS_VERSION={js_version}"); + let mut files_paths = glob("./../pgml-cms/**/*.md") + .expect("Failed to read pgml-cms directory") + .map(|p| p.unwrap()) + .collect::>(); + files_paths.sort(); + let mut hasher = std::hash::DefaultHasher::new(); + for path in files_paths { + let contents = read_to_string(path.clone()).expect("Error reading file"); + hasher.write(&contents.into_bytes()); + } + let cms_hash = hasher.finish(); + println!("cargo:rustc-env=CMS_HASH={cms_hash}"); } diff --git a/pgml-dashboard/src/utils/markdown.rs b/pgml-dashboard/src/utils/markdown.rs index 55c42b9b1..2d4deea6a 100644 --- a/pgml-dashboard/src/utils/markdown.rs +++ b/pgml-dashboard/src/utils/markdown.rs @@ -1239,7 +1239,7 @@ pub struct SiteSearch { impl SiteSearch { pub async fn new() -> anyhow::Result { let collection = pgml::Collection::new( - "hypercloud-site-search-c-2", + env!("CMS_HASH"), Some( std::env::var("SITE_SEARCH_DATABASE_URL") .context("Please set the `SITE_SEARCH_DATABASE_URL` environment variable")?, From af72457c44671395e1c21fa6888741107344022e Mon Sep 17 00:00:00 2001 From: SilasMarvin <19626586+SilasMarvin@users.noreply.github.com> Date: Wed, 28 Feb 2024 14:35:50 -0800 Subject: [PATCH 2/2] Doing it the fancy way --- pgml-dashboard/build.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pgml-dashboard/build.rs b/pgml-dashboard/build.rs index 004524e28..5be0e7afa 100644 --- a/pgml-dashboard/build.rs +++ b/pgml-dashboard/build.rs @@ -1,4 +1,5 @@ use glob::glob; +use std::collections::BTreeSet; use std::fs::read_to_string; use std::hash::Hasher; use std::path::PathBuf; @@ -46,11 +47,10 @@ fn main() { panic!("failed to bundle main.js"); } - let mut files_paths = glob("./../pgml-cms/**/*.md") + let files_paths = glob("./../pgml-cms/**/*.md") .expect("Failed to read pgml-cms directory") .map(|p| p.unwrap()) - .collect::>(); - files_paths.sort(); + .collect::>(); let mut hasher = std::hash::DefaultHasher::new(); for path in files_paths { let contents = read_to_string(path.clone()).expect("Error reading file"); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy