Uploaded image for project: 'Medici'
  1. Medici
  2. MMDB-1861

Clowder links generated by Javascript missed web path prefix (such as /medici)

XMLWordPrintableJSON

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Normal Normal
    • 2.0
    • None
    • None
    • None

      Found while testing searching in user metadata, in the search result table, the links to datasets or files were generated by the JavaScript explicitly with code using window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '') + "/datasets/" + ...

      This worked fine if Clowder's path has no prefix, such as "http://host1", however, if the web root has some prefix, such as http://clowder.ncsa.illinois.edu/medici/, then the link does not contain the "/medici/" part. Clicking it leads to "page not found", or gets redirected to a generic page.

      In /public/javascripts, searchUserMetadata.js and collectionDatasetsList.js have this issue. Rui had a fix for the former one, in https://opensource.ncsa.illinois.edu/stash/projects/MMDB/repos/medici-play/commits/6075ac374c0d7ab27db2444baa06fd009e800e97, but that's in a branch, not in "develop" yet.

      A tested solution is:
      1) add a JavaScript global variable "WEB_ROOT" in app/views/main.scala.html, assign it the routes to the Clowder root page:

                window["WEB_ROOT"] = "@routes.Application.index";

      2) use it in the JavaScript where such URL links are generated to replace the "window.location.protocol + ..." parts, such as:

      < fileThumbnail = "<img src='" + window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '') + "/fileThumbnail/" + respJSON[i].thumbnail + "/blob' "
      > fileThumbnail = "<img src='" + window["WEB_ROOT"] + "fileThumbnail/" + respJSON[i].thumbnail + "/blob' "

              mfelarca Mario Felarca
              ruiliu Rui Liu
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: