summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMhykol <mchaeldonald62@pm.me>2024-06-16 22:55:24 -0400
committerMhykol <mchaeldonald62@pm.me>2024-06-16 22:55:24 -0400
commit0cb7edbfc1d5b7f95a0d7f7350b0bf9e92edf072 (patch)
treeec613eecff1b71530f7743e10b967c5b3784ec9c /examples
parente72a9e5911b0fcfdaf8048400b055fe03391ad30 (diff)
Added more examples
Diffstat (limited to 'examples')
-rw-r--r--examples/scripts/index.js33
-rw-r--r--examples/scripts/shop.js62
2 files changed, 95 insertions, 0 deletions
diff --git a/examples/scripts/index.js b/examples/scripts/index.js
new file mode 100644
index 0000000..74d2130
--- /dev/null
+++ b/examples/scripts/index.js
@@ -0,0 +1,33 @@
+class Index {
+ constructor() {}
+
+ async Main() {
+ const data = {
+ main: `
+ <section>
+ <h1>Welcome to Cosmic!</h1>
+ </section>
+ `,
+ examples: `
+ <section>
+ <p>Please look in the 'examples' directory</p>
+ </section>
+ `
+ }
+ return {
+ html: data.main + data.examples,
+ assets: {
+ css: ['main.css'],
+ js: ['index.js', 'purify.js']
+ },
+ meta: {
+ title: 'Welcome to Cosmic!',
+ keywords: 'Cosmic',
+ description: 'Welcome to Cosmic!'
+ }
+ }
+ }
+}
+
+module.exports = (x) => {return new Index(x)}
+
diff --git a/examples/scripts/shop.js b/examples/scripts/shop.js
new file mode 100644
index 0000000..e4ef5be
--- /dev/null
+++ b/examples/scripts/shop.js
@@ -0,0 +1,62 @@
+const database = require('../source/database')
+const estore = database('EStore')
+
+class Shop {
+ constructor() {}
+
+ async Main() {
+ return estore.Query('SELECT * FROM Products').then(output => {
+ const data = {
+ start: `
+ <section id='shop'>
+ <div>
+ <h1>This is the Shop page</h1>
+ `,
+ body: '',
+ end: `
+ </div>
+ </section>
+ `
+ }
+ if (output) {
+ for (let i = 0; i < output[0].length; i++) {
+ data.body += `
+ <div class='item'>
+ <h2>${output[0][i].ProductName}</h2>
+ <p>ID: ${output[0][i].ID}</p>
+ </div>
+ `
+ }
+ } else {
+ data.body = `
+ There are no items in the database.
+ `
+ }
+ return {
+ html: data.start + data.body + data.end,
+ assets: {
+ css: ['main.css'],
+ js: ['index.js', 'purify.js']
+ },
+ meta: {
+ title: 'Shop Page',
+ keywords: 'Shop',
+ description: 'This is a shop page'
+ }
+ }
+ })
+ }
+ Product() {
+ const data = `
+ <section id='product'>
+ <div>
+ <h1>This is the Product page</h1>
+ <p>Description</p>
+ </div>
+ </section>
+ `
+ return data
+ }
+}
+
+module.exports = () => {return new Shop()}