Skip to content

Commit

Permalink
add test Pulgins Module
Browse files Browse the repository at this point in the history
  • Loading branch information
jksdou committed Aug 22, 2019
1 parent cb76969 commit ad16ba0
Show file tree
Hide file tree
Showing 13 changed files with 955 additions and 765 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<div navbar ng-init="currentItem='application.acme'"></div>
<div ng-show="Auth.processing||!loaded">
<div loading></div>
</div>

<div id="main" ng-show="!Auth.processing&&loaded" style="display:none" ng-init="load()">
<div>
<div class="module-header">
<h3>ACME 协议设置</h3>
</div>
Expand Down
13 changes: 13 additions & 0 deletions plugins/acme/static/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

var PluginsCACMEtrl = [
'$scope', 'Module',
function ($scope, Module) {
var module = 'plugins.acme';
Module.init(module, 'ACME');
$scope.loaded = false;

$scope.load = function () {
$scope.loaded = true;
};
}
];
73 changes: 73 additions & 0 deletions plugins/shadowsocks-libev/info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2019, doudoudzj
# All rights reserved.
#
# InPanel is distributed under the terms of the (new) BSD License.
# The full license can be found in 'LICENSE'.

'''Shadowsocks-libev Plugins'''

plugins_info = {
'name': 'Shadowsocks-libev',
'router': 'shadowsocks-libev',
'config': {
'centos': '/etc/shadowsocks-libev/config.json',
'debian': '/etc/default/shadowsocks-libev',
'ubuntu': '/etc/default/shadowsocks-libev',
'freebsd': '/usr/local/etc/shadowsocks-libev'
},
'script': {
'sysvinit': {
'start': '/etc/init.d/shadowsocks-libev start',
'stop': '/etc/init.d/shadowsocks-libev stop',
'restart': '/etc/init.d/shadowsocks-libev restart',
'status': '/etc/init.d/shadowsocks-libev status'
},
'systemd': {
'start': 'systemctl start shadowsocks-libev',
'stop': 'systemctl stop shadowsocks-libev',
'restart': 'systemctl restart shadowsocks-libev',
'status': 'systemctl status shadowsocks-libev',
}
},
'install': {
'yum': {
'repos': '',
'import': {
'from': 'https://copr.fedorainfracloud.org/coprs/librehat/shadowsocks/repo/epel-6/librehat-shadowsocks-epel-6.repo',
'to': ''
},
'shell': [
'yum install epel-release -y',
'yum install gcc gettext autoconf libtool automake make pcre-devel asciidoc xmlto c-ares-devel libev-devel libsodium-devel mbedtls-devel -y',
'yum update',
'yum install shadowsocks-libev'
],
},
'dnf': {
'repos': '',
'shell': [
'yum install epel-release -y',
'yum install gcc gettext autoconf libtool automake make pcre-devel asciidoc xmlto c-ares-devel libev-devel libsodium-devel mbedtls-devel -y',
'yum update',
'yum install shadowsocks-libev'
],
},
'apt': {
'repos': '/etc/default/shadowsocks-libev',
'shell': [
'sh -c \'printf "deb http://deb.debian.org/debian stretch-backports main" > /etc/apt/sources.list.d/stretch-backports.list\'',
'apt update',
'apt -t stretch-backports install shadowsocks-libev'
]
},
'brew': {
'repos': '',
'shell': [
'ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"',
'brew install shadowsocks-libev'
]
},
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div navbar ng-init="currentItem='application.shadowsocks'"></div>
<div navbar ng-init="currentItem='plugins.shadowsocks'"></div>
<div ng-show="Auth.processing||!loaded">
<div loading></div>
</div>
Expand Down
18 changes: 18 additions & 0 deletions plugins/shadowsocks-libev/static/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var PluginsShadowsocksCtrl = [
'$scope', 'Module',
function ($scope, Module) {
var module = 'plugins.shadowsocks';
Module.init(module, 'Shadowsocks');
$scope.loaded = false;
$scope.installed = false;

$scope.load = function () {
$scope.loaded = true;
$scope.check();
};

$scope.check = function () {
$scope.installed = false;
}
}
];
2 changes: 2 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def main():
'conf_path': os.path.join(root_path, 'data', 'config.ini'),
'index_path': os.path.join(root_path, 'static', 'index.html'),
'static_path': os.path.join(root_path, 'static'),
'plugins_path': os.path.join(root_path, 'plugins'),
'xsrf_cookies': True,
'cookie_secret': make_cookie_secret(),
'gzip': True
Expand All @@ -62,6 +63,7 @@ def main():
(r'/client/(.+)', web.ClientHandler),
(r'/((?:css|js|js.min|lib|partials|images|favicon\.ico|robots\.txt)(?:\/.*)?)',
web.StaticFileHandler, {'path': settings['static_path']}),
(r'/plugins/(.*)', web.StaticFileHandler, {'path': settings['plugins_path']}),
(r'/($)', web.StaticFileHandler, {'path': settings['index_path']}),
(r'/file/(.+)', web.FileDownloadHandler, {'path': '/'}),
(r'/fileupload', web.FileUploadHandler),
Expand Down
2 changes: 1 addition & 1 deletion static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ <h3 class="modal-title">登录即将超时 !</h3>
<script src="js/controllers/ecs.js"></script>
<script src="js/controllers/utils.js"></script>
<script src="js/controllers/database.js"></script>
<script src="js/controllers/application.js"></script>
<script src="js/controllers/plugins.js"></script>

</body>

Expand Down
45 changes: 0 additions & 45 deletions static/js/controllers/application.js

This file was deleted.

105 changes: 105 additions & 0 deletions static/js/controllers/plugins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
var PluginsHome = [
'$scope', 'Module',
function ($scope, Module) {
var module = 'plugins';
Module.init(module, '应用管理');
$scope.loaded = false;

$scope.load = function () {
$scope.loaded = true;
$scope.init_plugins();
};
$scope.init_plugins = function () {
// app.directive("runoobDirective", function() {
// return {
// template : "<h1>自定义指令!</h1>"
// };
// });
// angular.module('inpanel.directives', []).directive('acme', function () {
inpanel.directive("acme", function() {
return {
restrict: 'A',
transclude: true,
scope: {},
replace: true,
templateUrl: template_path + '/plugins/acme/static/index.html',
controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
$rootScope.navbar_loaded = true;
}]
};
})
// var plugins_list = [
// 'acme'
// ];
// plugins_list.forEach(function (i) {
// var directives_name = 'plugins' + i;
// angular.module('inpanel.directives', []).directive(directives_name, function () {
// return {
// restrict: 'A',
// transclude: true,
// scope: {},
// replace: true,
// templateUrl: template_path + '/plugins/' + i + '/index.html',
// controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
// $rootScope.navbar_loaded = true;
// }]
// };
// })
// });
console.log('加载路由')
// inpanel.config(['$routeProvider', function ($routeProvider) {
// var _r = function (t, c, a) {
// var r = {
// templateUrl: template_path + t + '.html?_v=' + _v,
// controller: c,
// reloadOnSearch: false
// };
// if (!a) r.resolve = Auth;
// return r;
// };
// $routeProvider.
// when('/plugins/acme', {redirectTo: '/plugins/acme/index'}).
// when('/plugins/acme/index', PluginsRouters);
// }]);
};
}
];

