-- Leo's gemini proxy

-- Connecting to r.bdr.sh:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini; lang=en

Blog Tooling


With so many of the bloggers I follow talking about the the latest release of MarsEdit[1], I've been getting tooling envy. While my blog[2] is a full-featured enterprise-grade state-of-the-art piece of software, it's not compatible with any of these tools :(. Surely, a lack of appropriate tooling is the real reason why I don't update as often.


[1] MarsEdit

[2] Blog


After a dozen misguided minutes of reading the atompub spec[3], I decided to integrate my tooling directly to my editor of choice: `nvim`.


[3] The atompub spec


Thanks to the marvels of VimScriptâ„¢ I can now add a text file to my blog with `:Blog add`, update the latest post with `:Blog update`, and publish to staging and live with `:Blog stage` and `:Blog publish`. And all it took was a couple of hours of searching how to write commands in vim[4], learning the difference between `<args>` and `<q-args>`, and a ton of sunken cost bias.


[4] How to write commands in vim


Here you can see the code in its entirety (with a couple replacements):



command -nargs=? Blog :call Blog(<q-args>)

function! Blog(...)

  let command = get(a:, 1, 0)
  let path = expand("%:p")

  if command == "add"
    if path == ""
      echo "This buffer is not a text file"
    else
      echo "Adding ".path." to blog"
      call system("blog --add ".path)
    endif
    return
  endif

  if command == "update"
    if path == ""
      echo "This buffer is not a text file"
    else
      echo "Updating ".path." to blog"
      call system("blog --update ".path)
    endif
    return
  endif

  if command == "stage"
    echo "Publishing blog to staging"
    call system("blog --publish <staging_url>")
    return
  endif

  if command == "publish"
    echo "Publishing blog"
    call system("blog --publish <blog_url>")
    call system("blog --publish-archive <gemini_url>")
    return
  endif

  if command == "help"
    echo "Available commands:"
    echo "\tadd\t\tadds current file to blog"
    echo "\tupdate\t\tupdates latest entry of blog with current file"
    echo "\tstage\t\tpublish blog to staging"
    echo "\tpublish\t\tpublish blog to production"
    echo "\thelp\t\tthis message"
    return
  endif

  echo "Unknown command, run :Blog help for help"

endfunction

Surely, this is all I need to form a publishing habit.


Written, published, edited, republished, debugged, and republished with nvim.

-- Response ended

-- Page fetched on Mon May 20 21:11:01 2024