Skip to content

Commit

Permalink
template update
Browse files Browse the repository at this point in the history
  • Loading branch information
driskull committed Jun 28, 2017
1 parent ce873fd commit 34bc2d1
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 78 deletions.
51 changes: 5 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,53 +24,13 @@ The PMG template is also easily configurable. A complete list of features and en
1. To deploy this application, download the template from Portal/ArcGIS Online and unzip it.
2. Copy the unzipped folder containing the web app template files, such as index.html, to your web server. You can rename the folder to change the URL through which users will access the application. By default the URL to the app will be `http://<Your Web Server>/<app folder name>/index.html`
3. Change the sharing host, found in options.js inside the config folder for the application, to the sharing URL for ArcGIS Online or Portal. For ArcGIS Online users, keep the default value of www.arcgis.com or specify the name of your organization.
- ArcGIS Online Example: `"sharingurl": location.protocol + "//" + “<your organization name>.maps.arcgis.com`
- Portal Example where `arcgis` is the name of the Web Adaptor: `"sharingurl": location.protocol + "//" + "webadaptor.domain.com/arcgis"`
4. If you are using Portal or a local install of the ArcGIS API for JavaScript, change all references to the ArcGIS API for JavaScript in index.html to refer to your local copy of the API. Search for the references containing `"//js.arcgis.com/3.20"` and replace this portion of the reference with the url to your local install.
- For example: `"//webadaptor.domain.com/arcgis/jsapi/jsapi"` where `arcgis` is the name of your Web Adaptor.
- ArcGIS Online Example: `"sharingurl": "https://" + “<your organization name>.maps.arcgis.com`
- Portal Example where `arcgis` is the name of the Web Adaptor: `"sharingurl": "https://" + "webadaptor.domain.com/arcgis"`
4. If you are using Portal or a local install of the ArcGIS API for JavaScript, change all references to the ArcGIS API for JavaScript in index.html to refer to your local copy of the API. Search for the references containing `"https://js.arcgis.com/3.21"` and replace this portion of the reference with the url to your local install.
- For example: `"https://webadaptor.domain.com/arcgis/jsapi/jsapi"` where `arcgis` is the name of your Web Adaptor.
5. Copy a map or group ID from Portal/ArcGIS Online and replace the default web map ID in the application’s index.html page. You can now run the application on your web server or customize the application further.

### Deployment Notes

#### Secure feature services
If your application edits features in a feature service, contains secure services or web maps that aren't shared publicly, or generate requests that exceed 200 characters, you may need to set up and use a proxy page. Common situations where you may exceed the URL length are using complex polygons as input to a task or specifying a spatial reference using well-known text (WKT). For details on installing and configuring a proxy page see [Using the proxy](https://developers.arcgis.com/javascript/jshelp/ags_proxy.html). If you do not have an Internet connection, you will need to access and deploy the ArcGIS API for JavaScript documentation from [developers.arcgis.com](https://developers.arcgis.com/).

#### Caching
After altering JavaScript files, you may encounter caching prohibiting you and/or users from seeing updates without refreshing the page multiple times.

To prevent caching with a deployment you could either:

