about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--gn/data/group.scm7
-rw-r--r--web/gn-uri.scm36
2 files changed, 25 insertions, 18 deletions
diff --git a/gn/data/group.scm b/gn/data/group.scm
index 1505b21..3d31a0b 100644
--- a/gn/data/group.scm
+++ b/gn/data/group.scm
@@ -12,12 +12,13 @@
             get-group-links
             ))
 
-(define (get-group-links gnid)
-  "Return all the URIs that link to group info, e.g. for Mus_musculus"
+(define (get-group-links gnid func)
+  "Return all the URIs that link to group info, e.g. for Mus_musculus.
+   Uses func to transform the link - if required."
   (let ([recs (car (cdr (compile-groups-meta)))]
         [uri (mk-gnid gnid)])
     (filter-map
      (lambda (r) (if (string=? (second r) uri)
-                     `(("ref" . ,(mk-id (car r))))
+                     (func (car r))
                      #f)) recs)
   ))
diff --git a/web/gn-uri.scm b/web/gn-uri.scm
index 951b24d..de70ea7 100644
--- a/web/gn-uri.scm
+++ b/web/gn-uri.scm
@@ -1,5 +1,7 @@
 (define-module (web gn-uri)
   #:use-module (ice-9 string-fun)
+  #:use-module (ice-9 match)
+  #:use-module (ice-9 regex)
 
   #:export (
             get-version
@@ -36,37 +38,41 @@
 (define get-version
   "2.0")
 
-; (define (base-url)
+; (define base-url
 ;  "https://luna.genenetwork.org")
 
 ;(define (prefix)
 ;  "Build the API URL including version"
-;  (string-append (base-url) "/api/v" get-version))
+;  (string-append base-url "/api/v" get-version))
 
-(define (base-url)
+(define base-url
   "http://localhost:8091")
 
-(define uri-base-url
+(define uri-base-url ; always points to genenetwork.org!
   "http://genenetwork.org")
 
 (define (prefix)
   "Build the API URL including version"
-  (base-url))
+  base-url)
 
 (define* (mk-url postfix #:optional (ext ""))
-  "Add the path to the API URL"
-  (string-append (prefix) "/" postfix ext))
+  "Makes a fully qualified URL by adding the path (postfix+ext) to the API URL.
+   If there is an existing http+hostname no prefix is added"
+  (match (string-match "^http:" postfix)
+    [ #f (string-append (prefix) "/" postfix ext)]
+    [ _ (string-append postfix ext)]
+    ))
 
 (define* (mk-uri postfix)
-  "Add the path to the GN URI"
+  "Add the path to the GN URI. A URI always points to http://genenetwork.org/"
   (string-append uri-base-url "/" postfix))
 
 (define (mk-html path)
-  "Create a pointer to HTML documentation"
-  (string-append (base-url) "/" path ".html"))
+  "Create a pointer to API HTML documentation"
+  (mk-url path ".html"))
 
 (define (mk-doc path)
-  "Create a pointer to HTML documentation"
+  "Create a pointer to API HTML documentation (doc infix)"
   (mk-html (string-append "doc/" path)))
 
 (define (mk-meta path)
@@ -74,12 +80,15 @@
   (mk-url path ".meta.json"))
 
 (define (mk-data path)
-  "Create a JSON URL for the API path"
+  "Append .json for the API path. If it is not a full URL it will prepend the host"
   (mk-url path ".json"))
 
 (define (mk-term postfix)
   (mk-html (string-append "term" "/" postfix)))
 
+(define (mk-predicate postfix)
+  (mk-html (string-append "predicate" "/" postfix)))
+
 (define (mk-id postfix)
   "Expand URL to make $api/id/identifier.
    If postfix is a path it will only apply the last element"
@@ -89,6 +98,3 @@
   "Expand URL to make http://genenetwork.org/id/identifier.
    If postfix is a path it will only apply the last element"
   (mk-uri (string-append "id" "/" (url-parse-id postfix))))
-
-(define (mk-predicate postfix)
-  (mk-html (string-append "predicate" "/" postfix)))