hxii / picoblog-py

Opinionated twtxt -> html generator in Python
https://0xff.nu/picoblog
2 stars 0 forks source link
blog python twtxt

Picoblog (Python Version)

Picoblog is my somewhat opinionated interpretation and usage of twtxt. It started it's life as a PHP script, but seeing as I mostly forgot how to write and use PHP as well as the fact that I now use Python as part of work, I figured I'll rewrite it. The rendered file is now static, as I figured I don't necessarily update it often enough for it to be dynamic.

This code is provided as an example, although you're more than welcome to use it as is (your own template provided, of course!).

Notes

Usage

usage: main.py [-h] [-t TEMPLATE] [-w] input output

Picoblog builds an html file using a template from a twtxt (https://twtxt.readthedocs.io) feed.

positional arguments:
  input                 Input file (TWTXT format)
  output                Output file (HTML)

options:
  -h, --help            show this help message and exit
  -t TEMPLATE, --template TEMPLATE
                        Template to use (HTML)
  -w, --watch           Watch input file for changes (15s)

Template

Here's a very (VERY) basic template usage:

<div class="entries">
    {% for date, entries in tweets.items() %}
    <section class="day" id="{{ date }}">
    {% for entry in entries %}
        <article class="entry">{{ entry.1 }}</article>
    {% endfor %}
    </section>
    {% endfor %}
</div>

TODO