You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by ij...@apache.org on 2014/08/05 17:13:23 UTC
svn commit: r1615941 -
/jena/Experimental/jena-fuseki2/src/main/webapp/js/app/models/fuseki-server.js
Author: ijd
Date: Tue Aug 5 15:13:23 2014
New Revision: 1615941
URL: http://svn.apache.org/r1615941
Log:
Minor tidy up: use window.location.path to extract document root path
Modified:
jena/Experimental/jena-fuseki2/src/main/webapp/js/app/models/fuseki-server.js
Modified: jena/Experimental/jena-fuseki2/src/main/webapp/js/app/models/fuseki-server.js
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/webapp/js/app/models/fuseki-server.js?rev=1615941&r1=1615940&r2=1615941&view=diff
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/webapp/js/app/models/fuseki-server.js (original)
+++ jena/Experimental/jena-fuseki2/src/main/webapp/js/app/models/fuseki-server.js Tue Aug 5 15:13:23 2014
@@ -23,14 +23,7 @@ define(
var FusekiServer = Backbone.Model.extend( {
/** This initializer occurs when the module starts, not when the constructor is invoked */
init: function( options ) {
- // The base URL includes the webapp name.
- // Remove everything from the last "/" (inc frag and query string)
- // Leave it with no trailing "/"
- var b = window.location.href ;
- b = b.replace(/#[^#]*$/, "") ;
- b = b.replace(/\?[^\?]*$/, "") ;
- b = b.replace(/\/[^/]*$/, "") ;
- this._baseURL = b ;
+ this._baseURL = this.currentRootPath();
this._managementURL = null;
this.set( "selectedDatasetName", PageUtils.queryParam( "ds" ) )
@@ -40,6 +33,11 @@ define(
return this._baseURL;
},
+ /** Return the URL from which we extract the details of the current server */
+ serverDetailsURL: function() {
+ return sprintf( "%s/$/server", this.baseURL() );
+ },
+
/** Return the URL for issuing commands to the management API, or null if no API defined */
managementURL: function() {
return this._managementURL;
@@ -74,9 +72,8 @@ define(
/** Load and cache the remote server description. Trigger change event when done */
loadServerDescription: function() {
var self = this;
- var serverDetailsURL = sprintf( "%s/$/server", this.baseURL() );
- return this.getJSON( serverDetailsURL )
- .done( function( data ) {
+ return this.getJSON( this.serverDetailsURL() )
+ .done( function( data ) {
self.saveServerDescription( data );
} )
.then( function() {
@@ -136,6 +133,12 @@ define(
method: "post"
}
);
+ },
+
+ /** Extract the server root path from the current window href */
+ currentRootPath: function() {
+ var path = window.location.path.replace( /\/[^/]*$/, "" );
+ return sprintf( "http://%s:%s%s", window.location.hostname, window.location.port, path );
}
} );