Skip to content

Inputs for the fediverse-pasture

These inputs are basis for the data on Fediverse interoperability available at data.funfedi.dev and then funfedi.dev. The goal in separating this out is to be able to separate the varying pieces.

Available inputs

Name Number of inputs short name
total 310
Recommended Objects
4
Recommended Media Attachment Format 4 recommended_attachments
HTML Tags
155
Basic HTML tags 14 html_tags_base
Extra HTML Tags 8 html_tags_extra
HTML tags 34 html_tags
HTML tags - that generally should not be supported 13 html_bad
HTML tags for article 34 html_tags_article
HTML tags in summary 34 html_tags_summary
The anchor HTML tag 18 html_anchor
Object Content
84
Attachments 11 attachments
Content Warnings 7 content_warnings
Emoji 7 emoji
Hashtags 13 hashtags
Image Attachments 17 image_attachments
Image Description 6 image_description
Mentions 10 mentions
Quotes 13 quotes
Object Properties
53
Attribution Format 5 attributed_to
Language support 9 language
Necessary Properties 5 necessary_properties
Object types 14 object_types
Url Parameter 13 url
Variations of inReplyTo 7 in_reply_to
Technical Properties
14
Hashtags and JSON-LD 5 hashtag_jsonld
JSON-LD @context 6 context
Public addressing 3 public_addressing

Usage

Most inputs do not make assumptions about the actor being used to serve the objects. This means that one can use them in general contexts.

Some inputs such as Variations of inReplyTo however require assets. This means that one has to download the assets and serve them at http://pasture-one-actor/assets/ to be able to use the inputs.

The assets are also available as a codeberg package, here.

Contributing

Adding new inputs is fairly straightforward. First take a look at one of the existing files

fediverse_pasture_inputs/inputs/attributed_to.py
# SPDX-FileCopyrightText: 2024 Helge
#
# SPDX-License-Identifier: MIT

from fediverse_pasture_inputs.types import InputData, Details, Support
from fediverse_pasture_inputs.utils import format_as_json, is_supported

attributed_to_examples = [
    {"attributedTo": "http://pasture-one-actor/actor", "content": "single element"},
    {
        "attributedTo": ["http://pasture-one-actor/actor"],
        "content": "single element as list",
    },
    {
        "attributedTo": [
            "http://pasture-one-actor/actor",
            "http://pasture-one-actor/second",
        ],
        "content": "two elements as list",
    },
    {
        "attributedTo": {"type": "Person", "id": "http://pasture-one-actor/actor"},
        "content": "a dictionary",
    },
    {
        "attributedTo": [{"type": "Person", "id": "http://pasture-one-actor/actor"}],
        "content": "a dictionary",
    },
]

details = Details(
    title={
        "mastodon": "| attributedTo | account | Example |",
        "misskey": "| attributedTo | user | Example |",
    },
    extractor={
        "activity": lambda x: format_as_json(x.get("object", {}).get("attributedTo")),
        "mastodon": lambda x: format_as_json(x.get("account")),
        "misskey": lambda x: format_as_json(x.get("user")),
    },
)

support = Support(
    title="attributedTo",
    result={
        "activity": lambda x: format_as_json(
            x.get("object", {}).get("attributedTo"), small=True
        )[0],
        "mastodon": is_supported,
        "misskey": is_supported,
    },
)

data = InputData(
    title="Attribution Format",
    frontmatter="""
`attributedTo` is defined [here in the ActivityStreams Vocabulary](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-attributedto). It allows us to tell, who authored / owns the object.

This test explores what is allowed in the field.

""",
    filename="attributed_to.md",
    group="Object Properties",
    examples=attributed_to_examples,
    details=details,
    support=support,
)

and then at the corresponding page. I hope one can guess the relationship between attributed_to_examples variable and the provided examples just by looking at it.

So if you want to modify or add something, one can just do it following this pattern. Then one can check that everything works correctly by running

uv sync --frozen
uv run python -mfediverse_pasture_inputs docs
uv run mkdocs serve

The updated objects can then by viewed at http://localhost:8000/. By running pytest via

uv run pytest

one can furthermore ensure that the new inputs pass basic sanity checks.

Installing the package

Available at pypi via

pip install fediverse-pasture-inputs

Funding

This code was created as part of Fediverse Test Framework.

A project funded through the NGI0 Core Fund, a fund established by NLnet with financial support from the European Commission’s Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 101092990.