https://github.com/capjamesg/micropub

A Micropub client and server implemented in Python Flask.

https://github.com/capjamesg/micropub

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.3%) to scientific vocabulary

Keywords

indieweb micropub

Keywords from Contributors

projection interactive generic sequences archival transformers yolov5 genomics observability autograding
Last synced: 6 months ago · JSON representation

Repository

A Micropub client and server implemented in Python Flask.

Basic Info
  • Host: GitHub
  • Owner: capjamesg
  • License: mit
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 1.2 MB
Statistics
  • Stars: 4
  • Watchers: 1
  • Forks: 2
  • Open Issues: 5
  • Releases: 0
Topics
indieweb micropub
Created over 4 years ago · Last pushed almost 2 years ago
Metadata Files
Readme License

README.md

Micropub Client and Endpoint

This repository contains the code behind my Micropub client and endpoint. Unusually, the client and endpoint are both part of the same codebase. This is because I built this client and endpoint concurrently and wanted to keep the code as part of the same project.

The client.py file contains all of the code for the Micropub client. micropubhelper.py, createitems.py, and micropub.py contain code relevant to the Micropub server.

This application is powered by Python Flask.

Screenshot

Micropub homepage

Specification Compliance

This project is in development. As a result, the contents of this repository have not yet passed the Micropub client or server specifciations published on micropub.rocks.

So far, the receiving end has 30 of the 34 specification requirements in the micropub.rocks implementation report. The implementation report is here:

https://micropub.rocks/implementation-reports/servers/593/qcErwj2OOC2MiSqE6QeU

Installation

Setting up your environment

First, set up a virtual environment:

python3 -m venv venv
source venv/bin/activate

Next, you will need to install the required dependencies for this project. You can do so by running this command:

pip install -r requirements.txt

Configuration

To use this endpoint, you need to create a config.py file with the following values:

UPLOAD_FOLDER = "/path/to/website/assets/folder/"
ALLOWED_EXTENSIONS = set(["png", "jpeg", "jpg"])
HOME_FOLDER = "/path/to/folder/for/website/"
ENDPOINT_URL = "https://yourmicropubendpoint.com/micropub"
MEDIA_ENDPOINT_URL = "https://yourmicropubendpoint.com/media"

GITHUB_KEY = "GITHUB_ACCESS_TOKEN"
GOOGLE_API_KEY = "GOOGLE_CLOUD_API_KEY"

TWITTER_BEARER_TOKEN = "TWITTER_API_TOKEN"

ME = "yourdomain.com"
CALLBACK_URL = "https://yourdomain.com/micropub/callback"
CLIENT_ID = "https://yourdomain.com"

These values are all required for the endpoint to work. UPLOADFOLDER and HOMEFOLDER should be where you keep your website assets folder and website root folder, respectively. In my case, UPLOADFOLDER points to my /assets/ folder in my Jekyll repository and HOMEFOLDER points to my root folder in my Jekyll repository.

This project uses PyGitHub to upload posts published through the Micropub server to GitHub. For this feature to work, you need to specify a GitHub access token that has access to read and write to a repository.

The Google API key is used for finding locations when you post a checkin. This feature is only implemented when one does not specify the address of where they are in a checkin. To disable this feature, go to the processcheckin() function in createitems.py and comment out the code related to the Google Cloud API.

You will also need to create a folder for each post type you want to support. This is essential because the Micropub server does not create these folders automatically. The folders you need to create to support all post types are:

- _webmention
- _rsvp
- _repost
- _likes
- _notes
- _coffee
- _bookmark
- _checkin

Start the application

With the dependencies installed, you can run the application by using this command:

python3 wsgi.py

Client Schemas

The /schemas page shows schemas for every POST request the Micropub client can make (excluding media endpoint requests).

You can refer to this page without downloading the client by going to templates/schemas.html in the source code.

You can use these schemas to help understand the data the client will send to a server.

Only JSON objects are documented on the schemas page. Support for form encoded requests is not yet stable and as a result has not been documented on the schemas page.

Server Role

The role of the server is to turn the POST requests from the client into files that can then be uploaded to a Jekyll blog or any blog that uses similar front matter. You can modify the server to create a different page type. To do so, I would suggest taking a look at the writetofile() function in create_items.py.

Here is a webmention that the server created after receiving a "reply" POST request from the client:

category:
- Webmention
in-reply-to:
- https://jamesg.blog
layout: webmention
published: 2021-09-12 08:36:55.916905
title: Webmention to Home   James Coffee Blog

Relevant Resources

Here are some relevant resources that you might find useful if you are interested in building a Micropub client or server or would like to use the one in this repository:

Acknowledgements

The emojis.json file that the automatic emoji detection system uses on the /post page was retrieved from this Gist by harplife.

The supported TLDs list used for automatic linking is from the iana.org TLDs list.

Contributors

  • capjamesg

Owner

  • Name: James
  • Login: capjamesg
  • Kind: user
  • Location: Scotland
  • Company: @Roboflow

from words, wonder.

GitHub Events

Total
  • Pull request event: 1
  • Fork event: 1
Last Year
  • Pull request event: 1
  • Fork event: 1

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 97
  • Total Committers: 2
  • Avg Commits per committer: 48.5
  • Development Distribution Score (DDS): 0.124
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
capjamesg j****g@j****g 85
dependabot[bot] 4****] 12
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 2
  • Total pull requests: 17
  • Average time to close issues: over 2 years
  • Average time to close pull requests: 6 days
  • Total issue authors: 2
  • Total pull request authors: 2
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.06
  • Merged pull requests: 12
  • Bot issues: 0
  • Bot pull requests: 16
Past Year
  • Issues: 1
  • Pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • btrem (1)
  • capjamesg (1)
Pull Request Authors
  • dependabot[bot] (18)
  • btrem (2)
Top Labels
Issue Labels
Pull Request Labels
dependencies (18)

Dependencies

requirements.txt pypi
  • Deprecated ==1.2.13
  • Flask ==2.0.2
  • Flask-Session ==0.4.0
  • Jinja2 ==3.0.2
  • MarkupSafe ==2.0.1
  • Pillow ==9.0.1
  • PyGithub ==1.55
  • PyJWT ==2.4.0
  • PyNaCl ==1.4.0
  • PyYAML ==6.0
  • Werkzeug ==2.0.2
  • beautifulsoup4 ==4.10.0
  • bs4 ==0.0.1
  • cachelib ==0.4.1
  • certifi ==2021.10.8
  • cffi ==1.15.0
  • charset-normalizer ==2.0.7
  • click ==8.0.3
  • html5lib ==1.1
  • idna ==3.3
  • indieweb_utils ==0.1.2
  • itsdangerous ==2.0.1
  • mf2py ==1.1.2
  • pycparser ==2.20
  • requests ==2.26.0
  • six ==1.16.0
  • soupsieve ==2.2.1
  • urllib3 ==1.26.7
  • webencodings ==0.5.1
  • wrapt ==1.13.3
Dockerfile docker
  • python 3.9.0 build