diff --git a/.db/pages.db b/.db/pages.db new file mode 100644 index 0000000..1b5dbdc --- /dev/null +++ b/.db/pages.db @@ -0,0 +1,22 @@ +{"_id":"SuEkh6Yntj0DqTXH","title":"Page 2","body":"Page 2 body"} +{"_id":"TPzu5FlP8sSk1sw2","title":"Page 1","body":"Page 1 body"} +{"_id":"QbhUo8GKhCmGpWAG","title":"Test page","body":"Test page body"} +{"_id":"QbhUo8GKhCmGpWAG","title":"Updated test page","body":"Updated test page body"} +{"$$deleted":true,"_id":"QbhUo8GKhCmGpWAG"} +{"_id":"n3BCUhBuahuud0j9","title":"Test page","body":"Test page body"} +{"$$deleted":true,"_id":"n3BCUhBuahuud0j9"} +{"_id":"5Vxa7B2O5eyafWlh","title":"Page 1","body":"Page 1 body"} +{"_id":"MjlC5zMfL79xW1Wp","title":"Page 2","body":"Page 2 body"} +{"_id":"yU6Yb0igW7OETm4f","title":"Parent page","body":"Parent page body"} +{"_id":"Sf6LIWuXqOrOT8Br","title":"Child page","body":"Child page body","parent":"yU6Yb0igW7OETm4f"} +{"$$deleted":true,"_id":"yU6Yb0igW7OETm4f"} +{"$$deleted":true,"_id":"Sf6LIWuXqOrOT8Br"} +{"_id":"AIQ0Q5j7lzEsjlQA","title":"Test page","body":"Test page body"} +{"$$deleted":true,"_id":"AIQ0Q5j7lzEsjlQA"} +{"_id":"jBEBKXUIHSjTTYW3","title":"Test page","body":"Test page body"} +{"$$deleted":true,"_id":"jBEBKXUIHSjTTYW3"} +{"_id":"mHBnGkfWxJ8eH3IC","title":"Test page","body":"Test page body"} +{"_id":"mHBnGkfWxJ8eH3IC","title":"Updated test page","body":"Updated test page body"} +{"$$deleted":true,"_id":"mHBnGkfWxJ8eH3IC"} +{"_id":"32l7Wg0P971HuSkx","title":"Test page","body":"Test page body"} +{"$$deleted":true,"_id":"32l7Wg0P971HuSkx"} diff --git a/bin/www b/bin/www index e35e019..fbe6089 100755 --- a/bin/www +++ b/bin/www @@ -3,7 +3,7 @@ /** * Module dependencies. */ -const app = require('../app'); +const app = require('../src/app'); const debug = require('debug')('codex.editor.docs:server'); const http = require('http'); @@ -88,4 +88,4 @@ function onListening() { debug('Listening on ' + bind); } -module.exports = {server, app}; \ No newline at end of file +module.exports = {server, app}; diff --git a/database/pages.js b/database/pages.js deleted file mode 100644 index 0e007ad..0000000 --- a/database/pages.js +++ /dev/null @@ -1,5 +0,0 @@ -const Datastore = require('nedb'); - -const db = new Datastore({filename: './db/pages.db', autoload: true}); - -module.exports = db; \ No newline at end of file diff --git a/package.json b/package.json index da9cc68..76ee838 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "scripts": { "start": "nodemon ./bin/www", "test": "mocha --recursive ./test", - "lint": "eslint --fix --cache ./**/*.js", - "build": "webpack ./frontend/js/app.js --o='./public/dist/bundle.js' --output-library=Docs -d", + "lint": "eslint --fix --cache ./src/**/*.js", + "build": "webpack ./src/frontend/js/app.js --o='./public/dist/bundle.js' --output-library=Docs -d", "precommit": "yarn lint && yarn test --exit" }, "dependencies": { diff --git a/public/dist/bundle.js b/public/dist/bundle.js index bf83031..f7c5a65 100644 --- a/public/dist/bundle.js +++ b/public/dist/bundle.js @@ -1,9 +1,9 @@ -var Docs=function(n){var e={};function t(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return n[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}return t.m=n,t.c=e,t.d=function(n,e,o){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:o})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var r in n)t.d(o,r,function(e){return n[e]}.bind(null,r));return o},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s="./frontend/js/app.js")}({"./frontend/js/app.js": -/*!****************************!*\ - !*** ./frontend/js/app.js ***! - \****************************/ -/*! no static exports found */function(module,exports,__webpack_require__){"use strict";eval('\n\nvar _main = __webpack_require__(/*! ../styles/main.pcss */ "./frontend/styles/main.pcss");\n\nvar _main2 = _interopRequireDefault(_main);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }\n\nmodule.exports = function Docs() {\n _classCallCheck(this, Docs);\n\n console.log(\'CodeX Docs initialized\');\n};//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9mcm9udGVuZC9qcy9hcHAuanMuanMiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly9Eb2NzLy4vZnJvbnRlbmQvanMvYXBwLmpzPzNhMmUiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IGNzcyBmcm9tICcuLi9zdHlsZXMvbWFpbi5wY3NzJztcblxubW9kdWxlLmV4cG9ydHMgPSBjbGFzcyBEb2NzIHtcbiAgY29uc3RydWN0b3IoKXtcbiAgICBjb25zb2xlLmxvZygnQ29kZVggRG9jcyBpbml0aWFsaXplZCcpO1xuXG4gIH1cbn1cbiJdLCJtYXBwaW5ncyI6Ijs7QUFBQTtBQUNBOzs7Ozs7O0FBQ0E7QUFDQTtBQUNBO0FBQUE7QUFFQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///./frontend/js/app.js\n')},"./frontend/styles/main.pcss": -/*!***********************************!*\ - !*** ./frontend/styles/main.pcss ***! - \***********************************/ -/*! no static exports found */function(module,exports){eval("// removed by extract-text-webpack-plugin//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9mcm9udGVuZC9zdHlsZXMvbWFpbi5wY3NzLmpzIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8vRG9jcy8uL2Zyb250ZW5kL3N0eWxlcy9tYWluLnBjc3M/NmFjOCJdLCJzb3VyY2VzQ29udGVudCI6WyIvLyByZW1vdmVkIGJ5IGV4dHJhY3QtdGV4dC13ZWJwYWNrLXBsdWdpbiJdLCJtYXBwaW5ncyI6IkFBQUEiLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///./frontend/styles/main.pcss\n")}}); \ No newline at end of file +var Docs=function(n){var e={};function c(t){if(e[t])return e[t].exports;var r=e[t]={i:t,l:!1,exports:{}};return n[t].call(r.exports,r,r.exports,c),r.l=!0,r.exports}return c.m=n,c.c=e,c.d=function(n,e,t){c.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:t})},c.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},c.t=function(n,e){if(1&e&&(n=c(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var t=Object.create(null);if(c.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var r in n)c.d(t,r,function(e){return n[e]}.bind(null,r));return t},c.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return c.d(e,"a",e),e},c.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},c.p="",c(c.s="./src/frontend/js/app.js")}({"./src/frontend/js/app.js": +/*!********************************!*\ + !*** ./src/frontend/js/app.js ***! + \********************************/ +/*! no static exports found */function(module,exports,__webpack_require__){"use strict";eval('\n\nvar _main = __webpack_require__(/*! ../styles/main.pcss */ "./src/frontend/styles/main.pcss");\n\nvar _main2 = _interopRequireDefault(_main);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }\n\nmodule.exports =\n/**\n * @constructor\n */\nfunction Docs() {\n _classCallCheck(this, Docs);\n\n console.log(\'CodeX Docs initialized\');\n};//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9zcmMvZnJvbnRlbmQvanMvYXBwLmpzLmpzIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8vRG9jcy8uL3NyYy9mcm9udGVuZC9qcy9hcHAuanM/YmM1NSJdLCJzb3VyY2VzQ29udGVudCI6WyIvLyBObyBpbnNwZWN0aW9uIGZvciB1bnVzZWQgdmFyIGBjc3NgIGJlY2F1c2UgaXQncyB1c2VkIGZvciBjc3MgYnVuZGxlXG4vLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgbm8tdW51c2VkLXZhcnNcbmltcG9ydCBjc3MgZnJvbSAnLi4vc3R5bGVzL21haW4ucGNzcyc7XG5cbm1vZHVsZS5leHBvcnRzID0gY2xhc3MgRG9jcyB7XG4gIC8qKlxuICAgKiBAY29uc3RydWN0b3JcbiAgICovXG4gIGNvbnN0cnVjdG9yKCkge1xuICAgIGNvbnNvbGUubG9nKCdDb2RlWCBEb2NzIGluaXRpYWxpemVkJyk7XG4gIH1cbn07XG4iXSwibWFwcGluZ3MiOiI7O0FBRUE7QUFDQTs7Ozs7OztBQUNBO0FBQ0E7OztBQUdBO0FBQUE7QUFDQTtBQUFBO0FBQ0EiLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///./src/frontend/js/app.js\n')},"./src/frontend/styles/main.pcss": +/*!***************************************!*\ + !*** ./src/frontend/styles/main.pcss ***! + \***************************************/ +/*! no static exports found */function(module,exports){eval("// removed by extract-text-webpack-plugin//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9zcmMvZnJvbnRlbmQvc3R5bGVzL21haW4ucGNzcy5qcyIsInNvdXJjZXMiOlsid2VicGFjazovL0RvY3MvLi9zcmMvZnJvbnRlbmQvc3R5bGVzL21haW4ucGNzcz83N2VjIl0sInNvdXJjZXNDb250ZW50IjpbIi8vIHJlbW92ZWQgYnkgZXh0cmFjdC10ZXh0LXdlYnBhY2stcGx1Z2luIl0sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///./src/frontend/styles/main.pcss\n")}}); \ No newline at end of file diff --git a/app.js b/src/app.js similarity index 93% rename from app.js rename to src/app.js index b9fb314..7396df3 100644 --- a/app.js +++ b/src/app.js @@ -16,7 +16,7 @@ app.use(logger('dev')); app.use(express.json()); app.use(express.urlencoded({extended: true})); app.use(cookieParser()); -app.use(express.static(path.join(__dirname, 'public'))); +app.use(express.static(path.join(__dirname, '../public'))); app.use('/', routes); // catch 404 and forward to error handler diff --git a/controllers/pages.js b/src/controllers/pages.js similarity index 100% rename from controllers/pages.js rename to src/controllers/pages.js diff --git a/frontend/.postcssrc b/src/frontend/.postcssrc similarity index 100% rename from frontend/.postcssrc rename to src/frontend/.postcssrc diff --git a/frontend/js/app.js b/src/frontend/js/app.js similarity index 100% rename from frontend/js/app.js rename to src/frontend/js/app.js diff --git a/frontend/styles/main.pcss b/src/frontend/styles/main.pcss similarity index 100% rename from frontend/styles/main.pcss rename to src/frontend/styles/main.pcss diff --git a/models/page.js b/src/models/page.js similarity index 97% rename from models/page.js rename to src/models/page.js index df15ef5..1b0b1b8 100644 --- a/models/page.js +++ b/src/models/page.js @@ -1,4 +1,4 @@ -const {pages} = require('../database'); +const {pages} = require('../utils/database/index'); /** * @typedef {Object} PageData @@ -157,4 +157,4 @@ class Page { } } -module.exports = Page; \ No newline at end of file +module.exports = Page; diff --git a/routes/home.js b/src/routes/home.js similarity index 100% rename from routes/home.js rename to src/routes/home.js diff --git a/routes/index.js b/src/routes/index.js similarity index 100% rename from routes/index.js rename to src/routes/index.js diff --git a/routes/pages.js b/src/routes/pages.js similarity index 100% rename from routes/pages.js rename to src/routes/pages.js diff --git a/database/index.js b/src/utils/database/index.js similarity index 100% rename from database/index.js rename to src/utils/database/index.js diff --git a/src/utils/database/pages.js b/src/utils/database/pages.js new file mode 100644 index 0000000..c169825 --- /dev/null +++ b/src/utils/database/pages.js @@ -0,0 +1,5 @@ +const Datastore = require('nedb'); + +const db = new Datastore({filename: './.db/pages.db', autoload: true}); + +module.exports = db; diff --git a/views/error.twig b/src/views/error.twig similarity index 100% rename from views/error.twig rename to src/views/error.twig diff --git a/views/index.twig b/src/views/index.twig similarity index 100% rename from views/index.twig rename to src/views/index.twig diff --git a/views/layout.twig b/src/views/layout.twig similarity index 78% rename from views/layout.twig rename to src/views/layout.twig index 1909d50..aab39ab 100644 --- a/views/layout.twig +++ b/src/views/layout.twig @@ -2,7 +2,7 @@