diff --git a/core/pluggable.coffee b/core/pluggable.coffee index a37b0ff..587b8a6 100644 --- a/core/pluggable.coffee +++ b/core/pluggable.coffee @@ -111,19 +111,3 @@ exports.initializePlugins = (callback) -> initializeService plugin, callback , callback ], callback - -exports.writeConfig = (path, content, callback) -> - tmp.file - mode: 0o750 - , (err, filepath, fd) -> - fs.writeSync fd, content, 0, 'utf8' - fs.closeSync fd - - child_process.exec "sudo cp #{filepath} #{path}", (err) -> - throw err if err - - fs.unlink path, -> - callback() - -exports.sudoSu = (account, command) -> - return "sudo su #{account.username} -c '#{command}'" diff --git a/plugin/rpvhost/action.coffee b/plugin/rpvhost/action.coffee deleted file mode 100644 index 6ac9b09..0000000 --- a/plugin/rpvhost/action.coffee +++ /dev/null @@ -1,7 +0,0 @@ -{renderAccount} = require '../../core/middleware' - -module.exports = exports = express.Router() - -if config.plugins.rpvhost.index_page - app.get '/', renderAccount, (req, res) -> - res.render path.join(__dirname, './view/index') diff --git a/plugin/rpvhost/index.coffee b/plugin/rpvhost/index.coffee index 8e09e51..d10ec1c 100644 --- a/plugin/rpvhost/index.coffee +++ b/plugin/rpvhost/index.coffee @@ -1,10 +1,16 @@ -action = require './action' +path = require 'path' -app.view_hook.menu_bar.push - href: '//blog.rpvhost.net' - target: '_blank' - html: '官方博客' +{pluggable} = app +{renderAccount} = app.middleware module.exports = name: 'rpvhost' type: 'extension' + +pluggable.registerHook 'view.layout.menu_bar', module.exports, + href: '//blog.rpvhost.net' + target: '_blank' + body: '官方博客' + +app.get '/', renderAccount, (req, res) -> + res.render path.join(__dirname, './view/index') diff --git a/plugin/wiki/index.coffee b/plugin/wiki/index.coffee index deb3652..3e5b02a 100644 --- a/plugin/wiki/index.coffee +++ b/plugin/wiki/index.coffee @@ -1,33 +1,14 @@ -markdown = require('markdown').markdown -path = require 'path' -fs = require 'fs' - {pluggable} = app {renderAccount} = app.middleware +wiki = require './wiki' + module.exports = name: 'wiki' type: 'extension' -pluggable.hooks.view.layout.menu_bar.push +pluggable.registerHook 'view.layout.menu_bar', module.exports, href: '/wiki/' body: '用户手册' -app.use '/wiki', renderAccount, (req, res) -> - url = req.url.substr '/wiki'.length - - unless url - url = 'README.md' - - filename = path.resolve path.join __dirname, '../../WIKI', url - baseDir = path.resolve path.join __dirname, '../../WIKI' - - unless filename[0 .. baseDir.length - 1] == baseDir - return res.status(403).end() - - fs.readFile filename, (err, data) -> - if err - return res.status(404).send err.toString() - res.render 'wiki', - title: url - content: markdown.toHTML data.toString() +app.use '/wiki', renderAccount, wiki.router diff --git a/plugin/wiki/locale/zh_CN.json b/plugin/wiki/locale/zh_CN.json new file mode 100644 index 0000000..0db3279 --- /dev/null +++ b/plugin/wiki/locale/zh_CN.json @@ -0,0 +1,3 @@ +{ + +} diff --git a/plugin/wiki/wiki.coffee b/plugin/wiki/wiki.coffee new file mode 100644 index 0000000..91b32ba --- /dev/null +++ b/plugin/wiki/wiki.coffee @@ -0,0 +1,22 @@ +markdown = require('markdown').markdown +path = require 'path' +fs = require 'fs' + +exports.router = (req, res) -> + url = req.url.substr '/wiki'.length + + unless url + url = 'README.md' + + filename = path.resolve path.join __dirname, '../../WIKI', url + baseDir = path.resolve path.join __dirname, '../../WIKI' + + unless filename[0 .. baseDir.length - 1] == baseDir + return res.status(403).end() + + fs.readFile filename, (err, data) -> + if err + return res.status(404).send err.toString() + res.render 'wiki', + title: url + content: markdown.toHTML data.toString() diff --git a/sample/rpvhost.config.coffee b/sample/rpvhost.config.coffee index e69de29..e923532 100644 --- a/sample/rpvhost.config.coffee +++ b/sample/rpvhost.config.coffee @@ -0,0 +1,67 @@ +module.exports = + web: + name: 'RP 主机' + url: 'http://rpvhost.net' + listen: '/home/rpadmin/rootpanel.sock' + google_analytics_id: 'UA-49193300-2' + + account: + cookie_time: 30 * 24 * 3600 * 1000 + + i18n: + version: '0.1' + available_language: ['zh_CN'] + default_language: 'zh_CN' + default_timezone: 'Asia/Shanghai' + + plugin: + available_extensions: ['rpvhost', 'bitcoin', 'wiki'] + available_services: [] + + billing: + currency: 'CNY' + + force_freeze: + when_balance_below: 0 + when_arrears_above: 0 + + billing_cycle: 10 * 60 * 1000 + + plans: + all: + t_name: 'plans.all.name' + t_description: 'plans.all.name.description' + + billing_by_time: + unit: 24 * 3600 * 1000 + price: 10 / 30 + + services: [] + resources: {} + + mongodb: + user: 'rpadmin' + password: 'password' + host: 'localhost' + name: 'RootPanel' + + redis: + host: '127.0.0.1' + port: 6379 + password: 'password' + prefix: 'RP' + + redis_password: 'password' + + email: + send_from: 'robot@rpvhost.net' + + account: + service: 'Postmark' + auth: + user: 'postmark-api-token' + pass: 'postmark-api-token' + + plugins: + bitcoin: + coinbase_api_key: 'coinbase-simple-api-key'