diff options
author | Adam Novak | 2020-04-17 11:35:49 -0700 |
---|---|---|
committer | Adam Novak | 2020-04-17 11:35:49 -0700 |
commit | ea55ccc246a032e9c32e0899785da068be2e8dc5 (patch) | |
tree | 209f5f35972d640e4d838562eaeec6c703c6a08d | |
parent | e823bf1b464fcb8f52a91dcaebaf5b82cafc06dc (diff) | |
download | bh20-seq-resource-ea55ccc246a032e9c32e0899785da068be2e8dc5.tar.gz bh20-seq-resource-ea55ccc246a032e9c32e0899785da068be2e8dc5.tar.lz bh20-seq-resource-ea55ccc246a032e9c32e0899785da068be2e8dc5.zip |
Call URLs IRIs because that's more general
-rw-r--r-- | bh20simplewebuploader/main.py | 20 | ||||
-rw-r--r-- | bh20simplewebuploader/templates/form.html | 4 |
2 files changed, 12 insertions, 12 deletions
diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 0b1616b..253f0e5 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -49,11 +49,11 @@ def name_to_label(field_name): return string.capwords(field_name.replace('_', ' ')) -def is_url(string): +def is_iri(string): """ - Return True if the given string looks like a URL, and False otherwise. + Return True if the given string looks like an IRI, and False otherwise. - Used for finding type URLs in the schema. + Used for finding type IRIs in the schema. Right now only supports http(s) URLs because that's all we have in our schema. """ @@ -101,7 +101,7 @@ def generate_form(schema): for field_name, field_type in by_name.get(type_name, {}).get('fields', {}).items(): # For each field - ref_url = None + ref_iri = None if not isinstance(field_type, str): # If the type isn't a string @@ -113,15 +113,15 @@ def generate_form(schema): # by the format, but if they occur, we might as well try to # handle them. if isinstance(predicate, str): - if is_url(predicate): - ref_url = predicate + if is_iri(predicate): + ref_iri = predicate else: # Assume it's a dict. Look at the fields we know about. for field in ['_id', 'type']: field_value = predicate.get(field, None) - if isinstance(field_value, str) and is_url(field_value) and ref_url is None: + if isinstance(field_value, str) and is_iri(field_value) and ref_iri is None: # Take the first URL-looking thing we find - ref_url = field_value + ref_iri = field_value break @@ -146,8 +146,8 @@ def generate_form(schema): record['id'] = '.'.join(parent_keys + [field_name]) record['label'] = name_to_label(field_name) record['required'] = not optional and not subtree_optional - if ref_url: - record['ref_url'] = ref_url + if ref_iri: + record['ref_iri'] = ref_iri if field_type == 'string': record['type'] = 'text' # HTML input type elif field_type == 'int': diff --git a/bh20simplewebuploader/templates/form.html b/bh20simplewebuploader/templates/form.html index df66e8c..9cfb60f 100644 --- a/bh20simplewebuploader/templates/form.html +++ b/bh20simplewebuploader/templates/form.html @@ -224,8 +224,8 @@ <label for="{{ record['id'] }}"> {{ record['label'] }} {{ "*" if record['required'] else "" }} - {% if 'ref_url' in record %} - <a href="{{ record['ref_url'] }}" title="More Info" target="_blank">?</a> + {% if 'ref_iri' in record %} + <a href="{{ record['ref_iri'] }}" title="More Info" target="_blank">?</a> {% endif %} </label> <input type="{{ record['type'] }}" id="{{ record['id'] }}" name="{{ record['id'] }}" {{ "required" if record['required'] else "" }}> |