* Implement versioning on individual JavaScript files in the **[javascript/home.js](https://github.com/Esri/map-gallery-template-js/blob/master/javascript/home.js#L12)** and **[javascript/map.js](https://github.com/Esri/map-gallery-template-js/blob/master/javascript/map.js#L14)** files:

```javascript
//"application/common", //Current
"application/common?version=1.0", //After implementation
```

* **or** Implement [Dojo's cacheBurst](https://dojotoolkit.org/documentation/tutorials/1.10/dojo_config) (`cacheBust: true`) to the **[javascript/djConfig.js](https://github.com/Esri/map-gallery-template-js/blob/master/javascript/djConfig.js)** file to avoid module caching:

```javascript
// Dojo Config with cacheBust
var dojoConfig = {
parseOnLoad: true,
cacheBust: true, //Add cacheBust and set to true
packages: [{
name: "esriTemplate",
location: path_location
}, {
name: "application",
location: path_location + '/javascript'
}, {
name: "templateConfig",
location: path_location_tc
}, {
name: "config",
location: path_location + '/config'
}]
};
```

However, caching can be a good thing and speed up the initial load of an application, keep this in mind if you implement either option.
> **Note:** If your application edits features in a feature service, contains secure services or web maps that aren't shared publicly, or generate requests that exceed 200 characters, you may need to set up and use a proxy page. Common situations where you may exceed the URL length are using complex polygons as input to a task or specifying a spatial reference using well-known text (WKT). For details on installing and configuring a proxy page see [Using the proxy](https://developers.arcgis.com/javascript/jshelp/ags_proxy.html). If you do not have an Internet connection, you will need to access and deploy the ArcGIS API for JavaScript documentation from [developers.arcgis.com](https://developers.arcgis.com/).
[New to Github? Get started here.](https://github.com/)

Expand Down Expand Up @@ -110,4 +70,3 @@ See the License for the specific language governing permissions and
limitations under the License.

A copy of the license is available in the repository's [license.txt](https://raw.github.com/Esri/map-gallery-template-js/master/license.txt) file.

6 changes: 3 additions & 3 deletions config/commonConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ define(
bingMapsKey: "ArAavTvIHoG3w9HwhroJuCFAzUttY_pQQvjdmHmZHQQfv6wahgxcyOiT3op-SCni",
helperServices: {
geometry: {
url: location.protocol + "//utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"
url: "https://utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"
},
printTask: {
url: location.protocol + "//utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"
url: "https://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"
},
geocode: [{
url: location.protocol + "//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"
url: "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"
}]
}
};
Expand Down
7 changes: 3 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta charset="utf-8" />
<meta name="fragment" content="!">
<title></title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
<meta name="Keywords" content="" />
<meta name="Description" content="" />
<!-- iOS -->
Expand All @@ -19,8 +18,8 @@
<meta property="og:site_name" content="esri" />
<!-- End Facebook -->
<!-- STYLESHEETS -->
<link rel="stylesheet" href="//js.arcgis.com/3.20/dijit/themes/claro/claro.css">
<link href="//js.arcgis.com/3.20/dojox/form/resources/Rating.css" rel="stylesheet" />
<link rel="stylesheet" href="https://js.arcgis.com/3.21/dijit/themes/claro/claro.css">
<link href="https://js.arcgis.com/3.21/dojox/form/resources/Rating.css" rel="stylesheet" />
<link href="css/reset.css" rel="stylesheet" type="text/css" />
<link href="css/960.css" rel="stylesheet" type="text/css" />
<link href="css/common.css" rel="stylesheet" type="text/css" />
Expand Down Expand Up @@ -72,7 +71,7 @@ <h1 id="homeHeading"></h1>
<div id="footer"></div>
<!-- JAVASCRIPT -->
<script type="text/javascript" src="javascript/djConfig.js"></script>
<script type="text/javascript" src="//js.arcgis.com/3.20"></script>
<script type="text/javascript" src="https://js.arcgis.com/3.21"></script>
<script type="text/javascript">
require(["application/home"], function (App) {
var myApp = App();
Expand Down
20 changes: 8 additions & 12 deletions javascript/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ define([
}
if (appLocation !== -1) { //hosted or portal
var instance = location.pathname.substr(0, appLocation);
this._options.sharingurl = location.protocol + "//" + location.host + instance;
this._options.proxyUrl = location.protocol + '//' + location.host + instance + "/sharing/proxy";
this._options.sharingurl = "https://" + location.host + instance;
this._options.proxyUrl = 'https://' + location.host + instance + "/sharing/proxy";
//check sign-in status
IdentityManager.checkSignInStatus(this._options.sharingurl + "/sharing").then(
lang.hitch(this, function (credential) {
Expand Down Expand Up @@ -276,16 +276,16 @@ define([
}

if (this._options.sharingurl) { //sharing url specified
this._options.mobilePortalUrl = 'arcgis:' + '//' + location.host;
this._options.mobilePortalUrl = 'arcgis://' + location.host;
//sharing url set in config file so use default services
} else if (appLocation !== -1) { //hosted or portal
this._options.isOrg = true;
var instance = location.pathname.substr(0, appLocation);
this._options.sharingurl = location.protocol + "//" + location.host + instance;
this._options.proxyurl = location.protocol + '//' + location.host + instance + "/sharing/proxy";
this._options.mobilePortalUrl = 'arcgis:' + '//' + location.host;
this._options.sharingurl = "https://" + location.host + instance;
this._options.proxyurl = 'https://' + location.host + instance + "/sharing/proxy";
this._options.mobilePortalUrl = 'arcgis://' + location.host;
} else { //default to arcgis.com
this._options.sharingurl = location.protocol + "//" + "www.arcgis.com";
this._options.sharingurl = "https://www.arcgis.com";
this._options.mobilePortalUrl = "arcgis://www.arcgis.com";
}
arcgisUtils.arcgisUrl = this._options.sharingurl + "/sharing/rest/content/items";
Expand Down Expand Up @@ -436,11 +436,7 @@ define([
html += '<a class="addthis_counter addthis_bubble_style"></a>';
html += '</div>';
// addthis url
var addthisURL = "http://s7.addthis.com/js/250/addthis_widget.js#pubid=";
// https support
if (addthisURL && location.protocol === "https:") {
addthisURL = addthisURL.replace('http:', 'https:');
}
var addthisURL = "https://s7.addthis.com/js/250/addthis_widget.js#pubid=";
// load share script
ioScript.get({
url: addthisURL + this._options.addThisProfileId
Expand Down
3 changes: 1 addition & 2 deletions javascript/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,7 @@ define([
modifiedDate = new Date(data.results[i].modified);
// date format for locale
modifiedLocalized = locale.format(modifiedDate, {
selector: "date",
datePattern: i18n.viewer.main.datePattern
selector: "date"
});
}
// html
Expand Down
9 changes: 3 additions & 6 deletions javascript/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,7 @@ define([
var commentDate = new Date(this.globalComments[i].created);
// date format for locale
var dateLocale = locale.format(commentDate, {
selector: "date",
datePattern: i18n.viewer.main.datePattern
selector: "date"
});
html += i18n.viewer.comments.posted + ' ' + dateLocale;
html += ' ' + i18n.viewer.comments.by + ' ';
Expand Down Expand Up @@ -796,8 +795,7 @@ define([
d = new Date(itemInfo.item.created);
// date format for locale
dateLocale = locale.format(d, {
selector: "date",
datePattern: i18n.viewer.main.datePattern
selector: "date"
});
html += '<li><strong>' + i18n.viewer.mapPage.createdLabel + '</strong><br />' + dateLocale + '</li>';
}
Expand All @@ -807,8 +805,7 @@ define([
d = new Date(itemInfo.item.modified);
// date format for locale
dateLocale = locale.format(d, {
selector: "date",
datePattern: i18n.viewer.main.datePattern
selector: "date"
});
html += '<li><strong>' + i18n.viewer.itemInfo.modifiedLabel + '</strong><br />' + dateLocale + '</li>';
}
Expand Down
9 changes: 4 additions & 5 deletions map.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta charset="utf-8" />
<meta name="fragment" content="!">
<title></title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
<meta name="Keywords" content="" />
<meta name="Description" content="" />
<!-- iOS -->
Expand All @@ -19,9 +18,9 @@
<meta property="og:site_name" content="esri" />
<!-- End Facebook -->
<!-- STYLESHEETS -->
<link rel="stylesheet" href="//js.arcgis.com/3.20/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="//js.arcgis.com/3.20/esri/css/esri.css">
<link href="//js.arcgis.com/3.20/dojox/form/resources/Rating.css" rel="stylesheet" />
<link rel="stylesheet" href="https://js.arcgis.com/3.21/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.21/esri/css/esri.css">
<link href="https://js.arcgis.com/3.21/dojox/form/resources/Rating.css" rel="stylesheet" />
<link href="css/reset.css" rel="stylesheet" type="text/css" />
<link href="css/960.css" rel="stylesheet" type="text/css" />
<link href="css/common.css" rel="stylesheet" type="text/css" />
Expand Down Expand Up @@ -101,7 +100,7 @@ <h2 id="legendHeader"></h2>
<div id="footer"></div>
<!-- JAVASCRIPT -->
<script type="text/javascript" src="javascript/djConfig.js"></script>
<script type="text/javascript" src="//js.arcgis.com/3.20"></script>
<script type="text/javascript" src="https://js.arcgis.com/3.21"></script>
<script type="text/javascript">
require(["application/map"], function (App) {
App();
Expand Down

0 comments on commit 34bc2d1

Please sign in to comment.