All ferenda projects contains a built-in web application. This app provides navigation, document display and search.
During development, you can just ferenda-build.py runserver
. This starts up a single-threaded web server in the foreground with the web application, by default accessible as http://localhost:8000/
You can also run the web application under any WSGI server, such as mod_wsgi, uWSGI or Gunicorn. ferenda-setup
creates a file called wsgi.py
alongside ferenda-build.py
which is used to serve the ferenda web app using WSGI. This is the contents of that file:
from ferenda.manager import make_wsgi_app
inifile = os.path.join(os.path.dirname(__file__), "ferenda.ini")
application = make_wsgi_app(inifile=inifile)
In your httpd.conf:
WSGIScriptAlias / /path/to/project/wsgi.py
WSGIPythonPath /path/to/project
<Directory /path/to/project>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
The ferenda web app consists mainly of static files. Only search and API requests are dynamically handled. By default though, all static files are served by the ferenda web app. This is simple to set up, but isn't optimal performance-wise.
Just run gunicorn wsgi:application
In keeping with Linked Data principles, all URIs for your documents should be retrievable. By default, all URIs for your documents start with http://localhost:8000/res
(e.g. http://localhost:8000/res/rfc/4711
-- this is controlled by the url
parameter in ferenda.ini
). These URIs are retrievable when you run the built-in web server during development, as described above.
For each resource, use the Accept
header to retrieve different versions of it:
curl -H "Accept: text/html" http://localhost:8000/res/rfc/4711
returnsrfc/generated/4711.html
curl -H "Accept: application/xhtml+xml" http://localhost:8000/res/rfc/4711
returnsrfc/parsed/4711.xhtml
curl -H "Accept: application/rdf+xml" http://localhost:8000/res/rfc/4711
returnsrfc/distilled/4711.rdf
curl -H "Accept: text/turtle" http://localhost:8000/res/rfc/4711
returnsrfc/distilled/4711.rdf
, but in Turtle formatcurl -H "Accept: text/plain" http://localhost:8000/res/rfc/4711
returnsrfc/distilled/4711.rdf
, but in NTriples format
You can also get extended information about a single document in various RDF flavours. This extended information includes everything that ~ferenda.DocumentRepository.construct_annotations
returns, i.e. information about documents that refer to this document.
curl -H "Accept: application/rdf+xml" http://localhost:8000/res/rfc/4711/data
returns a RDF/XML combination ofrfc/distilled/4711.rdf
andrfc/annotation/4711.grit.xml
curl -H "Accept: text/turtle" http://localhost:8000/res/rfc/4711/data
returns the same in Turtle formatcurl -H "Accept: text/plain" http://localhost:8000/res/rfc/4711/data
returns the same in NTriples formatcurl -H "Accept: application/json" http://localhost:8000/res/rfc/4711/data
returns the same in JSON-LD format.
Each docrepo exposes information about the data it contains through it's dataset URI. This is a single URI (controlled by ~ferenda.DocumentRepository.dataset_uri
) which can be queried in a similar way as the document resources above:
curl -H "Accept: application/html" http://localhost/dataset/rfc
returns a HTML view of a Table of Contents for all documents (seetoc
)curl -H "Accept: text/plain" http://localhost/dataset/rfc
returnsrfc/distilled/dump.nt
which contains all RDF statements for all documents in the repository.curl -H "Accept: application/rdf+xml" http://localhost/dataset/rfc
returns the same, but in RDF/XML format.curl -H "Accept: text/turtle" http://localhost/dataset/rfc
returns the same, but in turtle format.
In some environments, it might be difficult to set the Accept header. Therefore, it's also possible to request different versions of a resource using a file extension suffix. Ie. requesting http://localhost:8000/res/base/123.ttl
gives the same result as requesting the resource http://localhost:8000/res/base/123
using the Accept: text/turtle
header. The following extensions can be used
Content-type | Extension |
---|---|
application/xhtml+xml | .xhtml |
---------------------- | --------- |
application/rdf+xml | .rdf |
---------------------- | --------- |
text/turtle | .ttl |
---------------------- | --------- |
text/plain | .nt |
---------------------- | --------- |
application/json | .json |
See also restapi
.