Browse Source

refactor: logging + search modules PH

Nicolas Giard 6 years ago
parent
commit
9c6a4f6c20
34 changed files with 327 additions and 189 deletions
  1. 18 11
      client/components/admin/admin-editor.vue
  2. 18 20
      client/components/admin/admin-logging.vue
  3. 16 10
      client/components/admin/admin-search.vue
  4. 3 4
      config.sample.yml
  5. 1 3
      server/app/data.yml
  6. 1 1
      server/master.js
  7. 0 0
      server/modules/logging/bugsnag/logger.js
  8. 0 0
      server/modules/logging/console/logger.js
  9. 0 0
      server/modules/logging/loggly/logger.js
  10. 0 0
      server/modules/logging/papertrail/logger.js
  11. 0 0
      server/modules/logging/rollbar/logger.js
  12. 0 0
      server/modules/logging/sentry/logger.js
  13. 0 26
      server/modules/search/algolia.js
  14. 7 0
      server/modules/search/algolia/definition.yml
  15. 26 0
      server/modules/search/algolia/engine.js
  16. 7 0
      server/modules/search/aws/definition.yml
  17. 26 0
      server/modules/search/aws/engine.js
  18. 0 26
      server/modules/search/azure.js
  19. 7 0
      server/modules/search/azure/definition.yml
  20. 26 0
      server/modules/search/azure/engine.js
  21. 0 26
      server/modules/search/db.js
  22. 7 0
      server/modules/search/db/definition.yml
  23. 26 0
      server/modules/search/db/engine.js
  24. 0 26
      server/modules/search/elasticsearch.js
  25. 7 0
      server/modules/search/elasticsearch/definition.yml
  26. 26 0
      server/modules/search/elasticsearch/engine.js
  27. 7 0
      server/modules/search/manticore/definition.yml
  28. 26 0
      server/modules/search/manticore/engine.js
  29. 0 26
      server/modules/search/solr.js
  30. 7 0
      server/modules/search/solr/definition.yml
  31. 26 0
      server/modules/search/solr/engine.js
  32. 7 0
      server/modules/search/sphinx/definition.yml
  33. 26 0
      server/modules/search/sphinx/engine.js
  34. 6 10
      server/setup.js

+ 18 - 11
client/components/admin/admin-editor.vue

@@ -1,6 +1,6 @@
 <template lang='pug'>
-  v-card(flat)
-    v-card(flat, :color='$vuetify.dark ? "grey darken-4" : "grey lighten-5"').pa-3.pt-4
+  v-card(tile, :color='$vuetify.dark ? "grey darken-4" : "grey lighten-5"')
+    .pa-3.pt-4
       .headline.primary--text Editor
       .subheading.grey--text Configure the content editor
     v-tabs(:color='$vuetify.dark ? "primary" : "grey lighten-4"', fixed-tabs, :slider-color='$vuetify.dark ? "white" : "primary"', show-arrows)
@@ -8,21 +8,24 @@
       v-tab(key='code') Markdown
 
       v-tab-item(key='settings', :transition='false', :reverse-transition='false')
-        v-card.pa-3
+        v-card.pa-3(flat, tile)
+          .body-2.grey--text.text--darken-1 Select which editors to enable:
+          .caption.grey--text.pb-2 Some editors require additional configuration in their dedicated tab (when selected).
           v-form
             v-radio-group(v-model='selectedEditor')
               v-radio(v-for='(editor, n) in editors', :key='n', :label='editor.text', :value='editor.value', color='primary')
-            v-divider
-            v-btn(color='primary')
-              v-icon(left) chevron_right
-              | Set Editor
-            v-btn(icon)
-              v-icon.grey--text refresh
       v-tab-item(key='code', :transition='false', :reverse-transition='false')
-        v-card.pa-3
+        v-card.pa-3(flat, tile)
           v-form
             v-subheader Editor Configuration
-            .body-1 This editor has no configuration options you can modify.
+            .body-1.ml-3 This editor has no configuration options you can modify.
+    v-card-chin
+      v-btn(color='primary', @click='save')
+        v-icon(left) chevron_right
+        span Apply Configuration
+      v-spacer
+      v-btn(icon, @click='refresh')
+        v-icon.grey--text refresh
 
 </template>
 
