Posting from the Desktop

While I have a web interface for manipulating the web site, I've felt having a permanent app running in the systray for posting wherever would remove friction from posting. Time to scratch another code itch and pull up VSCode.


My source code is up at Breaking it down:

  • src/bitbucket.go has the Bitbucket API interaction code
  • src/httpclient.go has the generic http interaction override code, so test scripts can mock Bitbucket API
  • src/main.go is the base code, where I also included the fyne code for making a GUI executable
  • src/markdown-template.go has HTML snippets to wrap around HTML-ified markdown to see what the post looks like
  • src/parse-file.go has code I snagged from my vonblog app to parse Markdown to HTML
  • src/post-struct.go has the structure of a post (frontmatter, etc.)
  • src/validator.go validates submitted code, and has some parse-guesses to convert weird date formats


The gui can currently:

  • Browse folders in Bitbucket/blog to find a file to edit
  • Create a new markdown file for editing locally
  • Save (commit+push) a markdown file to Bitbucket - any selected media files go too
  • Preview the markdown
  • Popup a window with extended post metadata (e.g. a Resume or Review have additional types; indieweb posts have specific codes)
  • Browse local folders for media to upload.
  • Create my gallery tag around media selected to upload automatically
  • I keep forgetting how to do blockquotes, so I added a blockquote button


To adjust selected text in the widget.Entry you manipulate the clipboard.

1oldClipboard := mainWindow.Clipboard().Content()
3s := &fyne.ShortcutPaste{Clipboard: mainWindow.Clipboard()}

The multipart library is a must use for multipart uploading. It makes file uploads much easier.

I have to remember to use omitentry in structs to stop blank entries showing everywhere.

1type FrontMatter struct {
2	Created          string            `yaml:"Created"`
3	Updated          string            `yaml:"Updated,omitempty"`

I will have to extract some of my common Markdown and Frontmatter handling functions to another library, so I can include that in both vonblog the blog builder and vonpost the GUI post system. Duplication is problematic.

By adding contenteditable="true" spellcheck="true" to the HTML preview template, my browser will highlight spelling issues for me to look at. Without me needing to add a spell checker to my code. Cheating!

The authorisation is now using BitBucket's OAuth interface for the APIs rather than username/ password plugging into the interface, which makes me feel safer at least.