diff --git a/plugins/csvn/index.html b/plugins/csvn/index.html index ab8bb9f05..7753a0976 100755 --- a/plugins/csvn/index.html +++ b/plugins/csvn/index.html @@ -8,6 +8,7 @@
服务
自启动
+手动编辑
用户管理
项目管理
使用说明
diff --git a/plugins/csvn/index.py b/plugins/csvn/index.py index d302b565f..bf190feb1 100755 --- a/plugins/csvn/index.py +++ b/plugins/csvn/index.py @@ -150,6 +150,14 @@ def initdUinstall(): return 'ok' +def csvnEdit(): + data = {} + data['svn_access_file'] = getServerDir() + '/data/conf/svn_access_file' + data['commit_tpl'] = getPluginDir() + '/hook/commit.tpl' + data['post_commit_tpl'] = getPluginDir() + '/hook/post-commit.tpl' + return public.getJson(data) + + def userAdd(): args = getArgs() if not 'username' in args: @@ -512,6 +520,45 @@ def projectAclSet(): return 'ok' +def getCsvnUser(): + user = 'admin_sync' + + acl = getAllAclList() + if '' in acl: + tmp = acl[''] + is_has = False + for data in tmp: + if data['user'] == user: + is_has = True + if not is_has: + tmp.append({'user': user, 'acl': 'r'}) + acl[''] = tmp + makeAclFile(acl) + return user + + +def getCsvnPwd(user): + if app_debug: + return user + '123' + pwd_file = 'data/csvn_sync.pl' + + if os.path.exists(pwd_file): + return public.readFile(pwd_file).strip() + + import time + cur_time = time.time() + rand_pwd = public.md5(str(cur_time)) + pwd = user + rand_pwd[:5] + + htpasswd = getServerDir() + "/bin/htpasswd" + svn_auth_file = getServerDir() + "/data/conf/svn_auth_file" + cmd = htpasswd + ' -b ' + svn_auth_file + ' ' + user + ' ' + pwd + data = public.execShell(cmd) + + public.writeFile(pwd_file, pwd) + return pwd + + def projectScriptLoad(): args = getArgs() @@ -533,8 +580,8 @@ def projectScriptLoad(): ct_content = public.readFile(commit_tpl) ct_content = ct_content.replace('{$PROJECT_DIR}', public.getRootDir()) ct_content = ct_content.replace('{$PORT}', getHttpPort()) - ct_content = ct_content.replace('{$CSVN_USER}', 'admin') - ct_content = ct_content.replace('{$CSVN_PWD}', 'admin123Q') + ct_content = ct_content.replace('{$CSVN_USER}', getCsvnUser()) + ct_content = ct_content.replace('{$CSVN_PWD}', getCsvnPwd(getCsvnUser())) public.writeFile(commit_file, ct_content) public.execShell('chmod 777 ' + commit_file) @@ -611,12 +658,8 @@ if __name__ == "__main__": print initdInstall() elif func == 'initd_uninstall': print initdUinstall() - elif func == 'run_info': - print runInfo() - elif func == 'conf': - print getConf() - elif func == 'save_conf': - print saveConf() + elif func == 'csvn_edit': + print csvnEdit() elif func == 'user_list': print userList() elif func == 'user_add': diff --git a/plugins/csvn/js/csvn.js b/plugins/csvn/js/csvn.js index 9cf3357af..73cbf4991 100755 --- a/plugins/csvn/js/csvn.js +++ b/plugins/csvn/js/csvn.js @@ -15,6 +15,25 @@ function csvnPost(method,args,callback){ },'json'); } + + +function csvnEdit(){ + + csvnPost('csvn_edit',{} , function(data){ + console.log(data); + var rdata = $.parseJSON(data.data); + var edit = '通用的手动编辑:
'; + edit +='