Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

IndieWeb Post Type Discovery

A library to discover the post type of a web page in accordance with the IndieWeb Post Type Discovery specification.

Installation

To install this package, run the following command:

pip install post-type-discovery

You can import the package using the following line of code:

import post_type_discovery

Usage

This library contains a get_post_type function that returns the post type of a linked web page.

This function uses the following syntax:

get_post_type(url, custom_properties=[])

Here are the arguments you can use:

  • url: The URL of the web page to discover the post type of.
  • custom_properties: A list of custom properties to use when discovering the post type. This list must contain tuples.

The function returns a single string with the post type of the specified web page.

See the Post Type Discovery specification for a full list of post types.

Custom Properties

The structure of the custom properties tuple is:

(attribute_to_look_for, value_to_return)

An example custom property value is:

custom_properties = [
    ("poke-of", "poke")
]

This function would look for a poke-of attribute on a web page and return the "poke" value.

By default, this function contains all of the attributes in the Post Type Discovery mechanism.

Custom properties are added to the end of the post type discovery list, just before the "article" property. All specification property types will be checked before your custom attribute.

Here is an example of the get_post_type function in use:

import indieauth_helpers

url = "https://jamesg.blog/2021/12/06/advent-of-bloggers-6/"

post_type = indieauth_helpers.discover_endpoint(url)

print(post_type)

This code returns the following string:

article

License

This project is licensed under the MIT license.

Contributing

This project welcomes contributions from anyone who wants to improve the library.

Feel free to create an issue or pull request on GitHub and your contribution will be reviewed.

Contributors

  • capjamesg

Metadata

Release files for post-type-discovery 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for post-type-discovery 1.0.0
File Size Uploaded
post-type-discovery-1.0.0.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for post-type-discovery 1.0.0
File Interpreter ABI Platform
post_type_discovery-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.4 kB

Release files / post-type-discovery-1.0.0.tar.gz

Download URL post-type-discovery-1.0.0.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
197f8247a0ead8a0422c61e82e74d59a2d836cb22acea118b30e82ddd9968711
BLAKE2b-256 checksum
How to use checksums
438f9778579a27057dace728cfa067c0e4b3e94ebb968e85c7f18f36c65fa45b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

Release files / post_type_discovery-1.0.0-py3-none-any.whl

Download URL post_type_discovery-1.0.0-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6853a7401437849e402a4b0d3171fcf54f44e4e911a1e2732414f5d6004741eb
BLAKE2b-256 checksum
How to use checksums
0589e373faaed0577ecf0334cb39145ba1a971b9250a9635e1f0d6951a6fba90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page