SDS-Labels is a static web-based application for generating shipping labels to be used by the Statewide Delivery System, a service managed and coordinated by the State Library of Ohio. More information about the service can be found on the State Library's website.
SDS Labels uses the following libraries:
TaffyDB consumes a JSON file, output.json, of the shipping label data and creates a JavaScript-like database of the entries:
// Initialise TaffyDB from JSON file
function initDB() {
let xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (this.readyState === 4 && this.status === 200) {
data = JSON.parse(this.responseText);
db = TAFFY(data);
db.sort("name"); // Alphabetize
loadOptions();
}
};
xmlhttp.open("GET", "output.json", true);
xmlhttp.send();
}If the JSON structure is malformed, the entries will not populate the dropdown menus. If the dropdown menus are empty, verify the structure of the JSON data, and correct it. A single label object will look like the following:
{
"id": 9999,
"libid": 900,
"name": "A Single Library",
"address": "123 Very Nice Rd.",
"city": "Columbus",
"state": "OH",
"zip": 43201,
"seo": "XXX",
"hub": "ZZZ",
"route": 9999,
"latitude": "39.98153098",
"longitude": "-82.99600477",
"is_primary": true
}The output.json content may occasionally need to be updated to add entries as new libraries enter the program. When adding a new library, append their new entry to the end of the output.json file. You can omit the id field when adding a new entry; the workflow (below) will assign one automatically.The critical thing to remember is that the id value must be unique.
When adding a branch location for an existing library in the list, you can duplicate the libid value for the branch, but the is_primary value must be set to false for the new branch. Only 1 entry per libid can be flagged as true in the is_primary field.
A GitHub Actions workflow, .github/workflows/sort-libraries.yml, automatically sorts output.json alphabetically by library name each time a change to output.json or sort_libraries.py is pushed to main. The sort is performed by sort_libraries.py:
python sort_libraries.py output.jsonContinue to append the new entry to the bottom of output.json without an id, push to main, and the workflow will normalize the file, automatically assigning a new id for you.