Skip to content

Commit

Permalink
(flavor) templated-site v2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
devinivy committed Aug 30, 2020
1 parent d71d5d7 commit 49c169e
Show file tree
Hide file tree
Showing 16 changed files with 120 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.min.js
*.build.js
3 changes: 3 additions & 0 deletions lib/path.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = __dirname;
3 changes: 3 additions & 0 deletions lib/plugins/@hapi.inert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = {};
3 changes: 3 additions & 0 deletions lib/plugins/@hapi.vision.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = {};
4 changes: 4 additions & 0 deletions lib/public/css/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body {
color: white;
background-color: black;
}
1 change: 1 addition & 0 deletions lib/public/css/main.min.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
body{color:#fff;background-color:#000}
3 changes: 3 additions & 0 deletions lib/public/js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

console.log('Hello, pals!');
1 change: 1 addition & 0 deletions lib/public/js/main.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"use strict";console.log("Hello, pals!");
11 changes: 11 additions & 0 deletions lib/routes/home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

module.exports = {
method: 'get',
path: '/',
handler: {
view: {
template: 'home'
}
}
};
11 changes: 11 additions & 0 deletions lib/routes/public.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

module.exports = {
method: 'get',
path: '/public/{p*}',
handler: {
directory: {
path: 'public'
}
}
};
File renamed without changes.
7 changes: 7 additions & 0 deletions lib/templates/home.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{#> layout title="Home" }}

{{#*inline "content"}}
Hello, pals! This is the homepage.
{{/inline}}

{{/layout}}
32 changes: 32 additions & 0 deletions lib/templates/partials/layout.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!doctype html>
<html>
<head>
<title>{{title}}</title>

{{#if options.developmentMode}}
<link rel="stylesheet" href="{{baseURI}}/public/css/main.css">
{{else}}
<link rel="stylesheet" href="{{baseURI}}/public/css/main.min.css">
{{/if}}

{{#> head-block}}
{{!-- Custom <head> content per page could be added. --}}
{{/head-block}}
</head>

<body>
{{#> content}}
{{!-- Content goes here. --}}
{{/content}}

{{#if options.developmentMode}}
<script src="{{baseURI}}/public/js/main.js"></script>
{{else}}
<script src="{{baseURI}}/public/js/main.min.js"></script>
{{/if}}

{{#> scripts-block}}
{{!-- Custom scripts per page can be added. --}}
{{/scripts-block}}
</body>
</html>
18 changes: 18 additions & 0 deletions lib/view-manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

const Handlebars = require('handlebars');

module.exports = (server, options) => ({
path: 'templates',
partialsPath: 'templates/partials',
helpersPath: 'templates/helpers',
isCached: !options.developmentMode,
defaultExtension: 'hbs',
engines: {
hbs: Handlebars
},
context: {
options,
baseURI: server.realm.modifiers.route.prefix || ''
}
});
18 changes: 14 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
"scripts": {
"start": "node server",
"test": "lab -a @hapi/code -L",
"lint": "eslint ."
"lint": "eslint .",
"build:css": "postcss lib/public/css/main.css -o lib/public/css/main.min.css --use cssnano --no-map",
"build:js": "uglifyjs lib/public/js/main.js -o lib/public/js/main.min.js",
"build": "npm run build:css && npm run build:js"
},
"dependencies": {
"@hapi/boom": "9.x.x",
"joi": "17.x.x",
"haute-couture": "3.x.x"
"@hapi/inert": "6.x.x",
"@hapi/vision": "6.x.x",
"handlebars": "4.x.x",
"haute-couture": "3.x.x",
"joi": "17.x.x"
},
"devDependencies": {
"@hapi/code": "8.x.x",
Expand All @@ -21,10 +27,14 @@
"@hapi/lab": "23.x.x",
"babel-eslint": "10.x.x",
"confidence": "4.x.x",
"cssnano": "4.x.x",
"dotenv": "8.x.x",
"eslint": "7.x.x",
"hpal": "2.x.x",
"hpal-debug": "1.x.x",
"toys": "2.x.x"
"postcss": "7.x.x",
"postcss-cli": "7.x.x",
"toys": "2.x.x",
"uglify-js": "3.x.x"
}
}
8 changes: 7 additions & 1 deletion server/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ module.exports = new Confidence.Store({
plugins: [
{
plugin: '../lib', // Main plugin
options: {}
options: {
developmentMode: {
$filter: { $env: 'NODE_ENV' },
$default: true,
production: false
}
}
},
{
plugin: {
Expand Down

0 comments on commit 49c169e

Please sign in to comment.