DEV Community

Cover image for Generating image preview for geany
suntong
suntong

Posted on

1

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:

{{range .Images}}{{$img:=.}}{{/* theme name */}}{{$tn:=$img | basename}}{{/* theme title */}}{{$tt:=(printf "The %s Theme" $tn | clk2uc)}}
### [{{$tt}}](../colorschemes/{{$tn}}.conf)
[![{{$img}}]({{$img}})]({{$img}} "{{$tt}}")
[{{$tt}} Direct Download](https://raw.githubusercontent.com/geany/geany-themes/master/colorschemes/{{$tn}}.conf)
{{end}}
  • 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.

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more