Skip to content

Commit

Permalink
Merge pull request #99 from OBOFoundry/allow-303-status
Browse files Browse the repository at this point in the history
Add support for 303 See Other status, closes #94
  • Loading branch information
jamesaoverton committed Nov 24, 2015
2 parents 6f99884 + 5950feb commit c059b6d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
3 changes: 3 additions & 0 deletions config/obo.yml
Expand Up @@ -39,13 +39,15 @@ entries:
# Term redirects for CHEBI
- regex: ^/obo/CHEBI_(\d+)$
replacement: http://www.ebi.ac.uk/chebi/searchId.do?chebiId=CHEBI:$1
status: see other
tests:
- from: /CHEBI_15377
to: http://www.ebi.ac.uk/chebi/searchId.do?chebiId=CHEBI:15377

# Term redirects for HAO
- regex: ^/obo/HAO_(\d+)$
replacement: http://api.hymao.org/api/ontology/ontology_class/HAO_$1
status: see other
tests:
- from: /HAO_0000000
to: http://api.hymao.org/api/ontology/ontology_class/HAO_0000000
Expand All @@ -54,6 +56,7 @@ entries:
# Match digits or UniProt ID, see http://www.uniprot.org/help/accession_numbers
- regex: ^/obo/PR_(\d+|[OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2})$
replacement: http://pir.georgetown.edu/cgi-bin/pro/entry_pro?id=PR_$1
status: see other
tests:
- from: /PR_000000001
to: http://pir.georgetown.edu/cgi-bin/pro/entry_pro?id=PR_000000001
Expand Down
4 changes: 4 additions & 0 deletions tools/config.schema.yml
Expand Up @@ -70,6 +70,10 @@ mapping:
pattern: /^(https?|ftp)\:\/\/.+/
required: true
unique: false
"status":
type: str
required: false
pattern: /^(permanent|temporary|see other)$/
"tests":
type: seq
required: false
Expand Down
2 changes: 1 addition & 1 deletion tools/examples/test2.htaccess
Expand Up @@ -4,4 +4,4 @@

RedirectMatch temp "(?i)^/obo/test2/project$" "http://example.org/project.html"
RedirectMatch temp "(?i)^/obo/test2/branches/(.*)$" "http://example.org/branches/$1"
RedirectMatch temp "(?i)^/obo/test2/TEST_(\d+)$" "http://example.org/about/TEST_$1"
RedirectMatch seeother "(?i)^/obo/test2/TEST_(\d+)$" "http://example.org/about/TEST_$1"
1 change: 1 addition & 0 deletions tools/examples/test2.yml
Expand Up @@ -25,6 +25,7 @@ entries:

- regex: (?i)^/obo/test2/TEST_(\d+)$
replacement: http://example.org/about/TEST_$1
status: see other
tests:
- from: /TEST_1234
replacement: http://example.org/about/TEST_1234
8 changes: 5 additions & 3 deletions tools/test.py
Expand Up @@ -160,10 +160,12 @@ def process_entry(base_url, i, entry):
# Validate status code.
status = '302'
if 'status' in entry:
if entry['status'] == 'temporary':
status = '302'
elif entry['status'] == 'permanent':
if entry['status'] == 'permanent':
status = '301'
elif entry['status'] == 'temporary':
status = '302'
elif entry['status'] == 'see other':
status = '303'
else:
raise ValueError('Invalid status "%s" for entry %d' % (entry['status'], i))
test['status'] = status
Expand Down
6 changes: 4 additions & 2 deletions tools/translate-entries.py
Expand Up @@ -151,14 +151,16 @@ def process_entry(base_url, i, entry):
# Validate status code
status = 'temporary'
if 'status' in entry:
if entry['status'] in ('temporary', 'permanent'):
if entry['status'] in ('permanent', 'temporary', 'see other'):
status = entry['status']
else:
raise ValueError('Invalid status "%s" for entry %d' % (entry['status'], i))

# Note: Apache config uses "temp" instead of "temporary"
# Switch to Apache's preferred names
if status == 'temporary':
status = 'temp'
elif status == 'see other':
status = 'seeother'

return 'RedirectMatch %s "%s" "%s"' % (status, source, replacement)

Expand Down

0 comments on commit c059b6d

Please sign in to comment.