adiwg / mdEditor

Web application for writing metadata, an ADIwg project
https://www.mdeditor.org
GNU General Public License v3.0
45 stars 25 forks source link

Load Custom Profiles from URL #584

Open jwaspin opened 1 year ago

jwaspin commented 1 year ago

Loading Dynamic Profiles

The current dynamic profile loading process includes the NGGDPP profiles by default. This is not desirable so we want to decouple those profiles from the core profiles.

Using an input box on the profiles' settings page, we can load a secondary set of profiles dynamically, which would allow for the use of anyone's custom profiles, so long as they are formatted as a proper manifest.json file.

Custom profiles loaded from the URL should be stored the same way other custom profiles are stored - noting that this is separate from how the core profiles are loaded.

Checklist:

Profile manifest file

A profile manifest file is a JSON file containing an array of one or more references to mdEditor profile definitions. The format is as follows:

[
  {
    "name": "definition name",
    "url": "url to profile definition"
  }
]

Example manifest file

[
  {
    "name": "AK Region Project Profile",
    "url": "https://usfws.github.io/ak-md-profiles/ak-proj-profile.json"
  },
  {
    "name": "AK Region Product Profile",
    "url": "https://usfws.github.io/ak-md-profiles/ak-proj-profile.json"
  }
]
jwaspin commented 1 year ago

This feature is complete but mdProfiles and mdKeywords need to be updated before merging this PR.

hmaier-fws commented 11 months ago

@jwaspin I noticed two problems.

1) Thesaurus

I tried loading a manifest file from another location (https://raw.githubusercontent.com/hmaier-fws/ak-md-profiles/dev/ak-manifest.json) and received the following error:

TypeError: e.thesauri is not iterable (cannot read property undefined) at e.loadCustomProfilesFromUrl

It looks like it's trying to read thesauri. But not all custom profiles will have thesauri. I tried it with another manifest that pointed to profile definitions that had a null thesaurus array (https://raw.githubusercontent.com/hmaier-fws/ak-md-profiles/dev/ak-manifest2.json). That did work.

A check needs to be added that allows a definition without a thesaurus to be loaded. A profile definition file is not required to contain all sections.

2) URL hash

Loading the query parameter works fine from "/dashboard?loadProfilesFrom=" but it won't work from the hashed url "/#/dashboard?loadProfilesFrom=". The production version of the editor is served using a hashed url (https://go.mdeditor.org/#/).

jwaspin commented 10 months ago

@hmaier-fws Fixed both issues.