FEP-888d: Using w3id.org/fep as a namespace for extension terms and for FEP documents

wrt the codeberg headers and content-type, this was detailed extensively above and would be addressed by using a static deploy host that can correctly set CORS and Content-Type headers, i.e. not codeberg.

wrt low availability of codeberg, this would also be addressed by using a host other than codeberg.

these are not strictly part of the fep, though. the fep is about using https://w3id.org/fep as a prefix for fep resources. the fep going to FINAL does not imply that the .htaccess rules can never be changed.

a PURL service is not a link shortener. the point of using a PURL service is to allow for consistent references while also allowing the ultimate network location to change. in practical terms, this means that we can move off of codeberg and all PURLs will continue to work fine simply by updating the redirects. the bet being made is that w3id.org/fep will be longer-lived than codeberg.org/fediverse/fep.

the fep site can use w3id.org/fep as well, if desired. if it’s not hosted on codeberg, it can address the above issues as well.

wrt “official fep policy”, that is a different matter than individuals deciding to use these PURLs or not. the fep exists and the redirects have been set up already. anyone is free to use or not use them.

maybe? i would instead heavily advise people not to request application/json. but i’m not sure if there is any harm in allowing this. it would be like allowing application/xml instead of application/rdf+xml, or allowing text/plain instead of text/turtle. technically incorrect, but forgiving.

these links will likewise break if codeberg ever goes down, if codeberg ever discontinues codeberg.page, or if the fep project ever migrates away from codeberg.

1 Like

Definitely it’s important to use a purl service. Maintaining stable URLs on the order of decades is hard work.

I added code to the activitystrea.ms library to allow pre-loading a context document, and it appears to be working well, but others like Fedify are still having problem with FEP 5711. It’d be nice to get these context documents hosted on stable servers before finalising this FEP.

In the past months it seems that Codeberg Pages has switched from pages-server to git-pages as the backend for their hosted sites.

Previously, a blocker for pointing the w3id uris at the static site was that pages-server would add correct Content-Type headers but not add CORS headers, so browser-based javascript jsonld processors like JSON-LD Playground would not work.

Per git-pages/git-pages: Scalable static site server for Git forges (like GitHub Pages or Netlify) - Codeberg.org it seems that the new git-pages backend supports Netlify-style _headers file-based configuration, so we can test if that works for the site at fediverse.codeberg.page/fep – and if it does, that blocker would no longer be a blocker. (The uptime or availability of Codeberg Pages is still in question, but we can hope that the new backend might bring more stability?)

Sometime in the coming weeks I would like to revisit all this, and see if we can get any issues worked out before pursuing FINAL status again.

2 Likes

@silverpill I’ve finally got time to look at this again. According to https://docs.codeberg.org/codeberg-pages/advanced-usage/#custom-headers the following _headers file should work, I think?

