https://github.com/dnlbauer/django-signposting
A Django middleware that adds FAIR signposting headers to HTTP responses, making your web application more FAIR.
https://github.com/dnlbauer/django-signposting
django fair fair-data links linkset rfc8288 signposting
Last synced: 11 months ago
JSON representation
A Django middleware that adds FAIR signposting headers to HTTP responses, making your web application more FAIR.
- Host: GitHub
- URL: https://github.com/dnlbauer/django-signposting
- Owner: dnlbauer
- License: mit
- Created: 2024-08-15T20:18:41.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-18T16:25:02.000Z (over 1 year ago)
- Last Synced: 2024-11-18T16:58:50.770Z (over 1 year ago)
- Topics: django, fair, fair-data, links, linkset, rfc8288, signposting
- Language: Python
- Homepage:
- Size: 42 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/dnlbauer/django-signposting/actions/workflows/python-package.yml)
# FAIR signposting middleware for Django
`django_signposting` is a Django middleware library that facilitates the addition of
FAIR signposting headers to HTTP responses.
This middleware helps in making your data more FAIR (Findable, accessible, interoperable, reuseable) by
embedding signposting headers in responses, guiding clients to relevant resources linked to the response content.
Based on the [Signposting](https://github.com/stain/signposting) library.
## Features
- Automatically adds signposting headers to HTTP responses.
- Signposts can be added manually or automatically be parsed from JSON-LD/schema.org
- Supports multiple relation types with optional media type specification.
- Easily integrable with existing Django applications.
### Signposts are formatted and added as Link headers
```bash
curl -I http://localhost:8000
HTTP/2 200
...
link: ; rel="type" ,
; rel="author" ,
; rel="item" ; type="application/zip"
```
## Installation
```bash
pip install django-signposting
```
## Usage
### Automatic parsing of JSON-LD
The library can automatically add signposts to web pages that already make
metadata available via JSON-LD in HTML via `` tags, i.e.:
```HTML
<!DOCTYPE html>
<html>
<head>
<script type="application/ld+json">{"@context": "https://schema.org", "@type": ["WebSite", "Dataset"], "author": {"@type": "Person", "name": "Daniel Bauer", "url": "https://orcid.org/0000-0001-9447-460X"}, "description": "A dataset of things.", "hasPart": [{"@type": "ImageObject", "encodingFormat": "image/png", "url": "http://example.com/image.png"}, {"@type": "ImageObject", "encodingFormat": "image/png", "url": "http://example.com/image2.png"}], "license": {"@type": "CreativeWork", "name": "CC BY 4.0", "url": "https://creativecommons.org/licenses/by/4.0/"}, "name": "My Dataset", "sameAs": [{"@type": "MediaObject", "contentUrl": "https://example.com/download.zip", "encodingFormat": "application/zip"}, {"@type": "MediaObject", "contentUrl": "https://example.com/metadata.json"}], "url": "https://example.com"}
Hello, world!