Skip to main content
  1. Posts/

New Day 14 - New Year, New Look

NewDays blog hugo

Blog front page in Hugo-Octopress vs Blowfish
Blog front page in Hugo-Octopress vs Blowfish

In which we make the blog look a little different, while bringing along some of the things we like.


But First…
#

I think I’ve learned enough from working on my wfcish package for the moment. A more generic tile-based wave function map regenerator may be in the works when I have a use for it (retro MMO fuzzing, perhaps?).

Tweaking a Few of the Shortcodes
#

Sticking with Hugo for now, but switching over the theme to Blowfish. I like the look, but as usual will need to add some abilities to handle the existing blog content.

Code Blocks
#

First, can we have Octopress-style codeblocks that look at home in the Blowfish theme? Let’s try:

layouts/shortcodes/codeblock.html
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
<!-- inspired by https://discourse.gohugo.io/t/filenames-for-code-blocks/32466/3 -->

{{ $title := .Get "title" }}
{{ $lang := .Get "lang" }}
{{ $linenostart := .Get "linenostart" | default 1 }}
{{ $options :=  print "linenos=true,linenostart=" $linenostart }}
{{ $input := (trim .Inner "\n\r") }}
  <div class="flex rounded-md border border-primary-400 px-1 text-xs font-normal text-primary-700 dark:border-primary-600 dark:text-primary-400">
      <div class="flex-1">{{ $title }}</div>
      <div class="flex-2 text-right"><a href="{{ .Get "url" }}">{{ .Get "linktext" }}</a></div>
  </div>
{{ highlight $input $lang $options }}

Example:

pkg/wfcish/wfcish.go
161
162
163
164
165
166
167
168
169
170
171
172
func (wm *WaveMapContents) updateCellEntropies() {
	// Asynchronously make sure the entropy is valid in each interesting cell
	// (not nil or collapsed)

	// Which cells can we fan out?
	fanOuts := make([]*SuperpositionCell, 0, 50)
	for _, cell := range wm.cellArray {
		if cell == nil || cell.isCollapsed() || cell.entropyValid {
			continue
		}
		fanOuts = append(fanOuts, cell)
	}

Arbitrary starting line number, link with customizable linktext, decent-ish styling, check.

Code Captions
#

In some places I use codecaption which may not have a link to the code repo:

layouts/shortcodes/codecaption.html
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
<!-- inspired by https://discourse.gohugo.io/t/filenames-for-code-blocks/32466/3 -->

{{ $title := .Get "title" }}
{{ $lang := .Get "lang" }}
{{ $linenostart := .Get "linenostart" | default 1 }}
{{ $options :=  print "linenos=table,linenostart=" $linenostart }}
{{ $input := (trim .Inner "\n\r") }}
  <div class="flex rounded-md border border-primary-400 px-1 text-xs font-normal text-primary-700 dark:border-primary-600 dark:text-primary-400">
{{ with .Get "title" }}
  <div class="flex-1">{{ $title }}</div>
{{ end}}
{{ with .Get "url" }}
  <div class="flex-1 text-right"><a href="{{ .Get "url" }}">{{ .Get "linktext" }}</a></div>
{{ end }}
  </div>
{{ highlight $input $lang $options }}

Example:

Default.sublime-commands
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
  {
    "caption": "Reg Replace: Convert Octopress 2 blog post to Jekyll3 custom",
    "command": "reg_replace",
    "args": {"replacements": ["remove_trailing_spaces", "octo_to_jekyll_center_img",
      "octo_to_jekyll_center_img",
      "octo_to_jekyll_single_cat", "octo_to_jekyll_two_cat",
      "octo_to_jekyll_backtick_codeblock", "octo_to_jekyll_backtick_newline",
      "octo_to_jekyll_backtick_plain",
      "octo_to_jekyll_heading_newline", "remove_trailing_spaces"]}
  },

Seems to work.

Image Captions
#

After a bit of experimentation, this seems to be a valid way of converting the imgcap tag to standard markdown:

layouts/shortcodes/imgcap.html
2
3
4
5
{{ $title := .Get "title" }}
{{ $src := .Get "src" }}

{{ printf "![%s](%s \"%s\")" $title $src $title | markdownify }}

Example:

No more hidden wolves
No more hidden wolves

Of Course, Raw HTML
#

layouts/shortcodes/rawhtml.html
1
2
3
{{/*  Thanks to Ana Ulin https://anaulin.org/blog/hugo-raw-html-shortcode/  */}}
<!-- raw html -->
{{.Inner}}

Example:


      
                              A dog
                         
             ~~~~~~~~~~~~  
             ~~. . . . . 
             ~~. v . . . 
             ~~. . . . . 
             ~~. . . A . 
             ~~. . . . . 
                                                                                      
      Your spellbook explodes!                                                        
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
       ->                                                                             
                                                                                      
       R                           Hits       : 20/36            Hits Taken : 16   
       L                           Experience : 4996             Magic Points: 4  
                                   Stamina    : 10  

One More Thing…
#

After a quiet beginning to the year, I have some exciting stuff planned. We’ll see.


More to come
More to come

theme-tweaks New Day 14 Code