gogs 基本改造结束

pull/494/head
midoks 2 years ago
parent e5c53323a5
commit 43071db317
  1. 43
      plugins/gogs/index.py
  2. 22
      plugins/gogs/js/gogs.js

@ -788,6 +788,10 @@ def projectScriptSelf():
if os.path.isfile(filePath):
tmp['path'] = filePath
tmp['name'] = os.path.basename(filePath)
tmp['is_hidden'] = False
if tmp['name'].endswith('.txt'):
tmp['is_hidden'] = True
dlist.append(tmp)
dlist_sum = len(dlist)
@ -968,6 +972,43 @@ def projectScriptSelf_Enable():
return mw.returnJson(True, '关闭成功!')
def projectScriptSelf_Status():
args = getArgs()
data = checkArgs(args, ['user', 'name', 'file', 'status'])
if not data[0]:
return data[1]
user = args['user']
name = args['name'] + '.git'
file = args['file']
status = args['status']
custom_hooks = getRootPath() + '/' + user + '/' + \
name + '/custom_hooks'
self_path = custom_hooks + '/self'
if not os.path.exists(self_path):
os.mkdir(self_path)
# 日志也删除
log_file = custom_hooks + '/self_logs/' + file + '.log'
if os.path.exists(log_file):
os.remove(log_file)
if status == '1':
file_abs = self_path + '/' + file
file_text_abs = self_path + '/' + file + '.txt'
os.rename(file_abs, file_text_abs)
return mw.returnJson(True, '开始禁用成功!')
else:
file_abs = self_path + '/' + file.strip('.txt')
file_text_abs = self_path + '/' + file
os.rename(file_text_abs, file_abs)
return mw.returnJson(True, '开始使用成功!')
return mw.returnJson(True, '禁用成功!')
def getRsaPublic():
path = getHomeDir()
path += '/.ssh/id_rsa.pub'
@ -1057,6 +1098,8 @@ if __name__ == "__main__":
print(projectScriptSelf_Rename())
elif func == 'project_script_self_enable':
print(projectScriptSelf_Enable())
elif func == 'project_script_self_status':
print(projectScriptSelf_Status())
elif func == 'get_rsa_public':
print(getRsaPublic())
elif func == 'get_total_statistics':

@ -527,9 +527,14 @@ function projectScriptSelfRender(user, name){
body += '<tr><td colspan="3" style="text-align:center;">无脚本数据</td></tr>';
} else{
for (var i = 0; i < data.length; i++) {
var b_status = '<a class="btlink status" data-index="'+i+'" target="_blank">已使用</a>';
if (data[i]["is_hidden"]){
b_status = '<a class="btlink status" data-index="'+i+'" target="_blank">已隐藏</a>';
}
body += '<tr>'+
'<td>' + data[i]["name"]+'</td>'+
'<td>' + '<a class="btlink" target="_blank">已使用</a>'+'</td>'+
'<td>' + b_status + '</td>'+
'<td>' +
'<a class="btlink del" data-index="'+i+'" target="_blank">删除</a>' + ' | ' +
'<a class="btlink edit" data-index="'+i+'" target="_blank">编辑</a>' + ' | ' +
@ -544,6 +549,21 @@ function projectScriptSelfRender(user, name){
$('#gogs_self_table tbody').html(body);
$('#gogs_self_table .page').html(rdata['data']['list']);
$('#gogs_self_table .status').click(function(){
var i = $(this).data('index');
var file = data[i]["name"];
var status = '1';
if (data[i]["is_hidden"]){
status = '0';
}
gogsPost('project_script_self_status', {'user':user,'name':name,'file':file, status:status}, function(data){
var data = $.parseJSON(data.data);
showMsg(data.msg ,function(){
projectScriptSelfRender(user, name);
},{icon:data.code?2:1,time:2000,shade: [0.3, '#000']},2000);
});
});
$('#gogs_self_table .del').click(function(){
var i = $(this).data('index');
var file = data[i]["name"];

Loading…
Cancel
Save