diff --git a/module/repo/control.php b/module/repo/control.php index 875182431b..44a49ed495 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -263,7 +263,7 @@ class repo extends control { $file = $entry; $repo = $this->repo->getRepoByID($repoID); - $entry = $this->repo->decodePath($entry); + $entry = urldecode($this->repo->decodePath($entry)); $revision = str_replace('*', '-', $revision); $this->scm->setEngine($repo); @@ -303,9 +303,10 @@ class repo extends control $this->view->entry = $entry; $this->view->path = $entry; $this->view->suffix = $suffix; - $this->view->content = $content; + $this->view->content = $content ? $content : ''; $this->view->pathInfo = $pathInfo; - $this->view->blames = $blames; + $this->view->blames = $blames ? $blames : array(); + $this->view->showEditor = (strpos($this->config->repo->images, "|$suffix|") === false and $suffix != 'binary') ? true : false; $this->display(); } @@ -1786,8 +1787,9 @@ class repo extends control */ public function ajaxGetFileTree($repoID, $branch = '') { - $repo = $this->repo->getRepoByID($repoID); - $files = $this->repo->getFileTree($repo, $branch); + $branch = base64_decode($branch); + $repo = $this->repo->getRepoByID($repoID); + $files = $this->repo->getFileTree($repo, $branch); return print($files); } diff --git a/module/repo/css/ajaxgeteditorcontent.css b/module/repo/css/ajaxgeteditorcontent.css index 2b38f47225..5c5656e3d1 100644 --- a/module/repo/css/ajaxgeteditorcontent.css +++ b/module/repo/css/ajaxgeteditorcontent.css @@ -16,3 +16,7 @@ #related .content, #related .btn {background-color: #F4F5F7; border: none;} #related .nav-tabs > li.active > a:before {background: none; height: 0;} #related .table-empty-tip {padding: 35px 10px;} +.repoCode .binary a .icon-download {font-size: 50px;} +.repoCode .binary, .repoCode .image {text-align: center;} +.repoCode .binary a {margin: 100px 0px; display: block;} +.repoCode .image {margin-top: 10px;} diff --git a/module/repo/js/common.js b/module/repo/js/common.js index e1ca5fdf60..645f1ea834 100644 --- a/module/repo/js/common.js +++ b/module/repo/js/common.js @@ -74,6 +74,8 @@ var distance = 0; */ function arrowTabs(domID, shift, hideRightBtn) { + if($('#' + domID).html() == '') return; + $('.btn-right, .btn-left').show(); if(hideRightBtn) $('.btn-right').hide(); diff --git a/module/repo/js/monaco.js b/module/repo/js/monaco.js index a0f4e363b4..8857a112e5 100644 --- a/module/repo/js/monaco.js +++ b/module/repo/js/monaco.js @@ -13,7 +13,7 @@ $(function() */ function createTab(filename, filepath) { - $('[data-path="' + filepath + '"]').closest('li').addClass('selected'); + $('[data-path="' + decodeURIComponent(filepath) + '"]').closest('li').addClass('selected'); var tabID = Base64.encode(filepath).replaceAll('=', '-'); return { title: filename, @@ -40,7 +40,7 @@ $(function() $(document).on('click', '.repoFileName', function() { - var path = $(this).data('path'); + var path = encodeURIComponent($(this).data('path')); var name = $(this).text(); var $tabs = $('#fileTabs').data('zui.tabs'); if(openedFiles.indexOf(path) == -1) openedFiles.push(path); @@ -52,7 +52,7 @@ $(function() /* Remove file path for opened files. */ $('#fileTabs').on('onClose', function(event, tab) { - var filepath = Base64.decode(tab.id.replaceAll('-', '=')); + var filepath = decodeURIComponent(Base64.decode(tab.id.replaceAll('-', '='))); var index = openedFiles.indexOf(filepath); if(index > -1) { @@ -66,7 +66,7 @@ $(function() /* Append file path into the title. */ $('#fileTabs').on('onLoad', function(event, tab) { var filepath = Base64.decode(tab.id.replaceAll('-', '=')); - $('#tab-nav-item-' + tab.id).attr('title', filepath); + $('#tab-nav-item-' + tab.id).attr('title', decodeURIComponent(filepath)); }); var link = createLink('repo', 'ajaxGetBranchesAndTags', 'repoID=' + repoID + '&oldRevision=' + branchID); @@ -87,7 +87,7 @@ $(function() */ function refreshFiles(branchOrTag) { - var link = createLink('repo', 'ajaxGetFileTree', 'repoID=' + repoID + '&branch=' + branchOrTag); + var link = createLink('repo', 'ajaxGetFileTree', 'repoID=' + repoID + '&branch=' + Base64.encode(branchOrTag)); $.get(link, function(data) { $('#modules').remove(); diff --git a/module/repo/lang/zh-cn.php b/module/repo/lang/zh-cn.php index b43d338247..4d69c3030b 100644 --- a/module/repo/lang/zh-cn.php +++ b/module/repo/lang/zh-cn.php @@ -26,7 +26,7 @@ $lang->repo->branch = '分支'; $lang->repo->tag = '标签'; $lang->repo->addWebHook = '添加Webhook'; $lang->repo->apiGetRepoByUrl = '接口:通过URL获取代码库'; -$lang->repo->blamTmpl = '%time 由%name提交%version %comment'; +$lang->repo->blamTmpl = '%time 由 %name 提交 %version %comment'; $lang->repo->notRelated = '暂时没有关联禅道对象'; $lang->repo->browseAction = '浏览代码库'; diff --git a/module/repo/view/ajaxgeteditorcontent.html.php b/module/repo/view/ajaxgeteditorcontent.html.php index b87d3a53e6..2843e0687d 100644 --- a/module/repo/view/ajaxgeteditorcontent.html.php +++ b/module/repo/view/ajaxgeteditorcontent.html.php @@ -13,11 +13,15 @@ include '../../common/view/header.lite.html.php'; js::set('jsRoot', $jsRoot); js::set('clientLang', $app->clientLang); js::set('fileExt', $this->config->repo->fileExt); -js::set('codeContent', trim($content)); js::set('file', $pathInfo); -js::set('blames', $blames); js::set('blameTmpl', $lang->repo->blamTmpl); js::set('repoID', $repoID); +js::set('showEditor', $showEditor); +if($showEditor) +{ + js::set('codeContent', trim($content)); + js::set('blames', $blames); +} js::import($jsRoot . '/zui/tabs/tabs.min.js'); js::import($jsRoot . 'monaco-editor/min/vs/loader.js'); $canLinkStory = common::hasPriv('repo', 'linkStory'); @@ -25,8 +29,14 @@ $canLinkBug = common::hasPriv('repo', 'linkBug'); $canLinkTask = common::hasPriv('repo', 'linkTask'); $canUnlinkObject = common::hasPriv('repo', 'unlinkObject'); ?> -