plugin rpvhost, bitcoin, wiki

This commit is contained in:
jysperm
2014-09-29 05:21:54 +08:00
parent bb606c18a4
commit 4a29e4d5bc
7 changed files with 107 additions and 51 deletions

View File

@@ -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}'"

View File

@@ -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')

View File

@@ -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')

View File

@@ -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

View File

@@ -0,0 +1,3 @@
{
}

22
plugin/wiki/wiki.coffee Normal file
View File

@@ -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()

View File

@@ -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'