diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 62dcbcb..aa18f6a 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: targets: wasm32-unknown-unknown components: rustfmt, clippy - name: Format check - run: cargo fmt --workspace --check + run: cargo fmt --all --check - name: Clippy run: cargo clippy --workspace -- -D warnings - name: Test diff --git a/backend/src/font_registry.rs b/backend/src/font_registry.rs index 58174df..f2fd209 100644 --- a/backend/src/font_registry.rs +++ b/backend/src/font_registry.rs @@ -1,7 +1,7 @@ -use std::collections::HashMap; use dreport_layout::FontData; use dreport_layout::font_meta::{self, FontFamilyInfo, FontVariantKey}; use dreport_layout::font_provider::FontProvider; +use std::collections::HashMap; /// Font registry — manages all available fonts from embedded defaults + external directory. pub struct FontRegistry { @@ -31,11 +31,26 @@ impl FontRegistry { fn load_embedded_defaults(&mut self) { let embedded: &[(&str, &[u8])] = &[ - ("NotoSans-Regular", include_bytes!("../fonts/NotoSans-Regular.ttf")), - ("NotoSans-Bold", include_bytes!("../fonts/NotoSans-Bold.ttf")), - ("NotoSans-Italic", include_bytes!("../fonts/NotoSans-Italic.ttf")), - ("NotoSans-BoldItalic", include_bytes!("../fonts/NotoSans-BoldItalic.ttf")), - ("NotoSansMono-Regular", include_bytes!("../fonts/NotoSansMono-Regular.ttf")), + ( + "NotoSans-Regular", + include_bytes!("../fonts/NotoSans-Regular.ttf"), + ), + ( + "NotoSans-Bold", + include_bytes!("../fonts/NotoSans-Bold.ttf"), + ), + ( + "NotoSans-Italic", + include_bytes!("../fonts/NotoSans-Italic.ttf"), + ), + ( + "NotoSans-BoldItalic", + include_bytes!("../fonts/NotoSans-BoldItalic.ttf"), + ), + ( + "NotoSansMono-Regular", + include_bytes!("../fonts/NotoSansMono-Regular.ttf"), + ), ]; for (_name, data) in embedded { @@ -60,13 +75,13 @@ impl FontRegistry { for entry in entries.flatten() { let p = entry.path(); - if p.extension().is_some_and(|e| e == "ttf" || e == "otf") { - if let Ok(data) = std::fs::read(&p) { - if self.register_font(data) { - println!(" Font yüklendi: {}", p.display()); - } else { - eprintln!(" Font parse edilemedi: {}", p.display()); - } + if p.extension().is_some_and(|e| e == "ttf" || e == "otf") + && let Ok(data) = std::fs::read(&p) + { + if self.register_font(data) { + println!(" Font yüklendi: {}", p.display()); + } else { + eprintln!(" Font parse edilemedi: {}", p.display()); } } } @@ -141,7 +156,8 @@ impl FontProvider for FontRegistry { self.families .iter() .map(|(family_lower, variants)| { - let family = self.family_names + let family = self + .family_names .get(family_lower) .cloned() .unwrap_or_else(|| family_lower.clone()); diff --git a/backend/src/main.rs b/backend/src/main.rs index 31f3ef2..23a0fd2 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -14,7 +14,8 @@ async fn main() -> anyhow::Result<()> { println!("Font registry başlatılıyor..."); let registry = Arc::new(FontRegistry::new()); - let family_count = dreport_layout::font_provider::FontProvider::list_families(registry.as_ref()).len(); + let family_count = + dreport_layout::font_provider::FontProvider::list_families(registry.as_ref()).len(); println!("Font registry hazır ({} font ailesi)", family_count); let cors = CorsLayer::new() diff --git a/backend/src/routes/fonts.rs b/backend/src/routes/fonts.rs index ed52203..f40afa4 100644 --- a/backend/src/routes/fonts.rs +++ b/backend/src/routes/fonts.rs @@ -1,10 +1,9 @@ use axum::{ - Router, + Json, Router, extract::{Path, State}, http::{StatusCode, header}, response::IntoResponse, routing::get, - Json, }; use dreport_layout::font_provider::FontProvider; use serde::Serialize; @@ -25,15 +24,14 @@ struct FontVariantResponse { } /// GET /api/fonts — list all available font families -async fn list_fonts( - State(registry): State>, -) -> Json> { +async fn list_fonts(State(registry): State>) -> Json> { let families = registry.list_families(); let response: Vec = families .into_iter() .map(|f| FontFamilyResponse { family: f.family, - variants: f.variants + variants: f + .variants .into_iter() .map(|v| FontVariantResponse { weight: v.weight, diff --git a/backend/src/routes/health.rs b/backend/src/routes/health.rs index 0535cd8..b079506 100644 --- a/backend/src/routes/health.rs +++ b/backend/src/routes/health.rs @@ -1,4 +1,4 @@ -use axum::{Router, routing::get, Json}; +use axum::{Json, Router, routing::get}; use serde::Serialize; use std::sync::Arc; diff --git a/backend/src/routes/render.rs b/backend/src/routes/render.rs index 61550eb..aad4435 100644 --- a/backend/src/routes/render.rs +++ b/backend/src/routes/render.rs @@ -1,10 +1,9 @@ use axum::{ - Router, + Json, Router, extract::State, http::{StatusCode, header}, response::IntoResponse, routing::post, - Json, }; use serde::Deserialize; use std::sync::Arc; diff --git a/core/src/models.rs b/core/src/models.rs index 0af3f27..6b28c9d 100644 --- a/core/src/models.rs +++ b/core/src/models.rs @@ -296,7 +296,7 @@ pub enum TemplateElement { #[serde(rename = "rich_text")] RichText(RichTextElement), #[serde(rename = "chart")] - Chart(ChartElement), + Chart(Box), } impl TemplateElement { @@ -406,11 +406,19 @@ pub struct ContainerElement { pub break_inside: String, } -fn default_auto() -> String { "auto".to_string() } +fn default_auto() -> String { + "auto".to_string() +} -fn default_column() -> String { "column".to_string() } -fn default_stretch() -> String { "stretch".to_string() } -fn default_start() -> String { "start".to_string() } +fn default_column() -> String { + "column".to_string() +} +fn default_stretch() -> String { + "stretch".to_string() +} +fn default_start() -> String { + "start".to_string() +} #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] @@ -488,7 +496,9 @@ pub struct RepeatingTableElement { pub repeat_header: Option, } -fn default_true() -> Option { Some(true) } +fn default_true() -> Option { + Some(true) +} #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] @@ -519,7 +529,7 @@ pub struct ShapeElement { #[derive(Debug, Clone, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase", default)] pub struct CheckboxStyle { - pub size: Option, // mm — kare boyutu + pub size: Option, // mm — kare boyutu pub check_color: Option, // checkmark rengi pub border_color: Option, // kare kenar rengi pub border_width: Option, // kenar kalınlığı @@ -531,8 +541,8 @@ pub struct CheckboxElement { pub id: String, pub position: PositionMode, pub size: SizeConstraint, - pub checked: Option, // statik değer - pub binding: Option, // dinamik boolean binding + pub checked: Option, // statik değer + pub binding: Option, // dinamik boolean binding pub style: CheckboxStyle, } @@ -583,10 +593,18 @@ pub struct FormatConfig { } impl FormatConfig { - fn default_thousands_sep() -> String { ".".to_string() } - fn default_decimal_sep() -> String { ",".to_string() } - fn default_currency_symbol() -> String { "₺".to_string() } - fn default_currency_position() -> String { "suffix".to_string() } + fn default_thousands_sep() -> String { + ".".to_string() + } + fn default_decimal_sep() -> String { + ",".to_string() + } + fn default_currency_symbol() -> String { + "₺".to_string() + } + fn default_currency_position() -> String { + "suffix".to_string() + } } impl Default for FormatConfig { diff --git a/frontend/src/components/editor/LayoutRenderer.vue b/frontend/src/components/editor/LayoutRenderer.vue index c5f6bc7..6f2fc87 100644 --- a/frontend/src/components/editor/LayoutRenderer.vue +++ b/frontend/src/components/editor/LayoutRenderer.vue @@ -1,5 +1,5 @@