Skip to content

StateLibraryofOhio/SDS-Labels

Repository files navigation

SDS-Labels

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.

Tools Used

SDS Labels uses the following libraries:

Notes on Usage

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.

Automated Sorting

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.json

Continue 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.

About

Labels for the Statewide Delivery Service

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors