@caboodle-tech/node-simple-server 2.0.0 → 3.0.1

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 CHANGED
@@ -4,7 +4,7 @@ A small but effective node based server for development sites, customizable live
4
4
 
5
5
  :heavy_check_mark:  You want to add live reloading to the development process of a static site.
6
6
 
7
- :heavy_check_mark:  You want easy two-way communication from the back-end and front-end of your development site with built-in WebSockets ready for use.
7
+ :heavy_check_mark:  You want easy two-way communication from the back-end and front-end of your development site or web based application with built-in WebSockets ready for use.
8
8
 
9
9
  :heavy_check_mark:  You want more fine grained control over the whole live reloading process.
10
10
 
@@ -12,11 +12,13 @@ A small but effective node based server for development sites, customizable live
12
12
 
13
13
  :heavy_check_mark:  You want to easily setup a LAN application for educational purposes or other development; must be on the same LAN, please consider security implications.
14
14
 
15
+ :heavy_check_mark:  You want to easily setup a web based application that leverages the browser as your apps GUI but can interact with system data via websocket; great for internal applications.
16
+
15
17
  ## Installation
16
18
 
17
19
  ### Manually:
18
20
 
19
- Noe Simple Server (NSS) can be manually incorporated into your development process/ application. Extract the `nss` folder from the [latest release](https://github.com/caboodle-tech/node-simple-server/releases/) and then `import` the server module into your code, similar to:
21
+ Node Simple Server (NSS) can be manually incorporated into your development process/ application. Extract the `nss` folder from the [latest release](https://github.com/caboodle-tech/node-simple-server/releases/) and then `import` the server module into your code, similar to:
20
22
 
21
23
  ```javascript
22
24
  import NodeSimpleServer from './nss.js';
@@ -50,17 +52,21 @@ NSS is designed to be controlled and/or wrapped by another application. The bare
50
52
 
51
53
  ```javascript
52
54
  /**
53
- * Import NSS. Here it is being imported from a manual install.
55
+ * If you want/need to import NSS from a manual install replace the below import statement with:
56
+ *
57
+ * import NodeSimpleServer from './nss.js';
58
+ *
54
59
  * NOTE: Manual installs must include the handlers directory one directory higher than NSS.
55
60
  */
56
- import NodeSimpleServer from './nss.js';
61
+ import NodeSimpleServer from '@caboodle-tech/node-simple-server'
62
+ import { fileURLToPath } from 'url';
57
63
  import path from 'path'
58
64
 
59
65
  // This is needed for ES modules.
60
66
  const __filename = fileURLToPath(import.meta.url);
61
67
  const __dirname = path.dirname(__filename);
62
68
 
63
- // Determine what directory to watch for changes.
69
+ // Determine what directory to watch for changes; defaults to project root.
64
70
  const websiteRoot = __dirname;
65
71
 
66
72
  // Build a bare minimum server options object.
@@ -71,9 +77,6 @@ const serverOptions = {
71
77
  // Get a new instance of NSS.
72
78
  const Server = new NodeSimpleServer(serverOptions);
73
79
 
74
- // Start the server.
75
- Server.start();
76
-
77
80
  // A bare minimum callback to handle most development changes.
78
81
  function watcherCallback(event, path, extension) {
79
82
  if (extension === 'css') {
@@ -94,14 +97,30 @@ function watcherCallback(event, path, extension) {
94
97
  }
95
98
  }
96
99
 
97
- // Build a bare minimum watcher options object.
100
+ // A bare minimum callback to handle all websocket messages from the frontend.
101
+ function websocketCallback(messageObject, pageId) {
102
+ // Interpret and do what you need to with the message:
103
+ const datatype = messageObject.type
104
+ const data = messageObject.data;
105
+ console.log(`Received ${datatype} data from page ${pageId}: ${data}`)
106
+
107
+ // Respond to the page that sent the message if you like:
108
+ Server.message(pageId, 'Messaged received!');
109
+ }
110
+
111
+ Server.addWebsocketCallback('.*', websocketCallback);
112
+
113
+ // A bare minimum watcher options object; use for development, omit for production.
98
114
  const watcherOptions = {
99
115
  events: {
100
116
  all: watcherCallback, // Just send everything to a single function.
101
117
  },
102
118
  };
103
119
 
104
- // Watch the current directory for changes.
120
+ // Start the server.
121
+ Server.start();
122
+
123
+ // Watch the current directory for changes; use for development, omit for production.
105
124
  Server.watch(websiteRoot, watcherOptions);
106
125
  ```
107
126
 
@@ -129,10 +148,26 @@ const Server = new NodeSimpleServer(options);
129
148
 
130
149
  - If a directory is requested should the directory listing page be shown.
131
150
 
151
+ #### **disableAutoRestart**    default: false
152
+
153
+ - If the server shuts off or crashes do not attempt to auto reconnect to it.
154
+
155
+ #### **hostAddress**    default: 127.0.0.1
156
+
157
+ - What IPv4 address or domain name to listen on.
158
+
159
+ **NOTE:** This is an advanced setting and should rarely need to be altered.
160
+
132
161
  #### **indexPage**    default: index.html
133
162
 
134
163
  - If a directory is requested consider this file to be the index page if it exits at that location.
135
164
 
165
+ #### **liveReloading**    default: true
166
+
167
+ - Reload the frontend when changes occur on the backend; disable if using NSS in a *production* setting.
168
+
169
+ **NOTE:** Even if you are not watching for any events this loads a full NSS developer websocket into all pages on the server address. Disabling this will load only a simplified NSS websocket.
170
+
136
171
  #### **port**    default: 5000
137
172
 
138
173
  - The port number the HTTP and WebSocket server should listen on for requests.
@@ -273,7 +308,7 @@ With your new instance of NSS you can call any of the following public methods:
273
308
 
274
309
  ## Changelog
275
310
 
276
- The [current changelog is here](./changelogs/v2.md). All [other changelogs are here](./changelogs).
311
+ The [current changelog is here](./changelogs/v3.md). All [other changelogs are here](./changelogs).
277
312
 
278
313
  ## Contributions
279
314
 
package/bin/nss.js CHANGED
@@ -23,13 +23,16 @@ class NodeSimpleServer {
23
23
  callbacks: [],
24
24
  contentType: 'text/html',
25
25
  dirListing: false,
26
+ disableAutoRestart: false,
27
+ hostAddress: '127.0.0.1',
26
28
  indexPage: 'index.html',
29
+ liveReloading: true,
27
30
  port: 5000,
28
31
  root: Path.normalize(`${process.cwd()}${Path.sep}`),
29
32
  running: false
30
33
  };
31
34
 
32
- #reload = ['.html', '.htm'];
35
+ #reload = ['.asp', '.html', '.htm', '.php', '.php3'];
33
36
 
34
37
  #server = null;
35
38
 
@@ -40,7 +43,7 @@ class NodeSimpleServer {
40
43
  map: {}
41
44
  };
42
45
 
43
- #VERSION = '2.0.0';
46
+ #VERSION = '3.0.1';
44
47
 
45
48
  #watching = [];
46
49
 
@@ -60,14 +63,29 @@ class NodeSimpleServer {
60
63
  * servers root directory.
61
64
  */
62
65
  constructor(options = {}) {
63
- if (options.disableAutoRestart) {
64
- this.#OPS.disableAutoRestart = true;
65
- }
66
66
  if (options.contentType) {
67
67
  this.#OPS.contentType = options.contentType;
68
68
  }
69
- if (options.dirListing) {
70
- this.#OPS.dirListing = options.dirListing;
69
+ if ('dirListing' in options) {
70
+ if (this.whatIs(options.dirListing) === 'boolean') {
71
+ this.#OPS.dirListing = options.dirListing;
72
+ }
73
+ }
74
+ if ('disableAutoRestart' in options) {
75
+ if (this.whatIs(options.disableAutoRestart) === 'boolean') {
76
+ this.#OPS.disableAutoRestart = options.disableAutoRestart;
77
+ }
78
+ }
79
+ if (options.hostAddress) {
80
+ this.#OPS.hostAddress = options.hostAddress;
81
+ }
82
+ if (options.index) {
83
+ this.#OPS.index = options.index;
84
+ }
85
+ if ('liveReloading' in options) {
86
+ if (this.whatIs(options.liveReloading) === 'boolean') {
87
+ this.#OPS.liveReloading = options.liveReloading;
88
+ }
71
89
  }
72
90
  if (options.port) {
73
91
  this.#OPS.port = options.port;
@@ -78,6 +96,8 @@ class NodeSimpleServer {
78
96
  this.#OPS.root += Path.sep;
79
97
  }
80
98
  }
99
+
100
+ this.#OPS.hostAddress = `${this.#OPS.hostAddress}:${this.#OPS.port}`;
81
101
  this.#loadHandlers();
82
102
  }
83
103
 
@@ -308,9 +328,13 @@ class NodeSimpleServer {
308
328
 
309
329
  const dirListingSrc = Path.join(APP_ROOT, 'handlers', 'dir-listing.html');
310
330
  const forbiddenSrc = Path.join(APP_ROOT, 'handlers', 'forbidden.html');
311
- const liveReloadingSrc = Path.join(APP_ROOT, 'handlers', 'live-reloading.html');
312
331
  const notFoundSrc = Path.join(APP_ROOT, 'handlers', 'not-found.html');
313
332
 
333
+ let liveReloadingSrc = Path.join(APP_ROOT, 'handlers', 'live-reloading.html');
334
+ if (!this.#OPS.liveReloading) {
335
+ liveReloadingSrc = Path.join(APP_ROOT, 'handlers', 'websocket-only.html');
336
+ }
337
+
314
338
  let dirListingContent = '';
315
339
  try {
316
340
  dirListingContent = Fs.readFileSync(dirListingSrc, { encoding: 'utf-8', flag: 'r' });
@@ -326,6 +350,8 @@ class NodeSimpleServer {
326
350
  liveReloadingContent = Fs.readFileSync(liveReloadingSrc, { encoding: 'utf-8', flag: 'r' });
327
351
  } catch (_) { liveReloadingContent = '<!-- 500 Internal Server Error -->'; }
328
352
 
353
+ liveReloadingContent = liveReloadingContent.replace('{{HOST_ADDRESS}}', this.#OPS.hostAddress);
354
+
329
355
  let notFoundContent = '';
330
356
  try {
331
357
  notFoundContent = Fs.readFileSync(notFoundSrc, { encoding: 'utf-8', flag: 'r' });
@@ -752,8 +778,15 @@ class NodeSimpleServer {
752
778
 
753
779
  // Handle future incoming WebSocket messages from this page.
754
780
  socket.on('message', (message) => {
755
- // NSS messages have a standard format
781
+ // NSS messages have a standard format.
756
782
  const msgObj = JSON.parse(message.toString());
783
+ // If message is a ping send pong and stop.
784
+ if (msgObj.type === 'string') {
785
+ if (msgObj.message === 'ping') {
786
+ this.message(pageId, 'pong');
787
+ return;
788
+ }
789
+ }
757
790
  // See if the message belongs to a callback and send it there.
758
791
  for (let i = 0; i < this.#OPS.callbacks.length; i++) {
759
792
  const regex = this.#OPS.callbacks[i][0];
@@ -820,6 +853,7 @@ class NodeSimpleServer {
820
853
  // Create the HTTP server.
821
854
  this.#server = Http.createServer(this.#serverListener.bind(this));
822
855
  // Capture connection upgrade requests so we don't break WebSocket connections.
856
+ // eslint-disable-next-line no-unused-vars
823
857
  this.#server.on('upgrade', (request, socket) => {
824
858
  /*
825
859
  * Node's http server is capable of handling websocket but you have to manually
@@ -0,0 +1,8 @@
1
+ ### NSS 3.0.1 (18 December 2023)
2
+
3
+ - chore: Correct and update README. Several settings were undocumented and new ones have been added.
4
+ - !feat: Corrected a bug where frontend websocket messages had the wrong object structure using `data` instead of `message`. Updated the websocket demo to show this correction.
5
+ - feat: Added `websocket-only.html` which will load basic websocket communications into the page and nothing else when `liveReloading` is set to `false`.
6
+ - !feat: Added the `hostAddress` option and modified `live-reloading.html` and `websocket-only.html` to work with this new option.
7
+
8
+ BREAKING CHANGES: Technically still compatible with v2 but implementations have changed.
@@ -0,0 +1,62 @@
1
+ import Path from 'path';
2
+ import { fileURLToPath } from 'url';
3
+ import Server from '../../bin/nss.js';
4
+
5
+ // eslint-disable-next-line no-underscore-dangle
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ // eslint-disable-next-line no-underscore-dangle
8
+ const __dirname = Path.dirname(__filename);
9
+
10
+ const WebsiteDemo = () => {
11
+ // Determine where the directory for the website demo is.
12
+ const websiteRoot = Path.normalize(Path.join(__dirname, '..', 'www-production'));
13
+
14
+ // Minimal server configuration.
15
+ const serverOptions = {
16
+ disableAutoRestart: true, // Production mode, do not visually show when the server disconnects.
17
+ liveReloading: false, // Production mode, load only the NSS websocket into pages.
18
+ dirListing: true,
19
+ root: websiteRoot
20
+ };
21
+
22
+ // Get a new server instance.
23
+ const server = new Server(serverOptions);
24
+
25
+ // Start the server.
26
+ server.start();
27
+
28
+ // A bare minimum callback to handle changes.
29
+ function callback(event, path, ext) {
30
+ console.log(event, path, ext);
31
+ if (ext === 'css') {
32
+ server.reloadAllStyles();
33
+ return;
34
+ }
35
+ if (ext === 'js') {
36
+ server.reloadAllPages();
37
+ return;
38
+ }
39
+ if (event === 'change') {
40
+ server.reloadSinglePage(path);
41
+ }
42
+ }
43
+
44
+ // Build a bare minimum watcher options object.
45
+ const watcherOptions = {
46
+ events: {
47
+ all: callback
48
+ },
49
+ ignoreInitial: true
50
+ };
51
+
52
+ /**
53
+ * Watch everything in the www-website directory for changes.
54
+ *
55
+ * NOTE: Watching for file changes is optional. If you build a local app or
56
+ * a monitoring app that only needs NSS's websocket you can safely skip
57
+ * setting up `watch`.
58
+ */
59
+ server.watch(websiteRoot, watcherOptions);
60
+ };
61
+
62
+ export default WebsiteDemo;
@@ -65,7 +65,7 @@ const WebsocketDemo = () => {
65
65
  // We record reply counts by page so make sure we have a record for this page.
66
66
  if (!replyCount[pageId]) { replyCount[pageId] = 0; }
67
67
  // Display the users message in the servers (NSS's) terminal.
68
- console.log(`[websocket:${pageId}] Message from frontend --> ${message.data}`);
68
+ console.log(`[websocket:${pageId}] Message from frontend --> ${message.message}`);
69
69
  // To demonstrate we can reply send a message back after a delay.
70
70
  setTimeout(() => {
71
71
  replyCount[pageId] += 1;
package/examples/run.js CHANGED
@@ -1,3 +1,4 @@
1
+ import ProdWebsiteDemo from './controllers/prod-website.js';
1
2
  import WebsiteDemo from './controllers/website.js';
2
3
  import WebsocketDemo from './controllers/websocket.js';
3
4
 
@@ -8,6 +9,9 @@ if (process.argv.length > 2) {
8
9
  }
9
10
 
10
11
  switch (runDemo) {
12
+ case 'production':
13
+ ProdWebsiteDemo();
14
+ break;
11
15
  case 'websocket':
12
16
  WebsocketDemo();
13
17
  break;
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,96 @@
1
+ @font-face {
2
+ font-family: 'Roboto';
3
+ src: url('../assets/fonts/roboto/roboto-regular.woff2') format('woff2'),
4
+ url('../assets/fonts/roboto/roboto-regular.woff') format('woff'),
5
+ url('../assets/fonts/roboto/roboto-regular.ttf') format('truetype')
6
+ }
7
+
8
+ :root {
9
+ --padding: 15px
10
+ }
11
+
12
+ html,
13
+ body {
14
+ margin: 0;
15
+ padding: 0;
16
+ font-size: 62.5%;
17
+ font-family: 'Roboto', sans-serif;
18
+ height: 100%;
19
+ overflow: hidden;
20
+ }
21
+
22
+ body {
23
+ display: flex;
24
+ flex-direction: column;
25
+ }
26
+
27
+ a {
28
+ text-decoration: none;
29
+ color: #1170bd;
30
+ cursor: pointer;
31
+ }
32
+
33
+ .loader {
34
+ width: 100px;
35
+ height: 100px;
36
+ margin: 20px;
37
+ display:inline-block;
38
+ }
39
+
40
+ #page-container {
41
+ flex: 1;
42
+ display: flex;
43
+ flex-direction: column;
44
+ font-size: 1.5rem;
45
+ overflow-y: auto;
46
+ }
47
+
48
+ #page-container .content {
49
+ display: block;
50
+ max-width: 1200px;
51
+ margin: 0 auto;
52
+ }
53
+
54
+ #page-container .content p {
55
+ font-size: 1.85rem;
56
+ line-height: 2.30rem;
57
+ }
58
+
59
+ header {
60
+ text-align: center;
61
+ padding: var(--padding);
62
+ }
63
+
64
+ header .logo {
65
+ max-height: 80px;
66
+ width: auto;
67
+ }
68
+
69
+ main {
70
+ flex: 1;
71
+ padding: var(--padding);
72
+ }
73
+
74
+ main #fox-container {
75
+ display: flex;
76
+ flex-direction: column;
77
+ justify-content: center;
78
+ align-items: center;
79
+ min-height: 300px;
80
+ background-color: #e1e1e1;
81
+ }
82
+
83
+ main #fox-details {
84
+ text-align: center;
85
+ }
86
+
87
+ footer {
88
+ text-align: center;
89
+ font-size: 2rem;
90
+ padding: var(--padding);
91
+ }
92
+
93
+ footer .heart-icon {
94
+ fill: #f06464;
95
+ margin: 0 2px -5px 2px;
96
+ }