diff --git a/plugins/gogs/index.html b/plugins/gogs/index.html
index e8127f1b6..f4dda400d 100755
--- a/plugins/gogs/index.html
+++ b/plugins/gogs/index.html
@@ -4,7 +4,8 @@
服务
自启动
自启动配置
- 运行配置
+ 配置文件
+ 配置修改
运行日志
@@ -13,5 +14,6 @@
\ No newline at end of file
diff --git a/plugins/gogs/index.py b/plugins/gogs/index.py
index 444b42b27..a094ed552 100755
--- a/plugins/gogs/index.py
+++ b/plugins/gogs/index.py
@@ -4,6 +4,7 @@
import time
import os
import sys
+import re
sys.path.append("/usr/local/lib/python2.7/site-packages")
import psutil
@@ -200,6 +201,40 @@ def runLog():
log_path = getServerDir() + '/log/gogs.log'
return log_path
+
+def getGogsConf():
+ gets = [
+ {'name': 'HOST', 'type': -1, 'ps': '主机地址'},
+ {'name': 'NAME', 'type': -1, 'ps': '数据库名称'},
+ {'name': 'USER', 'type': -1, 'ps': '数据库用户名'},
+ {'name': 'REQUIRE_SIGNIN_VIEW', 'type': 2, 'ps': '强制登录浏览'},
+ ]
+ conf = public.readFile(getConf())
+ result = []
+ for g in gets:
+ rep = g['name'] + '\s*=\s*(.*)'
+ tmp = re.search(rep, conf)
+ if not tmp:
+ continue
+ g['value'] = tmp.groups()[0]
+ result.append(g)
+ return public.getJson(result)
+
+
+def submitGogsConf():
+ gets = ['REQUIRE_SIGNIN_VIEW']
+ args = getArgs()
+ # print args
+ filename = getConf()
+ conf = public.readFile(filename)
+ for g in gets:
+ if g in args:
+ rep = g + '\s*=\s*(.*)'
+ val = g + ' = ' + args[g] + '\n'
+ conf = re.sub(rep, val, conf)
+ public.writeFile(filename, conf)
+ return public.returnJson(True, '设置成功')
+
if __name__ == "__main__":
func = sys.argv[1]
if func == 'status':
@@ -224,5 +259,9 @@ if __name__ == "__main__":
print getConf()
elif func == 'init_conf':
print getInitdConf()
+ elif func == 'get_gogs_conf':
+ print getGogsConf()
+ elif func == 'submit_gogs_conf':
+ print submitGogsConf()
else:
print 'fail'
diff --git a/plugins/gogs/info.json b/plugins/gogs/info.json
index 96f8efc20..a1f6c3a5d 100755
--- a/plugins/gogs/info.json
+++ b/plugins/gogs/info.json
@@ -2,7 +2,7 @@
"ps": "Gogs是一款极易搭建的自助Git服务",
"name": "gogs",
"title": "Gogs",
- "versions": ["0.11.79","0.11.66"],
+ "versions": ["0.11.86","0.11.79"],
"tip": "soft",
"checks": "server/gogs",
"author": "midoks",
diff --git a/plugins/gogs/js/gogs.js b/plugins/gogs/js/gogs.js
new file mode 100755
index 000000000..65d52bd21
--- /dev/null
+++ b/plugins/gogs/js/gogs.js
@@ -0,0 +1,98 @@
+
+function str2Obj(str){
+ var data = {};
+ kv = str.split('&');
+ for(i in kv){
+ v = kv[i].split('=');
+ data[v[0]] = v[1];
+ }
+ return data;
+}
+
+function gogsPost(method,args,callback, title){
+
+ var _args = null;
+ if (typeof(args) == 'string'){
+ _args = JSON.stringify(str2Obj(args));
+ } else {
+ _args = JSON.stringify(args);
+ }
+
+ var _title = '正在获取...';
+ if (typeof(title) != 'undefined'){
+ _title = title;
+ }
+
+ var loadT = layer.msg(_title, { icon: 16, time: 0, shade: 0.3 });
+ $.post('/plugins/run', {name:'gogs', func:method, args:_args}, function(data) {
+ layer.close(loadT);
+ if (!data.status){
+ layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
+ return;
+ }
+
+ if(typeof(callback) == 'function'){
+ callback(data);
+ }
+ },'json');
+}
+
+function gogsSetConfig(){
+ gogsPost('get_gogs_conf', '', function(data){
+ console.log(data);
+ var rdata = $.parseJSON(data.data);
+ console.log(rdata);
+ var mlist = '';
+ for (var i = 0; i < rdata.length; i++) {
+ var w = '140';
+ if (rdata[i].name == 'error_reporting') w = '250';
+ var ibody = '';
+ switch (rdata[i].type) {
+ case 0:
+ var selected_1 = (rdata[i].value == 1) ? 'selected' : '';
+ var selected_0 = (rdata[i].value == 0) ? 'selected' : '';
+ ibody = '';
+ break;
+ case 1:
+ var selected_1 = (rdata[i].value == 'On') ? 'selected' : '';
+ var selected_0 = (rdata[i].value == 'Off') ? 'selected' : '';
+ ibody = ''
+ break;
+ case 2:
+ var selected_1 = (rdata[i].value == 'true') ? 'selected' : '';
+ var selected_0 = (rdata[i].value == 'false') ? 'selected' : '';
+ ibody = ''
+ break;
+ }
+ mlist += '' + rdata[i].name + '' + ibody + ', ' + rdata[i].ps + '
'
+ }
+ var html = '\
+ ' + mlist + '\
+
\
+ \
+
\
+
';
+ $(".soft-man-con").html(html);
+ });
+}
+
+
+//提交PHP配置
+function submitGogsConf() {
+ var data = {
+ REQUIRE_SIGNIN_VIEW: $("select[name='REQUIRE_SIGNIN_VIEW']").val() || 'false',
+ };
+
+ gogsPost('submit_gogs_conf', data, function(ret_data){
+ var rdata = $.parseJSON(ret_data.data);
+ console.log(rdata);
+ layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
+ });
+}
\ No newline at end of file