Workflow 3
Export 3D procedural models, using python, from Fedora repository to 3D Web Viewer.
Scripts
Read_fedora.py
Command line script to print out containers from Fedora repository
Near the top of the script, ensure this line defines the URL at which your Fedora Repository is accessible:
fedora = "http://localhost:8080/fedora/rest"
Then run the script as follows:
./read_fedora.py [container_path(default="/")]
Running the script with no argument will display the containers present at the root of the Fedora repository. The script will print a message suggesting how to pass container paths in this case.
This script was written to determine how to retrieve information from the Fedora repository based on RDF relationships. The python RDFLib library understands multiple RDF formats, including the Turtle format returned to requests to Fedora. This script only prints the objects of tuples which use one Turtle predicate, ldp#contains , but the code could easily be modified to handle other RDF relationships including those from PCDM, Dublin Core, and Europeana Data Model. The code written to parse the Turtle responses is based on the RDFLib Getting Started examples.
Note the script is not programmed to handle paths for Binary resources, such as 3D model, image, and text files. Entering paths for these will result in an error like rdflib.plugin.PluginException: No plugin registered for (image/tiff, <class 'rdflib.parser.Parser'>) These plugins could be installed if required. .
Bottle Webapp
Bottle web app to browse Fedora repository containers
The web app may be run as a standalone program served at port 3000 (typically for local development), or via a WSGI-compatible web server such as via Apache + mod_wsgi.
Near the top of fedora.py , ensure this line defines the URL at which your Fedora Repository is accessible:
app.config["fedora"] = "http://localhost:8080/fedora/rest"
The app may be configured to serve from a sub-URI by defining the sub-URI in a settings.ini file placed in the same directory as the example settings.example.ini file and app.wsgi . If settings.ini is not present, the app will assume it is running at the root of the host's web space.
Standalone
./run.py
Logging and errors are output to this terminal.
Visit http://localhost:3000 .
WSGI
The web app will deploy to any WSGI-compatible web server.
We provide an example configuration of serving the app at the /fedora-viewer/ sub-URI via Apache + mod_wsgi here:
settings.ini:
[fedora] suburi=fedora-viewer RedirectMatch ^/fedora-viewer$ /fedora-viewer/ WSGIDaemonProcess fedora user=apache group=apache processes=1 threads=5 WSGIScriptAlias /fedora-viewer /var/local/www/python/keeping-data-alive/fedora/bottle-webapp/app.wsgi <Location /fedora-viewer/> Require all granted </Location> <Directory /var/local/www/python/keeping-data-alive/fedora/bottle-webapp> WSGIProcessGroup fedora WSGIApplicationGroup %{GLOBAL} Require all granted </Directory>
The Bottle web app was written to demonstrate the ability to retrieve and browse the same RDF data from Fedora, as well as identify 3D model files and render them for viewing within a browser. The page was written with Bootstrap so it is mobile-friendly.
Rendering the 3D models is achieved by parsing the list of resources within a LDP container for identifiers indicating file types by extensions, e.g. .dae , .obj , .jpg , .json , etc. When a .dae or .obj file is encountered, the page will render a three.js viewer and load the model and any accompanying textures. Collada ( .dae ) files contain paths to their textures and three.js will load them automatically. .obj files however use an addition .mtl file to render their textures. three.js supports loading textures for application to .obj models, but this has not been implemented yet. The necessary MTLLoader.js library has been included in the JavaScript files and implementation would be based on the three.js OBJLoader + MTLLoader example. In the mean time, all image texture files present alongside a .obj file are loaded and randomly applied to the faces of the model. Note that TIFF images are not supported by three.js.
The Bottle web app also is not programmed to handle loading Binary resources when requested through the buttons used to browse the Fedora repository. Clicking these links will return Error: 500 Internal Server Error messages.