diff --git a/_posts/blog/2022-02-20-weekly-07-2022.md b/_posts/blog/2022-02-20-weekly-07-2022.md index 318fb16..c3b829c 100644 --- a/_posts/blog/2022-02-20-weekly-07-2022.md +++ b/_posts/blog/2022-02-20-weekly-07-2022.md @@ -5,6 +5,7 @@ segments: - blog published: true date: 2022-02-20T17:50:56.214Z +thumbnail: /images/uploads/laptopbattery.jpg tags: - News - Weekly diff --git a/_posts/blog/2022-04-26-devbreak-2-stories-and-impressions-hack-kosice.md b/_posts/blog/2022-04-26-devbreak-2-stories-and-impressions-hack-kosice.md index 77a2f91..1ebdb8a 100644 --- a/_posts/blog/2022-04-26-devbreak-2-stories-and-impressions-hack-kosice.md +++ b/_posts/blog/2022-04-26-devbreak-2-stories-and-impressions-hack-kosice.md @@ -5,6 +5,7 @@ segments: - broadcasts published: true date: 2022-04-26T20:22:21.191Z +thumbnail: /images/uploads/deeevbreak2.jpeg tags: - DevBreak --- diff --git a/_posts/blog/2022-06-09-devbreak-3-full-stack-development.md b/_posts/blog/2022-06-09-devbreak-3-full-stack-development.md index 6ced5cf..d65eaad 100644 --- a/_posts/blog/2022-06-09-devbreak-3-full-stack-development.md +++ b/_posts/blog/2022-06-09-devbreak-3-full-stack-development.md @@ -5,6 +5,7 @@ segments: - broadcasts published: true date: 2022-06-09T20:22:21.191Z +thumbnail: /images/uploads/deevbreakdoninik.jpeg tags: - DevBreak --- diff --git a/_posts/blog/2022-06-26-our-attempt-at-rusty-game-jam-weekly-25-2022.md b/_posts/blog/2022-06-26-our-attempt-at-rusty-game-jam-weekly-25-2022.md index c49efc0..58576d2 100644 --- a/_posts/blog/2022-06-26-our-attempt-at-rusty-game-jam-weekly-25-2022.md +++ b/_posts/blog/2022-06-26-our-attempt-at-rusty-game-jam-weekly-25-2022.md @@ -1,16 +1,17 @@ --- -layout: blog -title: "Our attempt at Rusty game jam - Weekly #25-2022" segments: - blog - featured +notes: "" +layout: blog +title: "Our attempt at Rusty game jam - Weekly #25-2022" published: true date: 2022-06-26T20:02:47.419Z +thumbnail: /images/uploads/screenshot-from-2022-06-26-22-37-16.png tags: - News - Weekly - Development -notes: "" --- Long time no see! diff --git a/_posts/blog/2022-11-27-lovely-london-trip.md b/_posts/blog/2022-11-27-lovely-london-trip.md index 4e6392e..34ec9f9 100644 --- a/_posts/blog/2022-11-27-lovely-london-trip.md +++ b/_posts/blog/2022-11-27-lovely-london-trip.md @@ -5,6 +5,7 @@ segments: - blog published: true date: 2022-11-27T19:49:09.204Z +thumbnail: /images/uploads/image_7115.jpg tags: - News - Travel diff --git a/_posts/blog/2023-01-21-devbreak-4-state-of-js-2022.md b/_posts/blog/2023-01-21-devbreak-4-state-of-js-2022.md index 43d15f8..2546368 100644 --- a/_posts/blog/2023-01-21-devbreak-4-state-of-js-2022.md +++ b/_posts/blog/2023-01-21-devbreak-4-state-of-js-2022.md @@ -5,6 +5,7 @@ segments: - broadcasts published: true date: 2023-01-21T20:22:21.191Z +thumbnail: /images/uploads/devbreak-4-3-.png tags: - DevBreak --- diff --git a/_posts/blog/2023-02-04-devbreak-5-joys-and-concerns-of-engineering-manager.md b/_posts/blog/2023-02-04-devbreak-5-joys-and-concerns-of-engineering-manager.md index c40bd72..c927a0f 100644 --- a/_posts/blog/2023-02-04-devbreak-5-joys-and-concerns-of-engineering-manager.md +++ b/_posts/blog/2023-02-04-devbreak-5-joys-and-concerns-of-engineering-manager.md @@ -5,6 +5,7 @@ segments: - broadcasts published: true date: 2023-02-04T20:22:21.191Z +thumbnail: /images/uploads/devbreak.jpeg tags: - DevBreak --- diff --git a/_posts/blog/2023-04-27-keyboards-ergonomics-of-21st-century.md b/_posts/blog/2023-04-27-keyboards-ergonomics-of-21st-century.md index 7e96bfa..8398aec 100644 --- a/_posts/blog/2023-04-27-keyboards-ergonomics-of-21st-century.md +++ b/_posts/blog/2023-04-27-keyboards-ergonomics-of-21st-century.md @@ -6,6 +6,7 @@ segments: - featured published: true date: 2023-04-27T21:22:21.191Z +thumbnail: /images/uploads/teta.png tags: - Presentation - Keyboards diff --git a/_posts/blog/2023-06-24-letter-for-daniel.md b/_posts/blog/2023-06-24-letter-for-daniel.md index babc681..c833a30 100644 --- a/_posts/blog/2023-06-24-letter-for-daniel.md +++ b/_posts/blog/2023-06-24-letter-for-daniel.md @@ -5,6 +5,7 @@ segments: - blog published: true date: 2023-06-24T16:34:45.527Z +thumbnail: /images/uploads/img_9715-rotated.jpg tags: - News - Personal @@ -44,4 +45,4 @@ Don't believe someone just their words. Believe in actions. And if you have a ha You've been so healthy that you've been released home early. Your first day at home has been great. You thought me that 5 AM is a great time to wake up. The sun is already up and shining so we can shine as well. Your whole family loves you. I love your Mom. I love You. Thank you for coming into our lives. We will always love you. -![Your first day at home. You shared the happiness with us.](/images/uploads/20230621_204051.jpg "Your first day at home. You shared the happiness with us.") \ No newline at end of file +![Your first day at home. You shared the happiness with us.](/images/uploads/20230621_204051.jpg "Your first day at home. You shared the happiness with us.") diff --git a/_posts/blog/2023-08-29-i-built-my-3rd-custom-keyboard.md b/_posts/blog/2023-08-29-i-built-my-3rd-custom-keyboard.md index 79f75e0..d7feb1d 100644 --- a/_posts/blog/2023-08-29-i-built-my-3rd-custom-keyboard.md +++ b/_posts/blog/2023-08-29-i-built-my-3rd-custom-keyboard.md @@ -6,6 +6,7 @@ segments: - featured published: true date: 2023-08-29T19:34:17.071Z +thumbnail: /images/uploads/20230226_130037.jpg tags: - News - Keyboards diff --git a/axum_server/.zellij/dev-layout.kdl b/axum_server/.zellij/dev-layout.kdl index 6f06a8c..c261e89 100644 --- a/axum_server/.zellij/dev-layout.kdl +++ b/axum_server/.zellij/dev-layout.kdl @@ -14,6 +14,10 @@ layout { pane { command "just" args "tailwind" + } + pane { + command "just" + args "decap_server" } } pane size=2 borderless=true { diff --git a/axum_server/Cargo.toml b/axum_server/Cargo.toml index 677cd94..7fa70c5 100644 --- a/axum_server/Cargo.toml +++ b/axum_server/Cargo.toml @@ -30,3 +30,6 @@ opt-level = 1 lto = "thin" panic = "unwind" strip = false + +[profile.dev.package.askama_derive] +opt-level = 3 diff --git a/axum_server/src/blog_posts/blog_post_model.rs b/axum_server/src/blog_posts/blog_post_model.rs index a428e34..66a64a2 100644 --- a/axum_server/src/blog_posts/blog_post_model.rs +++ b/axum_server/src/blog_posts/blog_post_model.rs @@ -7,7 +7,6 @@ pub const BLOG_POST_PATH: &str = "../_posts/blog"; #[derive(Deserialize, Debug)] pub struct BlogPostMetadata { - pub layout: String, pub title: String, pub segments: Vec, pub published: bool, diff --git a/axum_server/src/blog_posts/featured_blog_posts.rs b/axum_server/src/blog_posts/featured_blog_posts.rs index e812924..207f28d 100644 --- a/axum_server/src/blog_posts/featured_blog_posts.rs +++ b/axum_server/src/blog_posts/featured_blog_posts.rs @@ -5,12 +5,11 @@ use crate::post_utils::{post_listing::get_post_list, post_parser::ParseResult}; use super::blog_post_model::{BlogPostMetadata, BLOG_POST_PATH}; pub async fn get_featured_blog_posts() -> Result>, StatusCode> { - let post_list = get_post_list::(BLOG_POST_PATH).await?; + let mut post_list = get_post_list::(BLOG_POST_PATH).await?; + post_list.retain(|post| post.metadata.segments.contains(&"featured".to_string())); + post_list.retain(|post| post.metadata.published); + post_list.sort_by_key(|post| post.metadata.date); + post_list.reverse(); - let featured_posts = post_list - .into_iter() - .filter(|post| post.metadata.segments.contains(&"featured".to_string())) - .collect(); - - Ok(featured_posts) + Ok(post_list) } diff --git a/axum_server/src/main.rs b/axum_server/src/main.rs index 69b9577..25da31c 100644 --- a/axum_server/src/main.rs +++ b/axum_server/src/main.rs @@ -8,6 +8,7 @@ mod components; mod feed; mod filters; mod pages; +mod picture_generator; mod post_utils; mod projects; mod router; diff --git a/axum_server/src/pages/blog_post_list.rs b/axum_server/src/pages/blog_post_list.rs index c59c4e4..b4b2e0f 100644 --- a/axum_server/src/pages/blog_post_list.rs +++ b/axum_server/src/pages/blog_post_list.rs @@ -30,6 +30,7 @@ pub async fn render_blog_post_list( let site_footer = render_site_footer().await?; let mut post_list = get_post_list::(BLOG_POST_PATH).await?; post_list.sort_by_key(|post| post.metadata.date); + post_list.retain(|post| post.metadata.published); post_list.reverse(); let posts = match &tag { diff --git a/axum_server/src/picture_generator/mod.rs b/axum_server/src/picture_generator/mod.rs new file mode 100644 index 0000000..7d2cf70 --- /dev/null +++ b/axum_server/src/picture_generator/mod.rs @@ -0,0 +1,24 @@ +/*! +This is going to be an attempt for creating HTML markup for serving and generating images +for the most common PIXEL_DENSITIES. +It should create `` elements with following features: + +- least amount of needed arguments +- for each pixel density it should have a definition in `srcset` +- create a `avif` type for the image for each pixel_density +- create an image in the original format for each pixel_density +- support case of `svg` therefore not doing any of the pixel_density logic + +These features might be considered later: +- support case for art direction (different pictures for different screen sizes) + + +TODO: figure wether `height` or `width` have to be known ahead of time + +## Usage + +It can be used from the rust code +It should be used from the templates as well +*/ + +pub mod picture_markup_generator; diff --git a/axum_server/src/picture_generator/picture_markup_generator.rs b/axum_server/src/picture_generator/picture_markup_generator.rs new file mode 100644 index 0000000..5d1d653 --- /dev/null +++ b/axum_server/src/picture_generator/picture_markup_generator.rs @@ -0,0 +1,101 @@ +use std::path::Path; + + +pub const PIXEL_DENSITIES: [f64; 5] = [1., 1.5, 2., 3., 4.]; + +#[derive(Debug, PartialEq)] +pub enum ExportFormat { + JPG, + AVIF, + SVG, + PNG, +} + +pub fn generate_picture_markup(orig_img_path: &str, width: u32, height: u32) -> String { + let exported_formats = get_export_formats(&orig_img_path); + + for export_format in exported_formats { + + // TODO get original img resolution and determine how many exports are going to be needed + // let orig_img_resolution = + // let resolutions = get_resolutions(width, height); + + let resolutions = vec![(300, 200), (450, 300), (600, 400), (900, 600), (1200, 800)]; + let generated_paths = get_generated_paths(orig_img_path, resolutions); + + } + let result = format!(""); + result +} + +fn get_generated_paths(orig_img_path: &str, &resolutions: Vec<(i32, i32)>) -> Vec { + +} + +#[test] +fn test_get_generated_paths { + let orig_img_path = "./images/uploads/img_name.jpg"; + let resolutions = vec![(300, 200), (450, 300), (600, 400), (900, 600), (1200, 800)]; + assert_eq!(get_generated_paths(orig_img_path,&resolutions), vec![]) +} + + +// TODO get original img resolution and determine how many exports are going to be needed +fn get_resolutions(orig_width: i32, orig_height: i32, width: i32, height: i32) -> Vec<(i32, i32)> { + todo!("get original img resolution and determine how many exports are going to be needed") +} + +fn generate_srcset(new_path: &str, width: u32, height: u32) -> &str { + todo!("generate srcset") +} + +fn get_export_formats(orig_img_path: &str) -> Vec { + let path = Path::new(&orig_img_path).extension().and_then(|ext| ext.to_str()); + + match path { + Some("jpg" | "jpeg") => vec![ExportFormat::AVIF, ExportFormat::JPG] + Some("png") => vec![ExportFormat::AVIF, ExportFormat::PNG] + Some(_) | None => vec![] + } +} + +#[test] +fn test_get_export_formats { + assert_eq!(get_export_formats("./images/uploads/img_name.jpg"), vec![ExportFormat::AVIF, ExportFormat::JPG]) +} +#[test] +fn test_generate_srcset() { + let width = 400; + let height = 200; + let orig_img_path = "./images/uploads/img_name.jpg"; + let result = "./generated_images/images/uploads/img_name_400x200.avif 1x, ./generated_images/images/uploads/img_name_500x300.avif 1.5x, ./generated_images/images/uploads/img_name_800x400.avif 2x, ./generated_images/images/uploads/img_name_1200x600.avif 3x, ./generated_images/images/uploads/img_name_1600x800.avif 4x"; + assert_eq!(generate_srcset(orig_img_path, width, height), result) +} + +#[test] +fn test_generate_picture_markup() { + let width = 300; + let height = 200; + let orig_img_path = "./images/uploads/img_name.jpg"; + let result = r#""" + + + + + + """#; + assert_eq!( + generate_picture_markup(orig_img_path, width, height), + result + ); +} diff --git a/axum_server/src/post_utils/post_listing.rs b/axum_server/src/post_utils/post_listing.rs index f760ea2..e484007 100644 --- a/axum_server/src/post_utils/post_listing.rs +++ b/axum_server/src/post_utils/post_listing.rs @@ -30,11 +30,8 @@ pub async fn get_post_list<'de, Metadata: DeserializeOwned>( .unwrap_or_else(|_| "DEV".to_owned()) .eq("PROD") { - posts = posts - .into_iter() - .filter(|post| !post.slug.starts_with("dev")) - .collect() + posts.retain(|post| !post.slug.starts_with("dev")) } - return Ok(posts); + Ok(posts) } diff --git a/axum_server/styles/output.css b/axum_server/styles/output.css index e936769..b65fcff 100644 --- a/axum_server/styles/output.css +++ b/axum_server/styles/output.css @@ -1,5 +1,5 @@ /* -! tailwindcss v3.4.7 | MIT License | https://tailwindcss.com +! tailwindcss v3.4.9 | MIT License | https://tailwindcss.com */ /* @@ -672,10 +672,6 @@ video { aspect-ratio: 16 / 9; } -.aspect-\[4\/3\] { - aspect-ratio: 4/3; -} - .h-0 { height: 0px; } @@ -832,11 +828,6 @@ video { object-fit: contain; } -.object-cover { - -o-object-fit: cover; - object-fit: cover; -} - .p-0 { padding: 0px; } diff --git a/axum_server/templates/components/post_preview.html b/axum_server/templates/components/blog_post_preview.html similarity index 79% rename from axum_server/templates/components/post_preview.html rename to axum_server/templates/components/blog_post_preview.html index ba4378b..c060f1e 100644 --- a/axum_server/templates/components/post_preview.html +++ b/axum_server/templates/components/blog_post_preview.html @@ -1,9 +1,11 @@

{{post.metadata.title}}

diff --git a/axum_server/templates/index.html b/axum_server/templates/index.html index bb0ad16..28ad53b 100644 --- a/axum_server/templates/index.html +++ b/axum_server/templates/index.html @@ -54,7 +54,7 @@
    {% for post in featured_blog_posts %}
  • - {% include "components/post_preview.html" %} + {% include "components/blog_post_preview.html" %}
  • {% endfor %} diff --git a/static/images/uploads/deeevbreak2.jpeg b/static/images/uploads/deeevbreak2.jpeg new file mode 100644 index 0000000..1af9660 --- /dev/null +++ b/static/images/uploads/deeevbreak2.jpeg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:81f7b369856fe0f79d5c8f6efffc9585eaecd723126dd8347b4de4b336d96ee6 +size 41667 diff --git a/static/images/uploads/deevbreakdoninik.jpeg b/static/images/uploads/deevbreakdoninik.jpeg new file mode 100644 index 0000000..83704a7 --- /dev/null +++ b/static/images/uploads/deevbreakdoninik.jpeg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2c7e937e446fe40c823271b508764790ad83f885b46550ed0677d2bb4e9dccf7 +size 40220 diff --git a/static/images/uploads/devbreak-4-3-.png b/static/images/uploads/devbreak-4-3-.png new file mode 100644 index 0000000..941cc44 --- /dev/null +++ b/static/images/uploads/devbreak-4-3-.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1009ea8c7a08f7a454eea7227ea0db3287a1571015745cabf9740221134c4236 +size 1494461 diff --git a/static/images/uploads/devbreak.jpeg b/static/images/uploads/devbreak.jpeg new file mode 100644 index 0000000..657ec1d --- /dev/null +++ b/static/images/uploads/devbreak.jpeg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7291b813c83c1a2e5b3ef6313d971a351f82b4efed5f865c08f994770443797f +size 50861 diff --git a/static/images/uploads/teta.png b/static/images/uploads/teta.png new file mode 100644 index 0000000..57273a6 --- /dev/null +++ b/static/images/uploads/teta.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8913d30812012cab23d06fe0b40faf188765a923317fca6a7a6f88bce3ab86aa +size 205612 diff --git a/static/resources/config.yml b/static/resources/config.yml index b664891..f0c58a8 100644 --- a/static/resources/config.yml +++ b/static/resources/config.yml @@ -17,7 +17,6 @@ collections: create: true # Allow users to create new documents in this collection slug: '{{year}}-{{month}}-{{day}}-{{slug}}' # Filename template, e.g., YYYY-MM-DD-title.md fields: # The fields for each document, usually in front matter - - { label: 'Layout', name: 'layout', widget: 'hidden', default: 'blog' } - { label: 'Title', name: 'title', widget: 'string' } - label: 'Segments' name: 'segments'