@@ -35,6 +38,10 @@ export default {
       ],
       selectedEditor: 'code'
     }
+  },
+  methods: {
+    save() {},
+    refresh() {}
   }
 }
 </script>

+ 18 - 20
client/components/admin/admin-logging.vue

@@ -1,6 +1,6 @@
 <template lang='pug'>
-  v-card(flat)
-    v-card(flat, :color='$vuetify.dark ? "grey darken-4" : "grey lighten-5"').pa-3.pt-4
+  v-card(tile, :color='$vuetify.dark ? "grey darken-4" : "grey lighten-5"')
+    .pa-3.pt-4
       .headline.primary--text Logging
       .subheading.grey--text Configure the system logger(s)
     v-tabs(:color='$vuetify.dark ? "primary" : "grey lighten-4"', fixed-tabs, :slider-color='$vuetify.dark ? "white" : "primary"', show-arrows)
@@ -8,7 +8,7 @@
       v-tab(v-for='svc in activeServices', :key='svc.key') {{ svc.title }}
 
       v-tab-item(key='settings', :transition='false', :reverse-transition='false')
-        v-card.pa-3
+        v-card.pa-3(flat, tile)
           .body-2.pb-2 Select which logging service to enable:
           v-form
             v-checkbox(
@@ -21,29 +21,27 @@
               :disabled='svc.key === `console`'
               hide-details
             )
-            v-divider
-            v-btn(color='primary')
-              v-icon(left) chevron_right
-              | Set Services
-            v-btn(color='black', dark, @click='toggleConsole')
-              v-icon(left) keyboard
-              | View Console
-            v-btn(color='black', dark)
-              v-icon(left) layers_clear
-              | Purge Logs
-            v-btn(icon, @click='refresh')
-              v-icon.grey--text refresh
 
       v-tab-item(v-for='(svc, n) in activeServices', :key='svc.key', :transition='false', :reverse-transition='false')
-        v-card.pa-3
+        v-card.pa-3(flat, tile)
           v-form
             v-subheader Service Configuration
             .body-1(v-if='!svc.props || svc.props.length < 1') This logging service has no configuration options you can modify.
             v-text-field(v-else, v-for='prop in svc.props', :key='prop', :label='prop', prepend-icon='mode_edit')
-            v-divider
-            v-btn(color='primary')
-              v-icon(left) chevron_right
-              | Save Configuration
+
+    v-card-chin
+      v-btn(color='primary', @click='save')
+        v-icon(left) chevron_right
+        span Apply Configuration
+      v-btn(color='black', dark, @click='toggleConsole')
+        v-icon(left) keyboard
+        span View Console
+      v-btn(color='black', dark)
+        v-icon(left) layers_clear
+        span Purge Logs
+      v-spacer
+      v-btn(icon, @click='refresh')
+        v-icon.grey--text refresh
 
     logging-console(v-model='showConsole')
 </template>

+ 16 - 10
client/components/admin/admin-search.vue

@@ -1,6 +1,6 @@
 <template lang='pug'>
-  v-card(flat)
-    v-card(flat, tile, :color='$vuetify.dark ? "grey darken-4" : "grey lighten-5"').pa-3.pt-4
+  v-card(tile, :color='$vuetify.dark ? "grey darken-4" : "grey lighten-5"')
+    .pa-3.pt-4
       .headline.primary--text Search Engine
       .subheading.grey--text Configure the search capabilities of your wiki
     v-tabs(:color='$vuetify.dark ? "primary" : "grey lighten-4"', fixed-tabs, :slider-color='$vuetify.dark ? "white" : "primary"', show-arrows)
@@ -11,17 +11,12 @@
       v-tab(key='solr') Solr
 
       v-tab-item(key='settings')
-        v-card.pa-3
+        v-card.pa-3(flat, tile)
           v-form
+            .body-2.grey--text.text--darken-1 Select the search engine to use:
+            .caption.grey--text.pb-2 Some engines require additional configuration in their dedicated tab (when selected).
             v-radio-group(v-model='selectedEngine')
               v-radio(v-for='(engine, n) in engines', :key='n', :label='engine.text', :value='engine.value', color='primary')
