Skip to content

rmoorman/kaku

 
 

Repository files navigation

Downloads Requirements Status

書く- to write

Kaku is a Python Flask app and a small daemon designed to manage the more dynamic requirements of a modern IndieWeb site.

Currently this code is very opinionated as I am writing it for use with my own site.

Requirements and Assumptions

  • Python v2.7
  • Kaku is written using Flask and takes advantage of the builtin Jinja template handling
  • Because Kaku needs to to store state information for authentication and authorization, it requires a Redis database
  • All Micropub and Webmention calls are handled, dispatched and then an HTTP code 202 is returned.

Features

  • Micropub endpoint /micropub
  • Webmention endpoint /webmention
  • Indieauth endpoints /login, /logout, /auth and /success
  • Token generation endpoint /token

Post source files that are determined to be new, updated or deleted will have a Kaku Event generated. This event is generated by either the Flask app as part of a web request, or by a command line call via kaku_events.py.

If a post is shown to have changed then the HTML for the post is generated and the index page is updated.

Configuration

The Flask part of Kaku uses the normal Flask settings.py configuration file, see https://github.com/bear/kaku/blob/master/kaku/settings.py for reference. kaku_events.py uses a json config file, see https://github.com/bear/kaku/blob/master/kaku_events.py for an example of it.

Installation

All of the dependencies are outlined in a pip installable '''requirements.txt''' file.

Running

First start the event handler

$ python kaku_events.py --help
usage: kaku_events.py [-h] [--config CONFIG] [--file FILE] [--force]

optional arguments:
  -h, --help       show this help message and exit
  --config CONFIG
  --file FILE      A specific markdown file to check and then exit
  --force          Force any found markdown files (or specific file) to be
                   considered an update.

$ python kaku_events.py --config ./kaku_events.cfg

and then the Flask app

KAKU_SETTINGS=./kaku_settings.py uwsgi --socket 127.0.0.1:5000 --module service --callable application

Kaku has available the Flask style management app manage.py.

TODO

handle the following requests:

  • GET /.well-known/browserid?domain=palala.org
  • Micropub Edit and Delete events

Debug info

curl https://bear.im/micropub -d mp-action=delete -d "url=https://bear.im/2016/123/testing-delete" -H "Authorization: Bearer XXXX"

curl https://bear.im/micropub -d mp-action=undelete -d "url=https://bear.im/2016/123/testing-delete" -H "Authorization: Bearer XXXX"

python kaku_events.py --config ./kaku_events.cfg --file ~/content/2016/123/testing-delete.md --force

Post files example

  • testing-delete.md -- markdown for the post, also contains the immutable metadata
  • testing-delete.json -- metadata for post
  • testing-delete.deleted -- semaphore file to mark the post as deleted
  • testing-delete.html -- generated html
  • testing-delete.mentions -- Webmentions that have been sent to the post
  • testing-delete.outboundmentions -- json blob of any current Webmention sent from the post
$ cat testing-delete.md
Title:   testing delete
Date:    2016-05-02 03:53:14
Tags:    None
Author:  bear
Slug:    testing-delete
Summary: testing delete

this post will be deleted

[webmention.rocks delete/1](https://webmention.rocks/delete/1)
$ cat testing-delete.json
{
  "xml": "<p>This article has been deleted.</p>",
  "author": "bear",
  "url": "/bearlog/2016/123/testing-delete.html",
  "route": "2016/123/testing-delete",
  "title": "testing delete",
  "doy": "123",
  "modified": 1462747458.57246,
  "summary": "testing delete",
  "content": "this post will be deleted\r\n\r\n[webmention.rocks delete/1](https://webmention.rocks/delete/1)\r\n\r\n",
  "deleted": "2016-05-09 04:06:32",
  "html": "<p>This article has been deleted.</p>",
  "created": "2016-05-02 03:53:14",
  "key": "20160502035314",
  "year": "2016",
  "date": "2016-05-02 03:53:14",
  "path": "/home/bearim/content/2016/123",
  "slug": "testing-delete",
  "tags": "None",
  "published": "2016-05-02 03:53:14"
}

About

書く- to write

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 96.1%
  • HTML 2.0%
  • Makefile 1.9%