GMOD / jbrowse

JBrowse 1, a full-featured genome browser built with JavaScript and HTML5. For JBrowse 2, see https://github.com/GMOD/jbrowse-components.
http://jbrowse.org
Other
460 stars 199 forks source link

Serving JBrowse assets from a different directory #636

Closed ialarmedalien closed 8 years ago

ialarmedalien commented 8 years ago

As a factor of the way the server is set up and how I am using JBrowse, I have to specify a separate URL for serving assets (css, JS, plugins, etc.). For the most part, I can solve this by setting config.baseUrl to http://my.server.com/jbrowse_assets. I have also moved all the css files into their own directory (much tidier) and altered a couple of relative paths and added symlinks for src and img. This setup works for most files, but the following files still get served from http://my.server.com/jbrowse/ instead of .../jbrowse_assets/:

/img/JBrowseLogo_small.png /img/Empty.png /plugins/RegexSequenceSearch/css/main.css

I couldn't find any documentation of whether baseUrl should be used for this purpose, but it seems to work, apart from these three cases.

1) Is there a recommended way to use a separate directory for serving JBrowse assets?

2) Is there something anomalous in the path resolution that is causing these three files not to use baseUrl?

cmdcolin commented 8 years ago

Interesting issue. Looks like baseUrl is an undocumented option (?) but it probably should be documented and maybe could even be fixed in this case !

cmdcolin commented 8 years ago

Is this changing the "baseUrl" from the script line dojo.js in index.html?

ialarmedalien commented 8 years ago

Yes, and also in the config section further down the page. I generate the page from a template based on index.html, but with the baseUrl and dataRoot set by the app. The relevant bits of code:

<script type="text/javascript" src="[% jbrowse_assets %]src/dojo/dojo.js"
  data-dojo-config="async: 1, baseUrl: '[% jbrowse_assets %]src'"></script>
<script type="text/javascript" src="[% jbrowse_assets %]src/JBrowse/init.js"></script>
<script type="text/javascript">
    window.onerror=function(msg){
    [... snip a load of identical code here ...]
               var config = {
                   containerID: "GenomeBrowser",
                   baseUrl: "[% jbrowse_assets %]",
                   dataRoot: "[% data_dir %]",
                   queryParams: queryParams,
    [... etc.]
enuggetry commented 8 years ago

"I think" you may have to "hack" resolveUrl() in Browser.js to fix the PNG references.

One "cleaner" way to do this w/o modifying Browser.js is to create a plugin that hacks the function.

I have a simple example here, a plugin that hacks the showTracks() function to modify it's behavior.

https://github.com/GMOD/jbrowse/tree/Eric_work_f1/plugins/CategoryUrl

You might hack it to return something like (applying some special case logic): return "http://myurl.com/" + url;

As for /plugins/RegexSequenceSearch/css/main.css, it's probably a similar problem. Try fooling with "location" parameter of the plugin config in tracklist.json. http://gmod.org/wiki/JBrowse_Configuration_Guide#Using_Plugins (you'd probably have to move the entire plugin module to your asset server)

On Mon, Sep 28, 2015 at 2:29 PM, girlwithglasses notifications@github.com wrote:

Yes, and also in the config section further down the page. I generate the page from a template based on index.html, but with the baseUrl and dataRoot set by the app. The relevant bits of code:

<script type="text/javascript" src="[% jbrowse_assets %]src/dojo/dojo.js" data-dojo-config="async: 1, baseUrl: '[% jbrowse_assets %]src'">

Githubissues.
  • Githubissues is a development platform for aggregating issues.