-            v-divider
-            v-btn(color='primary')
-              v-icon(left) chevron_right
-              | Set Engine
-            v-btn(color='black', dark)
-              v-icon(left) refresh
-              | Rebuild Index
       v-tab-item(key='db')
         v-card.pa-3 TODO
       v-tab-item(key='algolia')
@@ -31,6 +26,17 @@
       v-tab-item(key='solr')
         v-card.pa-3 TODO
 
+    v-card-chin
+      v-btn(color='primary', @click='save')
+        v-icon(left) chevron_right
+        span Apply Configuration
+      v-btn(color='black', dark)
+        v-icon(left) refresh
+        | Rebuild Index
+      v-spacer
+      v-btn(icon, @click='refresh')
+        v-icon.grey--text refresh
+
 </template>
 
 <script>

+ 3 - 4
config.sample.yml

@@ -11,12 +11,11 @@
 port: 80
 
 # ---------------------------------------------------------------------
-# Data Directories
+# IP address the server should listen to
 # ---------------------------------------------------------------------
+# Do not change unless you know what you are doing!
 
-paths:
-  content: ./content
-  data: ./data
+bindIP: 0.0.0.0
 
 # ---------------------------------------------------------------------
 # Database

+ 1 - 3
server/app/data.yml

@@ -7,9 +7,7 @@ defaults:
   config:
     # File defaults
     port: 80
-    paths:
-      repo: ./repo
-      data: ./data
+    bindIP: 0.0.0.0
     db:
       type: postgres
       host: localhost

+ 1 - 1
server/master.js

