DEV Community

Cover image for Generating image preview for geany
suntong
suntong

Posted on

Generating image preview for geany

This is a follow up to my previous blog, Generating image preview easily, which talks about image preview gallery auto-generation in general. It talks about how powerful the Go Template Engine is (which is what easygen is based on), and how easy the auto-generation can be customized.

Now, the new requirement, from the review of my PR, for geany specifically, is that,

What if the header linked directly to the theme file so it could be downloaded directly into the user's theme directory, and then leave the images to link to the PNG file?

Aha, two "fancy" changes, I like the challenge, and will add one more --

There are two ways to link the theme file, one is to link to its github page address; and the other is to link to the raw file at githubusercontent.com, to show the file as-is.

Moreover, one further requirement is that, one image, which is not exactly a theme screenshot, should be removed from the output (the README.md).

The solution is still simple.

  • to remove the unnecessary image from README.md, remove it from the driving data:

    ls *.png | grep -v screenshot-missing | sed 's/^/  - /; 1s/^/Images:\n/; ' | tee /tmp/Images.yaml
    
  • and the updated template is just:

  • the auto-generation is still the same as before:

    easygen ~+1/Images.tmpl /tmp/Images.yaml | tee README.md
    

That's it. You can check out the end result here.

Top comments (0)