-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1757 tm new routing #342
Closed
Closed
1757 tm new routing #342
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
262d4ab
add wip routing
soyarsauce b817dc2
Add prettier deps
soyarsauce a9bbb60
Add scripts
soyarsauce db434c7
Add husky
soyarsauce 32f6852
Apply prettier
soyarsauce 25aa4dc
Merge branch 'prettier-apply' into 1757-tm-new-routing
soyarsauce 0b046c3
Move prerendered routes into /prerender/
soyarsauce 5c1ff17
Ensure there are no multiple meta description tags
soyarsauce 3ae279e
Remove seperate prerender index to ejs
soyarsauce b67a03f
Update proper path for index
soyarsauce d6da6aa
wip remote stash
soyarsauce 253162d
Add sitemap generator
soyarsauce 4f525fc
Add sitemap generation
soyarsauce 9f5de41
Fix sitemap generation, speed up prerendering
soyarsauce 1daa20c
Merge branch 'prettier-new-apply' into 1757-tm-new-routing
soyarsauce 81b9616
Use named export
soyarsauce f1a4ebc
Make sure disclaimer gets shown on top, on load
soyarsauce 8704431
Use safer puppeteer concurrent route #
soyarsauce fcdb655
Update travis for prerender test
soyarsauce c8675bc
Merge remote-tracking branch 'origin/master' into 1757-tm-new-routing
soyarsauce File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
language: node_js | ||
dist: trusty | ||
addons: | ||
apt: | ||
packages: | ||
- libnss3 | ||
node_js: | ||
- '8' | ||
script: | ||
- gulp lint release | ||
env: | ||
- NODE_OPTIONS=--max_old_space_size=2048 | ||
before_install: | ||
# Enable user namespace cloning | ||
- "sysctl kernel.unprivileged_userns_clone=1" |
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,51 @@ | ||
var fs = require("fs"); | ||
var path = require("path"); | ||
var URI = require("urijs"); | ||
var CATALOG_ROUTE = require("terriajs/lib/ReactViewModels/TerriaRouting").CATALOG_ROUTE; | ||
|
||
const rootGroupName = "Root Group"; | ||
|
||
const getNameFromItem = item => item.name; | ||
const getIdFromItem = item => item.id; | ||
|
||
|
||
const getRoutes = (topCatalogItem, currentRoute = rootGroupName) => | ||
topCatalogItem.reduce((acc, catalogItem) => { | ||
const nameForCurrentItem = getNameFromItem(catalogItem); | ||
// Id is used for uniqueid, so disregard any pathing | ||
const idFromItem = getIdFromItem(catalogItem); | ||
const finalRoute = idFromItem || `${currentRoute}/${nameForCurrentItem}`; | ||
const items = catalogItem.items && getRoutes(catalogItem.items, finalRoute); | ||
|
||
if (items) { | ||
return [...acc, ...items, finalRoute]; | ||
} | ||
return [...acc, finalRoute]; | ||
}, []); | ||
/** | ||
* Given an array of init names for files in wwwroot/init/, traverse the catalog | ||
* and generate a list of routes to be prerendered at build time | ||
* | ||
* @param {Array} initUrls | ||
*/ | ||
function generateRoutes(initUrls) { | ||
const resUrl = url => | ||
path.resolve(__dirname, "..", "wwwroot", "init", `${url}.json`); | ||
|
||
const getCatalogFromInitName = initName => resUrl(initName); | ||
|
||
const routesFromInitCatalogs = initUrls.reduce((acc, initName) => { | ||
const fsPathForInit = getCatalogFromInitName(initName); | ||
const data = fs.readFileSync(fsPathForInit, "utf8"); | ||
const literal = JSON.parse(data).catalog; | ||
|
||
return [...acc, ...getRoutes(literal, `${rootGroupName}`)]; | ||
}, []); | ||
|
||
const encodedRoutes = routesFromInitCatalogs.map(route => `${CATALOG_ROUTE}${URI.encode(route)}`); | ||
|
||
// Make sure we also prerender /catalog/ incase user reloads on it? or serve up in terriajs server? | ||
return [CATALOG_ROUTE, ...encodedRoutes]; | ||
} | ||
|
||
module.exports = generateRoutes; |
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,35 @@ | ||
const generateUrl = (loc, lastmod, changefreq, priority) => (` | ||
<url> | ||
<loc>${loc}</loc> | ||
<lastmod>${lastmod}</lastmod> | ||
<changefreq>${changefreq}</changefreq> | ||
<priority>${priority}</priority> | ||
</url> | ||
`); | ||
|
||
/** | ||
* Generate a sitemap to be written out during build | ||
* | ||
* @param {string} baseUrl absolute URL to where your map is going to be deployed to, with a trailing slash | ||
* @param {array} catalogRoutes list of routes, e.g. ['/catalog', '/catalog/someId'] | ||
*/ | ||
const generateTerriaSitemap = (baseUrl, catalogRoutes) => { | ||
if (typeof baseUrl !== 'string') { | ||
throw 'baseUrl passed to generateTerriaSitemap is not a string?'; | ||
} | ||
if (baseUrl.substr(0,4) !== 'http') { | ||
throw 'baseUrl does not look absolute, check that it begins with http or https'; | ||
} | ||
const baseUrlWithoutTrailingSlash = (baseUrl.substr(-1) === '/') ? baseUrl.slice(0,-1) : baseUrl; | ||
const date = new Date().toISOString().substr(0, 10); | ||
|
||
const start = '<?xml version="1.0" encoding="UTF-8"?>'; | ||
const urlsetStart = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; | ||
const urlsetEnd = `</urlset>`; | ||
const homeUrl = generateUrl(baseUrl, date, 'daily', '0.9'); | ||
const routeUrls = catalogRoutes.map(route => generateUrl(`${baseUrlWithoutTrailingSlash}${route}`, date, 'weekly', '0.5')); | ||
|
||
return `${start}${urlsetStart}${homeUrl}${routeUrls.join('')}${urlsetEnd}`; | ||
}; | ||
|
||
module.exports = generateTerriaSitemap; |
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
{ | ||
"port": 3001, | ||
|
||
"baseHref": "/", | ||
|
||
"allowProxyFor" : [ | ||
"nicta.com.au", | ||
"gov.au", | ||
|
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,42 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" class="terria"> | ||
<head> | ||
<base href="<%= baseHref %>"> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"> <!-- Use Chrome Frame in IE --> | ||
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> | ||
<meta name="description" content="A web map built on Terria Map" data-react-helmet="true"> | ||
<meta name="copyright" content="Copyright(c) 2012-2016 National ICT Australia Limited (NICTA), CSIRO Data61. All rights reserved."> | ||
<meta name="apple-mobile-web-app-capable" content="yes"> | ||
|
||
<link rel="apple-touch-icon" sizes="57x57" href="favicons/apple-icon-57x57.png"> | ||
<link rel="apple-touch-icon" sizes="60x60" href="favicons/apple-icon-60x60.png"> | ||
<link rel="apple-touch-icon" sizes="72x72" href="favicons/apple-icon-72x72.png"> | ||
<link rel="apple-touch-icon" sizes="76x76" href="favicons/apple-icon-76x76.png"> | ||
<link rel="apple-touch-icon" sizes="114x114" href="favicons/apple-icon-114x114.png"> | ||
<link rel="apple-touch-icon" sizes="120x120" href="favicons/apple-icon-120x120.png"> | ||
<link rel="apple-touch-icon" sizes="144x144" href="favicons/apple-icon-144x144.png"> | ||
<link rel="apple-touch-icon" sizes="152x152" href="favicons/apple-icon-152x152.png"> | ||
<link rel="apple-touch-icon" sizes="180x180" href="favicons/apple-icon-180x180.png"> | ||
<link rel="icon" type="image/png" sizes="192x192" href="favicons/android-icon-192x192.png"> | ||
<link rel="icon" type="image/png" sizes="32x32" href="favicons/favicon-32x32.png"> | ||
<link rel="icon" type="image/png" sizes="96x96" href="favicons/favicon-96x96.png"> | ||
<link rel="icon" type="image/png" sizes="16x16" href="favicons/favicon-16x16.png"> | ||
<link rel="manifest" href="favicons/manifest.json"> | ||
<meta name="msapplication-TileColor" content="#282D32"> | ||
<meta name="msapplication-TileImage" content="favicons/ms-icon-144x144.png"> | ||
<meta name="theme-color" content="#282D32"> | ||
|
||
<title>Terria Map</title> | ||
|
||
<!-- Leaflet --> | ||
<script>L_PREFER_CANVAS = true;</script> | ||
<script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script> | ||
</head> | ||
|
||
<body> | ||
|
||
<div id='ui'></div> | ||
<script src="<%= baseHref %>build/TerriaMap.js"></script> | ||
</body> | ||
</html> |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually now index.html gets updated as part of the
render-datasource-templates
gulp task, should we remove this from source to avoid confusion?