Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Commit

Permalink
add standard header/footer; separate ncss and common fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyajohnson committed Jun 19, 2018
1 parent 30e3662 commit 74d9b9e
Show file tree
Hide file tree
Showing 10 changed files with 237 additions and 172 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,7 @@ public class CatalogViewContextParser {

public Map<String, Object> getCatalogViewContext(Catalog cat, boolean isLocalCatalog) {
Map<String, Object> model = new HashMap<>();
String googleTrackingCode = htmlConfig.getGoogleTrackingCode();
if (googleTrackingCode.isEmpty()) googleTrackingCode = null;
model.put("googleTracking", googleTrackingCode);

model.put("serverName", serverInfo.getName());
model.put("logoUrl", serverInfo.getLogoUrl());
model.put("logoAlt", serverInfo.getLogoAltText());
addBaseContext(model);

List<CatalogItemContext> catalogItems = new ArrayList<>();
addCatalogItems(cat, catalogItems, isLocalCatalog, 0);
Expand All @@ -56,22 +50,32 @@ public Map<String, Object> getCatalogViewContext(Catalog cat, boolean isLocalCat
public Map<String, Object> getDatasetViewContext(Dataset ds, HttpServletRequest req, boolean isLocalCatalog)
{
Map<String, Object> model = new HashMap<>();
addBaseContext(model);

model.put("googleTracking", htmlConfig.getGoogleTrackingCode());
DatasetContext context = new DatasetContext(ds, isLocalCatalog);
populateDatasetContext(ds, context, req, isLocalCatalog);

model.put("dataset", context);

return model;
}

private void addBaseContext(Map<String, Object> model) {
String googleTrackingCode = htmlConfig.getGoogleTrackingCode();
if (googleTrackingCode.isEmpty()) googleTrackingCode = null;
model.put("googleTracking", googleTrackingCode);
model.put("serverName", serverInfo.getName());
model.put("logoUrl", serverInfo.getLogoUrl());
model.put("logoAlt", serverInfo.getLogoAltText());
model.put("installName", htmlConfig.getInstallName());
model.put("installUrl", htmlConfig.getInstallUrl());
model.put("webappName", htmlConfig.getWebappName());
model.put("webappUrl", htmlConfig.getWebappUrl());

DatasetContext context = new DatasetContext(ds, isLocalCatalog);
populateDatasetContext(ds, context, req, isLocalCatalog);

model.put("dataset", context);

return model;
model.put("webappVersion", htmlConfig.getWebappVersion());
model.put("webappBuildTimestamp", htmlConfig.getWebappVersionBuildDate());
model.put("webbappDocsUrl", htmlConfig.getWebappDocsUrl());
model.put("hostInst", htmlConfig.getHostInstName());
model.put("hostInstUrl", htmlConfig.getHostInstUrl());
}

protected void addCatalogItems(DatasetNode cat, List<CatalogItemContext> catalogItems, boolean isLocalCatalog, int level)
Expand Down
14 changes: 4 additions & 10 deletions tds/src/main/webapp/WEB-INF/templates/catalog.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!--/* Replace this "head" element with the one in commonFragments. Pass the "title" element below to the fragment. */-->
<head th:replace="templates/commonFragments :: head(~{::title}, ~{::script}, ~{::link})">
<title>TDS Catalog</title>
<link rel="stylesheet" href="/thredds/tdsCat.css" type="text/css">
<link rel="stylesheet" href="/thredds/tds.css" type="text/css">
<!-- Google Analytics -->
<script th:if="${googleTracking != null}" type="text/javascript" th:inline="javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
Expand All @@ -19,12 +19,10 @@
</head>

<body>
<img th:src="${logoUrl}" th:alt="${logoAlt}" align="left" valign="top">
<h1 th:text="${serverName}"/>

<hr size="1" noshade="noshade">
<div th:replace="~{templates/datasetFragments :: catalogHeader}"/>

<table width="100%" cellspacing="0" cellpadding="5" align="center">
<table width="100%" cellspacing="0" cellpadding="5" align="center">
<tbody>

<tr>
Expand All @@ -48,11 +46,7 @@ <h1 th:text="${serverName}"/>
</tbody>
</table>

<hr size="1" noshade="noshade">

<h3><a href="/thredds/catalog.html">Initial TDS Installation (please change threddsConfig.xml)</a> at <a href="http://www.my.site/">My Group</a> see <a href="/thredds/info/serverInfo.html"> Info </a><br>
THREDDS Data Server [Version $projectVersion - $buildTimestamp] <a href="http://www.unidata.ucar.edu/software/thredds/current/tds/reference/index.html"> Documentation</a>
</h3>
<div th:replace="~{templates/datasetFragments :: catalogFooter}"/>

</body>
</html>
115 changes: 12 additions & 103 deletions tds/src/main/webapp/WEB-INF/templates/commonFragments.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</head>

<body>

<div class="header" th:fragment="header(titleText, switchLinks)">
<div class="pageTitle">
<h1 th:text="${titleText}">NetCDF Subset Service</h1>
Expand All @@ -37,115 +38,23 @@ <h4 th:replace="${switchLinks}">Switch to alternate request type.</h4>
</div>
</div>

<div class="dataset" th:fragment="dataset(datasetDesc)">
<h2>
<!-- Don't allow line break to occur between "Dataset:" label and the path. -->
Dataset:&nbsp;<span id="datasetPath" class="black" th:text="${datasetPath}">
/thredds/ncss/some/dataset/path
</span>
</h2>
<!--/* ncssStation.html is the only template that will override this default elem. */-->
<h4 th:replace="${datasetDesc}">(<a href="dataset.xml">Dataset Description</a>)</h4>
</div>

<!--/********************************** Sidebar fragments **********************************/-->

<div id="map" th:fragment="map"> <!-- This div is where we install the OpenLayers.Map in initMap(). --> </div>

<div id="latLonSubset" class="tabPane sidebarInput" th:fragment="latLonSubset">
<h5>Bounding box (in decimal degrees)</h5>

<div class="boundingBoxGrid">
<label class="topLabel" for="north">North</label>
<input class="topBox" type="text" name="north" id="north" required />

<label class="leftLabel" for="west">West</label>
<input class="leftBox" type="text" name="west" id="west" required />

<label class="rightLabel" for="east">East</label>
<input class="rightBox" type="text" name="east" id="east" required />

<label class="bottomLabel" for="south">South</label>
<input class="bottomBox" type="text" name="south" id="south" required />
</div>

<div th:replace=":: resetButtonContainer(fullLatLonExt)" />
</div>

<div id="pointSubset" class="tabPane sidebarInput" th:fragment="pointSubset">
<h5>Nearest to location (in decimal degrees)</h5>

<div class="verticalInputBoxesGrid vibg_2boxes">
<label class="vibg_label1" for="latitude">Latitude:</label>
<input class="vibg_box1" type="text" name="latitude" id="latitude" size="10" required/>

<label class="vibg_label2" for="longitude">Longitude:</label>
<input class="vibg_box2" type="text" name="longitude" id="longitude" size="10" required/>
</div>
</div>

<div id="timeSubsetInput" th:fragment="timeSubsetInput">
<div class="tabContainer">
<button type="button" onclick="selectTab(timeRangeSubset, this)" class="defaultButton">Time range</button>

<button type="button" onclick="selectTab(singleTimeSubset, this)">Single time</button>
</div>

<div id="timeRangeSubset" class="tabPane sidebarInput">
<div class="verticalInputBoxesGrid vibg_3boxes">
<label class="vibg_label1" for="time_start">Start:</label>
<input class="vibg_box1" type="text" name="time_start" id="time_start" size="27" required />

<label class="vibg_label2" for="time_end">End:</label>
<input class="vibg_box2" type="text" name="time_end" id="time_end" size="27" required />

<label class="vibg_label3" for="timeStride">Stride:</label>
<input class="vibg_box3" type="text" name="timeStride" id="timeStride" size="10" value="1" required />
</div>

<div th:replace=":: resetButtonContainer(fullTimeExt)" />
</div>

<div id="singleTimeSubset" class="tabPane sidebarInput">
<label for="time">Time:</label>
<input type="text" name="time" id="time" size="27" required />
</div>
</div>

<div id="outputFormatInput" class="sidebarInput" th:fragment="outputFormatInput">
<label for="accept">Format:</label>

<select id="accept" name="accept" size="1">
<option th:each="opt : ${accept}" th:value="${opt}" th:text="${opt}">format</option>
</select>
<div th:fragment="header">
<div class="header">
<div class="header-logo"><img th:src="${logoUrl}" th:alt="${logoAlt}"></div>
<div class="header-info"><h3><strong><a class="static" th:href="${webappUrl}" th:text="${webappName}"></a></strong></h3>
<h3><strong><a class="static" th:href="${installUrl}" th:text="${installName}"></a></strong></h3></div>
</div>

<div class="resetButtonContainer" th:fragment="resetButtonContainer(inputsMap)">
<button type="button" class="resetButton" th:onclick="|setInputValues(${inputsMap})|">
Reset to full extension
</button>
</div>

<!--/***************************************************************************************/-->

<div class="requestBuilder" th:fragment="requestBuilder">
<h3>NCSS request URL:</h3>
<pre id="urlBuilder">THIS WILL BE REPLACED BY buildAccessUrl().</pre>
</div>

<div class="buttons" th:fragment="buttons">
<button type="submit">Submit</button>
<button type="button" onclick="resetForm()">Reset</button>
</div>

<div class="footer" th:fragment="footer">
<h3>
<a href="http://www.unidata.ucar.edu/software/thredds/current/tds/reference/services/NetcdfSubsetServiceReference.html">
NetCDF Subset Service Documentation
</a>
</h3>
<div th:fragment="footer">
<div class="footer-buffer"></div>
<div class="footer">
<h4><a class="static" th:href="${installUrl}" th:text="${installName}"></a> at <a class="static" th:href="${hostInstUrl}" th:text="${hostInst}"></a> see <a class="static" href="/thredds/info/serverInfo.html"> Info </a></h4>
<h4><th:block th:text="${webappName} + ' [Version ' + ${webappVersion} + ' - ' + ${webappBuildTimestamp} + ']'"/><a class="static" th:href="${webbappDocsUrl}"> Documentation</a></h4>
</div>
</div>
</body>

</body>
</html>
14 changes: 4 additions & 10 deletions tds/src/main/webapp/WEB-INF/templates/dataset.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,8 @@

<body>

<!-- TODO: Make common header -->
<table width="100%">
<tbody><tr><td>
<img th:src="${logoUrl}" th:alt="${logoAlt}" align="left" valign="top" hspace="10" vspace="2">
<h3><strong><a th:href="${installUrl}" th:text="${installName}">THREDDS-DEV Data Server</a></strong></h3>
<h3><strong><a th:href="${webappUrl}" th:text="${webappName}">THREDDS Data Server</a></strong></h3>
</td></tr>
</tbody>
</table>

<div th:replace="~{templates/datasetFragments :: catalogHeader}"/>

<h2 th:text="'Catalog ' + ${dataset.getCatUrl()}"></h2>
<h2 th:text="'Dataset: ' + ${dataset.getName()}"></h2>
Expand Down Expand Up @@ -53,6 +46,7 @@ <h2 th:text="'Dataset: ' + ${dataset.getName()}"></h2>

<div th:replace="${dataset.getViewerLinks().size() > 0} ? ~{templates/datasetFragments :: viewers} : ~{}"/>

<!--TODO: make common footer -->
<div th:replace="~{templates/datasetFragments :: catalogFooter}"/>

</body>
</html>
138 changes: 138 additions & 0 deletions tds/src/main/webapp/WEB-INF/templates/ncssFragments.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

<!--/* The indentation of the fragments below matches the indentation of the elements that they will replace in the
target templates. Do not normalize it, or else the generated HTML won't be pretty any more. */-->

<body>
<div class="header" th:fragment="header(titleText, switchLinks)">
<div class="pageTitle">
<h1 th:text="${titleText}">NetCDF Subset Service</h1>
<h4 th:replace="${switchLinks}">Switch to alternate request type.</h4>
</div>

<div class="unidata">
<div class="appTitle">
<img src="https://www.unidata.ucar.edu/img/v3/logos/uniTitle.png">
<div>
<span class="bold">THREDDS Data Server</span>
<span class="service">NetCDF Subset Service</span>
</div>
</div>

<img src="https://www.unidata.ucar.edu/img/v3/logos/uniLogo.png">
</div>
</div>

<div class="dataset" th:fragment="dataset(datasetDesc)">
<h2>
<!-- Don't allow line break to occur between "Dataset:" label and the path. -->
Dataset:&nbsp;<span id="datasetPath" class="black" th:text="${datasetPath}">
/thredds/ncss/some/dataset/path
</span>
</h2>
<!--/* ncssStation.html is the only template that will override this default elem. */-->
<h4 th:replace="${datasetDesc}">(<a href="dataset.xml">Dataset Description</a>)</h4>
</div>

<!--/********************************** Sidebar fragments **********************************/-->

<div id="map" th:fragment="map"> <!-- This div is where we install the OpenLayers.Map in initMap(). --> </div>

<div id="latLonSubset" class="tabPane sidebarInput" th:fragment="latLonSubset">
<h5>Bounding box (in decimal degrees)</h5>

<div class="boundingBoxGrid">
<label class="topLabel" for="north">North</label>
<input class="topBox" type="text" name="north" id="north" required />

<label class="leftLabel" for="west">West</label>
<input class="leftBox" type="text" name="west" id="west" required />

<label class="rightLabel" for="east">East</label>
<input class="rightBox" type="text" name="east" id="east" required />

<label class="bottomLabel" for="south">South</label>
<input class="bottomBox" type="text" name="south" id="south" required />
</div>

<div th:replace=":: resetButtonContainer(fullLatLonExt)" />
</div>

<div id="pointSubset" class="tabPane sidebarInput" th:fragment="pointSubset">
<h5>Nearest to location (in decimal degrees)</h5>

<div class="verticalInputBoxesGrid vibg_2boxes">
<label class="vibg_label1" for="latitude">Latitude:</label>
<input class="vibg_box1" type="text" name="latitude" id="latitude" size="10" required/>

<label class="vibg_label2" for="longitude">Longitude:</label>
<input class="vibg_box2" type="text" name="longitude" id="longitude" size="10" required/>
</div>
</div>

<div id="timeSubsetInput" th:fragment="timeSubsetInput">
<div class="tabContainer">
<button type="button" onclick="selectTab(timeRangeSubset, this)" class="defaultButton">Time range</button>

<button type="button" onclick="selectTab(singleTimeSubset, this)">Single time</button>
</div>

<div id="timeRangeSubset" class="tabPane sidebarInput">
<div class="verticalInputBoxesGrid vibg_3boxes">
<label class="vibg_label1" for="time_start">Start:</label>
<input class="vibg_box1" type="text" name="time_start" id="time_start" size="27" required />

<label class="vibg_label2" for="time_end">End:</label>
<input class="vibg_box2" type="text" name="time_end" id="time_end" size="27" required />

<label class="vibg_label3" for="timeStride">Stride:</label>
<input class="vibg_box3" type="text" name="timeStride" id="timeStride" size="10" value="1" required />
</div>

<div th:replace=":: resetButtonContainer(fullTimeExt)" />
</div>

<div id="singleTimeSubset" class="tabPane sidebarInput">
<label for="time">Time:</label>
<input type="text" name="time" id="time" size="27" required />
</div>
</div>

<div id="outputFormatInput" class="sidebarInput" th:fragment="outputFormatInput">
<label for="accept">Format:</label>

<select id="accept" name="accept" size="1">
<option th:each="opt : ${accept}" th:value="${opt}" th:text="${opt}">format</option>
</select>
</div>

<div class="resetButtonContainer" th:fragment="resetButtonContainer(inputsMap)">
<button type="button" class="resetButton" th:onclick="|setInputValues(${inputsMap})|">
Reset to full extension
</button>
</div>

<!--/***************************************************************************************/-->

<div class="requestBuilder" th:fragment="requestBuilder">
<h3>NCSS request URL:</h3>
<pre id="urlBuilder">THIS WILL BE REPLACED BY buildAccessUrl().</pre>
</div>

<div class="buttons" th:fragment="buttons">
<button type="submit">Submit</button>
<button type="button" onclick="resetForm()">Reset</button>
</div>

<div class="footer" th:fragment="footer">
<h3>
<a href="http://www.unidata.ucar.edu/software/thredds/current/tds/reference/services/NetcdfSubsetServiceReference.html">
NetCDF Subset Service Documentation
</a>
</h3>
</div>
</body>

</body>
</html>
Loading

0 comments on commit 74d9b9e

Please sign in to comment.