holy shit the responsiveness
Some checks failed
test / cargo test (push) Failing after 1m24s

This commit is contained in:
Michal Vanko 2024-09-25 12:55:05 +02:00
parent fc26d77bfc
commit 1eb0f55264
9 changed files with 140 additions and 102 deletions

View File

@ -19,9 +19,15 @@ pub fn generate_picture_markup(
width: u32, width: u32,
height: u32, height: u32,
alt_text: &str, alt_text: &str,
class_name: Option<&str>,
generate_image: bool, generate_image: bool,
) -> Result<String, anyhow::Error> { ) -> Result<String, anyhow::Error> {
let exported_formats = get_export_formats(orig_img_path); 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() { if exported_formats.is_empty() {
return Ok(formatdoc!( return Ok(formatdoc!(
@ -29,6 +35,7 @@ pub fn generate_picture_markup(
src="{orig_img_path}" src="{orig_img_path}"
width="{width}" width="{width}"
height="{height}" height="{height}"
{class_attr}
alt="{alt_text}" alt="{alt_text}"
>"# >"#
)); ));
@ -99,6 +106,7 @@ pub fn generate_picture_markup(
width="{width}" width="{width}"
height="{height}" height="{height}"
alt="{alt_text}" alt="{alt_text}"
{class_attr}
>"# >"#
); );
@ -307,7 +315,14 @@ fn test_generate_picture_markup() {
</picture>"#, </picture>"#,
}; };
assert_eq!( assert_eq!(
generate_picture_markup(orig_img_path, width, height, "Testing image alt", false) generate_picture_markup(
orig_img_path,
width,
height,
"Testing image alt",
None,
false
)
.expect("picture markup has to be generated"), .expect("picture markup has to be generated"),
result result
); );

View File

@ -125,8 +125,14 @@ pub fn parse_html(markdown: &str, generate_images: bool) -> String {
); );
// Place image into the content with scaled reso to a boundary // Place image into the content with scaled reso to a boundary
let picture_markup = let picture_markup = generate_picture_markup(
generate_picture_markup(&dest_url, max_width, max_height, &title, generate_images) &dest_url,
max_width,
max_height,
&title,
None,
generate_images,
)
.unwrap_or(formatdoc!( .unwrap_or(formatdoc!(
r#" r#"
<img <img

View File

@ -76,10 +76,6 @@ strong {
@apply font-medium; @apply font-medium;
} }
img[height] {
height: revert-layer;
}
.article-body { .article-body {
h1 { 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; @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;

View File

@ -654,6 +654,18 @@ video {
grid-row: span 3 / span 3; grid-row: span 3 / span 3;
} }
.float-start {
float: inline-start;
}
.clear-left {
clear: left;
}
.clear-both {
clear: both;
}
.m-0 { .m-0 {
margin: 0px; margin: 0px;
} }
@ -710,11 +722,6 @@ video {
margin-bottom: 1.25rem; margin-bottom: 1.25rem;
} }
.my-4 {
margin-top: 1rem;
margin-bottom: 1rem;
}
.mb-1 { .mb-1 {
margin-bottom: 0.25rem; margin-bottom: 0.25rem;
} }
@ -739,6 +746,30 @@ video {
margin-top: 0.75rem; 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 { .block {
display: block; display: block;
} }
@ -787,6 +818,18 @@ video {
height: 240px; height: 240px;
} }
.h-auto {
height: auto;
}
.h-\[236px\] {
height: 236px;
}
.max-h-\[236px\] {
max-height: 236px;
}
.min-h-full { .min-h-full {
min-height: 100%; min-height: 100%;
} }
@ -807,6 +850,11 @@ video {
width: 180px; width: 180px;
} }
.w-fit {
width: -moz-fit-content;
width: fit-content;
}
.max-w-\[32rem\] { .max-w-\[32rem\] {
max-width: 32rem; max-width: 32rem;
} }
@ -819,22 +867,6 @@ video {
max-width: 64rem; 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-w-xl {
max-width: 36rem; max-width: 36rem;
} }
@ -1161,10 +1193,6 @@ strong {
font-weight: 500; font-weight: 500;
} }
img[height] {
height: revert-layer;
}
.article-body { .article-body {
h1 { h1 {
margin-left: auto; margin-left: auto;
@ -1808,14 +1836,49 @@ article a:visited {
} }
@media (min-width: 640px) { @media (min-width: 640px) {
.sm\:float-none {
float: none;
}
.sm\:clear-none {
clear: none;
}
.sm\:my-4 { .sm\:my-4 {
margin-top: 1rem; margin-top: 1rem;
margin-bottom: 1rem; margin-bottom: 1rem;
} }
.sm\:mx-auto { .sm\:ml-0 {
margin-left: auto; margin-left: 0px;
margin-right: auto; }
.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 { .sm\:py-4 {
@ -1830,11 +1893,6 @@ article a:visited {
margin-bottom: 2rem; margin-bottom: 2rem;
} }
.md\:mx-auto {
margin-left: auto;
margin-right: auto;
}
.md\:grid { .md\:grid {
display: grid; display: grid;
} }

View File

@ -1,8 +1,8 @@
<article class="grid grid-cols-[max-content_1fr] grid-rows-[max-content_1fr_max-content] grid-flow-col gap-4 md:gap-x-8 break-inside-avoid"> <article class="sm:grid sm:grid-cols-[max-content_1fr] sm:grid-rows-[max-content_1fr_max-content] sm:grid-flow-col sm:gap-4 md:gap-x-8 break-inside-avoid clear-both sm:clear-none">
<aside class="row-span-3 self-center"> <aside class="row-span-3 self-center float-start sm:float-none mr-3 mb-3 sm:ml-0 sm:mb-0">
{% match post.metadata.thumbnail %} {% match post.metadata.thumbnail %}
{% when Some with (orig_path) %} {% when Some with (orig_path) %}
{{ crate::picture_generator::picture_markup_generator::generate_picture_markup(orig_path, 180, 240, "Article thumbnail", true).unwrap_or("thumbnail not found".to_string())|safe }} {{ crate::picture_generator::picture_markup_generator::generate_picture_markup(orig_path, 180, 240, "Article thumbnail", None, true).unwrap_or("thumbnail not found".to_string())|safe }}
{% when None %} {% when None %}
<div> <div>
{% include "components/blog_post_default_thumbnail.html" %} {% include "components/blog_post_default_thumbnail.html" %}
@ -15,7 +15,7 @@
</h3> </h3>
</header> </header>
<section class="text-base leading-5 text-slate-800 md:text-xl text-justify">{{post.body|description_filter|safe}}</section> <section class="text-base leading-5 text-slate-800 md:text-xl text-justify">{{post.body|description_filter|safe}}</section>
<footer class="text-sm md:text-base lg:text-lg"> <footer class="text-sm md:text-base lg:text-lg mt-3 sm:mt-0">
<ul class="inline-block"> <ul class="inline-block">
{% for tag in post.metadata.tags %} {% for tag in post.metadata.tags %}
<li class="inline-block"> <li class="inline-block">

View File

@ -18,7 +18,7 @@
{% match project.metadata.cover_image %} {% match project.metadata.cover_image %}
{% when Some with (source) %} {% when Some with (source) %}
{% let picture = crate::picture_generator::picture_markup_generator::generate_picture_markup(source, 420, 236, "Project cover", true).unwrap_or("cover not found".to_string()) %} {% let picture = crate::picture_generator::picture_markup_generator::generate_picture_markup(source, 420, 236, "Project cover", Some("max-h-[236px]"), true).unwrap_or("cover not found".to_string()) %}
<figure class="mx-4 my-2 flex justify-center"> <figure class="mx-4 my-2 flex justify-center">
{% match project.metadata.link %} {% match project.metadata.link %}
{% when Some with (href) %} {% when Some with (href) %}

View File

@ -1,15 +1,15 @@
{% macro social_card_start(svg, heading) %} {% macro social_card_start(svg, heading, img) %}
<section class="border rounded-md bg-pink-200 m-4 p-4"> <section class="border rounded-md bg-pink-200 m-4 p-4 w-fit">
<header class="flex text-center justify-center items-center gap-2 mb-2"> <header class="flex text-center justify-center items-center gap-2 mb-2">
<svg aria-hidden="true" class="h-7 w-7 fill-blue-950"> <svg aria-hidden="true" class="h-7 w-7 fill-blue-950">
<use xlink:href="/svg/icons-sprite.svg#{{svg}}" /> <use xlink:href="/svg/icons-sprite.svg#{{svg}}" />
</svg> </svg>
<h3 class="text-lg font-medium mb-1">{{heading|safe}}</h3> <h3 class="text-lg font-medium mb-1">{{heading|safe}}</h3>
</header> </header>
{% let alt_text = format!("{svg} thumbnail") %}
{% endmacro %} {{ crate::picture_generator::picture_markup_generator::generate_picture_markup(img, 420, 200, alt_text, Some("h-auto"), true).unwrap_or("thumbnail not found".to_string())|safe }}
{% macro social_card_end() %} </section>
</section>
{% endmacro %} {% endmacro %}

View File

@ -1,52 +1,12 @@
<h2 class="text-blue-950 font-bold text-2xl m-5 md:text-4xl">Socials</h2> <h2 class="text-blue-950 font-bold text-2xl m-5 md:text-4xl">Socials</h2>
{% call sc::social_card_start("twitch", "I stream (almost) regularly on <em>twitch.tv</em>") %}
<!-- <script src= "https://player.twitch.tv/js/embed/v1.js"></script> -->
<!-- <div id="twitch-player" class="h-64 aspect-video rounded overflow-hidden"></div> -->
<!-- <script type="text/javascript"> -->
<!-- var options = { -->
<!-- width: "100%", -->
<!-- height: "100%", -->
<!-- channel: "michalvankodev", -->
<!-- parent: ["localhost"] -->
<!-- }; -->
<!-- var player = new Twitch.Player("twitch-player", options); -->
<!-- player.setVolume(0.5); -->
</script>
{% call sc::social_card_end() %}
{% call sc::social_card_start("tiktok", "Highlights can be found on <em>TikTok</em>") %} <section class="flex flex-col items-center">
<!-- STYLES needed to overwrite tiktok embed css --> {% call sc::social_card_start("twitch", "I stream (almost) regularly on <em>twitch.tv</em>", "images/social/instagram_plain.png") %}
<!-- <blockquote -->
<!-- class="h-64 aspect-video overflow-hidden p-0 m-0 tiktok-embed bg-pink-200" -->
<!-- cite="https://www.tiktok.com/@michalvankodev" -->
<!-- data-unique-id="michalvankodev" -->
<!-- data-embed-from="embed_page" -->
<!-- data-embed-type="creator" -->
<!-- style="max-width:780px; min-width:288px; margin: 0; padding: 0; border-radius: 8px" -->
<!-- > -->
<!-- <section> -->
<!-- <a target="_blank" href="https://www.tiktok.com/@michalvankodev?refer=creator_embed">@michalvankodev</a> -->
<!-- </section> -->
<!-- </blockquote> -->
<!-- <script async src="https://www.tiktok.com/embed.js"></script> -->
{% call sc::social_card_end() %}
{% call sc::social_card_start("youtube", "Vlogs and highlights can be found on <em>YouTube</em>") %} {% call sc::social_card_start("tiktok", "Highlights can be found on <em>TikTok</em>", "images/social/instagram_plain.png") %}
<!-- TODO create our own youtube widget which will populate this window on build -->
<!-- <iframe -->
<!-- class="h-64 aspect-video" -->
<!-- id="ytplayer" -->
<!-- type="text/html" -->
<!-- width="100%" -->
<!-- height="100%" -->
<!-- src="https://www.youtube.com/embed/?listType=playlist&list=PLjUl8tFKyR8rCsckLn93PAwQg6tf0cyBl&enablejsapi=1&color=white" -->
<!-- frameborder="0" -->
<!-- allowfullscreen -->
<!-- ></iframe> -->
{% call sc::social_card_end() %}
{% call sc::social_card_start("youtube", "Vlogs and highlights can be found on <em>YouTube</em>", "images/social/instagram_plain.png") %}
{% call sc::social_card_start("instagram", "Photos and stories shared on <em>Instagram</em>") %} {% call sc::social_card_start("instagram", "Photos and stories shared on <em>Instagram</em>", "images/social/instagram_plain.png") %}
<!-- <blockquote class="instagram-media aspect-video h-64" data-instgrm-permalink="https://www.instagram.com/michalvankodev/" data-instgrm-version="12" style=" background:#FFF; border:0; border-radius:3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width:540px; min-width:326px; padding:0; width:99.375%; height:256px; max-height:100%;"></blockquote><script async src="https://www.instagram.com/embed.js"></script> -->
{% call sc::social_card_end() %}
</section>

BIN
static/images/social/instagram_plain.png (Stored with Git LFS) Normal file

Binary file not shown.