59 lines
2.1 KiB
Markdown
59 lines
2.1 KiB
Markdown
|
|
# microblog.py
|
|
|
|
Simple and stylish text-to-html microblog generator.
|
|
|
|
## Requirements
|
|
|
|
python3 date make curl pycurl urllib
|
|
|
|
`date` is `date` from GNU Core Utilities. `make` is only used to demonstrate the examples in `example/`. The latter three are optional; `curl`, `pycurl` and `urllib` are only used for the uploader script.
|
|
|
|
### Usage
|
|
|
|
Send three arguments minimum to `python`. The fourth argument for an e-mail address is optional.
|
|
|
|
python microblog.py ./template.html ./content.txt user@mailhost.tld
|
|
|
|
The resulting web page is outputted from standard output. Therefore:
|
|
|
|
python microblog.py ./template.html ./content.txt user@mailhost.tld > result.html
|
|
|
|
Use a Makefile (or another script) to simplify invocation.
|
|
|
|
cp example/Makefile .
|
|
|
|
This script generates three text files after operation.
|
|
|
|
* `postsperpage.txt`, holds an integer for the number of posts to render per page (default: 20). Thi is a configuration file that is created if it does not exist).
|
|
* `lastfullpage.txt`, holds an integer for the last page rendered by the paginator.
|
|
* `updatedfiles.txt`, a list of files updated by the script for use in automated uploads.
|
|
|
|
### Writing Content
|
|
|
|
See `example/demo.txt`.
|
|
|
|
The content file is a plain text file of posts. Each post has two types of information: timestamp and message. For example:
|
|
|
|
|
|
Thu Mar 17 11:11:11 PM EDT 2022
|
|
Today I ate ice cream.
|
|
It was strawberry flavored.
|
|
#TouchingGrass
|
|
|
|
Thu Mar 16 2:22:22 PM EDT 2022
|
|
I took these pictures.
|
|
./images/1.jpg ./images/2.jpg ./images/3.jpg
|
|
|
|
|
|
|
|
* the first line of the file must be empty (newline character only).
|
|
* the two last lines of the file must be empty
|
|
* html can be placed in the message for embedded videos and rich text
|
|
|
|
## Anything else
|
|
|
|
This is a script I wrote for personal use. The output can be seen on [https://likho.neocities.org/microblog/index.html](https://likho.neocities.org/microblog/index.html). I figure someone else may want to use it for their own personal websites, so it is published.
|
|
|
|
It works for me and my workflow; therefore, it is simple and involves little lines of code. But I am still open to comments, questions, or suggetions.
|