From 0cb7edbfc1d5b7f95a0d7f7350b0bf9e92edf072 Mon Sep 17 00:00:00 2001 From: Mhykol Date: Sun, 16 Jun 2024 22:55:24 -0400 Subject: Added more examples --- examples/scripts/index.js | 33 +++++++++++++++++++++++++ examples/scripts/shop.js | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 examples/scripts/index.js create mode 100644 examples/scripts/shop.js 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: ` +
+

Welcome to Cosmic!

+
+ `, + examples: ` +
+

Please look in the 'examples' directory

+
+ ` + } + 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: ` +
+
+

This is the Shop page

+ `, + body: '', + end: ` +
+
+ ` + } + if (output) { + for (let i = 0; i < output[0].length; i++) { + data.body += ` +
+

${output[0][i].ProductName}

+

ID: ${output[0][i].ID}

+
+ ` + } + } 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 = ` +
+
+

This is the Product page

+

Description

+
+
+ ` + return data + } +} + +module.exports = () => {return new Shop()} -- cgit v1.2.3-70-g09d2