var PluginsRouters = function () {
var t = 'acme/index'; // acme/index.html
var c = [
'$scope', 'Module', function ($scope, Module) {
var module = 'plugins';
var section = Module.getSection();
Module.init(module, '应用管理');
$scope.loaded = false;
console.log($scope, section);
$scope.load = function () {
$scope.loaded = true;
};
}
];
var p = {
templateUrl: template_path + '/plugins/' + t + '.html?_v=' + _v,
controller: c,
reloadOnSearch: false,
resolve: Auth
};
console.log(p);
return p;
};

var PluginsCtrl = [
'$scope', 'Module',
function ($scope, Module) {
var module = 'plugins';
var section = Module.getSection();
Module.init(module, '应用管理');
$scope.loaded = false;
console.log('插件', section);
$scope.load = function () {
$scope.loaded = true;
};
}
];

17 changes: 8 additions & 9 deletions static/js/core.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var releasetime = '2019-08-08 16:40:40 GMT+0800';
var _v = new Date(releasetime.replace(/-/g, '/')).getTime() / 1000;
//if (1) _v += Math.random(); // ie test mode
angular.module('inpanel', ['inpanel.services', 'inpanel.directives', 'inpanel.filters']).
config(['$routeProvider', function ($routeProvider) {
var inpanel = angular.module('inpanel', ['inpanel.services', 'inpanel.directives', 'inpanel.filters']);
inpanel.config(['$routeProvider', function ($routeProvider) {
var _r = function (t, c, a) {
var r = {
templateUrl: template_path + '/partials/' + t + '.html?_v=' + _v,
Expand Down Expand Up @@ -69,17 +69,16 @@ config(['$routeProvider', function ($routeProvider) {
when('/ecs/:section', _r('ecs/setting', ECSSettingCtrl)).
when('/setting', _r('setting', SettingCtrl)).
when('/secure', _r('secure', SecureCtrl)).
when('/application', _r('application/index', ApplicationCtrl)).
when('/application/shadowsocks', _r('application/shadowsocks', ApplicationShadowsocksCtrl)).
when('/application/acme', _r('application/acme', ApplicationCACMEtrl)).
when('/plugins', _r('plugins/index', PluginsHome)).
when('/plugins/:section', _r('plugins/plugins', PluginsCtrl)).
when('/log', _r('log', LogCtrl)).
when('/logout', _r('logout', LogoutCtrl)).
when('/sorry', _r('sorry', SorryCtrl)).
otherwise({
redirectTo: '/sorry'
});
}]).
run(['$rootScope', '$location', 'Request', function ($rootScope, $location, Request) {
}])
inpanel.run(['$rootScope', '$location', 'Request', function ($rootScope, $location, Request) {
$rootScope.sec = function (sec) {
$location.search('s', sec)
};
Expand All @@ -105,8 +104,8 @@ run(['$rootScope', '$location', 'Request', function ($rootScope, $location, Requ
'page_number': 1
};
$rootScope.$proxyroot = location_path;
}]).
value('version', {
}])
inpanel.value('version', {
'version': '1.1.1',
'build': '20',
'releasetime': releasetime,
Expand Down
Loading

0 comments on commit ad16ba0

Please sign in to comment.