Giter Site home page Giter Site logo

capjamesg / microformats-to-mediawiki Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 98 KB

A webhook that turns a page marked up with a microformats h-entry object into a MediaWiki page.

License: MIT No Attribution

Python 39.57% HTML 60.43%
bot indieweb mediawiki microformats2

microformats-to-mediawiki's Introduction

Publish a microformats h-entry to MediaWiki

This repository contains a script and web server to publish a microformats h-entry to MediaWiki.

This project is being used on the Breakfast and Coffee to allow wiki submissions from other websites.

Getting Started

First, install the required dependencies for this project:

pip3 -r requirements.txt

Then, create a config.py file with the following variables:

PASSPHRASE="the unique password you want to use to access the webhook"
LGNAME="your bot username for the wiki you are using"
LGPASSWORD="your bot password for the wiki you are using"
SYNDICATION_LINK="your wiki URL"
API_URL="the URL of your wiki api.php file"
REQUIRE_SYNDICATION_LINK=False

You can get the LGNAME and LGPASSWORD values using the Bot passwords MediaWiki feature.

If REQUIRE_SYNDICATION_LINK is set to True, the API will only accept posts that have a syndication link to the wiki homepage. This is useful if you want to ensure that only posts that are syndicated to your wiki are added to the wiki. If you set this to False, the API will accept any post that has a valid URL and the right markup.

Finally, run the web server:

python3 wsgi.py

The web server creates an endpoint at /webhook where you can send POST requests.

The endpoint looks for a payload from webmention.io, which is being used to host the Breakfast and Coffee Webmention endpoint.

You can change the "url_to_parse" variable to change the way in which the URL to parse is retrieved, depending on how you want your webhook to work.

Type checking and linting

You can run a type check and lint on this codebase using the following command:

tox

API Documentation

This API contains a single endpoint that creates a wiki page for a user.

Authentication

To use this API, you need to specify a ?passphrase= URL argument. The value of this argument should be equal to the PASSPHRASE value you set in your config.py file.

Create a wiki page

To create a wiki page, you must be registered with the MediaWiki associated with the installation of this software. Your MediaWiki username must be equal to the domain from which you want to post a URL. This ensures that you cannot submit an arbitrary post to the wiki that you do not own.

Request syntax:

GET /webhook?passphrase=[passphrase]
Content-Type: application/json

Request Body:

{
    "post": {
        "url": "https://example.com"
    }
}

The body of your request should include the URL of the post you want to add to the wiki. The post must be marked up with either h-entry or h-review microformats. A response from the webmention.io webhook feature is compatible with the API.

If the post is a h-review, your post will be created as a review page on the wiki. If a page already exists for the place you want to review, your review will be appended to the existing page.

h-entry posts are created as regular wiki entries.

This endpoint may return the following status codes:

  • 403: A valid passphrase was not specified or the domain who created the post is not registered as a user on the wiki.
  • 400: A valid post URL was not specified or a syndication link was not present.
  • 201: Your post was created successfully. A 201 response will send a Location: header that contains the URL of the post created on the MediaWiki.

All edits are made in the name of the bot user specified in your configuration file.

Technologies

  • Python
  • Flask

License

This project is licensed under the MIT 0 license.

Contributors

  • capjamesg

microformats-to-mediawiki's People

Contributors

capjamesg avatar dependabot[bot] avatar

Watchers

 avatar

microformats-to-mediawiki's Issues

Editing a page should not replace a review list

Review lists should be independent from the rest of the content on a page. This means:

  1. We need a wiki page on Breakfast and Coffee that explains review lists are not editable unlike the rest of a page.
  2. The microformats-to-mediawiki tool needs to enforce the editing rule. Editing a page should replace the contents above the "Reviews" section on a page.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.