rpvhost plugin

This commit is contained in:
jysperm
2014-08-20 16:05:54 +08:00
parent ee17bd0434
commit 2b68bd33f1
9 changed files with 70 additions and 45 deletions

View File

@@ -10,25 +10,27 @@ global._ = require 'underscore'
global.ObjectID = require('mongodb').ObjectID
global.express = require 'express'
global.async = require 'async'
global.path = require 'path'
global.app = express()
global.config = require './config'
global.i18n = require './core/i18n'
global.utils = require './core/router/utils'
global.plugin = require './core/plugin'
if fs.existsSync(config.web.listen)
fs.unlinkSync config.web.listen
bindRouters = (app) ->
bindRouters = ->
app.use require 'middleware-injector'
app.use '/', require './core/router/index'
for module_name in ['account', 'admin', 'panel', 'plan', 'ticket', 'wiki', 'bitcoin']
app.use "/#{module_name}", require './core/router/' + module_name
plugin = require './core/plugin'
plugin.loadPlugins app
plugin.loadPlugins()
app.get '/', (req, res) ->
res.redirect '/panel/'
exports.connectDatabase = (callback) ->
{user, password, host, name} = config.mongodb

View File

@@ -3,6 +3,7 @@ module.exports =
url: 'http://rp3.rpvhost.net'
listen: 3000
listen: '/home/rpadmin/rootpanel.sock'
google_analytics_id: 'UA-49193300-2'
account:
cookie_time: 30 * 24 * 3600 * 1000
@@ -12,20 +13,17 @@ module.exports =
availableLanguage: ['zh_CN']
plugin:
availablePlugin: ['linux', 'ssh', 'phpfpm', 'mysql', 'nginx', 'memcached', 'mongodb', 'redis']
available_extensions: ['rpvhost']
available_services: ['shadowsocks']
plans:
all:
price: 10
t_name: '所有服务(默认)'
t_service: '支持所有服务'
t_resources: '磁盘: 520MB, 内存: 27MB, 流量: 37GB'
services: ['linux', 'ssh', 'phpfpm', 'mysql', 'nginx', 'memcached', 'mongodb', 'redis']
resources:
cpu: 144
storage: 520
transfer: 39
memory: 27
price: 0
t_name: 'ShadowSocks 按量付费'
t_service: 'ShadowSocks'
t_resources: '0.6 CNY / G'
services: ['shadowsocks']
resources: {}
nodes:
us1:
@@ -64,6 +62,9 @@ module.exports =
coinbase_api_key: null
plugins:
rpvhost:
index_page: true
linux:
monitor_cycle: 30 * 1000

View File

@@ -15,17 +15,25 @@ app.view_hook =
exports.get = (name) ->
return require path.join(__dirname, "../plugin/#{name}")
exports.loadPlugins = (app) ->
for name in config.plugin.availablePlugin
i18n.loadPlugin path.join(__dirname, "../plugin/#{name}/locale"), name
exports.loadPlugin = (name) ->
plugin_path = path.join(__dirname, "../plugin/#{name}")
plugin = require plugin_path
plugin = exports.get name
if fs.existsSync path.join(plugin_path, 'locale')
i18n.loadPlugin path.join(plugin_path, 'locale'), name
if fs.existsSync path.join(path.join(__dirname, "../plugin/#{name}"), 'static')
app.use harp.mount('/plugin/' + name, path.join(path.join(__dirname, "../plugin/#{name}"), 'static'))
if fs.existsSync path.join(plugin_path, 'static')
app.use harp.mount('/plugin/' + name, path.join(plugin_path, 'static'))
if plugin.action
app.use ('/plugin/' + name), plugin.action
if plugin.action
app.use ('/plugin/' + name), plugin.action
exports.loadPlugins = ->
for name in config.plugin.available_services
exports.loadPlugin name
for name in config.plugin.available_extensions
exports.loadPlugin name
exports.writeConfig = (path, content, callback) ->
tmp.file

View File

@@ -1,6 +0,0 @@
{renderAccount} = require './middleware'
module.exports = exports = express.Router()
exports.get '/', renderAccount, (req, res) ->
res.render 'index'

View File

@@ -19,10 +19,12 @@ html
#navbar-collapse.collapse.navbar-collapse
ul.nav.navbar-nav
for item in app.view_hook.menu_bar
li
a(href=item.href)= item.html
li
a(href='//blog.rpvhost.net', target='_blank') 官方博客
if item.target
li
a(href=item.href, target=item.target)= item.html
else
li
a(href=item.href)= item.html
ul.nav.navbar-nav.navbar-right
if account
li
@@ -53,13 +55,14 @@ html
p= t('app.description')
#footer
script.
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-49193300-2', 'auto');
ga('send', 'pageview');
if config.web.google_analytics_id
script.
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '#{config.web.google_analytics_id}', 'auto');
ga('send', 'pageview');
script(src='http://cdn.staticfile.org/jquery/2.0.3/jquery.min.js')
script(src='http://cdn.staticfile.org/twitter-bootstrap/3.2.0/js/bootstrap.min.js')
script(src='/script/layout.js')

View File

@@ -0,0 +1,7 @@
{renderAccount} = require '../../core/router/middleware'
module.exports = exports = express.Router()
if config.plugin.rpvhost.index_page
app.get '/', renderAccount, (req, res) ->
res.render path.join(__dirname, './view/index')

View File

@@ -0,0 +1,10 @@
action = require './action'
app.view_hook.menu_bar.push
href: '//blog.rpvhost.net'
target: '_blank'
html: '官方博客'
module.exports =
name: 'rpvhost'
type: 'extension'

View File

@@ -1,10 +1,10 @@
extends layout
extends ../../../core/view/layout
prepend head
title RP 主机Linux 虚拟主机 | #{t('app.name')}
append head
link(rel='stylesheet', href='/style/index.css')
link(rel='stylesheet', href='/plugin/rpvhost/style/index.css')
block content
#page-title
@@ -60,12 +60,12 @@ block content
#page-footer
.container
p
a(href= 'https://github.com/jysperm/RootPanel') RootPanel
a(href='https://github.com/jysperm/RootPanel') RootPanel
|   v#{app.package.version}
p
for author in app.package.contributors
| by  
a(href= author.url)= author.name
a(href=author.url)= author.name
#site-not-exist.modal
.modal-dialog