浏览代码

Use existing values during configure mode

NGPixel 8 年之前
父节点
当前提交
b7442443d3
共有 5 个文件被更改,包括 31 次插入16 次删除
  1. 0 0
      assets/js/configure.min.js
  2. 29 6
      client/js/configure.js
  3. 0 9
      config.sample.yml
  4. 0 1
      configure.js
  5. 2 0
      views/configure/index.pug

文件差异内容过多而无法显示
+ 0 - 0
assets/js/configure.min.js


+ 29 - 6
client/js/configure.js

@@ -1,5 +1,7 @@
 'use strict'
 
+/* global appconfig */
+
 import jQuery from 'jquery'
 import _ from 'lodash'
 import Vue from 'vue'
@@ -43,14 +45,14 @@ jQuery(document).ready(function ($) {
         results: []
       },
       conf: {
-        title: 'Wiki',
-        host: 'http://',
-        port: 80,
-        lang: 'en',
-        db: 'mongodb://localhost:27017/wiki',
+        title: appconfig.title || 'Wiki',
+        host: appconfig.host || 'http://',
+        port: appconfig.port || 80,
+        lang: appconfig.lang || 'en',
+        db: appconfig.db || 'mongodb://localhost:27017/wiki',
         pathData: './data',
         pathRepo: './repo',
-        gitUseRemote: true,
+        gitUseRemote: (appconfig.git !== false),
         gitUrl: '',
         gitBranch: 'master',
         gitAuthType: 'ssh',
@@ -108,6 +110,27 @@ jQuery(document).ready(function ($) {
         return perc
       }
     },
+    mounted: function () {
+      if (appconfig.paths) {
+        this.conf.pathData = appconfig.paths.data || './data'
+        this.conf.pathRepo = appconfig.paths.repo || './repo'
+      }
+      if (appconfig.git !== false && _.isPlainObject(appconfig.git)) {
+        this.conf.gitUrl = appconfig.git.url || ''
+        this.conf.gitBranch = appconfig.git.branch || 'master'
+        if (_.isPlainObject(appconfig.git.auth)) {
+          this.conf.gitAuthType = appconfig.git.auth.type || 'ssh'
+          this.conf.gitAuthSSHKey = appconfig.git.auth.privateKey || ''
+          this.conf.gitAuthUser = appconfig.git.auth.username || ''
+          this.conf.gitAuthPass = appconfig.git.auth.password || ''
+          this.conf.gitAuthSSL = (appconfig.git.auth.sslVerify !== false)
+        }
+        if (_.isPlainObject(appconfig.git.signature)) {
+          this.conf.gitSignatureName = appconfig.git.signature.name || ''
+          this.conf.gitSignatureEmail = appconfig.git.signature.email || ''
+        }
+      }
+    },
     methods: {
       proceedToWelcome: function (ev) {
         this.state = 'welcome'

+ 0 - 9
config.sample.yml

@@ -93,15 +93,6 @@ auth:
 
 sessionSecret: 1234567890abcdefghijklmnopqrstuvxyz
 
-# ---------------------------------------------------------------------
-# Administrator email
-# ---------------------------------------------------------------------
-# An admin account will be created using the email specified here.
-# The password is set to "admin123" by default. Change it immediately
-# upon login!!!
-
-admin: admin@company.com
-
 # ---------------------------------------------------------------------
 # Database Connection String
 # ---------------------------------------------------------------------

+ 0 - 1
configure.js

@@ -323,7 +323,6 @@ module.exports = (port, spinner) => {
         } else {
           conf.auth = { local: { enabled: true } }
         }
-        conf.admin = req.body.adminEmail
         conf.db = req.body.db
         if (req.body.gitUseRemote === false) {
           conf.git = false

+ 2 - 0
views/configure/index.pug

@@ -10,6 +10,8 @@ html(data-logic='configure')
       link(rel='icon', type='image/png', sizes=favsize + 'x' + favsize, href='/favicons/favicon-' + favsize + 'x' + favsize + '.png')
 
     // JS / CSS
+    script(type='text/javascript').
+      var appconfig = !{JSON.stringify(conf)};
     script(type='text/javascript', src='/js/configure.min.js')
 
   body

部分文件因为文件数量过多而无法显示