From f8161f2e7aae5ca5223ebd9202c38f7dd25e352b Mon Sep 17 00:00:00 2001 From: NGPixel Date: Mon, 9 Jan 2017 22:45:56 -0500 Subject: [PATCH] Added appdata support --- agent.js | 12 ++++++----- app/data.yml | 48 +++++++++++++++++++++++++++++++++++++++++++ libs/entries.js | 3 +-- libs/git.js | 3 +-- libs/local.js | 5 +---- libs/uploads-agent.js | 7 ++----- libs/uploads.js | 3 +-- server.js | 16 ++++++++------- views/auth/login.pug | 2 +- 9 files changed, 71 insertions(+), 28 deletions(-) create mode 100644 app/data.yml diff --git a/agent.js b/agent.js index 2b079494..e31dc002 100644 --- a/agent.js +++ b/agent.js @@ -25,11 +25,13 @@ global.winston = require(CORE_PATH + 'core-libs/winston')(IS_DEBUG); winston.info('[AGENT] Background Agent is initializing...'); -var appconfig = require(CORE_PATH + 'core-libs/config')('./config.yml'); -global.db = require(CORE_PATH + 'core-libs/mongodb').init(appconfig); -global.upl = require('./libs/uploads-agent').init(appconfig); -global.git = require('./libs/git').init(appconfig); -global.entries = require('./libs/entries').init(appconfig); +let appconf = require(CORE_PATH + 'core-libs/config')(); +global.appconfig = appconf.config; +global.appdata = appconf.data; +global.db = require(CORE_PATH + 'core-libs/mongodb').init(); +global.upl = require('./libs/uploads-agent').init(); +global.git = require('./libs/git').init(); +global.entries = require('./libs/entries').init(); global.mark = require('./libs/markdown'); // ---------------------------------------- diff --git a/app/data.yml b/app/data.yml new file mode 100644 index 00000000..f4d9df23 --- /dev/null +++ b/app/data.yml @@ -0,0 +1,48 @@ +# --------------------------------- +# DO NOT EDIT THIS FILE! +# This is reserved for system use! +# --------------------------------- +name: Wiki.js +capabilities: + guest: true + rights: true + manyAuthProviders: true +defaults: + config: + title: Wiki + host: http://localhost + port: 80 + paths: + repo: ./repo + data: ./data + uploads: + maxImageFileSize: 3, + maxOtherFileSize: 100 + lang: en + public: false + auth: + local: + enabled: true + microsoft: + enabled: false + google: + enabled: false + facebook: + enabled: false + db: mongodb://localhost/wiki + sessionSecret: null + admin: null + git: + url: null + branch: master + auth: + type: basic + username: null + password: null + publicKey: null + privateKey: null + sslVerify: true + signature: + name: Wiki + email: wiki@example.com +# --------------------------------- \ No newline at end of file diff --git a/libs/entries.js b/libs/entries.js index 15f6fd7c..ae9445cf 100644 --- a/libs/entries.js +++ b/libs/entries.js @@ -18,10 +18,9 @@ module.exports = { /** * Initialize Entries model * - * @param {Object} appconfig The application config * @return {Object} Entries model instance */ - init(appconfig) { + init() { let self = this; diff --git a/libs/git.js b/libs/git.js index 79e034a5..d10edca6 100644 --- a/libs/git.js +++ b/libs/git.js @@ -34,10 +34,9 @@ module.exports = { /** * Initialize Git model * - * @param {Object} appconfig The application config * @return {Object} Git model instance */ - init(appconfig) { + init() { let self = this; diff --git a/libs/local.js b/libs/local.js index c4a1630e..2b8b8b92 100644 --- a/libs/local.js +++ b/libs/local.js @@ -9,8 +9,6 @@ var path = require('path'), /** * Local Data Storage - * - * @param {Object} appconfig The application configuration */ module.exports = { @@ -22,10 +20,9 @@ module.exports = { /** * Initialize Local Data Storage model * - * @param {Object} appconfig The application config * @return {Object} Local Data Storage model instance */ - init(appconfig) { + init() { this._uploadsPath = path.resolve(ROOTPATH, appconfig.paths.repo, 'uploads'); this._uploadsThumbsPath = path.resolve(ROOTPATH, appconfig.paths.data, 'thumbs'); diff --git a/libs/uploads-agent.js b/libs/uploads-agent.js index 013433a3..f65eb8a4 100644 --- a/libs/uploads-agent.js +++ b/libs/uploads-agent.js @@ -13,9 +13,7 @@ var path = require('path'), _ = require('lodash'); /** - * Uploads - * - * @param {Object} appconfig The application configuration + * Uploads - Agent */ module.exports = { @@ -27,10 +25,9 @@ module.exports = { /** * Initialize Uploads model * - * @param {Object} appconfig The application config * @return {Object} Uploads model instance */ - init(appconfig) { + init() { let self = this; diff --git a/libs/uploads.js b/libs/uploads.js index e38a691a..7eae1f28 100644 --- a/libs/uploads.js +++ b/libs/uploads.js @@ -23,10 +23,9 @@ module.exports = { /** * Initialize Local Data Storage model * - * @param {Object} appconfig The application config * @return {Object} Uploads model instance */ - init(appconfig) { + init() { this._uploadsPath = path.resolve(ROOTPATH, appconfig.paths.repo, 'uploads'); this._uploadsThumbsPath = path.resolve(ROOTPATH, appconfig.paths.data, 'thumbs'); diff --git a/server.js b/server.js index abb82824..bae8dc44 100644 --- a/server.js +++ b/server.js @@ -25,14 +25,16 @@ winston.info('[SERVER] Wiki.js is initializing...'); // Load global modules // ---------------------------------------- -var appconfig = require(CORE_PATH + 'core-libs/config')('./config.yml'); -global.lcdata = require('./libs/local').init(appconfig); -global.db = require(CORE_PATH + 'core-libs/mongodb').init(appconfig); -global.entries = require('./libs/entries').init(appconfig); -global.git = require('./libs/git').init(appconfig, false); +let appconf = require(CORE_PATH + 'core-libs/config')(); +global.appconfig = appconf.config; +global.appdata = appconf.data; +global.lcdata = require('./libs/local').init(); +global.db = require(CORE_PATH + 'core-libs/mongodb').init(); +global.entries = require('./libs/entries').init(); +global.git = require('./libs/git').init(false); global.lang = require('i18next'); global.mark = require('./libs/markdown'); -global.upl = require('./libs/uploads').init(appconfig); +global.upl = require('./libs/uploads').init(); // ---------------------------------------- // Load modules @@ -87,7 +89,7 @@ app.use(express.static(path.join(ROOTPATH, 'assets'))); // Passport Authentication // ---------------------------------------- -var strategy = require(CORE_PATH + 'core-libs/auth')(passport, appconfig); +var strategy = require(CORE_PATH + 'core-libs/auth')(passport); global.rights = require(CORE_PATH + 'core-libs/rights'); rights.init(); diff --git a/views/auth/login.pug b/views/auth/login.pug index 9163b674..8b0bec23 100644 --- a/views/auth/login.pug +++ b/views/auth/login.pug @@ -63,5 +63,5 @@ html #copyright = t('footer.poweredby') + ' ' a.icon(href='https://github.com/Requarks/wiki') - i.fa.fa-github + i.icon-github a(href='https://github.com/Requarks/wiki') Requarks Wiki \ No newline at end of file