little-boxes/README.md

81 wiersze
2.4 KiB
Markdown
Czysty Zwykły widok Historia

2018-06-11 20:50:02 +00:00
# Little Boxes
2019-04-11 19:52:57 +00:00
<a href="https://d.a4.io/tsileo/little-boxes"><img src="https://d.a4.io/api/badges/tsileo/little-boxes/status.svg" alt="Build Status"></a>
2018-06-12 18:15:46 +00:00
<img src="https://img.shields.io/pypi/pyversions/little-boxes.svg" />
2018-06-13 19:46:14 +00:00
<a href="https://github.com/tsileo/little-boxes/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-ISC-red.svg?style=flat" alt="License"></a>
2018-06-13 19:54:46 +00:00
<a href="https://github.com/ambv/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
2018-06-11 20:54:14 +00:00
Tiny [ActivityPub](https://activitypub.rocks/) framework written in Python, both database and server agnostic.
2018-06-11 20:50:02 +00:00
2018-06-11 20:56:03 +00:00
**Still in early development, and not published on PyPI yet.**
2018-07-01 08:39:50 +00:00
Until a first version is released, the main goal of this framework is to power the [microblog.pub microblog engine](http://github.com/tsileo/microblog.pub).
2018-06-13 19:54:46 +00:00
## Features
- Database and server agnostic
2018-07-18 07:38:48 +00:00
- You need to implement a backend that respond to activity side-effects
2018-06-18 19:30:57 +00:00
- This also mean you're responsible for serving the activities/collections and receiving them
2018-06-13 19:54:46 +00:00
- ActivityStreams helper classes
- with Outbox/Inbox abstractions
2018-07-18 07:38:48 +00:00
- Content helper using Markdown
2018-06-13 19:54:46 +00:00
- with helpers for parsing hashtags and linkify content
- Key (RSA) helper
- HTTP signature helper
- JSON-LD signature helper
- Webfinger helper
2018-06-11 20:50:02 +00:00
## Getting Started
```python
from little_boxes import activitypub as ap
from mydb import db_client
2018-06-13 19:46:14 +00:00
class MyBackend(ap.Backend):
2018-06-11 20:50:02 +00:00
def __init__(self, db_connection):
self.db_connection = db_connection
2018-06-13 19:46:14 +00:00
def inbox_new(self, as_actor: ap.Person, activity: ap.Activity) -> None:
2018-06-11 20:50:02 +00:00
# Save activity as "as_actor"
# [...]
2018-06-13 19:46:14 +00:00
def post_to_remote_inbox(self, as_actor: ap.Person, payload: ap.ObjectType, recipient: str) -> None:
2018-06-11 20:50:02 +00:00
# Send the activity to the remote actor
# [...]
db_con = db_client()
my_backend = MyBackend(db_con)
ap.use_backend(my_backend)
me = ap.Person({}) # Init an actor
outbox = ap.Outbox(me)
follow = ap.Follow(actor=me.id, object='http://iri-i-want-follow')
2018-06-11 20:50:02 +00:00
outbox.post(follow)
```
2018-06-11 22:14:29 +00:00
2018-06-13 19:54:46 +00:00
2018-06-11 22:14:29 +00:00
## Projects using Little Boxes
- [microblog.pub](http://github.com/tsileo/microblog.pub) (using MongoDB as a backend)
2018-07-15 12:36:07 +00:00
- [pubgate](https://github.com/autogestion/pubgate)
2018-06-12 17:57:40 +00:00
2018-06-13 19:54:46 +00:00
2018-06-12 17:57:40 +00:00
## Contributions
TODO: document Mypy, flake8 and black.
PRs are welcome, please open an issue to start a discussion before your start any work.
2018-06-13 19:54:46 +00:00
## License
ISC, see the LICENSE file.