/*
  Access-Control-Allow-Origin: *

I’m not sure where to PR this file, though. I think it might be the root of the pages branch, but I’m not 100% sure how to hook it into the automatic deployments.

Right now, a JSON-LD file like https://fediverse.codeberg.page/fep/fep/888d/fep-888d.jsonld is responding with the correct Content-Type: application/ld+json but still omitting the Access-Control-Allow-Origin – which should be resolved by creating the _headers file at the root of the site and deploying that branch.

Once I’ve confirmed that the correct headers are being served, I can update the w3id .htaccess rules to start pointing to fediverse.codeberg.page instead of to raw.codeberg.page as raw.codeberg.page is being deprecated soon – Migrating from Pages v2 | Codeberg Documentation says that it’ll be offline by 2026-12-31.

1 Like

The site is built from files in scripts/docs directory: https://codeberg.org/fediverse/fep/src/branch/main/scripts/docs. Putting _headers there should be enough.

Thanks; confirmed it works on the FEP generated site now and includes the proper headers.

Draft PR #976 - WIP: 888d: Update mapping to Codeberg Pages and cleanup language - fediverse/fep - Codeberg.org created to update FEP-888d. In particular this update includes the following changes:

  • Introductory sections use more precise language now
  • Mention the static site as something that now exists aside from the repo itself
  • Update the mappings to use the static site instead of the repo where feasible (the repo/raw is still used for the catch-all fallback)
    • Fix potential accidental doubling of file extensions with content negotiation
  • Clarified how defining terms in a FEP can work with either a dedicated context identifier or with the FEP identifier itself
  • Changed exampleC to refer to datetimes since that’s a more commonly useful thing to do
  • Fix mention of scripts/make_definitions.py to instead refer to the FEP subresource (since it was moved out of the FEP process-wide scripts folder a long time ago)
  • Add ap-miscellany and uddp to references

TODO: update script to selectively load context.jsonld instead of always doing it
TODO: figure out how to catch context.jsonld in .htaccess rules separately from term definitions
TODO: rerun make_definitions.py for updated term definition of exampleC
TODO: PR .htaccess changes to w3id service on Github

2 Likes

Draft PR updated. Two noteworthy changes:

  • .htaccess rules were simplified and cleaned up
  • Clarify what FEP authors need to do to make use of the .htaccess rules

In cleaning up the .htaccess rules, some functional changes were made:

  • URL hacking with .html and content negotiation with Accept: text/html used to point to script-generated HTML files with RDFa markup preserved. This has been dropped; these requests now map to the site-generated HTML pages. Unfortunately, these site-generated HTML pages have a few issues that prevent proper RDFa parsing, but maybe these issues can be fixed in the future.
  • FEP identifiers regex capture is now more tightly defined to only capture FEP slugs according to our current rules – 4 hexadecimal digits, not arbitrary-length alphanumeric sequences. This was done to fix a bug where the FEP subresource rule was capturing resources that aren’t FEP subresources; for example, https://fediverse.codeberg.page/fep/final/ is not a FEP.
  • The generic catch-all rule no longer points to repo/raw paths. It is now pointing to Codeberg Pages like all the other rules.

I want to discuss the FEP site’s HTML pages and the rendering behavior of the static site generation. Right now, people using make_definitions.py end up in a situation where there are two HTML pages they could be pointing to:

  1. https://fediverse.codeberg.page/fep/fep/888d/exampleB/ – generated by the static site generator, presumably from the README.md at https://codeberg.org/fediverse/fep/src/branch/main/fep/888d/exampleB/README.md
  2. https://fediverse.codeberg.page/fep/fep/888d/exampleB/exampleB.html – generated by the definitions script

I’d like to have a single HTML page being served gracefully, but currently the former has some issues. Looking at the source code makes it clear. This is the Markdown currently generated by the definitions script:

# exampleB

URI
: `https://w3id.org/fep/888d/exampleB`

Label
: has example relation B with

Comment
: A property that links to another node on the graph (for example, another object)

Domain
: [SomeType](https://w3id.org/fep/888d/SomeType)

Range
: An object (@id)

Required
: No

Functional
: No

Is defined by
: [FEP-888d](https://w3id.org/fep/888d)


## Examples

Example of a SomeType with properties exampleA, exampleB, exampleC

{
  "@context": "https://w3id.org/fep/888d",
  "@type": "SomeType",
  "exampleA": true,
  "exampleB": "https://example.com/some-object",
  "exampleC": [1, 1]
}

Which generates this HTML:

<article class="md-content__inner md-typeset">
<h1 id="exampleb">exampleB<a class="headerlink" href="#exampleb" title="Permanent link">¶</a></h1>
<p>URI
: <code>https://w3id.org/fep/888d/exampleB</code></p>
<p>Label
: has example relation B with</p>
<p>Comment
: A property that links to another node on the graph (for example, another object)</p>
<p>Domain
: <a href="https://w3id.org/fep/888d/SomeType">SomeType</a></p>
<p>Range
: An object (@id)</p>
<p>Required
: No</p>
<p>Functional
: No</p>
<p>Is defined by
: <a href="https://w3id.org/fep/888d">FEP-888d</a></p>
<h2 id="examples">Examples<a class="headerlink" href="#examples" title="Permanent link">¶</a></h2>
<p>Example of a SomeType with properties exampleA, exampleB, exampleC</p>
<div class="highlight"><pre id="__code_0"><span></span><code>{
  "@context": "https://w3id.org/fep/888d",
  "@type": "SomeType",
  "exampleA": true,
  "exampleB": "https://example.com/some-object",
  "exampleC": [1, 1]
}
</code></pre></div></article>

vs:

<!DOCTYPE html>
<html>
<head>
<title>exampleB</title>
</head>
<body>
<section id="exampleB" resource="https://w3id.org/fep/888d/exampleB" typeof="owl:ObjectProperty">
<h1>exampleB</h1>
<dl>
<dt>URI</dt>
<dd><code>https://w3id.org/fep/888d/exampleB</code></dd>
<dt>Label</dt>
<dd lang="en" property="rdfs:label">has example relation B with</dd>
<dt>Comment</dt>
<dd lang="en" property="rdfs:comment">A property that links to another node on the graph (for example, another object)</dd>
<dt>Domain</dt>
<dd><a href="https://w3id.org/fep/888d/SomeType" property="rdfs:domain">SomeType</a></dd>
<dt>Range</dt>
<dd property="rdfs:range" resource="rdfs:Resource">An object (@id)</dd>
<dt>Required</dt>
<dd content="0" datatype="xsd:nonNegativeInteger" property="owl:minCardinality">No</dd>
<dt>Functional</dt>
<dd>No</dd>
<dt>Is defined by</dt>
<dd><a href="https://w3id.org/fep/888d" property="rdfs:isDefinedBy">FEP-888d</a></dd>
</dl>
<pre title="Example of a SomeType with properties exampleA, exampleB, exampleC">
<code>
{
  "@context": "https://w3id.org/fep/888d",
  "@type": "SomeType",
  "exampleA": true,
  "exampleB": "https://example.com/some-object",
  "exampleC": [1, 1]
}
</code>
</pre>
</section>
</body>
</html>

We note that:

  • The id is forcibly lowercased instead of preserving the case
  • The dt/dd structure is lost entirely, indicating that there is no support for the Markdown definition lists extension

I think on my end I can do the following:

  • Make make_definitions.py stop outputting README.md – this was always a hack to make the Codeberg repo viewer show useful information without having to click into a specific term definition format.
  • Make make_definitions.py start outputting HTML that gets served on the FEP site a bit more “natively”… but I’m not sure what exactly needs to go into this. The alternative is to output the “plain-looking” HTML as index.html so something gets served correctly, but it would be nice to have some way of hooking into the themed/generated site so that the headers/navigation/etc are visible.

Question to @silverpill I guess: are you aware of a way to have the static site generator take HTML content as input instead of Markdown content? Otherwise, if there’s no good answer here, I guess we can just live with “plain” HTML term definitions like the ones currently live on pages like https://fediverse.codeberg.page/fep/fep/888d/exampleB/exampleB.html.

The generator will recognise HTML in its input and pass it through mostly unchanged.

I just tried copying your <section> ... </section> block into a FEP and running the generator locally. It appeared with the id and dt/dd parts unchanged. The only thing the generator changed was to add an id attribute to the <pre> tag:

<pre title="Example of a SomeType with properties exampleA, exampleB, exampleC" id="__code_exampleB">

So if you wrap your generated HTML in markdown, maybe it’ll do what you want.

2 Likes

We can enable the definition lists extension, that only requires one line in mkdocs.yml: https://squidfunk.github.io/mkdocs-material/setup/extensions/python-markdown/#definition-lists

Ah, interesting, I’ll play around locally with def_list and attr_list to see if it’s feasible to support a more Markdown-y syntax for term definition blocks (instead of having people copy-paste the HTML from fep-888d.md and using it as a template). That should let people do something like this:

## Terms defined

<div
  id="exampleProperty"
  resource="https://w3id.org/fep/xxxx/exampleProperty"
  typeof="owl:ObjectProperty">

### `exampleProperty`

Label
: has example relation with {property="rdfs:label" lang="en"}

Comment
: An example of an object property {property="rdfs:comment" lang="en"}

Domain
: [SomeType](https://w3id.org/fep/888d/SomeType){property="rdfs:domain"}

Range
: Collection (@id) {property="rdfs:range" resource="as:Collection"}

Required
: No {property="owl:minCardinality" content="0" datatype="xsd:nonNegativeInteger"}

Functional
: Yes {property="owl:maxCardinality" content="1" datatype="xsd:nonNegativeInteger"}

Is defined by
: [FEP-xxxx](https://w3id.org/fep/xxxx){property="rdfs:isDefinedBy"}

#### Examples

...

</div>

Here, “Domain” is a demo using standard links with href, no support for prefixes. “Range” is a demo using resource attr with support for prefixes. I think the relative ease of writing term definitions like this makes it worth supporting, at the cost of enabling two extensions (def_list and attr_list). Previously it wasn’t feasible due to Codeberg’s Markdown viewer not supporting this syntax.

Two shortcomings:

  1. Most Markdown parsers don’t render <section> elements, instead relying on headers to form “implicit sections”. This means it’s unavoidable to at least introduce a single wrapping element like I used <div> here. It could also maybe be an <article>; it doesn’t have to be any specific property beyond just wrapping the definition.

  2. I’m a little wary about portability because attr_list support is not universally supported among alternative Markdown parsers or static site generators, if we ever decide to move away from mkdocs-material for any reason in the future. A sub-concern is that the attr_list extension of python-markdown is in maintenance mode, per Attribute Lists Extension - Python-Markdown – maybe this isn’t a huge problem as long as it works, but it could be an issue in the future as well. This is probably not a blocker, though.

One stretch goal I considered: advertising rel=alternate links pointing from each term definition format to other formats of the same term definition. I think this should be feasible for script-generated HTML pages, but not for site-generated HTML pages, since there isn’t a good way to hook into the <head> from a content file. It’s also not possible to serve Link headers dynamically via Codeberg Pages as far as I can tell, so that’s not an option. I think I might have to give up on declaring alternate formats.