Add manual maud class collector script
This commit is contained in:
parent
9c75092d12
commit
011c8c1a41
6 changed files with 84 additions and 8 deletions
71
darm_test/scripts/collect-maud-classes.rs
Executable file
71
darm_test/scripts/collect-maud-classes.rs
Executable file
|
@ -0,0 +1,71 @@
|
||||||
|
#!/usr/bin/env rust-script
|
||||||
|
//! This is a regular crate doc comment, but it also contains a partial
|
||||||
|
//! Cargo manifest. Note the use of a *fenced* code block, and the
|
||||||
|
//! `cargo` "language".
|
||||||
|
//!
|
||||||
|
//! ```cargo
|
||||||
|
//! [dependencies]
|
||||||
|
//! regex = "1"
|
||||||
|
//! walkdir = "2"
|
||||||
|
//! ```
|
||||||
|
|
||||||
|
use std::{
|
||||||
|
fs::{self, File},
|
||||||
|
io::{self, Write},
|
||||||
|
path::Path,
|
||||||
|
};
|
||||||
|
|
||||||
|
use regex::Regex;
|
||||||
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
|
fn main() -> io::Result<()> {
|
||||||
|
// Define the regex pattern to extract classes
|
||||||
|
let re = Regex::new(r"(?: \.(?P<tag>[\w-]+))").expect("Invalid regex pattern");
|
||||||
|
|
||||||
|
// Define the source directory to scan
|
||||||
|
let source_dir = "./src"; // Change this to your source directory
|
||||||
|
|
||||||
|
// Define the output file
|
||||||
|
let output_file = "./style/extracted-classes.txt";
|
||||||
|
let mut file = File::create(output_file)?;
|
||||||
|
|
||||||
|
println!("Scanning directory: {}", source_dir);
|
||||||
|
|
||||||
|
// Walk through the directory structure
|
||||||
|
for entry in WalkDir::new(source_dir)
|
||||||
|
.into_iter()
|
||||||
|
.filter_map(|e| e.ok())
|
||||||
|
.filter(|e| {
|
||||||
|
e.file_type().is_file() && e.path().extension().map_or(false, |ext| ext == "rs")
|
||||||
|
})
|
||||||
|
{
|
||||||
|
let path = entry.path();
|
||||||
|
println!("Processing file: {}", path.display());
|
||||||
|
let content = fs::read_to_string(path)?;
|
||||||
|
let mut classes = Vec::new();
|
||||||
|
|
||||||
|
// Extract all classes using the regex
|
||||||
|
for cap in re.captures_iter(&content) {
|
||||||
|
if let Some(tag_match) = cap.name("tag") {
|
||||||
|
let class = tag_match.as_str().to_string();
|
||||||
|
classes.push(class.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If classes were found, write them to the output file
|
||||||
|
if !classes.is_empty() {
|
||||||
|
writeln!(
|
||||||
|
file,
|
||||||
|
"class=\"{}\" <!-- {} -->",
|
||||||
|
classes.join(" "),
|
||||||
|
path.display()
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"Class extraction complete. Output written to {}",
|
||||||
|
output_file
|
||||||
|
);
|
||||||
|
Ok(())
|
||||||
|
}
|
|
@ -65,16 +65,16 @@ impl UiController {
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
async fn index(State(_): State<AppState>) -> impl IntoResponse {
|
async fn index(State(_): State<AppState>) -> impl IntoResponse {
|
||||||
main_page(maud! {
|
main_page(maud! {
|
||||||
div class="container p-4 mx-auto" {
|
div .container .p-4 .mx-auto {
|
||||||
h1 class="mb-4 text-2xl font-bold" {
|
h1 .m-4 .text-2xl .font-bold {
|
||||||
"LLM Chat App"
|
"LLM Chat App"
|
||||||
}
|
}
|
||||||
div class="p-6 bg-white rounded-lg shadow-md" {
|
div .p-6 .bg-white .rounded-lg .shadow-md {
|
||||||
div #chat class="mb-4" {
|
div #chat .m-4 {
|
||||||
// Chat messages will appear here
|
// Chat messages will appear here
|
||||||
}
|
}
|
||||||
form id="chat-form" {
|
form id="chat-form" {
|
||||||
textarea #user-input class="p-2 m-2 w-full rounded-lg border" data-bind-msginput placeholder="Type your message..." {}
|
textarea #user-input .p-2 .m-2 .w-full .rounded-lg .border data-bind-msginput placeholder="Type your message..." {}
|
||||||
button #send-btn class="btn" type="button" data-on-click="@get('/msg')" {
|
button #send-btn class="btn" type="button" data-on-click="@get('/msg')" {
|
||||||
"Send"
|
"Send"
|
||||||
}
|
}
|
||||||
|
|
3
darm_test/style/extracted-classes.txt
Normal file
3
darm_test/style/extracted-classes.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
class="into_response" <!-- ./src/assets.rs -->
|
||||||
|
class="selector merge_mode into selector merge_mode into container p-4 mx-auto m-4 text-2xl font-bold p-6 bg-white rounded-lg shadow-md m-4 p-2 m-2 w-full rounded-lg border render" <!-- ./src/ui/mod.rs -->
|
||||||
|
class="into_response into_response with_default_directive from_env_lossy pretty with_env_filter init body size_hint exact map merge merge fallback_service method_not_allowed_fallback layer layer layer layer layer with_state" <!-- ./src/main.rs -->
|
|
@ -122,7 +122,6 @@ line-height: inherit; }
|
||||||
.m-8{margin:2rem;}
|
.m-8{margin:2rem;}
|
||||||
.mx-auto{margin-left:auto;margin-right:auto;}
|
.mx-auto{margin-left:auto;margin-right:auto;}
|
||||||
.mb-2{margin-bottom:0.5rem;}
|
.mb-2{margin-bottom:0.5rem;}
|
||||||
.mb-4{margin-bottom:1rem;}
|
|
||||||
.inline-block{display:inline-block;}
|
.inline-block{display:inline-block;}
|
||||||
.h1{height:0.25rem;}
|
.h1{height:0.25rem;}
|
||||||
.w-full{width:100%;}
|
.w-full{width:100%;}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {
|
||||||
defineConfig,
|
defineConfig,
|
||||||
presetAttributify,
|
presetAttributify,
|
||||||
presetIcons,
|
presetIcons,
|
||||||
presetWind,
|
presetWind3,
|
||||||
presetTagify,
|
presetTagify,
|
||||||
presetTypography,
|
presetTypography,
|
||||||
transformerDirectives,
|
transformerDirectives,
|
||||||
|
@ -23,6 +23,7 @@ export default defineConfig({
|
||||||
"src/**/*.rs",
|
"src/**/*.rs",
|
||||||
"*/src/**/*.rs",
|
"*/src/**/*.rs",
|
||||||
"*/style/*.scss",
|
"*/style/*.scss",
|
||||||
|
"**/extracted-classes.txt",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
cli: {
|
cli: {
|
||||||
|
@ -32,12 +33,13 @@ export default defineConfig({
|
||||||
"src/**/*.rs",
|
"src/**/*.rs",
|
||||||
"*/src/**/*.rs",
|
"*/src/**/*.rs",
|
||||||
"*/style/*.scss",
|
"*/style/*.scss",
|
||||||
|
"**/extracted-classes.txt",
|
||||||
],
|
],
|
||||||
outFile: "./style/uno.css",
|
outFile: "./style/uno.css",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
presets: [
|
presets: [
|
||||||
presetWind(),
|
presetWind3({}),
|
||||||
presetAttributify({}),
|
presetAttributify({}),
|
||||||
presetTagify({}),
|
presetTagify({}),
|
||||||
presetIcons({}),
|
presetIcons({}),
|
||||||
|
|
|
@ -166,6 +166,7 @@
|
||||||
wasm-bindgen-cli_0_2_100
|
wasm-bindgen-cli_0_2_100
|
||||||
cargo-outdated
|
cargo-outdated
|
||||||
cargo-release
|
cargo-release
|
||||||
|
rust-script
|
||||||
calc
|
calc
|
||||||
# jre8 # needed for xmlls
|
# jre8 # needed for xmlls
|
||||||
dart-sass
|
dart-sass
|
||||||
|
|
Loading…
Add table
Reference in a new issue