The Vircadia inventory app has been created to work without the need of a database server. Instead it loads a database file into memory and uses a javascript database application called pouchDB. pouchDB pulls the database from the Bazaar/inventoryDB folder. This script is used to help pouchDB create the database file. In order for the database to be up to date, you must run this script each time the repo is changed. You will download the DB file and upload it to the inventoryDB folder in the repository.
You must ensure that this script has read access to all the Bazaar folders and files on the internet. The script does not work against local copies. If your distribution is on an Amazon S3 bucket you can make the entire bucket readonly to the public.
1) Open your bucket in the AWS S3 interface.{ "Version": "2012-10-17", "Statement": [ { "Sid": "PublicReadGetObject", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::#bucket#/*" } ] }
The script searches recursively for an index.json. The index.json tells the script what folders exist in each subfolder provided. When the app does not find an index.json in a folder it looks for a resource.json file. The resource.json file tells the app what kind of resource is in this folder and provides details for accessing it. Categories and subcategories are created from the index.json files. These categories are populated with resources based upon what is provided in the resource.json files. All this information is written to an in memory database. It's this database that we will export and upload to your file repository.
The database holds two types of records, folder and resource. The fields are as below:
var folders = { "_id": "bazaar", "r_type": "folder"; "name": "Bazaar", "parent": "repo", "type": "index", "path": "https://" }; var resource = { "_id": "kim", "r_type": "resource"; "name": "Kim", "parent": "Avatars", "type": "avatar", "path": "https://", "tags": ["Female","Avatar"] };
Click on the button provided and the script will recurse the repository you provide it. Note that this only works if you have followed the Vircadia pattern of placing an index.json to define the folders and the package.json to define the assets. Only valid JSON will do. It will generate a database and export the database in a gzip file. You will need to upload this file into the inventoryDB folder.
Enter the path to your repository and press the Download button... It may take a few minutes before the download begins. Do not click on the button more than once unless you want to download the export several times.
Place the gzip database file in the Bazaar/inventoryDB folder. You can use the link below to test the database once you have uploaded it to your repository.
Make sure you update the $repo variable in the demo.html file before you test it... otherwise it may fail or you will not be looking at your repo but mine... which may go away.
Demo Page