diff --git a/index.html b/index.html index dfea962..c38b73f 100644 --- a/index.html +++ b/index.html @@ -1,11 +1,11 @@ -Alex Mikhailov
+Alex Mikhailov

avatar.jpg

-
-

 

-
+
+

 

+

Full stack engineer FP-curious | λ-affected @@ -13,9 +13,9 @@ Wanna be rustacean 🦀 and/or secops guy 🔒

-
-

Experience

-
+
+

Experience

+
  • Current position @SamsungFood. Internal tools engineer for data platform ➡ Internal tools engineer for developers.
  • @@ -24,9 +24,9 @@ Fullstack engineer.
-
-

Technologies

-
+
+

Technologies

+

Work with:

@@ -43,9 +43,9 @@ Work with:
-
-

Contacts

-
+
+

Contacts

+

Contact me via:

diff --git a/posts.html b/posts.html index 6955ec6..ad12149 100644 --- a/posts.html +++ b/posts.html @@ -1,7 +1,7 @@ -Alex Mikhailov - Blog
-
-

Posts

-
+Alex Mikhailov - Blog
+
+

Posts

+
  • Keyboard journey
  • Org to HTML and back
  • diff --git a/posts/about_blog.html b/posts/about_blog.html index 3e17d90..90e0283 100644 --- a/posts/about_blog.html +++ b/posts/about_blog.html @@ -1,45 +1,45 @@ -Org to HTML and back
    +Org to HTML and back
    -
    -

    Disclaimer

    -
    +
    +

    Disclaimer

    +

    I'm neither proficient in Org Mode (further on "Org"), nor a good front-end engineer. I think that a simple solution is better than no solution. If you see a mistake, you can contact me via iam@fidonode.me.

    -
    -

    What is Org?

    -
    +
    +

    What is Org?

    +

    Your life in plain text @@ -55,9 +55,9 @@ Everything you can do in Org is to write a text. With a special markup, of cours

    -
    -

    Why Org Mode?

    -
    +
    +

    Why Org Mode?

    +
    1. Plain text. Plain text as a data source offers significant versatility. You can read and understand what happens in org files without needing Emacs.
    2. @@ -69,16 +69,16 @@ I do not have a habit of collecting and keeping information. I believe that disc
    -
    -

    Render Org to blog or whatever

    -
    +
    +

    Render Org to blog or whatever

    +

    Org already has a way to render files into HTML, allowing you to create simple HTML files with minimal styling. I'm not interesting in styling from org, so I decide to use picocss framework.

    -
    -

    Render HTML

    -
    +
    +

    Render HTML

    +

    I want to change some templates here and there. I've found esxml package. It is a decent DSL for writing XML/HTML. Here is how page header and footer look in this DSL. @@ -183,9 +183,9 @@ So everything is almost done. Time to use our custom publishing function in proj

    -
    -

    Static files

    -
    +
    +

    Static files

    +

    Yep, you may want to publish some photos with your blog or any other static files.

    @@ -205,9 +205,9 @@ Looks self explanatory.

    -
    -

    Whole build script

    -
    +
    +

    Whole build script

    +

    Here is the whole elisp script which I use to publish my blog. It have some additional quirks to work with doomscript ./build-site.el.

    @@ -365,9 +365,9 @@ Here is the whole elisp script which I use to publish my blog. It have some addi
    -
    -

    Publish through GitHub Action

    -
    +
    +

    Publish through GitHub Action

    +

    With all previous preparations, this step sounds simple like: emacs -Q --script ./build-site.el I've chosen a pretty standard way to publish static sites through GitHub Pages. Since I keep my Org files in a private repo, I need some additional steps to address it. I use the peaceiris/actions-gh-pages@v3 action to publish from my Org repo to the Pages repo. @@ -375,9 +375,9 @@ However, since I use Doom Emacs as my configuration framework, we n

    -
    -

    Install Emacs

    -
    +
    +

    Install Emacs

    +

    If you want to run Emacs Lisp, you need the whole Emacs, at least without GUI. In a GitHub Action, you can simply run:

    @@ -388,9 +388,9 @@ This way has a downside - you will install Emacs on each action run since the sy

    -
    -

    Just bring everything

    -
    +
    +

    Just bring everything

    +

    I need to take extra steps since I use Doom Emacs and have my configs in Org. You may also need to install dependencies for your configuration.

    @@ -426,9 +426,9 @@ Of course, I use a caching step to make the whole process faster:
    -
    -

    BTW I use GNU Emacs

    -
    +
    +

    BTW I use GNU Emacs

    +

    Here's the whole publishing workflow.

    @@ -507,26 +507,26 @@ jobs:
    -
    -

    What is next

    -
    +
    +

    What is next

    +

    I have a plans to make posts about next features:

    -
    -

    RSS Feed

    + -
    -

    Open Graph

    -
    +
    +

    Open Graph

    +

    Already implemented. Need to document process.

    -
    diff --git a/posts/add_rss_to_blog.html b/posts/add_rss_to_blog.html index 99c2a43..173a86a 100644 --- a/posts/add_rss_to_blog.html +++ b/posts/add_rss_to_blog.html @@ -1,35 +1,35 @@ -Org blog with RSS
    +Org blog with RSS
    -
    -

    Why do you even need RSS?

    -
    +
    +

    Why do you even need RSS?

    +

    RSS might seem like an outdated, marginal thing. But it still has at least one benefit—you can use an RSS feed as a sitemap for search engines. Plus, it's pretty geeky.

    -
    -

    Add RSS feed

    -
    +
    +

    Add RSS feed

    +

    So, what's happening here? Let's start by integrating our templating functions into the build.

    -
    -

    Use sitemap backend in the build

    -
    +
    +

    Use sitemap backend in the build

    +
    (setq org-publish-project-alist
           (list
            (list "blog-rss"
    @@ -59,9 +59,9 @@ How does it work? As you can see, we use the default sitemap generator from Org
     

    -
    -

    Publishing and formatting functions

    -
    +
    +

    Publishing and formatting functions

    +

    We need a mandatory dependency because we don't want to mess with forming correct XML by ourselves.

    diff --git a/posts/improve_code_blocks.html b/posts/improve_code_blocks.html index aef5a5d..f53cf9c 100644 --- a/posts/improve_code_blocks.html +++ b/posts/improve_code_blocks.html @@ -1,34 +1,34 @@ -Improve code blocks
    +Improve code blocks
    -
    -

    What is the problem with default highlighting?

    -
    +
    +

    What is the problem with default highlighting?

    +

    Htmlize works poorly with headless publishing. It lacks extensibility, including features like line numbers, a copy button, and the ability to highlight predefined parts of the code.

    -
    -

    Highlight.js

    -
    +
    +

    Highlight.js

    +
    -
    -

    Change code block template

    -
    +
    +

    Change code block template

    +

    We need to make small changes in how code blocks are rendered. By default, Org Export exports code blocks as <pre></pre>. For Highlight.js, we need <pre><code></code></pre>. Additionally, we need to set the correct language name in the class attribute. Since Highlight.js does not support elisp, I rewrite it to regular lisp using the my/replace-substring function.

    @@ -69,9 +69,9 @@ CONTENTS is nil. INFO is a plist holding contextual information."
    -
    -

    Plug Highlight.js

    -
    +
    +

    Plug Highlight.js

    +

    I do not want to load Highlight.js on every page, so I need to check if the initial Org file contains code blocks. Depending on this, we will render the part of the tree with JavaScript or not.

    @@ -105,9 +105,9 @@ I do not want to load Highlight.js on every page, so I need to check if the init
    -
    -

    Respect prefers-color-scheme

    -
    +
    +

    Respect prefers-color-scheme

    +

    Additionally, I think it's a good idea to respect the prefers-color-scheme property of the user's browser. We can switch CSS files based on this property. We should also subscribe to changes in this property to handle the edge case when it switches while reading the page.

    @@ -142,9 +142,9 @@ window
    -
    -

    Whole config

    -
    +
    +

    Whole config

    +

    In between posts I've switched from sxml to esxml so here is the current config.

    diff --git a/posts/keeb.html b/posts/keeb.html index b12c148..988e310 100644 --- a/posts/keeb.html +++ b/posts/keeb.html @@ -1,52 +1,52 @@ -My keyboard journey
    +My keyboard journey
    -
    -

    My end-game (at least I hope) keyboard

    -
    +
    +

    My end-game (at least I hope) keyboard

    +
    -
    -

    Keebs path

    -
    +
    +

    Keebs path

    +

    Sometimes I think about the long journey I've made with keebs. In childhood, I had decent membrane keyboards, most of which had an ergonomic profile like the MS. Not sure if it somehow affected my taste because I started my career with the simplest, cheapest board and typed countless lines of code on such keebs. Then I heard about clickity-clack mechanical keyboards and decided to try one. It was a simple Chinese keeb with a thick metal body, double-shot caps, and Cherry Brown switches. A decent thing to annoy everyone around you. I think this purchase marked my dive into mech keebs I'm not a geeky aficionado who thinks you can fix everything with a new keyboard, but I built a couple of them. I hope I've finally built the last one for quite some time.

    -
    -

    Dactyl manuform

    -
    +
    +

    Dactyl manuform

    +

    Almost all of the time, I struggle with my maximalism. So I decided to build the ultimate mechanical ergonomic split keyboard and chose the Dactyl Manuform. Sounds like a crazy idea. Zero experience with QMK, zero experience with hand-wired keyboards, and zero experience in 3D printing. The last problem was the easiest one; I just asked my friend to print the bodies from PETG polymer, and Bob's your uncle. I got two pieces of rough-layered plastic with all the support structures. God, it was a nightmare to clean these prints from supports and small artifacts, but I was happy. @@ -92,9 +92,9 @@ To be honest, this keeb was ugly, and I decided that I wanted a beautiful factor

    -
    -

    Moonlander

    -
    +
    +

    Moonlander

    +

    Nothing special. Ordered, paid, got it, tried it. Everything worked. Looked good. Happy year of typing. Bored. Annoyed. Too big and chunky. No concave. Quality not the best. Started planning the next one.

    @@ -107,9 +107,9 @@ Nothing special. Ordered, paid, got it, tried it. Everything worked. Looked good
    -
    -

    Custom Corne

    -
    +
    +

    Custom Corne

    +

    This journey started with discovering the Jian keyboard. It is a niche keeb from the Ru community focused on full support of the whole Russian layout. It was originally created by KGOH. I missed the group buy and decided that I could easily patch a Corne board with two additional keys to mimic the Jian. Interesting journey. I learned how to use KiCad, and how to export gerbers. @@ -158,9 +158,9 @@ Daily driver for ~6 months. Then the world changed, and I decided to leave my ho

    -
    -

    Dactyl manuform again

    -
    +
    +

    Dactyl manuform again

    +

    Two years late I've settled down in new country and decide that I want to bring back my dactyl manuform experience.

    @@ -174,13 +174,13 @@ Two years late I've settled down in new country and decide that I want to bring
    -
    -

    Hardware

    -
    +
    +

    Hardware

    +
    -
    -

    Body

    -
    +
    +

    Body

    +

    I've choose to use a Ryan's generator and generate body on top of Corne preset with all keys in last row and disabled stagger for the last two columns. Generator preset The body was printed by JLC3DP (JLCPCB printing department). I've choose SLS from nylon. Print has minor artifacts; I expected better quality. @@ -216,9 +216,9 @@ Overall, I'm happy with results. I also printed bottom plates and -

    Switches and caps

    -
    diff --git a/posts/posts_preview.html b/posts/posts_preview.html new file mode 100644 index 0000000..eae5061 --- /dev/null +++ b/posts/posts_preview.html @@ -0,0 +1,108 @@ +Posts preview
    +
    +

    What is imagemagick

    +
    +

    +Imagemagick is a ffmpeg of the image world. You can do a lot of fun things with it. For example you can take a picture, cut corners on it, place it on top of another image, add some text and get final result. So it is looks like a good tool for making previews from code. +

    +
    +
    +
    +

    Basic idea of this process

    +
    +

    +I want to hook a process of rendering post. Since this function called on each run of publishing and for each post it is a good idea to cache resulting images. I gonna simply check presence of preview image and use it as guard for running image generation. After that I gonna extract #+TITLE and #+DESCRIPTION properties from Org file. Each Org file I have, has next header: +

    +
    #+TITLE: Posts preview
    +#+DATE: &lt;2024-06-28 Fri&gt;
    +#+DESCRIPTION: Add post preview for OpenGraph cards
    +#+TAGS: @blogging @org-mode @elisp @imagemagick
    +
    +

    +So I with all these data I can generate my previews with simple script: +

    +
     #!/bin/bash
    + magick $4/with_profile.png \
    +     \( -size 850x150 \-background none -font Roboto-Regular -fill '#FEFEFE' label:"$1" -trim -gravity center -extent 850x150 \) \
    +     -gravity northeast -geometry +50+75 -composite /tmp/text_main.png
    + magick /tmp/text_main.png \( -size 1100x300 -background none -font Roboto-Regular -pointsize 50 -fill '#FFFFFF' pango:"$2" -trim -gravity center -extent 1100x300 \) -gravity east -geometry +40+140 -composite "$3"
    + #
    +
    +
    +
    + +
    +

    Integrate into build

    +
    +

    +As I already mention I gonna skip file generation when file already here. Here is the whole function. Pretty simple. Just prepare pathes, check some dependencies, create pathes and execute script which calls imagemagick. +

    +
    (defun my/render-preview (file-name title description)
    +  (let* ((has-imagemagick (executable-find "magick"))
    +	 (full-file-path (file-truename(format "%s%s/resources/images/preview/%s.png" script-directory my/blog-src-path file-name )))
    +	 (file-dir (file-name-directory full-file-path))
    +	 (has-dir (file-directory-p file-dir))
    +	 (has-file (file-exists-p full-file-path))
    +	 (path-to-script-root (format "%shelpers" script-directory))
    +	 (path-to-script (format "%s/og_image_gen.sh" path-to-script-root)))
    +    (if (and has-imagemagick
    +	     (and description (not (string= description ""))))
    +	(progn
    +	  (when (not has-file)
    +	    (progn
    +	      (when (not has-dir)
    +		(make-directory file-dir t))
    +	      (shell-command (format "bash '%s' '%s' '%s' '%s' '%s'" path-to-script title description full-file-path path-to-script-root))
    +	      )
    +	    ))
    +      (message "Imagemagick is not installed. Preview generation skipped.")
    +      )))
    +
    + +

    +And here is the part of my/template function related to OpenGraph meta tags. +

    +
    (defun my/template (contents info)
    +
    +  (let* ((title-str (org-export-data (plist-get info :title) info))
    +	 (description-str (org-export-data (plist-get info :description) info))
    +	 (file-path-str (org-export-data (plist-get info :input-file) info))
    +	 (base-directory-str (org-export-data (plist-get info :base-directory) info))
    +	 (file-name-str (file-relative-name file-path-str (format "%s/%s" script-directory base-directory-str)))
    +	 (img-link-str (format "%s/resources/images/preview/%s.png" my/url file-name-str))
    +
    +    (my/render-preview file-name-str title-str description-str)
    +
    +    (set-text-properties 0 (length title-str) nil title-str)
    +    (set-text-properties 0 (length description-str) nil description-str)
    +    (set-text-properties 0 (length img-link-str) nil img-link-str)
    +...
    +	      ;; OG block
    +	      (meta ((name . "description") (content .  ,description-str)))
    +	      (meta ((name . "og:description") (content . ,description-str)))
    +	      (meta ((name . "twitter:description") (content . ,description-str)))
    +
    +	      (meta ((name . "og:image") (content . ,img-link-str)))
    +	      (meta ((name . "twitter:image") (content . ,img-link-str)))
    +
    +	      (meta ((name . "og:title") (content . ,title-str)))
    +	      (meta ((name . "twitter:title") (content . ,title-str)))
    +
    +	      (meta ((name . "twitter:card") (content . "summary_large_image")))
    +
    +
    +

    +You can check whole function in previous post Improve code blocks. +

    +
    +
    +
    diff --git a/resources/images/preview/index.org.png b/resources/images/preview/index.org.png new file mode 100644 index 0000000..9a443cd Binary files /dev/null and b/resources/images/preview/index.org.png differ diff --git a/resources/images/preview/posts.org.png b/resources/images/preview/posts.org.png new file mode 100644 index 0000000..0629544 Binary files /dev/null and b/resources/images/preview/posts.org.png differ diff --git a/resources/images/preview/posts/about_blog.org.png b/resources/images/preview/posts/about_blog.org.png new file mode 100644 index 0000000..9e15324 Binary files /dev/null and b/resources/images/preview/posts/about_blog.org.png differ diff --git a/resources/images/preview/posts/improve_code_blocks.org.png b/resources/images/preview/posts/improve_code_blocks.org.png new file mode 100644 index 0000000..a49b495 Binary files /dev/null and b/resources/images/preview/posts/improve_code_blocks.org.png differ diff --git a/resources/images/preview/posts/keeb.org.png b/resources/images/preview/posts/keeb.org.png new file mode 100644 index 0000000..ace7d47 Binary files /dev/null and b/resources/images/preview/posts/keeb.org.png differ diff --git a/resources/images/preview/posts/posts_preview.org.png b/resources/images/preview/posts/posts_preview.org.png new file mode 100644 index 0000000..0cab056 Binary files /dev/null and b/resources/images/preview/posts/posts_preview.org.png differ diff --git a/rss.html b/rss.html index 3ba5465..a6bcba6 100644 --- a/rss.html +++ b/rss.html @@ -1,33 +1,39 @@ -rss
    +rss
    -
    diff --git a/rss.xml b/rss.xml index 1595795..54f3ffa 100644 --- a/rss.xml +++ b/rss.xml @@ -14,8 +14,8 @@ https://fidonode.me en - Thu, 27 Jun 2024 17:26:45 +0000 - Thu, 27 Jun 2024 17:26:45 +0000 + Sun, 30 Jun 2024 14:48:44 +0000 + Sun, 30 Jun 2024 14:48:44 +0000 Emacs 27.1 Org-mode 9.3 iam@fidonode.me (Alex M) @@ -25,6 +25,15 @@ + + Posts preview + https://fidonode.me/posts/posts_preview.html + iam@fidonode.me (Alex M) + https://fidonode.me/posts/posts_preview.html + Fri, 28 Jun 2024 00:00:00 +0000 + + + Improve code blocks https://fidonode.me/posts/improve_code_blocks.html