legacyweb-pages 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/README.md +5 -0
  2. package/ejstest.js +0 -0
  3. package/index.js +3 -0
  4. package/lib/page.js +125 -0
  5. package/lib/theme.js +46 -0
  6. package/package.json +17 -0
  7. package/samples/left-business/business.js +30 -0
  8. package/samples/left-business/content-home.pug +2 -0
  9. package/samples/left-business/content-page1.pug +2 -0
  10. package/samples/left-business/header.html +1 -0
  11. package/samples/left-christmas/christmas.js +30 -0
  12. package/samples/left-christmas/content-home.pug +2 -0
  13. package/samples/left-christmas/content-page1.pug +2 -0
  14. package/samples/left-christmas/header.html +1 -0
  15. package/samples/left-fall/content-home.pug +2 -0
  16. package/samples/left-fall/content-page1.pug +2 -0
  17. package/samples/left-fall/fall.js +30 -0
  18. package/samples/left-fall/header.html +1 -0
  19. package/samples/left-forest/content-home.pug +2 -0
  20. package/samples/left-forest/content-page1.pug +2 -0
  21. package/samples/left-forest/forest.js +33 -0
  22. package/samples/left-forest/header.html +1 -0
  23. package/samples/left-forest/images/leaves.jpg +0 -0
  24. package/samples/left-library/content-home.pug +2 -0
  25. package/samples/left-library/content-page1.pug +2 -0
  26. package/samples/left-library/header.html +1 -0
  27. package/samples/left-library/library.js +30 -0
  28. package/samples/left-ocean/content-home.pug +2 -0
  29. package/samples/left-ocean/content-page1.pug +2 -0
  30. package/samples/left-ocean/header.html +1 -0
  31. package/samples/left-ocean/ocean.js +30 -0
  32. package/samples/left-sami/content-home.pug +2 -0
  33. package/samples/left-sami/content-page1.pug +2 -0
  34. package/samples/left-sami/header.html +1 -0
  35. package/samples/left-sami/sami.js +30 -0
  36. package/samples/left-space/content-home.pug +2 -0
  37. package/samples/left-space/content-page1.pug +2 -0
  38. package/samples/left-space/header.html +1 -0
  39. package/samples/left-space/space.js +30 -0
  40. package/samples/left-spring/content-home.pug +2 -0
  41. package/samples/left-spring/content-page1.pug +2 -0
  42. package/samples/left-spring/header.html +1 -0
  43. package/samples/left-spring/spring.js +30 -0
  44. package/samples/left-summer/content-home.pug +2 -0
  45. package/samples/left-summer/content-page1.pug +2 -0
  46. package/samples/left-summer/header.html +1 -0
  47. package/samples/left-summer/summer.js +30 -0
  48. package/samples/left-winter/content-home.pug +2 -0
  49. package/samples/left-winter/content-page1.pug +2 -0
  50. package/samples/left-winter/header.html +1 -0
  51. package/samples/left-winter/winter.js +30 -0
  52. package/samples/ribbon-business/content-home.pug +55 -0
  53. package/samples/ribbon-business/content-page1.pug +2 -0
  54. package/samples/ribbon-business/header.html +1 -0
  55. package/samples/ribbon-business/ribbon-business.js +28 -0
  56. package/samples/ribbon-business/strip.pug +1 -0
  57. package/templates/leftpane.ejs +45 -0
  58. package/templates/ribbon.ejs +38 -0
  59. package/themes/business.json +28 -0
  60. package/themes/christmas.json +30 -0
  61. package/themes/fall.json +30 -0
  62. package/themes/forest.json +30 -0
  63. package/themes/library.json +30 -0
  64. package/themes/ocean.json +30 -0
  65. package/themes/sami.json +30 -0
  66. package/themes/space.json +29 -0
  67. package/themes/spring.json +30 -0
  68. package/themes/summer.json +30 -0
  69. package/themes/winter.json +30 -0
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # legacyweb-pages
2
+
3
+ This is a toolkit for generating simple pages for legacyweb.
4
+
5
+ It includes templates, themes, and functions for generating pages based on these. This project is currently under development.
package/ejstest.js ADDED
File without changes
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ const Page = require('./lib/page');
2
+
3
+ module.exports = Page;
package/lib/page.js ADDED
@@ -0,0 +1,125 @@
1
+ const ejs = require('ejs');
2
+ const express = require('express');
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const joi = require('joi');
6
+
7
+ const relativePath = joi.string().regex(/^\/[a-z0-9\/]*$/);
8
+
9
+ function Page(template, theme, title, home, addHomeLink=true, staticPaths=[]) {
10
+ this.setTemplate(template);
11
+ this.setTheme(theme);
12
+ this.pages = [];
13
+ this.links = [];
14
+ this.addPage({
15
+ path: '/',
16
+ gen: home.gen,
17
+ title,
18
+ method: 'get'
19
+ });
20
+ if (addHomeLink) {
21
+ this.addLink({
22
+ url: '/',
23
+ text: 'Home'
24
+ });
25
+ }
26
+ this.headerHtml = '';
27
+ this.port = process.env.EXPRESS_PORT || 3000;
28
+ this.app = express();
29
+
30
+ // Define static paths
31
+ staticPaths.forEach(staticPath => {
32
+ this.app.use('/images', express.static(staticPath));
33
+ });
34
+ }
35
+
36
+ Page.prototype.setTemplate = function(template) {
37
+ const templateFile = path.join(__dirname, '..', 'templates', `${template}.ejs`);
38
+ if (!fs.existsSync(templateFile)) {
39
+ throw new Error(`Theme "${templateFile}" does not exist`);
40
+ }
41
+ this.template = fs.readFileSync(templateFile, 'utf-8');
42
+ }
43
+
44
+ Page.prototype.setTheme = function(theme) {
45
+ const themeFile = path.join(__dirname, '..', 'themes', `${theme}.json`);
46
+ if (!fs.existsSync(themeFile)) {
47
+ throw new Error(`Theme "${theme}" does not exist`);
48
+ }
49
+ this.theme = JSON.parse(fs.readFileSync(themeFile), 'utf-8');
50
+ }
51
+
52
+ Page.prototype.setBgImage = function(element, bgImage) {
53
+ joi.attempt(element, joi.string().valid('body', 'links', 'strip', 'content'));
54
+ this.theme[element].bgImage = bgImage;
55
+ }
56
+
57
+ Page.prototype.setHeader = function(code) {
58
+ this.headerHtml = code;
59
+ }
60
+
61
+ Page.prototype.setStrip = function(code) {
62
+ this.stripHtml = code;
63
+ }
64
+
65
+ Page.prototype.addLink = function(link) {
66
+ joi.attempt(link, joi.object({
67
+ url: joi.alternatives().try(joi.string().uri(), relativePath).required(),
68
+ text: joi.string().min(1).required()
69
+ }));
70
+ this.links.push(link);
71
+ }
72
+
73
+ Page.prototype.addPage = function(page) {
74
+ let validatedPage = joi.attempt(page, joi.object({
75
+ path: relativePath.required(),
76
+ gen: joi.func().required(),
77
+ title: joi.string().min(1).required(),
78
+ method: joi.string().valid('get', 'post').default('get'),
79
+ middleware: joi.array().default([])
80
+ }));
81
+
82
+ this.pages.push(validatedPage);
83
+ }
84
+
85
+ Page.prototype.start = function() {
86
+
87
+ const legacyPage = this;
88
+
89
+ this.pages.forEach(page => {
90
+ const renderPage = async function(req, res) {
91
+ try {
92
+ // Render content first in case we want to change the theme, header, etc. as part of the gen fn
93
+ const content = await page.gen(req, res);
94
+
95
+ const data = Object.assign({
96
+ page: {
97
+ header: legacyPage.headerHtml,
98
+ strip: legacyPage.stripHtml,
99
+ links: legacyPage.links,
100
+ content
101
+ }
102
+ }, legacyPage.theme);
103
+ const renderedPage = ejs.render(legacyPage.template, data);
104
+
105
+ res.status(200).send(renderedPage);
106
+ } catch (err) {
107
+ const statusCode = err.status || 500;
108
+ return res.status(statusCode).send(err.message);
109
+ }
110
+ }
111
+
112
+ switch (page.method) {
113
+ case 'post':
114
+ legacyPage.app.post(page.path, page.middleware, renderPage);
115
+ return;
116
+ default:
117
+ legacyPage.app.get(page.path, page.middleware, renderPage);
118
+ return;
119
+ }
120
+ });
121
+
122
+ this.app.listen(this.port);
123
+ }
124
+
125
+ module.exports = Page
package/lib/theme.js ADDED
@@ -0,0 +1,46 @@
1
+ const joi = require('joi');
2
+
3
+ function Theme(theme) {
4
+ const schema = joi.object({
5
+ body: joi.object({
6
+ bgColor: joi.string().default('white'),
7
+ bgImage: joi.string().optional(),
8
+ linkColor: joi.string().default('blue'),
9
+ borderColor: joi.string().default('black'),
10
+ borderThickness: joi.number().default(4)
11
+ }).default(),
12
+ header: joi.object({
13
+ bgColor: joi.string().default('white'),
14
+ bgImage: joi.string().optional(),
15
+ font: joi.object({
16
+ face: joi.string().default('Tahoma'),
17
+ bold: joi.boolean().default(true),
18
+ color: joi.string().default('black')
19
+ }).default()
20
+ }).default(),
21
+ links: joi.object({
22
+ bgColor: joi.string().default('white'),
23
+ bgImage: joi.string().optional(),
24
+ font: joi.object({
25
+ face: joi.string().default('Tahoma'),
26
+ bold: joi.boolean.default(true),
27
+ color: joi.string().default('black')
28
+ }).default()
29
+ }),
30
+ content: joi.object({
31
+ bgColor: joi.string().default('white'),
32
+ bgImage: joi.string().optional(),
33
+ font: joi.object({
34
+ face: joi.string().default('Tahoma'),
35
+ bold: joi.boolean.default(false),
36
+ color: joi.string().default('black')
37
+ }).default()
38
+ }).default()
39
+ }).default();
40
+
41
+ const validated = joi.attempt(theme, schema, {stripUnknown: true});
42
+
43
+ return validated;
44
+ }
45
+
46
+ module.exports = Theme;
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "legacyweb-pages",
3
+ "version": "1.0.0",
4
+ "description": "A toolkit for generating legacyweb pages",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "Justin Schwartzbeck (justinmschw@gmail.com)",
10
+ "license": "ISC",
11
+ "dependencies": {
12
+ "ejs": "3.1.6",
13
+ "express": "4.17.2",
14
+ "joi": "17.5.0",
15
+ "pug": "3.0.2"
16
+ }
17
+ }
@@ -0,0 +1,30 @@
1
+ const Page = require('../../lib/page');
2
+ const pug = require('pug');
3
+ const fs = require('fs');
4
+
5
+ const header = fs.readFileSync('./header.html', 'utf-8');
6
+ const contentHome = pug.render(fs.readFileSync('./content-home.pug', 'utf-8'), {});
7
+ const contentPage1 = fs.readFileSync('./content-page1.pug', 'utf-8');
8
+
9
+ const myLeftPage = new Page('leftpane', 'business', 'Sample Page', {
10
+ gen: function() {
11
+ return Promise.resolve(contentHome);
12
+ }
13
+ });
14
+
15
+ myLeftPage.setHeader(header);
16
+
17
+ myLeftPage.addPage({
18
+ path: '/page1',
19
+ gen: async function() {
20
+ return Promise.resolve(pug.render(contentPage1, {name: 'Justin'}));
21
+ },
22
+ title: 'Page 1'
23
+ });
24
+
25
+ myLeftPage.addLink({
26
+ url: '/page1',
27
+ text: 'Page 1'
28
+ });
29
+
30
+ myLeftPage.start();
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Content goes here
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Hello #{name}
@@ -0,0 +1 @@
1
+ Sample Header
@@ -0,0 +1,30 @@
1
+ const Page = require('../../lib/page');
2
+ const pug = require('pug');
3
+ const fs = require('fs');
4
+
5
+ const header = fs.readFileSync('./header.html', 'utf-8');
6
+ const contentHome = pug.render(fs.readFileSync('./content-home.pug', 'utf-8'), {});
7
+ const contentPage1 = fs.readFileSync('./content-page1.pug', 'utf-8');
8
+
9
+ const myLeftPage = new Page('leftpane', 'christmas', 'Sample Page', {
10
+ gen: function() {
11
+ return Promise.resolve(contentHome);
12
+ }
13
+ });
14
+
15
+ myLeftPage.setHeader(header);
16
+
17
+ myLeftPage.addPage({
18
+ path: '/page1',
19
+ gen: async function() {
20
+ return Promise.resolve(pug.render(contentPage1, {name: 'Justin'}));
21
+ },
22
+ title: 'Page 1'
23
+ });
24
+
25
+ myLeftPage.addLink({
26
+ url: '/page1',
27
+ text: 'Page 1'
28
+ });
29
+
30
+ myLeftPage.start();
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Content goes here
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Hello #{name}
@@ -0,0 +1 @@
1
+ Sample Header
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Content goes here
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Hello #{name}
@@ -0,0 +1,30 @@
1
+ const Page = require('../../lib/page');
2
+ const pug = require('pug');
3
+ const fs = require('fs');
4
+
5
+ const header = fs.readFileSync('./header.html', 'utf-8');
6
+ const contentHome = pug.render(fs.readFileSync('./content-home.pug', 'utf-8'), {});
7
+ const contentPage1 = fs.readFileSync('./content-page1.pug', 'utf-8');
8
+
9
+ const myLeftPage = new Page('leftpane', 'fall', 'Sample Page', {
10
+ gen: function() {
11
+ return Promise.resolve(contentHome);
12
+ }
13
+ });
14
+
15
+ myLeftPage.setHeader(header);
16
+
17
+ myLeftPage.addPage({
18
+ path: '/page1',
19
+ gen: async function() {
20
+ return Promise.resolve(pug.render(contentPage1, {name: 'Justin'}));
21
+ },
22
+ title: 'Page 1'
23
+ });
24
+
25
+ myLeftPage.addLink({
26
+ url: '/page1',
27
+ text: 'Page 1'
28
+ });
29
+
30
+ myLeftPage.start();
@@ -0,0 +1 @@
1
+ Sample Header
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Content goes here
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Hello #{name}
@@ -0,0 +1,33 @@
1
+ const Page = require('../../lib/page');
2
+ const pug = require('pug');
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const header = fs.readFileSync('./header.html', 'utf-8');
7
+ const contentHome = pug.render(fs.readFileSync('./content-home.pug', 'utf-8'), {});
8
+ const contentPage1 = fs.readFileSync('./content-page1.pug', 'utf-8');
9
+
10
+ const myLeftPage = new Page('leftpane', 'forest', 'Sample Page', {
11
+ gen: function() {
12
+ return Promise.resolve(contentHome);
13
+ }
14
+ }, true, [path.join(__dirname, 'images')]);
15
+
16
+ myLeftPage.setBgImage('body', '/images/leaves.jpg');
17
+
18
+ myLeftPage.setHeader(header);
19
+
20
+ myLeftPage.addPage({
21
+ path: '/page1',
22
+ gen: async function() {
23
+ return Promise.resolve(pug.render(contentPage1, {name: 'Justin'}));
24
+ },
25
+ title: 'Page 1'
26
+ });
27
+
28
+ myLeftPage.addLink({
29
+ url: '/page1',
30
+ text: 'Page 1'
31
+ });
32
+
33
+ myLeftPage.start();
@@ -0,0 +1 @@
1
+ Sample Header
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Content goes here
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Hello #{name}
@@ -0,0 +1 @@
1
+ Sample Header
@@ -0,0 +1,30 @@
1
+ const Page = require('../../lib/page');
2
+ const pug = require('pug');
3
+ const fs = require('fs');
4
+
5
+ const header = fs.readFileSync('./header.html', 'utf-8');
6
+ const contentHome = pug.render(fs.readFileSync('./content-home.pug', 'utf-8'), {});
7
+ const contentPage1 = fs.readFileSync('./content-page1.pug', 'utf-8');
8
+
9
+ const myLeftPage = new Page('leftpane', 'library', 'Sample Page', {
10
+ gen: function() {
11
+ return Promise.resolve(contentHome);
12
+ }
13
+ });
14
+
15
+ myLeftPage.setHeader(header);
16
+
17
+ myLeftPage.addPage({
18
+ path: '/page1',
19
+ gen: async function() {
20
+ return Promise.resolve(pug.render(contentPage1, {name: 'Justin'}));
21
+ },
22
+ title: 'Page 1'
23
+ });
24
+
25
+ myLeftPage.addLink({
26
+ url: '/page1',
27
+ text: 'Page 1'
28
+ });
29
+
30
+ myLeftPage.start();
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Content goes here
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Hello #{name}
@@ -0,0 +1 @@
1
+ Sample Header
@@ -0,0 +1,30 @@
1
+ const Page = require('../../lib/page');
2
+ const pug = require('pug');
3
+ const fs = require('fs');
4
+
5
+ const header = fs.readFileSync('./header.html', 'utf-8');
6
+ const contentHome = pug.render(fs.readFileSync('./content-home.pug', 'utf-8'), {});
7
+ const contentPage1 = fs.readFileSync('./content-page1.pug', 'utf-8');
8
+
9
+ const myLeftPage = new Page('leftpane', 'ocean', 'Sample Page', {
10
+ gen: function() {
11
+ return Promise.resolve(contentHome);
12
+ }
13
+ });
14
+
15
+ myLeftPage.setHeader(header);
16
+
17
+ myLeftPage.addPage({
18
+ path: '/page1',
19
+ gen: async function() {
20
+ return Promise.resolve(pug.render(contentPage1, {name: 'Justin'}));
21
+ },
22
+ title: 'Page 1'
23
+ });
24
+
25
+ myLeftPage.addLink({
26
+ url: '/page1',
27
+ text: 'Page 1'
28
+ });
29
+
30
+ myLeftPage.start();
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Content goes here
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Hello #{name}
@@ -0,0 +1 @@
1
+ Sample Header
@@ -0,0 +1,30 @@
1
+ const Page = require('../../lib/page');
2
+ const pug = require('pug');
3
+ const fs = require('fs');
4
+
5
+ const header = fs.readFileSync('./header.html', 'utf-8');
6
+ const contentHome = pug.render(fs.readFileSync('./content-home.pug', 'utf-8'), {});
7
+ const contentPage1 = fs.readFileSync('./content-page1.pug', 'utf-8');
8
+
9
+ const myLeftPage = new Page('leftpane', 'sami', 'Sample Page', {
10
+ gen: function() {
11
+ return Promise.resolve(contentHome);
12
+ }
13
+ });
14
+
15
+ myLeftPage.setHeader(header);
16
+
17
+ myLeftPage.addPage({
18
+ path: '/page1',
19
+ gen: async function() {
20
+ return Promise.resolve(pug.render(contentPage1, {name: 'Justin'}));
21
+ },
22
+ title: 'Page 1'
23
+ });
24
+
25
+ myLeftPage.addLink({
26
+ url: '/page1',
27
+ text: 'Page 1'
28
+ });
29
+
30
+ myLeftPage.start();
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Content goes here
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Hello #{name}
@@ -0,0 +1 @@
1
+ Sample Header
@@ -0,0 +1,30 @@
1
+ const Page = require('../../lib/page');
2
+ const pug = require('pug');
3
+ const fs = require('fs');
4
+
5
+ const header = fs.readFileSync('./header.html', 'utf-8');
6
+ const contentHome = pug.render(fs.readFileSync('./content-home.pug', 'utf-8'), {});
7
+ const contentPage1 = fs.readFileSync('./content-page1.pug', 'utf-8');
8
+
9
+ const myLeftPage = new Page('leftpane', 'space', 'Sample Page', {
10
+ gen: function() {
11
+ return Promise.resolve(contentHome);
12
+ }
13
+ });
14
+
15
+ myLeftPage.setHeader(header);
16
+
17
+ myLeftPage.addPage({
18
+ path: '/page1',
19
+ gen: async function() {
20
+ return Promise.resolve(pug.render(contentPage1, {name: 'Justin'}));
21
+ },
22
+ title: 'Page 1'
23
+ });
24
+
25
+ myLeftPage.addLink({
26
+ url: '/page1',
27
+ text: 'Page 1'
28
+ });
29
+
30
+ myLeftPage.start();
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Content goes here
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Hello #{name}
@@ -0,0 +1 @@
1
+ Sample Header
@@ -0,0 +1,30 @@
1
+ const Page = require('../../lib/page');
2
+ const pug = require('pug');
3
+ const fs = require('fs');
4
+
5
+ const header = fs.readFileSync('./header.html', 'utf-8');
6
+ const contentHome = pug.render(fs.readFileSync('./content-home.pug', 'utf-8'), {});
7
+ const contentPage1 = fs.readFileSync('./content-page1.pug', 'utf-8');
8
+
9
+ const myLeftPage = new Page('leftpane', 'spring', 'Sample Page', {
10
+ gen: function() {
11
+ return Promise.resolve(contentHome);
12
+ }
13
+ });
14
+
15
+ myLeftPage.setHeader(header);
16
+
17
+ myLeftPage.addPage({
18
+ path: '/page1',
19
+ gen: async function() {
20
+ return Promise.resolve(pug.render(contentPage1, {name: 'Justin'}));
21
+ },
22
+ title: 'Page 1'
23
+ });
24
+
25
+ myLeftPage.addLink({
26
+ url: '/page1',
27
+ text: 'Page 1'
28
+ });
29
+
30
+ myLeftPage.start();
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Content goes here
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Hello #{name}
@@ -0,0 +1 @@
1
+ Sample Header
@@ -0,0 +1,30 @@
1
+ const Page = require('../../lib/page');
2
+ const pug = require('pug');
3
+ const fs = require('fs');
4
+
5
+ const header = fs.readFileSync('./header.html', 'utf-8');
6
+ const contentHome = pug.render(fs.readFileSync('./content-home.pug', 'utf-8'), {});
7
+ const contentPage1 = fs.readFileSync('./content-page1.pug', 'utf-8');
8
+
9
+ const myLeftPage = new Page('leftpane', 'summer', 'Sample Page', {
10
+ gen: function() {
11
+ return Promise.resolve(contentHome);
12
+ }
13
+ });
14
+
15
+ myLeftPage.setHeader(header);
16
+
17
+ myLeftPage.addPage({
18
+ path: '/page1',
19
+ gen: async function() {
20
+ return Promise.resolve(pug.render(contentPage1, {name: 'Justin'}));
21
+ },
22
+ title: 'Page 1'
23
+ });
24
+
25
+ myLeftPage.addLink({
26
+ url: '/page1',
27
+ text: 'Page 1'
28
+ });
29
+
30
+ myLeftPage.start();
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Content goes here
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Hello #{name}
@@ -0,0 +1 @@
1
+ Sample Header
@@ -0,0 +1,30 @@
1
+ const Page = require('../../lib/page');
2
+ const pug = require('pug');
3
+ const fs = require('fs');
4
+
5
+ const header = fs.readFileSync('./header.html', 'utf-8');
6
+ const contentHome = pug.render(fs.readFileSync('./content-home.pug', 'utf-8'), {});
7
+ const contentPage1 = fs.readFileSync('./content-page1.pug', 'utf-8');
8
+
9
+ const myLeftPage = new Page('leftpane', 'winter', 'Sample Page', {
10
+ gen: function() {
11
+ return Promise.resolve(contentHome);
12
+ }
13
+ });
14
+
15
+ myLeftPage.setHeader(header);
16
+
17
+ myLeftPage.addPage({
18
+ path: '/page1',
19
+ gen: async function() {
20
+ return Promise.resolve(pug.render(contentPage1, {name: 'Justin'}));
21
+ },
22
+ title: 'Page 1'
23
+ });
24
+
25
+ myLeftPage.addLink({
26
+ url: '/page1',
27
+ text: 'Page 1'
28
+ });
29
+
30
+ myLeftPage.start();
@@ -0,0 +1,55 @@
1
+ block content
2
+ p Content goes here
3
+ p a
4
+ p b
5
+ p c
6
+ p d
7
+ p e
8
+ p f
9
+ p g
10
+ p h
11
+ p i
12
+ p j
13
+ p k
14
+ p l
15
+ p m
16
+ p n
17
+ p o
18
+ p p
19
+ p q
20
+ p r
21
+ p s
22
+ p t
23
+ p u
24
+ p v
25
+ p w
26
+ p x
27
+ p y
28
+ p z
29
+ p Content goes here
30
+ p a
31
+ p b
32
+ p c
33
+ p d
34
+ p e
35
+ p f
36
+ p g
37
+ p h
38
+ p i
39
+ p j
40
+ p k
41
+ p l
42
+ p m
43
+ p n
44
+ p o
45
+ p p
46
+ p q
47
+ p r
48
+ p s
49
+ p t
50
+ p u
51
+ p v
52
+ p w
53
+ p x
54
+ p y
55
+ p z
@@ -0,0 +1,2 @@
1
+ block content
2
+ p Hello #{name}
@@ -0,0 +1 @@
1
+ Sample Header
@@ -0,0 +1,28 @@
1
+ const Page = require('../../lib/page');
2
+ const pug = require('pug');
3
+ const fs = require('fs');
4
+
5
+ const header = fs.readFileSync('./header.html', 'utf-8');
6
+ const strip = pug.render(fs.readFileSync('./strip.pug', 'utf-8'), {});
7
+ const contentHome = pug.render(fs.readFileSync('./content-home.pug', 'utf-8'), {});
8
+ const contentPage1 = fs.readFileSync('./content-page1.pug', 'utf-8');
9
+
10
+ const myRibbonPage = new Page('ribbon', 'business', 'Sample Page', {
11
+ gen: function() {
12
+ return Promise.resolve(contentHome);
13
+ }
14
+ });
15
+
16
+ myRibbonPage.setHeader(header);
17
+
18
+ myRibbonPage.setStrip(strip);
19
+
20
+ myRibbonPage.addPage({
21
+ path: '/page1',
22
+ gen: async function() {
23
+ return Promise.resolve(pug.render(contentPage1, {name: 'Justin'}));
24
+ },
25
+ title: 'Page 1'
26
+ });
27
+
28
+ myRibbonPage.start();
@@ -0,0 +1 @@
1
+ p This is where strip content goes: links, etc.
@@ -0,0 +1,45 @@
1
+ <html>
2
+ <body bgcolor="<%= body.bgColor %>" <% if (body.bgImage) { %>background="<%- body.bgImage %>"<% } %> link="<%= body.linkColor %>" vlink="<%= body.linkColor %>">
3
+
4
+ <table width="780px" border=0>
5
+ <tr>
6
+ <!-- This is actually where the "border" color is defined -->
7
+ <td bgcolor="<%= body.borderColor %>">
8
+
9
+ <!-- This inner table is where the page content (header, links, content) actually go
10
+ cellspacing = border thickness
11
+ -->
12
+ <table width="780px" border=0 cellspacing=<%= body.borderThickness %> >
13
+ <tr />
14
+
15
+ <td height=80px colspan=2 bgcolor="<%= header.bgColor %>" <% if (header.bgImage) { %> background="<%= header.bgImage %>" <% } %>>
16
+ <font size=7 face="<%= header.font.face %>" color="<%= header.font.color %>">
17
+ <% if (header.font.bold) { %> <b><%- page.header %></b> <% } else { %><%- page.header %><% } %>
18
+ </font>
19
+ </td>
20
+
21
+ <tr />
22
+ <td height=600px width=180px bgcolor="<%= links.bgColor %>" <% if (links.bgImage) { %> background="<%= links.bgImage %>" <% } %> valign=top>
23
+ <table border="0">
24
+ <% page.links.forEach(link => { %>
25
+ <tr>
26
+ <td <% if (links.bgColor) { %>bgcolor="<%= links.bgColor %>"<% } %>>
27
+ <font size=4 face="<%= links.font.face %>">
28
+ <% if (links.font.bold) { %><b><a href="<%- link.url %>"><%= link.text %></a></b><% } else { %><a href="<%- link.url %>"><%= link.text %></a><% } %>
29
+ </font>
30
+ </td>
31
+ </tr>
32
+ <%})%>
33
+ </table>
34
+ </td>
35
+ <td height=600px width=600px bgcolor="<%= content.bgColor %>" <% if (content.bgImage) { %> background="<%= content.bgImage %>" <% } %> valign=top>
36
+ <font face="<%= content.font.face %>">
37
+ <%- page.content %>
38
+ </font>
39
+ </td>
40
+ </table>
41
+ </td>
42
+ </table>
43
+
44
+ </body>
45
+ </html>
@@ -0,0 +1,38 @@
1
+ <html>
2
+ <body bgcolor="<%= body.bgColor %>" <% if (body.bgImage) { %>background="<%- body.bgImage %>"<% } %> link="<%= body.linkColor %>" vlink="<%= body.linkColor %>">
3
+ <center>
4
+ <table width="786px" border=0>
5
+ <tr>
6
+ <!-- This is actually where the "border" color is defined -->
7
+ <td bgcolor="<%= body.borderColor %>">
8
+
9
+ <!-- This inner table is where the page content (header, links, content) actually go
10
+ cellspacing = border thickness
11
+ -->
12
+ <table width="780px" border=0 cellspacing=<%= body.borderThickness %> >
13
+ <tr />
14
+
15
+ <td height=80px bgcolor="<%= header.bgColor %>" <% if (header.bgImage) { %> background="<%= header.bgImage %>" <% } %>>
16
+ <font size=7 face="<%= header.font.face %>" color="<%= header.font.color %>">
17
+ <% if (header.font.bold) { %> <b><%- page.header %></b> <% } else { %><%- page.header %><% } %>
18
+ </font>
19
+ </td>
20
+
21
+ <tr>
22
+ <td height=20px bgcolor="<%= links.bgColor %>" <% if (links.bgImage) { %> background="<%= links.bgImage %>" <% } %> valign=top>
23
+ <%- page.strip %>
24
+ </td>
25
+ </tr>
26
+ <tr />
27
+
28
+ <td bgcolor="<%= content.bgColor %>" <% if (content.bgImage) { %> background="<%= content.bgImage %>" <% } %> valign=top>
29
+ <font face="<%= content.font.face %>">
30
+ <%- page.content %>
31
+ </font>
32
+ </td>
33
+ </table>
34
+ </td>
35
+ </table>
36
+ </center>
37
+ </body>
38
+ </html>
@@ -0,0 +1,28 @@
1
+ {
2
+ "body": {
3
+ "bgColor": "#00008B",
4
+ "linkColor": "blue",
5
+ "borderColor": "black",
6
+ "borderThickness": 4
7
+ },
8
+ "header": {
9
+ "bgColor": "#808080",
10
+ "font": {
11
+ "face": "Courier New",
12
+ "bold": true
13
+ }
14
+ },
15
+ "links": {
16
+ "bgColor": "#D3D3D3",
17
+ "font": {
18
+ "face": "Tahoma",
19
+ "bold": true
20
+ }
21
+ },
22
+ "content": {
23
+ "bgColor": "#FFFFFF",
24
+ "font": {
25
+ "face": "Tahoma"
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "body": {
3
+ "bgColor": "#2F4F4F",
4
+ "linkColor": "#daa520",
5
+ "borderColor": "#daa520",
6
+ "borderThickness": 4
7
+ },
8
+ "header": {
9
+ "bgColor": "#b22222",
10
+ "font": {
11
+ "face": "Comic Sans MS",
12
+ "color": "#daa520",
13
+ "bold": true
14
+ }
15
+ },
16
+ "links": {
17
+ "bgColor": "#006400",
18
+ "font": {
19
+ "face": "Tahoma",
20
+ "color": "#daa520",
21
+ "bold": true
22
+ }
23
+ },
24
+ "content": {
25
+ "bgColor": "#FFFFFF",
26
+ "font": {
27
+ "face": "Tahoma"
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "body": {
3
+ "bgColor": "#006400",
4
+ "linkColor": "#DAA520",
5
+ "borderColor": "#B22222",
6
+ "borderThickness": 4
7
+ },
8
+ "header": {
9
+ "bgColor": "#DAA520",
10
+ "font": {
11
+ "face": "Georgia",
12
+ "color": "#B22222",
13
+ "bold": true
14
+ }
15
+ },
16
+ "links": {
17
+ "bgColor": "#B22222",
18
+ "font": {
19
+ "face": "Tahoma",
20
+ "color": "#FAFAD2",
21
+ "bold": true
22
+ }
23
+ },
24
+ "content": {
25
+ "bgColor": "#FFFFFF",
26
+ "font": {
27
+ "face": "Tahoma"
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "body": {
3
+ "bgColor": "#2F4F4F",
4
+ "linkColor": "#133c07",
5
+ "borderColor": "#2A1B0A",
6
+ "borderThickness": 4
7
+ },
8
+ "header": {
9
+ "bgColor": "#133c07",
10
+ "font": {
11
+ "face": "Courier New",
12
+ "color": "#70b15c",
13
+ "bold": true
14
+ }
15
+ },
16
+ "links": {
17
+ "bgColor": "#70b15c",
18
+ "font": {
19
+ "face": "Tahoma",
20
+ "color": "#133c07",
21
+ "bold": true
22
+ }
23
+ },
24
+ "content": {
25
+ "bgColor": "#FFFFFF",
26
+ "font": {
27
+ "face": "Tahoma"
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "body": {
3
+ "bgColor": "#8B4513",
4
+ "linkColor": "#ffffff",
5
+ "borderColor": "#2A1B0A",
6
+ "borderThickness": 4
7
+ },
8
+ "header": {
9
+ "bgColor": "#f1eea9",
10
+ "font": {
11
+ "face": "Times New Roman",
12
+ "color": "#000000",
13
+ "bold": true
14
+ }
15
+ },
16
+ "links": {
17
+ "bgColor": "#6f6e56",
18
+ "font": {
19
+ "face": "Tahoma",
20
+ "color": "#133c07",
21
+ "bold": true
22
+ }
23
+ },
24
+ "content": {
25
+ "bgColor": "#FFFFFF",
26
+ "font": {
27
+ "face": "Tahoma"
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "body": {
3
+ "bgColor": "#191970",
4
+ "linkColor": "#2F4F4F",
5
+ "borderColor": "#4682B4",
6
+ "borderThickness": 4
7
+ },
8
+ "header": {
9
+ "bgColor": "#2F4F4F",
10
+ "font": {
11
+ "face": "Courier New",
12
+ "color": "#F0FFFF",
13
+ "bold": true
14
+ }
15
+ },
16
+ "links": {
17
+ "bgColor": "#8DBC8F",
18
+ "font": {
19
+ "face": "Tahoma",
20
+ "color": "#778899",
21
+ "bold": true
22
+ }
23
+ },
24
+ "content": {
25
+ "bgColor": "#FFFFFF",
26
+ "font": {
27
+ "face": "Tahoma"
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "body": {
3
+ "bgColor": "#B22222",
4
+ "linkColor": "#FFD700",
5
+ "borderColor": "#FFD700",
6
+ "borderThickness": 4
7
+ },
8
+ "header": {
9
+ "bgColor": "#0000CD",
10
+ "font": {
11
+ "face": "Georgia",
12
+ "color": "#FFD700",
13
+ "bold": true
14
+ }
15
+ },
16
+ "links": {
17
+ "bgColor": "#008000",
18
+ "font": {
19
+ "face": "Tahoma",
20
+ "color": "#008000",
21
+ "bold": true
22
+ }
23
+ },
24
+ "content": {
25
+ "bgColor": "#FFFFFF",
26
+ "font": {
27
+ "face": "Tahoma"
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "body": {
3
+ "bgColor": "#000000",
4
+ "linkColor": "#000000",
5
+ "borderColor": "#32CD32",
6
+ "borderThickness": 4
7
+ },
8
+ "header": {
9
+ "bgColor": "#000000",
10
+ "font": {
11
+ "face": "Courier New",
12
+ "color": "#32CD32",
13
+ "bold": true
14
+ }
15
+ },
16
+ "links": {
17
+ "bgColor": "#788890",
18
+ "font": {
19
+ "face": "Tahoma",
20
+ "bold": true
21
+ }
22
+ },
23
+ "content": {
24
+ "bgColor": "#FFFFFF",
25
+ "font": {
26
+ "face": "Tahoma"
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "body": {
3
+ "bgColor": "#EEE8AA",
4
+ "linkColor": "#FAFAD2",
5
+ "borderColor": "#228B22",
6
+ "borderThickness": 4
7
+ },
8
+ "header": {
9
+ "bgColor": "#DAA520",
10
+ "font": {
11
+ "face": "Georgia",
12
+ "color": "#006400",
13
+ "bold": true
14
+ }
15
+ },
16
+ "links": {
17
+ "bgColor": "#006400",
18
+ "font": {
19
+ "face": "Tahoma",
20
+ "color": "#FAFAD2",
21
+ "bold": true
22
+ }
23
+ },
24
+ "content": {
25
+ "bgColor": "#FFFFFF",
26
+ "font": {
27
+ "face": "Tahoma"
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "body": {
3
+ "bgColor": "#00008B",
4
+ "linkColor": "#5F9EA0",
5
+ "borderColor": "#5F9EA0",
6
+ "borderThickness": 4
7
+ },
8
+ "header": {
9
+ "bgColor": "#006400",
10
+ "font": {
11
+ "face": "Georgia",
12
+ "color": "#FAFAD2",
13
+ "bold": true
14
+ }
15
+ },
16
+ "links": {
17
+ "bgColor": "#2F4F4F",
18
+ "font": {
19
+ "face": "Tahoma",
20
+ "color": "#FAFAD2",
21
+ "bold": true
22
+ }
23
+ },
24
+ "content": {
25
+ "bgColor": "#FFFFFF",
26
+ "font": {
27
+ "face": "Tahoma"
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "body": {
3
+ "bgColor": "#E0FFFF",
4
+ "linkColor": "#2F4F4F",
5
+ "borderColor": "#4682B4",
6
+ "borderThickness": 4
7
+ },
8
+ "header": {
9
+ "bgColor": "#5F9EA0",
10
+ "font": {
11
+ "face": "Georgia",
12
+ "color": "#F0FFFF",
13
+ "bold": true
14
+ }
15
+ },
16
+ "links": {
17
+ "bgColor": "#B0C4DE",
18
+ "font": {
19
+ "face": "Tahoma",
20
+ "color": "#778899",
21
+ "bold": true
22
+ }
23
+ },
24
+ "content": {
25
+ "bgColor": "#FFFFFF",
26
+ "font": {
27
+ "face": "Tahoma"
28
+ }
29
+ }
30
+ }