leponceau.org

Programming And Stuff, You Know The Thing…

BlogTool Release 1.0-SNAPSHOT.7492.20190201

Posted at — Feb 2, 2019

Download here.

BlogTool

ChangeLog Release 7492

Goal

To be able to use Google’s Blogger [tm] service with markdown. This in turn avoids a lock-in into their specific service. It also allows you to store your clean and clear markup in a version management system of your own choosing (subversion, git, mercurial etc.), while keeping the convenience of Google Blogger (cookie banner, HTML layouts, discussion feature, Google Analytics [tm], AdSense [tm] etc.).

Compatibility

BlogTool needs a Java runtime environment. It has been developed on Linux, but it should also run on Windows and Mac.

How It Works

The BlogTool separates two types of data: html generated from your markdown and resource files like images. The html gets pushed to Google Blogger, the resource files can be pushed via a 3rd party tool like rsync to a separate, simple file server.

The way how the separation works, provides you with another feature: unlike Hugo or Jekyll, you can effortlessly group all of a post’s assets in one directory instead of having to refer to a central assets directory (which is mighty stupid IMHO).

Be aware that the main operational mode is to push your local primary data (markdown) to Google Blogger [tm]. The copies existing at Google Blogger are treated as expendable. Do not use the Google Blogger frontend or any other tool together with BlogTool. Always work on your local, primary markdown data and use that to export. If you really want to mix your blogging experience with other tools that directly work against Google Blogger, you can detect blog posts that will be overwritten by BlogTool via the checksum stored at the start of each blog post:

<!-- 4369fe7972770e3c0506401ff9ef50ae6eb19065 -->

Don’t edit blog posts directly that start with such a marker.

Caution

Make a backup of your Google Blogger [tm] data/posts first.

Usage

java -jar blogtool.jar -b https://your-blog.blogspot.com

That command will traverse the directory structure below your current working directory and look for files ending in ‘.md’ or ‘.markdown’. The markdown files (articles) are expected to have the following format:

---
title: some title
tags:
  - label 1
  - label 2
---
some content using pegdown markup

The frontmatter is in Yaml format. The ‘title’ specification inside the frontmatter is required, the tags (labels) are optional.

During the first run, BlogTool will detect that the markdown file has no post id defined in its frontmatter and it will publish the article. Upon publishing, the following data will be added to the frontmatter:

The added id will be used in future runs to update the published remote post at blogspot.com. url has been added simply for convenience, while date will keep track/store when you first published your post - you can change this date manually anytime.

The BlogTool detects a necessary update by first fetching all remote posts, and then checking if anything of the following has changed:

Non-Post/Non-HTML Resources

If you don’t want to manually upload image resources and other file types, you can use the ‘-p’ option to adjust the generated resource links to point to another website. Example:

java -jar blogtool.jar -b https://blog.your.domain -p https://files.your.domain

Then use a tool like rsync to copy your assets in place:

rsync -ain --del --usermap="*":www-data --groupmap="*":www-data --exclude="**/*.md" \
    ./ root@files.your.domain:/var/www/files.your.domain/html/

Remove the n argument after verifying that nothing important gets deleted. This command likely needs to be adapted if you are using the virtual server for the files.your.domain for other things than just backing your Google Blogger blog. Personally, I’m running nginx on Debian 8 in conjunction with certbot. The domain is hosted on nameinfo.com and the vserver is sold by ultravps.eu. The default nginx configuration root setting was changed to root /var/www/$host/html;

When specifying the -p argument, relative resource links will be verified to point to a local resource file. Example: if ‘post001/content.md’ contains the markup [](graph.png), the BlogTool will abort processing if it doesn’t find a readable file at post001/graph.png. The generated HTML will then point to:

https://files.your.domain/post001/graph.png

and the nginx server will serve the file from:

files.your.domain:/var/www/files.your.domain/html/post001/graph.png

Limitations

BlogTool is currently being developed using OpenJDK 11. It’s recommended to use the same runtime environment.

Using Multiple Google Accounts

If you have multiple blogs and need multiple Google account logins for them, add -Dcred.storage.user=$id to the command line. $id is an arbitrary identifier to identify your credentials, ie. use one unique $id per Google login.

Import/Dump

If you already have posts on Google Blogger [tm], you might want to run

java -jar blogtool.jar -b https://blog.your.domain -i

once to import them into your local repository.

License

BlogTool is free to use.

Data Privacy

The free BlogTool version adds an invisible tag to published blog posts which makes the use of BlogTool theoretically trackable across the WWW.

Help / Feedback / Support / Website

BlogTool’s homepage can be found at:

https://blogtool.leponceau.org

Subscribe to the blog to get update notifications or use the comment section to give feedback or ask questions.

If you like BlogTool, think about using the donation option on the website.