@@ -170,7 +170,7 @@ module.exports = async () => {
   app.set('port', WIKI.config.port)
   WIKI.server = http.createServer(app)
 
-  WIKI.server.listen(WIKI.config.port)
+  WIKI.server.listen(WIKI.config.port, WIKI.config.bindIP)
   WIKI.server.on('error', (error) => {
     if (error.syscall !== 'listen') {
       throw error

+ 0 - 0
server/modules/logging/bugsnag.js → server/modules/logging/bugsnag/logger.js


+ 0 - 0
server/modules/logging/console.js → server/modules/logging/console/logger.js


+ 0 - 0
server/modules/logging/loggly.js → server/modules/logging/loggly/logger.js


+ 0 - 0
server/modules/logging/papertrail.js → server/modules/logging/papertrail/logger.js


+ 0 - 0
server/modules/logging/rollbar.js → server/modules/logging/rollbar/logger.js


+ 0 - 0
server/modules/logging/sentry.js → server/modules/logging/sentry/logger.js


+ 0 - 26
server/modules/search/algolia.js

@@ -1,26 +0,0 @@
-module.exports = {
-  key: 'algolia',
-  title: 'Algolia',
-  props: ['applicationID', 'adminAPIKey'],
-  activate(opts) {
-
-  },
-  deactivate(opts) {
-
-  },
-  query(opts) {
-
-  },
-  created(opts) {
-
-  },
-  updated(opts) {
-
-  },
-  deleted(opts) {
-
-  },
-  renamed(opts) {
-
-  }
-}

+ 7 - 0
server/modules/search/algolia/definition.yml

@@ -0,0 +1,7 @@
+key: algolia
+title: Algolia
+description: Algolia is a powerful search-as-a-service solution, made easy to use with API clients, UI libraries, and pre-built integrations.
+author: requarks.io
+logo: https://static.requarks.io/logo/algolia.svg
+website: https://www.algolia.com/
+props: {}

+ 26 - 0
server/modules/search/algolia/engine.js

@@ -0,0 +1,26 @@
+module.exports = {
+  activate() {
+
+  },
+  deactivate() {
+
+  },
+  query() {
+
+  },
+  created() {
+
+  },
+  updated() {
+
+  },
+  deleted() {
+
+  },
+  renamed() {
+
+  },
+  rebuild() {
+
+  }
+}

+ 7 - 0
server/modules/search/aws/definition.yml

@@ -0,0 +1,7 @@
+key: aws
+title: AWS CloudSearch
+description: Amazon CloudSearch is a managed service in the AWS Cloud that makes it simple and cost-effective to set up, manage, and scale a search solution for your website or application.
+author: requarks.io
+logo: https://static.requarks.io/logo/aws.svg
+website: https://aws.amazon.com/cloudsearch/
+props: {}

+ 26 - 0
server/modules/search/aws/engine.js

@@ -0,0 +1,26 @@
+module.exports = {
+  activate() {
+
+  },
+  deactivate() {
+
+  },
+  query() {
+
+  },
+  created() {
+
+  },
+  updated() {
+
+  },
+  deleted() {
+
+  },
+  renamed() {
+
+  },
+  rebuild() {
+
+  }
+}

+ 0 - 26
server/modules/search/azure.js

@@ -1,26 +0,0 @@
-module.exports = {
-  key: 'azure',
-  title: 'Azure Search',
-  props: ['apiKey', 'applicationID'],
-  activate(opts) {
-
-  },
-  deactivate(opts) {
-
-  },
-  query(opts) {
-
-  },
-  created(opts) {
-
-  },
-  updated(opts) {
-
-  },
-  deleted(opts) {
-
-  },
-  renamed(opts) {
-
-  }
-}

+ 7 - 0
server/modules/search/azure/definition.yml

@@ -0,0 +1,7 @@
+key: azure
+title: Azure Search
+description: AI-Powered cloud search service for web and mobile app development.
+author: requarks.io
+logo: https://static.requarks.io/logo/azure.svg
+website: https://azure.microsoft.com/services/search/
+props: {}

+ 26 - 0
server/modules/search/azure/engine.js

@@ -0,0 +1,26 @@
+module.exports = {
+  activate() {
+
+  },
+  deactivate() {
+
+  },
+  query() {
+
+  },
+  created() {
+
+  },
+  updated() {
+
+  },
+  deleted() {
+
+  },
+  renamed() {
+
+  },
+  rebuild() {
+
+  }
+}

+ 0 - 26
server/modules/search/db.js

@@ -1,26 +0,0 @@
-module.exports = {
-  key: 'db',
-  title: 'Database (built-in)',
-  props: [],
-  activate(opts) {
-
-  },
-  deactivate(opts) {
-
-  },
-  query(opts) {
-
-  },
-  created(opts) {
-
-  },
-  updated(opts) {
-
-  },
-  deleted(opts) {
-
-  },
-  renamed(opts) {
-
-  }
-}

+ 7 - 0
server/modules/search/db/definition.yml

@@ -0,0 +1,7 @@
+key: db
+title: Database (built-in)
+description: Default database-based search engine.
+author: requarks.io
+logo: https://static.requarks.io/logo/db.svg
+website: https://www.requarks.io/
+props: {}

+ 26 - 0
server/modules/search/db/engine.js

@@ -0,0 +1,26 @@
+module.exports = {
+  activate() {
+
+  },
+  deactivate() {
+
+  },
+  query() {
+
+  },
+  created() {
+
+  },
+  updated() {
+
+  },
+  deleted() {
+
+  },
+  renamed() {
+
+  },
+  rebuild() {
+
+  }
+}

+ 0 - 26
server/modules/search/elasticsearch.js

@@ -1,26 +0,0 @@
-module.exports = {
-  key: 'elasticsearch',
-  title: 'Elasticsearch',
-  props: [],
-  activate(opts) {
-
-  },
-  deactivate(opts) {
-
-  },
-  query(opts) {
-
-  },
-  created(opts) {
-
-  },
-  updated(opts) {
-
-  },
-  deleted(opts) {
-
-  },
-  renamed(opts) {
-
-  }
-}

+ 7 - 0
server/modules/search/elasticsearch/definition.yml

@@ -0,0 +1,7 @@
+key: elasticsearch
+title: Elasticsearch
+description: Elasticsearch is a distributed, RESTful search and analytics engine capable of solving a growing number of use cases.
+author: requarks.io
+logo: https://static.requarks.io/logo/elasticsearch.svg
+website: https://www.elastic.co/products/elasticsearch
+props: {}

+ 26 - 0
server/modules/search/elasticsearch/engine.js

@@ -0,0 +1,26 @@
+module.exports = {
+  activate() {
+
+  },
+  deactivate() {
+
+  },
+  query() {
+
+  },
+  created() {
+
+  },
+  updated() {
+
+  },
+  deleted() {
+
+  },
+  renamed() {
+
+  },
+  rebuild() {
+
+  }
+}

+ 7 - 0
server/modules/search/manticore/definition.yml

@@ -0,0 +1,7 @@
+key: manticore
+title: Manticore Search
+description: High performance full-text search engine with SQL and JSON support.
+author: requarks.io
+logo: https://static.requarks.io/logo/manticore.svg
+website: https://manticoresearch.com/
+props: {}

+ 26 - 0
server/modules/search/manticore/engine.js

@@ -0,0 +1,26 @@
+module.exports = {
+  activate() {
+
+  },
+  deactivate() {
+
+  },
+  query() {
+
+  },
+  created() {
+
+  },
+  updated() {
+
+  },
+  deleted() {
+
+  },
+  renamed() {
+
+  },
+  rebuild() {
+
+  }
+}

+ 0 - 26
server/modules/search/solr.js

@@ -1,26 +0,0 @@
-module.exports = {
-  key: 'solr',
-  title: 'Solr',
-  props: [],
-  activate(opts) {
-
-  },
-  deactivate(opts) {
-
-  },
-  query(opts) {
-
-  },
-  created(opts) {
-
-  },
-  updated(opts) {
-
-  },
-  deleted(opts) {
-
-  },
-  renamed(opts) {
-
-  }
-}

+ 7 - 0
server/modules/search/solr/definition.yml

@@ -0,0 +1,7 @@
+key: solr
+title: Solr
+description: Solr is the popular, blazing-fast, open source enterprise search platform built on Apache Lucene.
+author: requarks.io
+logo: https://static.requarks.io/logo/solr.svg
+website: http://lucene.apache.org/solr/
+props: {}

+ 26 - 0
server/modules/search/solr/engine.js

@@ -0,0 +1,26 @@
+module.exports = {
+  activate() {
+
+  },
+  deactivate() {
+
+  },
+  query() {
+
+  },
+  created() {
+
+  },
+  updated() {
+
+  },
+  deleted() {
+
+  },
+  renamed() {
+
+  },
+  rebuild() {
+
+  }
+}

+ 7 - 0
server/modules/search/sphinx/definition.yml

@@ -0,0 +1,7 @@
+key: sphinx
+title: Sphinx
+description: Sphinx is an open source full text search server, designed from the ground up with performance, relevance and integration simplicity in mind.
+author: requarks.io
+logo: https://static.requarks.io/logo/sphinx.svg
+website: http://sphinxsearch.com/
+props: {}

+ 26 - 0
server/modules/search/sphinx/engine.js

@@ -0,0 +1,26 @@
+module.exports = {
+  activate() {
+
+  },
+  deactivate() {
+
+  },
+  query() {
+
+  },
+  created() {
+
+  },
+  updated() {
+
+  },
+  deleted() {
+
+  },
+  renamed() {
+
+  },
+  rebuild() {
+
+  }
+}

+ 6 - 10
server/setup.js

@@ -1,4 +1,5 @@
 const path = require('path')
+const os = require('os')
 
 /* global WIKI */
 
@@ -89,16 +90,11 @@ module.exports = () => {
         })
       }
 
-      // Update config file
-      WIKI.logger.info('Writing config file to disk...')
-      let confRaw = await fs.readFileAsync(path.join(WIKI.ROOTPATH, 'config.yml'), 'utf8')
-      let conf = yaml.safeLoad(confRaw)
-
       // Create directory structure
-      await fs.ensureDir(conf.paths.data)
-      await fs.ensureDir(path.join(conf.paths.data, 'cache'))
-      await fs.ensureDir(path.join(conf.paths.data, 'temp-upload'))
-      await fs.ensureDir(conf.paths.content)
+      const tmpPath = path.join(os.tmpdir(), 'wikijs')
+      await fs.ensureDir(tmpPath)
+      await fs.ensureDir(path.join(tmpPath, 'cache'))
+      await fs.ensureDir(path.join(tmpPath, 'uploads'))
 
       // Set config
       _.set(WIKI.config, 'defaultEditor', 'markdown')
@@ -237,7 +233,7 @@ module.exports = () => {
 
   app.set('port', WIKI.config.port)
   WIKI.server = http.createServer(app)
-  WIKI.server.listen(WIKI.config.port)
+  WIKI.server.listen(WIKI.config.port, WIKI.config.bindIP)
 
   var openConnections = []