Interactive interface for browsing global, full-resolution satellite imagery
WV-520: Curl support added
Mike McGanne152351fe41c
diff --git a/build.xml b/build.xmlindex e5ba3bd1b..a7ae794b3 100644--- a/build.xml+++ b/build.xml@@ -209,6 +209,7 @@<include name="**/*.js"/><!-- Place any concatenation exceptions here --><exclude name="css/pages.css"/>+ <exclude name="css/bulkDownload.css"/><exclude name="ext/openlayers/theme/default/style.css"/><exclude name="**/TileWorker.js"/></fileset>diff --git a/etc/ant/js.build.xml b/etc/ant/js.build.xmlindex ab0cf698b..0038a1105 100644--- a/etc/ant/js.build.xml+++ b/etc/ant/js.build.xml@@ -150,6 +150,7 @@<file name="js/Worldview/DataDownload/SelectionListPanel.js"/><file name="js/Worldview/DataDownload/DownloadListPanel.js"/><file name="js/Worldview/DataDownload/WgetPage.js"/>+ <file name="js/Worldview/DataDownload/CurlPage.js"/><file name="js/Worldview/Widget/Map.js"/><file name="js/Worldview/Widget/Palette.js"/>diff --git a/src/css/bulkDownload.css b/src/css/bulkDownload.cssnew file mode 100644index 000000000..c2fa35583--- /dev/null+++ b/src/css/bulkDownload.css@@ -0,0 +1,38 @@+#BulkDownload body {+ background-color: rgb(25, 28, 32);+}++#BulkDownload h4 {+ margin-bottom: 0+}++#BulkDownload #page {+ background-color: #ffffff;+ margin: 20px;+ padding: 5px 20px 20px 20px;+ border-radius: 5px;+}++#BulkDownload pre {+ background-color: #eeeeee;+ padding: 5px;+ border: 1px dashed #dddddd;+}++#BulkDownload .label {+ margin-top: 10px;+ font-style: italic;+ color: #808080;+}++#BulkDownload #netrc-header {+ display: none;+}++#BulkDownload #netrc-instructions {+ display: none;+}++#BulkDownload #indirect-instructions {+ display: none;+}diff --git a/src/css/dataDownload.css b/src/css/dataDownload.cssindex 491488aa6..8011147ba 100644--- a/src/css/dataDownload.css+++ b/src/css/dataDownload.css@@ -1,12 +1,12 @@#dataDownload {padding-top: 10px;- display: inline-block;- float: left;- width: 100%;- height: 100%;- font-size: 1em;- color: #222;- text-shadow: none;+ display: inline-block;+ float: left;+ width: 100%;+ height: 100%;+ font-size: 1em;+ color: #222;+ text-shadow: none;}#dataDownload div.ui-button {@@ -17,24 +17,29 @@#DataDownload_DownloadListPanel .bd {background-color: rgb(25, 28, 32);overflow: auto;- padding: 10px;+ padding: 10px;color: #FFFBE7;}#DataDownload_DownloadListPanel ul {- display: list;+ display: list;margin: 0 5px;}#DataDownload_DownloadListPanel li {margin-top: 3px;display: list-item;- list-style-type: none;+ list-style-type: none;}#DataDownload_DownloadListPanel div.product li {- list-style-type: disc;- margin-left: 10px;+ list-style-type: disc;+ margin-left: 10px;+}++#DataDownload_DownloadListPanel .BulkDownload li {+ list-style-type: disc;+ margin-left: 10px;}#DataDownload_DownloadListPanel h3 {@@ -43,6 +48,12 @@color: #FFFBE7;}+#DataDownload_DownloadListPanel h4 {+ font-size: 11pt;+ font-weight: bold;+ color: #FFFBE7;+}+#DataDownload_DownloadListPanel h5 {font-size: 10pt;margin-top: 10px;@@ -63,11 +74,11 @@}#DataDownload_DownloadListPanel hr {- display: block;+ display: block;height: 1px;- border: 0;+ border: 0;border-top: 1px solid #404040;- margin: 1em 0;+ margin: 1em 0;padding: 0;}@@ -108,7 +119,7 @@#DataDownload_SelectionListPanel .bd {background-color: rgb(25, 28, 32);overflow: auto;- padding: 10px;+ padding: 10px;color: #FFFBE7;}@@ -133,7 +144,7 @@color:#8f939f;cursor:pointer;font-size:130%;-+}#DataDownload #DataDownloadcontent h3 span:hover{color:#000;diff --git a/src/index.html b/src/index.htmlindex 81cac2b06..33cbb60fa 100644--- a/src/index.html+++ b/src/index.html@@ -216,6 +216,7 @@<!-- link.dev --> <script type="text/javascript" src="js/Worldview/DataDownload/SelectionListPanel.js"></script><!-- link.dev --> <script type="text/javascript" src="js/Worldview/DataDownload/DownloadListPanel.js"></script><!-- link.dev --> <script type="text/javascript" src="js/Worldview/DataDownload/WgetPage.js"></script>+ <!-- link.dev --> <script type="text/javascript" src="js/Worldview/DataDownload/CurlPage.js"></script><!-- link.dev --> <script type="text/javascript" src="js/Worldview/Widget/Map.js"></script><!-- link.dev --> <script type="text/javascript" src="js/Worldview/Widget/Palette.js"></script>diff --git a/src/js/Worldview/DataDownload/CurlPage.js b/src/js/Worldview/DataDownload/CurlPage.jsnew file mode 100644index 000000000..8d258bd30--- /dev/null+++ b/src/js/Worldview/DataDownload/CurlPage.js@@ -0,0 +1,81 @@+/*+ * NASA Worldview+ *+ * This code was originally developed at NASA/Goddard Space Flight Center for+ * the Earth Science Data and Information System (ESDIS) project.+ *+ * Copyright (C) 2013 United States Government as represented by the+ * Administrator of the National Aeronautics and Space Administration.+ * All Rights Reserved.+ */+Worldview.namespace("DataDownload");++Worldview.DataDownload.CurlPage = (function() {++ var ns = {};++ ns.show = function(selection) {+ var page = window.open('pages/curl.html', 'Worldview_' + new Date());+ page.onload = function() {+ fillPage(page, selection);+ };+ };++ var fillPage = function(page, selection) {+ var commands = [];+ var hosts = {};+ var indirectLinks = [];+ $.each(selection, function(index, product) {+ $.each(product.list, function(index2, granule) {+ var netrc = "";+ if ( granule.urs ) {+ netrc = "--netrc ";+ }+ $.each(granule.links, function(index2, link) {+ if ( !link.data ) {+ return;+ }+ if ( product.noBulkDownload ) {+ indirectLinks.push("<li><a href='" + link.href + "'>" ++ link.href + "</a></li>");+ return;+ }+ commands.push("curl --remote-name " + netrc + link.href);+ if ( granule.urs ) {+ // Get the hostname from the URL, the text between+ // the double slash and the first slash after that+ var host = /\/\/([^\/]*)\//.exec(link.href);+ if ( host ) {+ hosts[host[1]] = true;+ }+ }+ });+ });+ });+ page.document.getElementById("commands").innerHTML =+ "<pre>" + commands.join("\n") + "</pre>";++ var netrcEntries = [];+ $.each(hosts, function(host, value) {+ netrcEntries.push("machine " + host + " login URS_USER " ++ "password URS_PASSWORD");+ });+ if ( netrcEntries.length > 0 ) {+ page.document.getElementById("netrc").innerHTML =+ "<pre>" + netrcEntries.join("\n") + "</pre>";+ page.document.getElementById("netrc-header")+ .style.display = "block";+ page.document.getElementById("netrc-instructions")+ .style.display = "block";+ }+ if ( indirectLinks.length > 0 ) {+ page.document.getElementById("indirect-instructions")+ .style.display = "block";+ page.document.getElementById("indirect").innerHTML =+ "<ul>" + indirectLinks.join("\n") + "</ul>";+ }+ };++ return ns;++})();\ No newline at end of filediff --git a/src/js/Worldview/DataDownload/DownloadListPanel.js b/src/js/Worldview/DataDownload/DownloadListPanel.jsindex d2467c710..1ac20493b 100644--- a/src/js/Worldview/DataDownload/DownloadListPanel.js+++ b/src/js/Worldview/DataDownload/DownloadListPanel.js@@ -60,6 +60,7 @@ Worldview.DataDownload.DownloadListPanel = function(config, model) {});$("#DataDownload_DownloadListPanel a.wget").click(showWgetPage);+ $("#DataDownload_DownloadListPanel a.curl").click(showCurlPage);}};@@ -78,6 +79,7 @@ Worldview.DataDownload.DownloadListPanel = function(config, model) {panel.destroy();panel = null;$("#DataDownload_DownloadListPanel a.wget").off("click", showWgetPage);+ $("#DataDownload_DownloadListPanel a.curl").off("click", showCurlPage);};var reformatSelection = function() {@@ -134,7 +136,8 @@ Worldview.DataDownload.DownloadListPanel = function(config, model) {$.each(product.granules, function(index, granule) {var item = {label: granule.downloadLabel || granule.label,- links: []+ links: [],+ urs: granule.urs};$.each(granule.links, function(index, link) {// Skip this link if now at the product level@@ -180,7 +183,8 @@ Worldview.DataDownload.DownloadListPanel = function(config, model) {// URIreturn {href: link.href,- title: ( link.title ) ? link.title : link.href.split("/").slice(-1)+ title: ( link.title ) ? link.title : link.href.split("/").slice(-1),+ data: ( link.rel === echo.REL_DATA )};};@@ -238,20 +242,27 @@ Worldview.DataDownload.DownloadListPanel = function(config, model) {};var bodyText = function() {- var bulk = "";- if ( isBulkDownloadable() ) {- bulk = "<div class='wget'>" +- "<a class='wget' href='#'>Bulk Download (wget)</a>" +- "</div>";- }var elements =[];if ( urs ) {elements.push(NOTICE);}- elements.push(bulk);$.each(selection, function(key, product) {elements.push(productText(product));});++ if ( isBulkDownloadable() ) {+ var bulk =+ "<h4>Bulk Download</h4>" ++ "<ul class='BulkDownload'>" ++ "<li><a class='wget' href='#'>Link List:</a> " ++ "For wget or download managers that accept a list of " ++ "URLs</li>" ++ "<li><a class='curl' href='#'>cURL Commands:</a> " ++ "List of commands that can be copied and pasted to " ++ "a terminal window to download using cURL.</li>" ++ "</ul>";+ elements.push(bulk);+ }var text = elements.join("\n<br/>\n") + "<br/>";return text;};@@ -260,9 +271,11 @@ Worldview.DataDownload.DownloadListPanel = function(config, model) {Worldview.DataDownload.WgetPage.show(selection);};+ var showCurlPage = function() {+ Worldview.DataDownload.CurlPage.show(selection);+ };+return self;};-$('#DataDownload #DataDownloadcontent h3 span').click(function(e){- console.log("TEST####");- });+diff --git a/src/pages/curl.html b/src/pages/curl.htmlnew file mode 100644index 000000000..fafe0c0ab--- /dev/null+++ b/src/pages/curl.html@@ -0,0 +1,50 @@+<!doctype html>+<html id="BulkDownload">+ <head>+ <title>EOSDIS Worldview - cURL Downloads</title>+ <link type="text/css" href="../css/bulkDownload.css" rel="Stylesheet" />+ </head>++ <body>+ <div id='page'>+ <h3>Download Commands</h3>+ <div id="commands"></div>+ <div id="netrc-header">+ Some download links require a URS account. Use the following+ netrc entries and follow the instructions below.+ </div>+ <div id="netrc"></div>+ <h3>Using <code>cURL</code> to Bulk Download Your Data</h3>+ <div id="netrc-instructions">+ <p>+ Add the netrc entries listed above to the following file:+ <ul>+ <li>Windows: <code>_netrc</code> file found in your home+ folder.+ </li>+ <li>+ Mac or Linux: <code>.netrc</code> file found in your+ home directory.+ </li>+ </ul>+ Replace <code>URS_USER</code> with your URS user name and+ <code>URS_PASSWORD</code> with your URS password. If this file does+ not exist, create a new one. Ensure that your are the only+ one that can read this file.+ </p>+ </div>+ <p>+ Open a terminal or command prompt, navigate to the directory+ or folder where you want to save the data, and cut and paste+ the Download Commands above.+ </p>+ <div id="indirect-instructions">+ Some items that you have selected do not directly link to a+ data file. Visit the following links and manually download each+ data file:+ </div>+ <div id="indirect">+ </div>+ </div>+ </body>+</html>