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.

Furthermore, the format of these inputs is quite simple, and so the hope is that more people will be able to contribute.

Contributing

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

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

from .types import InputData
from .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",
    },
]


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",
    examples=attributed_to_examples,
    detail_table=True,
    detail_extractor={
        "activity": lambda x: format_as_json(x.get("object", {}).get("attributedTo")),
        "mastodon": lambda x: format_as_json(x.get("account")),
        "firefish": lambda x: format_as_json(x.get("user")),
    },
    detail_title={
        "mastodon": "| attributedTo | account | Example |",
        "firefish": "| attributedTo | user | Example |",
    },
    support_table=True,
    support_title="attributedTo",
    support_result={
        "activity": lambda x: format_as_json(
            x.get("object", {}).get("attributedTo"), small=True
        )[0],
        "mastodon": is_supported,
        "firefish": is_supported,
    },
)

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.tool
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.