diff --git a/buildConfig.js b/buildConfig.js
index fc1cedaa9c..9c5be612f0 100644
--- a/buildConfig.js
+++ b/buildConfig.js
@@ -51,6 +51,18 @@ module.exports = (bundles, themeEntries, paths, extractThemesPlugin, prod, publi
chunks: ['mapstore2'],
inject: true,
hash: true
+ }), new HtmlWebpackPlugin({
+ template: path.join(paths.framework, 'embeddedTemplate.html'),
+ chunks: ['embedded'],
+ inject: true,
+ hash: true,
+ filename: 'embedded.html'
+ }), new HtmlWebpackPlugin({
+ template: path.join(paths.framework, 'apiTemplate.html'),
+ chunks: ['ms2-api'],
+ inject: 'head',
+ hash: true,
+ filename: 'api.html'
})] : []).concat(prod ? [new ParallelUglifyPlugin({
uglifyJS: {
sourceMap: false,
diff --git a/examples.js b/examples.js
index f5ddce970e..be959b4425 100644
--- a/examples.js
+++ b/examples.js
@@ -3,14 +3,14 @@ var path = require("path");
module.exports = {
mouseposition: path.join(__dirname, "web", "client", "examples", "mouseposition", "app"),
scalebar: path.join(__dirname, "web", "client", "examples", "scalebar", "app"),
- layertree: path.join(__dirname, "web", "client", "examples", "layertree", "app"),
+ // layertree: path.join(__dirname, "web", "client", "examples", "layertree", "app"),
"3dviewer": path.join(__dirname, "web", "client", "examples", "3dviewer", "app"),
- queryform: path.join(__dirname, "web", "client", "examples", "queryform", "app"),
+ // queryform: path.join(__dirname, "web", "client", "examples", "queryform", "app"),
featuregrid: path.join(__dirname, "web", "client", "examples", "featuregrid", "app"),
print: path.join(__dirname, "web", "client", "examples", "print", "app"),
login: path.join(__dirname, "web", "client", "examples", "login", "app"),
plugins: path.join(__dirname, "web", "client", "examples", "plugins", "app"),
- rasterstyler: path.join(__dirname, "web", "client", "examples", "rasterstyler", "app"),
+ // rasterstyler: path.join(__dirname, "web", "client", "examples", "rasterstyler", "app"),
api: path.join(__dirname, "web", "client", "examples", "api", "app")
// this example is not linked and seems to cause a big slow down with uglyfyplugin. disabled temporary
// styler: path.join(__dirname, "web", "client", "examples", "styler", "app")
diff --git a/web/client/apiTemplate.html b/web/client/apiTemplate.html
new file mode 100644
index 0000000000..1f2a60ec18
--- /dev/null
+++ b/web/client/apiTemplate.html
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+ Page with MapStore 2 API
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/web/client/components/share/ShareApi.jsx b/web/client/components/share/ShareApi.jsx
index d8f40c37f0..c69d2848c4 100644
--- a/web/client/components/share/ShareApi.jsx
+++ b/web/client/components/share/ShareApi.jsx
@@ -17,7 +17,8 @@ const CopyToClipboard = require('react-copy-to-clipboard');
const Message = require('../../components/I18N/Message');
const {Glyphicon, Col, Grid, Row, Tooltip, Button} = require('react-bootstrap');
const OverlayTrigger = require('../misc/OverlayTrigger');
-
+const {validateVersion} = require('../../selectors/version');
+const {trim} = require('lodash');
// css required
require('./share.css');
@@ -29,7 +30,8 @@ const codeApi = require('raw-loader!./api-template.raw');
class ShareApi extends React.Component {
static propTypes = {
shareUrl: PropTypes.string,
- shareConfigUrl: PropTypes.string
+ shareConfigUrl: PropTypes.string,
+ version: PropTypes.string
};
state = {copied: false};
@@ -38,7 +40,8 @@ class ShareApi extends React.Component {
const parsedCode = codeApi
.replace('__BASE__URL__', this.props.shareUrl)
.replace('__CONFIG__URL__', this.props.shareConfigUrl)
- .replace('__ORIGINAL_URL__', location.href);
+ .replace('__ORIGINAL_URL__', location.href)
+ .replace('__VERSION__', validateVersion(this.props.version) ? '?' + trim(this.props.version) : '');
const tooltip = (
{this.state.copied ? : }
);
diff --git a/web/client/components/share/SharePanel.jsx b/web/client/components/share/SharePanel.jsx
index 39131062c7..fffc4d9454 100644
--- a/web/client/components/share/SharePanel.jsx
+++ b/web/client/components/share/SharePanel.jsx
@@ -50,7 +50,8 @@ class SharePanel extends React.Component {
showAPI: PropTypes.bool,
onClose: PropTypes.func,
getCount: PropTypes.func,
- closeGlyph: PropTypes.string
+ closeGlyph: PropTypes.string,
+ version: PropTypes.string
};
static defaultProps = {
@@ -83,7 +84,7 @@ class SharePanel extends React.Component {
const social = ;
const direct =
;
const code = (
- {this.props.showAPI ? : null}
);
+ {this.props.showAPI ? : null});
const tabs = (
}>{direct}
diff --git a/web/client/components/share/__tests__/ShareApi-test.jsx b/web/client/components/share/__tests__/ShareApi-test.jsx
index a88cac92f3..133432769a 100644
--- a/web/client/components/share/__tests__/ShareApi-test.jsx
+++ b/web/client/components/share/__tests__/ShareApi-test.jsx
@@ -43,4 +43,40 @@ describe("The ShareEmbed component", () => {
expect(textareaEmbed.value.indexOf(shareConfigUrl) !== -1).toBe(true);
});
+ it('add version to API template', () => {
+ const url = location.href;
+ const shareConfigUrl = 'configurl';
+ const version = '18e36c9e2ce1cbf57648907ec177e02f0118764d';
+ const cmpSharePanel = ReactDOM.render(, document.getElementById("container"));
+ expect(cmpSharePanel).toExist();
+
+ const textareaEmbed = ReactDOM.findDOMNode(ReactTestUtils.scryRenderedDOMComponentsWithTag(cmpSharePanel, "textarea")[0]);
+ expect(textareaEmbed).toExist();
+ expect(textareaEmbed.value.indexOf('?' + version) !== -1).toBe(true);
+ });
+
+ it('add version ${mapstore2.version} to API template', () => {
+ const url = location.href;
+ const shareConfigUrl = 'configurl';
+ const version = '${mapstore2.version}';
+ const cmpSharePanel = ReactDOM.render(, document.getElementById("container"));
+ expect(cmpSharePanel).toExist();
+
+ const textareaEmbed = ReactDOM.findDOMNode(ReactTestUtils.scryRenderedDOMComponentsWithTag(cmpSharePanel, "textarea")[0]);
+ expect(textareaEmbed).toExist();
+ expect(textareaEmbed.value.indexOf('?' + version) !== -1).toBe(false);
+ });
+
+ it('add version ${mapstore2.version.error} to API template', () => {
+ const url = location.href;
+ const shareConfigUrl = 'configurl';
+ const version = '${mapstore2.version.error}';
+ const cmpSharePanel = ReactDOM.render(, document.getElementById("container"));
+ expect(cmpSharePanel).toExist();
+
+ const textareaEmbed = ReactDOM.findDOMNode(ReactTestUtils.scryRenderedDOMComponentsWithTag(cmpSharePanel, "textarea")[0]);
+ expect(textareaEmbed).toExist();
+ expect(textareaEmbed.value.indexOf('?' + version) !== -1).toBe(false);
+ });
+
});
diff --git a/web/client/components/share/api-template.raw b/web/client/components/share/api-template.raw
index 397de9b15b..356d336d0c 100644
--- a/web/client/components/share/api-template.raw
+++ b/web/client/components/share/api-template.raw
@@ -29,7 +29,7 @@
-
+
+
+
+
+
+
+
+
+