~shrik3/timeline-bot

script to integrate fedi timeline into static blogs
96a52b6f — Tianhao Wang 11 months ago
update license
bb261f38 — Tianhao Wang 1 year, 2 days ago
Create python-publish.yml
1a8140e5 — Tianhao Wang 11 months ago
fix readme

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~shrik3/timeline-bot
read/write
git@git.sr.ht:~shrik3/timeline-bot

You can also use your local clone with git send-email.

#integrate your fediverse timeline into your static blog!

#Motivation

I'd like to include my posts on fediverse into my blog without javascript. So I wrote a simple python script to fetch my posts via (Mastodon) server APIs and parse the posts into a json file. My static site generator (hugo) then use this data and render the posts into static HTML.

Demo(my own blog): https://shrik3.com/timeline/

#How to use

Prerequisites

  • Mastodon.py
  • python3.0 +
  • Register a new bot account and follow your main account

Usage
For the first time only, take a look at config.py and modify it. Most importantly

  • APPNAME name it whatever you like
  • BASEURL url of your instance
  • FOLLOW your main account
  • comment out the foolproof lines at the top of config.py.
./timelinebot.py

You will be prompted to input credentials for the bot account (not your main account!). After a successful login, the access token will be stored in token.secret and you no longer need to log in manually.

The script will fetch your posts and store them in tl.json. Then you can proceed to render this data into static pages with your site generator.

For Hugo
create a partial in your template. Maybe take a look at examples/hugo_timeline_partial.html.

Every time before you render the pages, run the timeline bot script and copy tl.json into your blog's data/ directory. For automation you may use examples/syncblog.sh

For non-pleroma users
Change the feature_set field in the code accordingly

self.session = Mastodon(client_id=self.config.CLIENTID, access_token=self.config.TOKEN, feature_set="pleroma")

Do not download other people's data without their permission!