diff --git a/axum_server/src/picture_generator/picture_markup_generator.rs b/axum_server/src/picture_generator/picture_markup_generator.rs index a916f66..84a4741 100644 --- a/axum_server/src/picture_generator/picture_markup_generator.rs +++ b/axum_server/src/picture_generator/picture_markup_generator.rs @@ -19,9 +19,15 @@ pub fn generate_picture_markup( width: u32, height: u32, alt_text: &str, + class_name: Option<&str>, generate_image: bool, ) -> Result { let exported_formats = get_export_formats(orig_img_path); + let class_attr = if let Some(class) = class_name { + format!(r#"class="{class}""#) + } else { + "".to_string() + }; if exported_formats.is_empty() { return Ok(formatdoc!( @@ -29,6 +35,7 @@ pub fn generate_picture_markup( src="{orig_img_path}" width="{width}" height="{height}" + {class_attr} alt="{alt_text}" >"# )); @@ -99,6 +106,7 @@ pub fn generate_picture_markup( width="{width}" height="{height}" alt="{alt_text}" + {class_attr} >"# ); @@ -307,8 +315,15 @@ fn test_generate_picture_markup() { "#, }; assert_eq!( - generate_picture_markup(orig_img_path, width, height, "Testing image alt", false) - .expect("picture markup has to be generated"), + generate_picture_markup( + orig_img_path, + width, + height, + "Testing image alt", + None, + false + ) + .expect("picture markup has to be generated"), result ); } diff --git a/axum_server/src/post_utils/post_parser.rs b/axum_server/src/post_utils/post_parser.rs index cc18fe4..a1350d8 100644 --- a/axum_server/src/post_utils/post_parser.rs +++ b/axum_server/src/post_utils/post_parser.rs @@ -125,17 +125,23 @@ pub fn parse_html(markdown: &str, generate_images: bool) -> String { ); // Place image into the content with scaled reso to a boundary - let picture_markup = - generate_picture_markup(&dest_url, max_width, max_height, &title, generate_images) - .unwrap_or(formatdoc!( - r#" + let picture_markup = generate_picture_markup( + &dest_url, + max_width, + max_height, + &title, + None, + generate_images, + ) + .unwrap_or(formatdoc!( + r#" {alt}"#, - alt = title, - src = dest_url, - )); + alt = title, + src = dest_url, + )); debug!( "Image link_type: {:?} url: {} title: {} id: {}", link_type, dest_url, title, id diff --git a/axum_server/styles/input.css b/axum_server/styles/input.css index 8967be5..74d6e25 100644 --- a/axum_server/styles/input.css +++ b/axum_server/styles/input.css @@ -76,10 +76,6 @@ strong { @apply font-medium; } -img[height] { - height: revert-layer; -} - .article-body { h1 { @apply px-4 text-2xl font-semibold text-blue-900 mb-3 mt-4 max-w-read mx-auto md:text-4xl lg:text-5xl; diff --git a/axum_server/styles/output.css b/axum_server/styles/output.css index c58874a..7ff7bb5 100644 --- a/axum_server/styles/output.css +++ b/axum_server/styles/output.css @@ -654,6 +654,18 @@ video { grid-row: span 3 / span 3; } +.float-start { + float: inline-start; +} + +.clear-left { + clear: left; +} + +.clear-both { + clear: both; +} + .m-0 { margin: 0px; } @@ -710,11 +722,6 @@ video { margin-bottom: 1.25rem; } -.my-4 { - margin-top: 1rem; - margin-bottom: 1rem; -} - .mb-1 { margin-bottom: 0.25rem; } @@ -739,6 +746,30 @@ video { margin-top: 0.75rem; } +.ml-1 { + margin-left: 0.25rem; +} + +.mr-1 { + margin-right: 0.25rem; +} + +.mr-2 { + margin-right: 0.5rem; +} + +.mb-4 { + margin-bottom: 1rem; +} + +.mr-4 { + margin-right: 1rem; +} + +.mr-3 { + margin-right: 0.75rem; +} + .block { display: block; } @@ -787,6 +818,18 @@ video { height: 240px; } +.h-auto { + height: auto; +} + +.h-\[236px\] { + height: 236px; +} + +.max-h-\[236px\] { + max-height: 236px; +} + .min-h-full { min-height: 100%; } @@ -807,6 +850,11 @@ video { width: 180px; } +.w-fit { + width: -moz-fit-content; + width: fit-content; +} + .max-w-\[32rem\] { max-width: 32rem; } @@ -819,22 +867,6 @@ video { max-width: 64rem; } -.max-w-sm { - max-width: 24rem; -} - -.max-w-96 { - max-width: 24rem; -} - -.max-w-\[30rem\] { - max-width: 30rem; -} - -.max-w-md { - max-width: 28rem; -} - .max-w-xl { max-width: 36rem; } @@ -1161,10 +1193,6 @@ strong { font-weight: 500; } -img[height] { - height: revert-layer; -} - .article-body { h1 { margin-left: auto; @@ -1808,14 +1836,49 @@ article a:visited { } @media (min-width: 640px) { + .sm\:float-none { + float: none; + } + + .sm\:clear-none { + clear: none; + } + .sm\:my-4 { margin-top: 1rem; margin-bottom: 1rem; } - .sm\:mx-auto { - margin-left: auto; - margin-right: auto; + .sm\:ml-0 { + margin-left: 0px; + } + + .sm\:mb-0 { + margin-bottom: 0px; + } + + .sm\:mt-0 { + margin-top: 0px; + } + + .sm\:grid { + display: grid; + } + + .sm\:grid-flow-col { + grid-auto-flow: column; + } + + .sm\:grid-cols-\[max-content_1fr\] { + grid-template-columns: max-content 1fr; + } + + .sm\:grid-rows-\[max-content_1fr_max-content\] { + grid-template-rows: max-content 1fr max-content; + } + + .sm\:gap-4 { + gap: 1rem; } .sm\:py-4 { @@ -1830,11 +1893,6 @@ article a:visited { margin-bottom: 2rem; } - .md\:mx-auto { - margin-left: auto; - margin-right: auto; - } - .md\:grid { display: grid; } diff --git a/axum_server/templates/components/blog_post_preview.html b/axum_server/templates/components/blog_post_preview.html index 0fac434..4a5f545 100644 --- a/axum_server/templates/components/blog_post_preview.html +++ b/axum_server/templates/components/blog_post_preview.html @@ -1,8 +1,8 @@ -
-