jsgui3-server 0.0.80 → 0.0.83
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.
- package/README.md +8 -1
- package/bundler/bundle.js +11 -0
- package/bundler/bundler.js +9 -0
- package/bundler/js-bundler.js +189 -0
- package/bundler/webpage-bundler.js +284 -0
- package/bundler/website-bundler.js +23 -0
- package/controls/README.md +8 -0
- package/controls/page/admin.js +75 -0
- package/controls/panel/admin.js +11 -0
- package/examples/controls/html-server-combo-box.js +5 -5
- package/examples/html-server.js +3 -0
- package/examples/square_box.js +35 -0
- package/examples/square_box_client.js +91 -0
- package/module.js +8 -0
- package/{single-control-server.js → old/_single-control-server.js} +157 -96
- package/old/single-control-server.js +108 -158
- package/{single-page-app.js → old/single-page-app.js} +2 -0
- package/{examples/demos → old}/square_box.js +1 -1
- package/package.json +10 -9
- package/page-context.js +1 -1
- package/publishing/http-css-publisher.js +0 -0
- package/publishing/{function-publisher.js → http-function-publisher.js} +12 -2
- package/publishing/http-html-page-publisher.js +5 -0
- package/publishing/http-html-publisher.js +25 -0
- package/publishing/http-jpeg-publisher.js +0 -0
- package/publishing/http-js-publisher.js +25 -0
- package/publishing/{observable-publisher.js → http-observable-publisher.js} +12 -6
- package/publishing/http-png-publisher.js +0 -0
- package/publishing/http-publisher.js +52 -0
- package/publishing/{resource-publisher.js → http-resource-publisher.js} +20 -1
- package/publishing/http-svg-publisher.js +0 -0
- package/publishing/http-webpage-publisher.js +112 -0
- package/publishing/http-website-publisher.js +262 -0
- package/publishing/notes.md +1 -0
- package/resources/README.md +16 -0
- package/resources/_old_website-resource.js +507 -0
- package/resources/compile/server-resource-compilation.js +41 -0
- package/resources/data-resource.js +14 -0
- package/resources/fs-resource.js +2 -4
- package/resources/jsbuilder/test/test_ast_node.js +0 -63
- package/resources/jsbuilder/test/test_project.js +1 -0
- package/resources/notes.txt +11 -0
- package/resources/server-installed-tools.js +29 -0
- package/resources/server-resource-pool.js +1 -44
- package/resources/website-css-resource.js +1 -1
- package/resources/website-javascript-resource.js +165 -34
- package/resources/website-resource.js +62 -294
- package/resources/website-static-html-resource.js +19 -16
- package/resources/website-template-html-resource.js +231 -0
- package/roadmap.md +46 -0
- package/server.js +711 -18
- package/website/webpage.js +169 -0
- package/website/website-group.js +16 -0
- package/website/website.js +227 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
const jsgui = require('jsgui3-html');
|
|
2
|
+
|
|
3
|
+
const oext = require('obext');
|
|
4
|
+
|
|
5
|
+
const {obs} = require('fnl');
|
|
6
|
+
|
|
7
|
+
// Website is a Publisher?
|
|
8
|
+
|
|
9
|
+
// Won't actually handle the HTTP requests.
|
|
10
|
+
const {Collection} = jsgui;
|
|
11
|
+
// Will link to / use the HTTP request handlers?
|
|
12
|
+
|
|
13
|
+
// Not sure this will be used...
|
|
14
|
+
// Maybe it can extend a control?
|
|
15
|
+
// Maybe a new Webpage object (not a Control) will be useful
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
// For the moment, an abstraction to represent a website.
|
|
19
|
+
|
|
20
|
+
// A 'name property' mixin?
|
|
21
|
+
|
|
22
|
+
class Webpage {
|
|
23
|
+
constructor(spec = {}) {
|
|
24
|
+
// Variety of routes get served with variety of different formats and options.
|
|
25
|
+
// Maybe will connect handlers with functionality.
|
|
26
|
+
|
|
27
|
+
// Could contain a bunch of resources.
|
|
28
|
+
// Then there are the relevant resource publishers.
|
|
29
|
+
let name;
|
|
30
|
+
if (spec.name) {
|
|
31
|
+
name = spec.name;
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(this, 'name', {
|
|
34
|
+
get() {
|
|
35
|
+
return name;
|
|
36
|
+
},
|
|
37
|
+
set(value) {
|
|
38
|
+
name = value;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
let title;
|
|
43
|
+
if (spec.title) {
|
|
44
|
+
title = spec.title;
|
|
45
|
+
};
|
|
46
|
+
Object.defineProperty(this, 'title', {
|
|
47
|
+
get() {
|
|
48
|
+
return title;
|
|
49
|
+
},
|
|
50
|
+
set(value) {
|
|
51
|
+
title = value;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// A URL or URL path property would make sense
|
|
56
|
+
|
|
57
|
+
let path;
|
|
58
|
+
if (spec.path) {
|
|
59
|
+
path = spec.path;
|
|
60
|
+
};
|
|
61
|
+
Object.defineProperty(this, 'path', {
|
|
62
|
+
get() {
|
|
63
|
+
return path;
|
|
64
|
+
},
|
|
65
|
+
set(value) {
|
|
66
|
+
path = value;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
Object.defineProperty(this, 'url_path', {
|
|
70
|
+
get() {
|
|
71
|
+
return path;
|
|
72
|
+
},
|
|
73
|
+
set(value) {
|
|
74
|
+
path = value;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Then its content
|
|
79
|
+
// Could be as HTML string.
|
|
80
|
+
// Could be encoded somehow (eg template, rjx)
|
|
81
|
+
// Could be a Control that represents a page
|
|
82
|
+
// Could be a Control that goes within a page, and the system needs to serve it within the right page.
|
|
83
|
+
|
|
84
|
+
let content;
|
|
85
|
+
|
|
86
|
+
if (spec.content) {
|
|
87
|
+
content = spec.content;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// Could be a Web_Document_Control or similar.
|
|
91
|
+
// A Control that takes up the whole of a web page.
|
|
92
|
+
Object.defineProperty(this, 'content', {
|
|
93
|
+
get() {
|
|
94
|
+
return content;
|
|
95
|
+
},
|
|
96
|
+
set(value) {
|
|
97
|
+
content = value;
|
|
98
|
+
|
|
99
|
+
// then depending on the type of content, it will prepare bundles in different ways.
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// .prepare_bundle function
|
|
105
|
+
// though the webpage publisher may be better for this.
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
// Requirements...
|
|
110
|
+
// Would depend on the content.
|
|
111
|
+
|
|
112
|
+
// Pages or routes...
|
|
113
|
+
|
|
114
|
+
// A Collection of Pages.
|
|
115
|
+
// May not be the best indexed way.
|
|
116
|
+
// Should be fine for the moment.
|
|
117
|
+
|
|
118
|
+
// Storing them all in a tree may be better.
|
|
119
|
+
// Could make other types of Collection with the same / very similar Collection API.
|
|
120
|
+
|
|
121
|
+
// The website may have a routing tree, not a router?
|
|
122
|
+
// Or both.
|
|
123
|
+
|
|
124
|
+
// The website can have pages, sections, menus etc.
|
|
125
|
+
// This could be a place (not Control) where the Controls are held together.
|
|
126
|
+
|
|
127
|
+
// Web pages....
|
|
128
|
+
// As well as applications / controls.
|
|
129
|
+
|
|
130
|
+
// Web pages can have a path (to serve on). The path is something more of a server property, but when editing it
|
|
131
|
+
// intuitively is a property of the page itself.
|
|
132
|
+
// Web pages can load in other content
|
|
133
|
+
// Some of it required to exist / be available at a specific address.
|
|
134
|
+
/*
|
|
135
|
+
website.pages.add(name, content);
|
|
136
|
+
|
|
137
|
+
website.pages.front = ...
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
// A render function...?
|
|
145
|
+
// Async / observable interface by default.
|
|
146
|
+
|
|
147
|
+
// Rendering the different parts of it, including building the JS?
|
|
148
|
+
// Or rendering just applies to the Controls.
|
|
149
|
+
// Build or Compile would prepare the relevant dependencies.
|
|
150
|
+
|
|
151
|
+
// render_html() returns Observable
|
|
152
|
+
|
|
153
|
+
// compile() returns Observable which returns Buffer for each compiled file.
|
|
154
|
+
// build() has got wider connotations than complile(), such as preparing images.
|
|
155
|
+
|
|
156
|
+
// Could provide client js files specifically built for that page within that page's directory structure, using the same file name
|
|
157
|
+
// but with .js extension. A single js file may be a good choice, such as for an app that gets embedded within a larger website.
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
// /pagesubdir/pagename_client.js
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
module.exports = Webpage;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Multiple sites
|
|
2
|
+
|
|
3
|
+
// eg google.com, google.co.uk etc
|
|
4
|
+
// all Google country service websites.
|
|
5
|
+
|
|
6
|
+
// Or all of the websites being served within a single server process.
|
|
7
|
+
|
|
8
|
+
const jsgui = require('jsgui3-html');
|
|
9
|
+
|
|
10
|
+
class Website_Group extends jsgui.Collection {
|
|
11
|
+
constructor(spec = {}) {
|
|
12
|
+
super(spec)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = Website_Group;
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
const jsgui = require('jsgui3-html');
|
|
2
|
+
const {tof, HTML_Document} = jsgui;
|
|
3
|
+
|
|
4
|
+
const oext = require('obext');
|
|
5
|
+
|
|
6
|
+
const Webpage = require('./webpage');
|
|
7
|
+
// Website is a Publisher?
|
|
8
|
+
|
|
9
|
+
const Page_Control_Admin = require('./../controls/page/admin');
|
|
10
|
+
|
|
11
|
+
// Won't actually handle the HTTP requests.
|
|
12
|
+
|
|
13
|
+
// Will link to / use the HTTP request handlers?
|
|
14
|
+
|
|
15
|
+
const {Collection} = jsgui;
|
|
16
|
+
// For the moment, an abstraction to represent a website.
|
|
17
|
+
|
|
18
|
+
// A 'name property' mixin?
|
|
19
|
+
|
|
20
|
+
// Not sure this even needs routes / router. Does not need to be optimised for serving at this stage.
|
|
21
|
+
|
|
22
|
+
class Website {
|
|
23
|
+
constructor(spec = {}) {
|
|
24
|
+
// Variety of routes get served with variety of different formats and options.
|
|
25
|
+
|
|
26
|
+
// Maybe will connect handlers with functionality.
|
|
27
|
+
|
|
28
|
+
// Could contain a bunch of resources.
|
|
29
|
+
// Then there are the relevant resource publishers.
|
|
30
|
+
|
|
31
|
+
let name;
|
|
32
|
+
|
|
33
|
+
if (spec.name) {
|
|
34
|
+
name = spec.name;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
Object.defineProperty(this, 'name', {
|
|
38
|
+
get() {
|
|
39
|
+
return name;
|
|
40
|
+
},
|
|
41
|
+
set(value) {
|
|
42
|
+
name = value;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
let pages = new Collection();
|
|
47
|
+
Object.defineProperty(this, 'pages', {
|
|
48
|
+
get() {
|
|
49
|
+
return pages;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
if (spec.content) {
|
|
54
|
+
const content = spec.content;
|
|
55
|
+
|
|
56
|
+
console.log('content', content);
|
|
57
|
+
console.log('tof(content)', tof(content));
|
|
58
|
+
|
|
59
|
+
const t_content = tof(content);
|
|
60
|
+
|
|
61
|
+
// And no pages set....
|
|
62
|
+
|
|
63
|
+
if (pages.length() === 0) {
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
if (t_content === 'function') {
|
|
67
|
+
|
|
68
|
+
// Create first and only page.
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
// is it an instance of an HTML_Document control?
|
|
73
|
+
|
|
74
|
+
// no it's a constructor rather than an instance.
|
|
75
|
+
|
|
76
|
+
// Need to call that function at some point.
|
|
77
|
+
// Maybe the later the better.
|
|
78
|
+
|
|
79
|
+
const root_page = new Webpage({
|
|
80
|
+
'name': 'Root Webpage',
|
|
81
|
+
'title': 'jsgui3-server',
|
|
82
|
+
//'content': 'This is a jsgui3-server root web page.',
|
|
83
|
+
'content': content,
|
|
84
|
+
'path': '/'
|
|
85
|
+
});
|
|
86
|
+
pages.push(root_page);
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
/*
|
|
90
|
+
if (content instanceof HTML_Document) {
|
|
91
|
+
console.log('t_content', t_content);
|
|
92
|
+
console.trace();
|
|
93
|
+
throw 'NYI';
|
|
94
|
+
} else {
|
|
95
|
+
console.log('t_content', t_content);
|
|
96
|
+
console.trace();
|
|
97
|
+
throw 'NYI';
|
|
98
|
+
}
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
// a constructor (I assume)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
} else {
|
|
108
|
+
console.log('t_content', t_content);
|
|
109
|
+
console.trace();
|
|
110
|
+
throw 'NYI';
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
} else {
|
|
115
|
+
throw 'NYI';
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
//throw 'stop';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// be able to get 'content' from the spec.
|
|
124
|
+
// if the setting is a single item for a single page, it could be easier.
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
// When a page gets pushed within pages, it will need to be added to the router routes.
|
|
130
|
+
|
|
131
|
+
// For the moment, let's start the website with one initial page.
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
// Seems not to need any JS.
|
|
135
|
+
|
|
136
|
+
// May be better to put some kind of JSGUI content into there.
|
|
137
|
+
// That will get the bundling working better.
|
|
138
|
+
|
|
139
|
+
// Make the content either a page control, or a standard (not full document) jsgui control.
|
|
140
|
+
|
|
141
|
+
// But a Control, even a Page_Control, should need and be given a context.?
|
|
142
|
+
// Maybe not while in unrendered / pre-rendered phase.
|
|
143
|
+
|
|
144
|
+
// Could try loading content from disk, and seeing what files get referenced.
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
// A control without a Page Context here.
|
|
148
|
+
// Or the page context would be a rendering of the root_page.
|
|
149
|
+
|
|
150
|
+
// Maybe render an actual placeholder control. Site_Placeholder perhaps?
|
|
151
|
+
|
|
152
|
+
// What if the content is a Control constructor?
|
|
153
|
+
// Should be able to call the constructor (in the right circumstances).
|
|
154
|
+
|
|
155
|
+
const use_coming_soon_jsgui3 = () => {
|
|
156
|
+
const ctrl_root = new jsgui.Control({
|
|
157
|
+
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const h1 = new jsgui.h1({});
|
|
161
|
+
h1.add('Website Coming Soon');
|
|
162
|
+
ctrl_root.add(h1);
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
// <a href="url">link text</a>
|
|
166
|
+
|
|
167
|
+
const p = new jsgui.p({});
|
|
168
|
+
//p.add('This website is being built using jsgui3-server');
|
|
169
|
+
p.add('This website is being built using ');
|
|
170
|
+
const a = new jsgui.a({});
|
|
171
|
+
a.dom.attributes.href = 'https://github.com/metabench/jsgui3-server';
|
|
172
|
+
a.add('jsgui3-server');
|
|
173
|
+
p.add(a);
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
ctrl_root.add(p);
|
|
177
|
+
|
|
178
|
+
const root_page = new Webpage({
|
|
179
|
+
'name': 'Root Webpage',
|
|
180
|
+
'title': 'jsgui3-server',
|
|
181
|
+
//'content': 'This is a jsgui3-server root web page.',
|
|
182
|
+
'content': ctrl_root,
|
|
183
|
+
'path': '/'
|
|
184
|
+
});
|
|
185
|
+
pages.push(root_page);
|
|
186
|
+
|
|
187
|
+
console.log('pages.length()', pages.length()); // Could definitely make collections more modern.
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
// Pages or routes...
|
|
196
|
+
|
|
197
|
+
// The website may have a routing tree, not a router?
|
|
198
|
+
// Or both.
|
|
199
|
+
|
|
200
|
+
// The website can have pages, sections, menus etc.
|
|
201
|
+
// This could be a place (not Control) where the Controls are held together.
|
|
202
|
+
|
|
203
|
+
// Web pages....
|
|
204
|
+
// As well as applications / controls.
|
|
205
|
+
|
|
206
|
+
// Web pages can have a path (to serve on). The path is something more of a server property, but when editing it
|
|
207
|
+
// intuitively is a property of the page itself.
|
|
208
|
+
// Web pages can load in other content
|
|
209
|
+
// Some of it required to exist / be available at a specific address.
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
/*
|
|
214
|
+
website.pages.add(name, content);
|
|
215
|
+
|
|
216
|
+
website.pages.front = ...
|
|
217
|
+
*/
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
module.exports = Website;
|