diff --git a/README.en.md b/README.en.md index ef22c86490dbaacabb6c35115199ccda31c5d08b..1d34534fbf4d0e30ce6eaf83d2b638af225fa044 100644 --- a/README.en.md +++ b/README.en.md @@ -6,7 +6,7 @@ bbb #### Software Architecture Software architecture description -#### Installation222222222222222 +#### Installation 1. xxxx 2. xxxx @@ -18,7 +18,7 @@ Software architecture description 2. xxxx 3. xxxx -#### Contribution +#### Contribution44444444444 1. Fork the repository 2. Create Feat_xxx branch diff --git a/_actions.html.haml b/_actions.html.haml index 0dcf8dfdcc05bea2df682c06fb66173b0b13d712..96970b4d4770b08f6bbcb15b78dcc0c33fb1b86b 100644 --- a/_actions.html.haml +++ b/_actions.html.haml @@ -6,11 +6,11 @@ - @is_item_readonly ||= is_upload_to_readonly?(@project, @ref, @blob.path) - if @project.online_edit_enabled && allowed_tree_edit? && on_branch && (!@project.block? || current_user.is_admin?) || can?(current_user, :create_lightweight_pr_allow_blank, @project) - if @is_item_readonly - = link_to t('bower.edit'), project_edit_blob_path(@project, @id), class: 'ui button edit-blob disabled-edit-readonly' + = link_to t('bower.edit'), project_blob_path(@project, @id), class: 'ui button edit-blob disabled-edit-readonly' - else - = link_to t('bower.edit'), project_edit_blob_path(@project, @id), class: 'ui button edit-blob', title: "#{t('project.branch.edit_only_login') if current_user.nil?}" + = link_to t('bower.edit'), project_blob_path(@project, @id), class: 'ui button edit-blob', title: "#{t('project.branch.edit_only_login') if current_user.nil?}" - else - = link_to t('bower.edit'), project_edit_blob_path(@project, @id), class: 'ui button disabled has_tooltip edit-blob', title: !on_branch ? t('project.branch.edit_on_branch') : t('project.branch.not_allow_edit') + = link_to t('bower.edit'), projectblob_path(@project, @id), class: 'ui button disabled has_tooltip edit-blob', title: !on_branch ? t('project.branch.edit_on_branch') : t('project.branch.not_allow_edit') - if @project.online_edit_enabled = link_to 'Web IDE', project_ide_path(@project, ref: @ref, blob: @blob.path), class: 'ui button web-ide', target: '_blank' if on_branch - if !@project.block? || current_user.is_admin? diff --git a/diff_excerpt.js b/diff_excerpt.js new file mode 100644 index 0000000000000000000000000000000000000000..62b0f001578ebeaaa74ca7a2c7f347007218ed5a --- /dev/null +++ b/diff_excerpt.js @@ -0,0 +1,184 @@ +/* eslint-disable vars-on-top */ +(function () { + var FETCH_COUNT = 20; + var IS_FETCHING = false; + var IS_PARALLEL_MODE = !!window.isParallelMode; + var fileTotalLineCounts = {}; + + jQuery.prototype.isFirstChild = function () { return $(this).is(':first-child'); } + jQuery.prototype.isLastChild = function () { return $(this).is(':last-child'); } + + function DiffExcerpt(diffFile) { + var $diffFile = $(diffFile); + + refreshExcerptOption($diffFile); + this.bindExcerptEvent($diffFile, { + url: $diffFile.data('url'), + filePath: $diffFile.data('file-path') + }); + } + + function getFileTotalLineCount($DOM) { + var $diffFile = $DOM.hasClass('diff-file') ? $DOM : $DOM.closest('.diff-file'); + if ($diffFile.length) { + var diffFileId = $diffFile.attr('id'); + if (!fileTotalLineCounts[diffFileId]) { + fileTotalLineCounts[diffFileId] = parseInt($diffFile.data('end-line-number'), 10); + } + return fileTotalLineCounts[diffFileId]; + } + return 0; + } + + function getExcerptHolderBothLine($excerptHolder) { + function _getLineNumber($lineHolder, defaultValue) { + return $lineHolder.length ? { + old: parseInt($lineHolder.find('.old_line [data-line-number]').data('line-number'), 10), + new: parseInt($lineHolder.find('.new_line [data-line-number]').data('line-number'), 10) + } : { + old: defaultValue, + new: defaultValue + } + } + + return { + prevLineNumber: _getLineNumber($excerptHolder.prev(), 0), + nextLineNumber: _getLineNumber($excerptHolder.next(), getFileTotalLineCount($excerptHolder)) + } + } + + function updateDiffHeader($excerptHolder) { + if ($excerptHolder.is(':not(:last-child)')) { + var $excerptLineContent = $excerptHolder.find('.line_content'); + + if (/@@ -\d+,\d+ \+\d+,\d+ @@/.test($excerptLineContent.text())) { + var bothLine = getExcerptHolderBothLine($excerptHolder); + var $untilLines = $excerptHolder.nextUntil('.excerpt-holder'); + var oldLinesCount = $untilLines.not(':has(.new)').length; + var newLinesCount = $untilLines.not(':has(.old)').length; + + $excerptLineContent.text( + '@@ -' + bothLine.nextLineNumber.old + ',' + oldLinesCount + ' +' + bothLine.nextLineNumber.new + ',' + newLinesCount + ' @@' + ); + } + } + } + + function initExcerptDOM(excerptArr) { + function _getDOM(diffClass, iconClass, title) { + return ( + '