Skip to main content

Find the post type associated with a web page in accordance with the Post Type Discovery algorithm.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

post-type-discovery-1.0.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

post_type_discovery-1.0.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file post-type-discovery-1.0.0.tar.gz.

File metadata

  • Download URL: post-type-discovery-1.0.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for post-type-discovery-1.0.0.tar.gz
Algorithm Hash digest
SHA256 197f8247a0ead8a0422c61e82e74d59a2d836cb22acea118b30e82ddd9968711
MD5 43df658c309027a9de76d88828a2f2aa
BLAKE2b-256 438f9778579a27057dace728cfa067c0e4b3e94ebb968e85c7f18f36c65fa45b

See more details on using hashes here.

File details

Details for the file post_type_discovery-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: post_type_discovery-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for post_type_discovery-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6853a7401437849e402a4b0d3171fcf54f44e4e911a1e2732414f5d6004741eb
MD5 29583b0cb3c707d6457182a5120bb7ee
BLAKE2b-256 0589e373faaed0577ecf0334cb39145ba1a971b9250a9635e1f0d6951a6fba90

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page