oyvindsk / web-oyvindsk.com

Simple website, blog and contact form written in go. Serves http://oyvindsk.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

web-oyvindsk.com

About

Simple go blog that serves http://oyvindsk.com.

I’m currently using it to test Google Cloud Run. It used to run on App Engine Standard, and I might convert it back in the future. Both are container based PaaS solutions. Run is newer, is Docker based and offers more flexibility. It does lack some App Engine’s features though. Both are fully managed (yay!) and can scale up "infinitely" and down to zero when there’s no traffic (also yay).

Goals

Serve pages, blog posts and static files.

Support useful things like RSS and comments (todo)

Generate blog posts from AsciiDoc, styled using the Tachyons css toolkit.

Content flow

AsciiDoc + metadata
=> Asciidoc python or asciidoctor, run locally with ./asciidoc-runner
=> generates html and pdf
=> Find and load metadata files for pages and blogposts (.toml)
=> HTML PostProcess: fix some things, like absolute image urls, that are needed for PDFs generation but wrong in the html
=> HTML PostProcess: remove standard css classes and add Tachyons classes
=> Go Templates: Put together a complete page from html, metadata and templates
=> Serve the pdf as well, as an alternative

Generating html the hard way

I’m currently re-writing this with a new layout and cleaner code. It uses an overly complicated way of producing html: Pages and blogposts are written in Asciidoc (similar to Markdown) and styled with the Tachyons CSS toolkit.

This is done mostly for fun, not necessarily recommended for anyone else =)

Problem

Asciidoctor generates html you don’t really have any control over. This is usually true for markdown processors as well. You would usually take the default styling (css) or write css customized to the Asciidoc generators html.

But Tachyons does not work this way. It expects you to style by putting the classe you want directly in the html code. See this example for Tailwind CSS, which works in a similar way.

Solution?

The html coming out of AsciiDoctor does not "work" with Tachyons. Therefore we want to change that, remove the stuff we don’t want (unneeded classes etc) and add Tachyones clases we want.

Processing html is actually not that hard using the golang.org/x/net/html go lib.

See the blogbackend/internal/tachyons/ package.

Pros

Fun!

Separation of content (the Asciidoc) from the presentations: 1) Go code + Tachyons, 2) PDF 3) Others, like Docbook?

The asciidoc can later be converted into pdfs, ebooks or alternative html+css with one of the two main AsciiDoc implementations (Asciidoc and Asciidoctor)

AsciiDoc is really nice to write in, hopefully saves me from having to go back and edit old blogposts in the future when I change my layout and design.

AsciiDoc will be useful for writing longer form as well, like an ebook.

Cons

Uncommon and ridiculously complicated.

No complete AsciiDoc implementation for go yet.

Although it’s much better than the Markdown universe, there’s still 2 implementations that are not 100% compatible.

Todo

Bugs

  • Bug: Links with "ø" (like cv’s.. ) do not work in the PDFs

Features

License

Go code (*.go files) are MIT / BSD 2-clause. Files in the blogbackend/static_files directory could have their own licenses.

About

Simple website, blog and contact form written in go. Serves http://oyvindsk.com


Languages

Language:CSS 54.0%Language:HTML 35.5%Language:Go 9.3%Language:Shell 0.8%Language:SCSS 0.4%Language:Dockerfile 0.2%