-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix #1728. Generalized Share embedded strings. More tests (#1729) * Fix #1738. Made optional share api and showTOC (#1739) With this options you can remove via configuration the API share tool and the showTOC checkbox. * Fix #1750.Add smarter shareURLs generator and tests
- Loading branch information
1 parent
9ea9d2f
commit 05bfc5e
Showing
9 changed files
with
233 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2017, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
const Url = require('url'); | ||
|
||
/** | ||
* Utility functions for Share tools | ||
* @memberof utils | ||
* @type {Object} | ||
*/ | ||
var ShareUtils = { | ||
/** | ||
* get the absolute URL from the local url and the url to convert | ||
* @param {string} localUrl the context where to evaluate the URL, typically location.href | ||
* @param {string} urlToConvert the url to convert | ||
* @return {string} the absolute url of the urlToConvert | ||
*/ | ||
getAbsoluteURL: (localUrl, urlToConvert) => { | ||
// case absolute URL | ||
if (urlToConvert.indexOf("http") === 0 || urlToConvert.indexOf("//") === 0) { | ||
return urlToConvert; | ||
} | ||
return Url.resolve(localUrl, urlToConvert); | ||
}, | ||
/** | ||
* get the url for the configuration in GeoStore parsing the hash string (`#/viewer/{maptype}/1`) | ||
* @param {string} url the context where to evaluate the URL, typically location.href | ||
* @param {string} geoStoreUrl the Base URL of GeoStore | ||
* @return {string} the absolute url of the GeoStore Resource | ||
*/ | ||
getConfigUrl: (url, geoStoreUrl) => { | ||
let urlParsedObj = Url.parse(url, true); | ||
if (!urlParsedObj.hash) { | ||
return null; | ||
} | ||
const start = urlParsedObj.hash.lastIndexOf('/') + 1; | ||
const end = urlParsedObj.hash.lastIndexOf('?') >= 0 ? urlParsedObj.hash.lastIndexOf('?') : urlParsedObj.hash.length; | ||
const mapId = urlParsedObj.hash.substring(start, end); | ||
return Url.resolve(ShareUtils.getAbsoluteURL(url, geoStoreUrl), ('data/' + mapId)); | ||
}, | ||
/** | ||
* Parses the API url to get the proper base path where to retrieve the js for the api. | ||
* @param {string} url the current context | ||
* @return {string} the base path of mapstore where to retrieve the js api. | ||
*/ | ||
getApiUrl: (url) => { | ||
let urlParsedObj = Url.parse(url, false); | ||
return urlParsedObj.protocol + '//' + urlParsedObj.host + urlParsedObj.pathname; | ||
} | ||
}; | ||
|
||
module.exports = ShareUtils; |
Oops, something went wrong.