From 86e60e6c5f5912d560419f7e4857c5ec9fbcf7c4 Mon Sep 17 00:00:00 2001 From: Sara Vieira Date: Thu, 22 Mar 2018 15:34:49 +0000 Subject: [PATCH] build(navigation): integrate namespaces and fonts --- packages/my-joy-images/package.json | 2 +- packages/my-joy-images/public/index.html | 2 +- packages/my-joy-instances/package.json | 2 +- packages/my-joy-instances/public/index.html | 2 +- packages/my-joy-navigation/lib/index.js | 83 +++++++++++-- packages/my-joy-navigation/package.json | 12 +- packages/my-joy-navigation/public/index.html | 2 +- .../public/static/css/libre-franklin.css | 31 +++++ .../libre-franklin/libre-franklin-bold.ttf | Bin 0 -> 81244 bytes .../libre-franklin/libre-franklin-light.ttf | Bin 0 -> 76968 bytes .../libre-franklin/libre-franklin-medium.ttf | Bin 0 -> 80732 bytes .../libre-franklin/libre-franklin-regular.ttf | Bin 0 -> 78768 bytes .../libre-franklin-semibold.ttf | Bin 0 -> 80352 bytes .../static/fonts/libre-franklin/license.txt | 93 +++++++++++++++ packages/my-joy-navigation/src/app.js | 25 +--- .../src/components/anchor.js | 13 ++ .../src/components/header.js | 2 +- .../my-joy-navigation/src/components/index.js | 2 + .../src/components/service.js | 3 + .../my-joy-navigation/src/components/sup.js | 14 +++ .../src/containers/datacenter.js | 75 +++++------- .../src/containers/services.js | 93 ++++++++------- packages/my-joy-navigation/src/header.js | 104 ++++++++-------- packages/my-joy-navigation/src/state/local.js | 111 +----------------- packages/my-joy-navigation/src/state/theme.js | 40 +++++++ 25 files changed, 415 insertions(+), 296 deletions(-) create mode 100644 packages/my-joy-navigation/public/static/css/libre-franklin.css create mode 100755 packages/my-joy-navigation/public/static/fonts/libre-franklin/libre-franklin-bold.ttf create mode 100755 packages/my-joy-navigation/public/static/fonts/libre-franklin/libre-franklin-light.ttf create mode 100755 packages/my-joy-navigation/public/static/fonts/libre-franklin/libre-franklin-medium.ttf create mode 100755 packages/my-joy-navigation/public/static/fonts/libre-franklin/libre-franklin-regular.ttf create mode 100755 packages/my-joy-navigation/public/static/fonts/libre-franklin/libre-franklin-semibold.ttf create mode 100755 packages/my-joy-navigation/public/static/fonts/libre-franklin/license.txt create mode 100644 packages/my-joy-navigation/src/components/anchor.js create mode 100644 packages/my-joy-navigation/src/components/sup.js create mode 100644 packages/my-joy-navigation/src/state/theme.js diff --git a/packages/my-joy-images/package.json b/packages/my-joy-images/package.json index ba745578..5dbdea0c 100644 --- a/packages/my-joy-images/package.json +++ b/packages/my-joy-images/package.json @@ -1,6 +1,6 @@ { "name": "my-joy-images", - "version": "1.3.6", + "version": "1.4.0", "private": true, "license": "MPL-2.0", "repository": "github:yldio/joyent-portal", diff --git a/packages/my-joy-images/public/index.html b/packages/my-joy-images/public/index.html index 7894e74b..94f53067 100644 --- a/packages/my-joy-images/public/index.html +++ b/packages/my-joy-images/public/index.html @@ -13,6 +13,6 @@
- + diff --git a/packages/my-joy-instances/package.json b/packages/my-joy-instances/package.json index 6d289c79..06e2c7b4 100644 --- a/packages/my-joy-instances/package.json +++ b/packages/my-joy-instances/package.json @@ -1,6 +1,6 @@ { "name": "my-joy-instances", - "version": "2.2.6", + "version": "2.3.0", "private": true, "license": "MPL-2.0", "repository": "github:yldio/joyent-portal", diff --git a/packages/my-joy-instances/public/index.html b/packages/my-joy-instances/public/index.html index 4e985743..eb081571 100644 --- a/packages/my-joy-instances/public/index.html +++ b/packages/my-joy-instances/public/index.html @@ -13,6 +13,6 @@
- + diff --git a/packages/my-joy-navigation/lib/index.js b/packages/my-joy-navigation/lib/index.js index 03f59079..324fb494 100644 --- a/packages/my-joy-navigation/lib/index.js +++ b/packages/my-joy-navigation/lib/index.js @@ -1,33 +1,90 @@ const Inert = require('inert'); const Path = require('path'); +const Url = require('url'); +const Intercept = require('apr-intercept'); +const Fs = require('mz/fs'); -const ROOT = Path.join(__dirname, '../build'); +const { NAMESPACE = 'navigation' } = process.env; exports.register = async server => { const manifest = require('../build/asset-manifest.json'); + const buildRoot = Path.join(__dirname, '../build'); + const buildStatic = Path.join(buildRoot, `${NAMESPACE}`); + const publicRoot = Path.join(__dirname, `../public/static`); - await server.register(Inert); + await server.register([ + { + plugin: Inert + } + ]); server.route([ { method: 'GET', - path: '/nav-static/{path*}', + path: `/${NAMESPACE}/service-worker.js`, config: { auth: false, - handler: (request, h) => { - const { params } = request; - const { path } = params; - - const file = manifest[path]; - - if (!file) { - return h.continue; + handler: { + file: { + path: Path.join(__dirname, '../build/service-worker.js') } + } + } + }, + { + method: 'GET', + path: `/${NAMESPACE}/favicon.ico`, + config: { + auth: false, + handler: { + file: { + path: Path.join(__dirname, '../build/favicon.ico') + } + } + } + }, + { + method: 'GET', + path: `/${NAMESPACE}/static/{rest*}`, + config: { + auth: false + }, + handler: async (request, h) => { + const { params } = request; + const { rest } = params; - return h.file(Path.join(ROOT, file), { - confine: ROOT + const publicPathname = Path.join(publicRoot, rest); + const [err1] = await Intercept( + Fs.access(publicPathname, Fs.constants.R_OK) + ); + + console.log({ publicPathname }); + + if (!err1) { + return h.file(publicPathname, { + confine: publicRoot }); } + + const buildMapPathname = Path.join(buildRoot, manifest[rest]); + const [err2] = await Intercept( + Fs.access(buildMapPathname, Fs.constants.R_OK) + ); + + console.log({ buildMapPathname }); + + if (!err2) { + return h.file(buildMapPathname, { + confine: buildStatic + }); + } + + console.log({ buildPathname }); + + const buildPathname = Path.join(buildStatic, rest); + return h.file(buildPathname, { + confine: buildStatic + }); } } ]); diff --git a/packages/my-joy-navigation/package.json b/packages/my-joy-navigation/package.json index 3c96e3e1..3b74c65f 100644 --- a/packages/my-joy-navigation/package.json +++ b/packages/my-joy-navigation/package.json @@ -1,15 +1,15 @@ { "name": "my-joy-navigation", - "version": "2.2.0", + "version": "2.3.1", "private": true, "license": "MPL-2.0", "main": "lib/index.js", "scripts": { - "dev": "NODE_ENV=development PREACT=1 REACT_APP_GQL_PORT=4000 PORT=3000 joyent-react-scripts start", + "dev": "NAMESPACE=navigation NODE_ENV=development PREACT=1 REACT_APP_GQL_PORT=3068 PORT=3000 joyent-react-scripts start", "build:test": "echo 0", "build:lib": "echo 0", - "build:bundle": "NODE_ENV=production redrun build", - "prepublish": "NODE_ENV=production redrun build", + "build:bundle": "NAMESPACE=navigation NODE_ENV=production redrun build", + "prepublish": "NAMESPACE=navigation NODE_ENV=production redrun build", "lint": "redrun lint:ci -- --fix", "lint:ci": "NODE_ENV=test eslint . --ext .js --ext .md", "test": "echo 0", @@ -22,6 +22,7 @@ "apollo-link": "^1.2.1", "apollo-link-http": "^1.5.2", "apollo-link-state": "^0.4.0", + "apr-intercept": "^3.0.3", "emotion": "^8.0.12", "emotion-theming": "^8.0.12", "graphql-tag": "^2.8.0", @@ -29,9 +30,10 @@ "joyent-icons": "^5.1.0", "joyent-ui-toolkit": "^6.0.0", "lodash.chunk": "^4.2.0", + "lodash.groupby": "^4.6.0", "lodash.keys": "^4.2.0", + "mz": "^2.7.0", "outy": "^0.1.2", - "param-case": "^2.1.1", "pascal-case": "^2.0.1", "preact": "^8.2.7", "preact-compat": "^3.18.0", diff --git a/packages/my-joy-navigation/public/index.html b/packages/my-joy-navigation/public/index.html index 4ff20351..242b419e 100644 --- a/packages/my-joy-navigation/public/index.html +++ b/packages/my-joy-navigation/public/index.html @@ -6,7 +6,7 @@