• Y
  • List All
  • Feedback
    • This Project
    • All Projects
Profile Account Log out
  • Favorite
  • Project
  • Recent History
Loading...
  • Log in
  • Sign up
kadrians / Testing_for_YONA star
  • Project homeH
  • CodeC
  • IssueI 1
  • Pull requestP
  • Review R
  • MilestoneM
  • BoardB 2
  • Files
  • Commit
  • Branches
Testing_for_YONAsourceappviewspartial_filediff.scala.html
Download as .zip file
File name
Commit message
Commit date
bin
Yona 1.16.0 Upload
02-04
lib
Yona 1.16.0 Upload
02-04
share/doc/api
Yona 1.16.0 Upload
02-04
source
Source Code Upload
02-04
README.md
Update README.md
02-04
File name
Commit message
Commit date
app
Source Code Upload
02-04
conf
Source Code Upload
02-04
docs
Source Code Upload
02-04
lib
Source Code Upload
02-04
project
Source Code Upload
02-04
public
Source Code Upload
02-04
support-script
Source Code Upload
02-04
test
Source Code Upload
02-04
.gitignore
Source Code Upload
02-04
.mailmap
Source Code Upload
02-04
.travis.yml
Source Code Upload
02-04
AUTHORS
Source Code Upload
02-04
LICENSE
Source Code Upload
02-04
NOTICE
Source Code Upload
02-04
README.md
Source Code Upload
02-04
build.sbt
Source Code Upload
02-04
dev.sh
Source Code Upload
02-04
dist.sh
Source Code Upload
02-04
is-alive-bot.sh
Source Code Upload
02-04
minify-js.sh
Source Code Upload
02-04
restart.sh
Source Code Upload
02-04
File name
Commit message
Commit date
actions
Source Code Upload
02-04
actors
Source Code Upload
02-04
assets/stylesheets
Source Code Upload
02-04
controllers
Source Code Upload
02-04
data
Source Code Upload
02-04
errors
Source Code Upload
02-04
mailbox
Source Code Upload
02-04
models
Source Code Upload
02-04
notification
Source Code Upload
02-04
playRepository
Source Code Upload
02-04
service
Source Code Upload
02-04
utils
Source Code Upload
02-04
validation
Source Code Upload
02-04
views
Source Code Upload
02-04
Global.java
Source Code Upload
02-04
File name
Commit message
Commit date
board
Source Code Upload
02-04
code
Source Code Upload
02-04
common
Source Code Upload
02-04
error
Source Code Upload
02-04
git
Source Code Upload
02-04
help
Source Code Upload
02-04
index
Source Code Upload
02-04
issue
Source Code Upload
02-04
migration
Source Code Upload
02-04
milestone
Source Code Upload
02-04
organization
Source Code Upload
02-04
project
Source Code Upload
02-04
reviewthread
Source Code Upload
02-04
search
Source Code Upload
02-04
site
Source Code Upload
02-04
user
Source Code Upload
02-04
welcome
Source Code Upload
02-04
layout.scala.html
Source Code Upload
02-04
layout_framed.scala.html
Source Code Upload
02-04
organizationLayout.scala.html
Source Code Upload
02-04
partial_comment_form_on_thread.scala.html
Source Code Upload
02-04
partial_comment_thread.scala.html
Source Code Upload
02-04
partial_diff.scala.html
Source Code Upload
02-04
partial_diff_comment_on_line.scala.html
Source Code Upload
02-04
partial_diff_line.scala.html
Source Code Upload
02-04
partial_filediff.scala.html
Source Code Upload
02-04
partial_update_notification.scala.html
Source Code Upload
02-04
projectLayout.scala.html
Source Code Upload
02-04
projectMenu.scala.html
Source Code Upload
02-04
restricted.scala.html
Source Code Upload
02-04
sidebar.scala.html
Source Code Upload
02-04
siteLayout.scala.html
Source Code Upload
02-04
siteLayout_framed.scala.html
Source Code Upload
02-04
Nell 02-04 97c4951 Source Code Upload UNIX
Raw Open in browser Change history
@** * Yobi, Project Hosting SW * * Copyright 2013 NAVER Corp. * http://yobi.io * * @author Yi EungJun * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. **@ @(diff: playRepository.FileDiff, threads: java.util.List[_ <: CodeCommentThread], projectB: Project, projectA: Project) @import playRepository.DiffLineType @import playRepository.DiffLine @import playRepository.FileDiff @import playRepository.Hunk @import org.eclipse.jgit.diff.DiffEntry @import org.eclipse.jgit.diff.RawText @import utils.TemplateHelper.DiffRenderer._ @import utils.TemplateHelper._ @import scala.collection.immutable.Map @import scala.collection.immutable.List @import FileDiff.Error._ @import scala.collection.JavaConversions._ @import org.apache.commons.lang.StringEscapeUtils.escapeHtml @import org.apache.commons.lang3.StringUtils @renderDiffLines(diff: playRepository.FileDiff, threads: Map[String, List[CodeCommentThread]]) = { @if(diff.isFileModeChanged) { <tr><td class="linenum"><div class="line-number" data-line-num="@diff.oldMode"></div><span class="hidden">@diff.oldMode</span></td><td class="linenum"><div class="line-number" data-line-num="@diff.newMode"></div><span class="hidden">@diff.newMode</span></td><td class="isBinary">@Messages("code.fileModeChanged")</td></tr> } @null match { case _ if diff.hasError(OTHERS_SIZE_EXCEEDED) => { <tr><td colspan=3>@Messages("code.skipDiff")</td></tr> } case _ if diff.hasAnyError(A_SIZE_EXCEEDED, B_SIZE_EXCEEDED) => { <tr><td colspan=3>@Messages("code.tooBigFile")</td></tr> } case _ if diff.hasError(DIFF_SIZE_EXCEEDED) => { <tr><td colspan=3>@Messages("code.tooBigDiff")</td></tr> } case _ if diff.hasError => { <tr><td colspan=3>@Messages("code.unknownError")</td></tr> } case _ => { @diff.getHunks match { case hunks if (hunks.size <= 0) => { @diff.isFileModeChanged match { case true => { } case false => { <tr><td colspan=3>@Messages("code.noChanges")</td></tr> } } } case hunks => { @for(hunk <- diff.getHunks) { <tr class="range"><td class="linenum"><div class="line-number" data-line-num="..."><span class="hidden">...</span></div></td><td class="linenum"><div class="line-number" data-line-num="..."><span class="hidden">...</span></div></td><td class="hunk">@@@@ -@(hunk.beginA + 1),@(hunk.endA - hunk.beginA) +@(hunk.beginB + 1),@(hunk.endB - hunk.beginB) @@@@</td></tr> @Html(renderLines(hunk.lines.toList, threads, eolMissingChecker(diff))) } } } } } } @renderRawFile(klass: String, path: String, rawText: RawText, side: CodeRange.Side, prefix: String, comments: Map[String, List[_ <: CodeCommentThread]]) = { @defining(new StringBuilder) { builder => @for(i <- 0 until rawText.size) @{ builder.append("<tr class='") builder.append(klass) builder.append("' data-line='") builder.append(i + 1) builder.append("' data-type='") builder.append(klass) builder.append("' data-side='") builder.append(if(klass.equals("remove")) "A" else "B") builder.append("'><td class='linenum'><i class='yobicon-comments'></i><div class='line-number'></div></td>") builder.append("<td class='linenum'><div class='line-number' data-line-num='") builder.append(i + 1) builder.append("'></div><span class='hidden'>") builder.append(i + 1) builder.append("</span></td><td class='code'><pre class='diff-partial-codeline'>") builder.append(prefix) builder.append(escapeHtml(rawText.getString(i))) if ((i + 1 == rawText.size) && rawText.isMissingNewlineAtEnd) { builder.append(noNewlineAtEof) } builder.append("</pre></td></tr>") builder.append(partial_diff_comment_on_line(threadsOrEmpty(comments, threadKey(path, side, i + 1))).toString.trim) } @Html(builder.toString) } } @renderAddedLines(diff: FileDiff, threads:Map[String, List[_ <: CodeCommentThread]], isBinaryOverwritten: Boolean = false) = { @null match { case _ if diff.hasError(OTHERS_SIZE_EXCEEDED) => { <tr><td colspan=3>@Messages("code.skipDiff")</td></tr> } case _ if diff.hasError(B_SIZE_EXCEEDED) => { <tr><td colspan=3>@Messages("code.tooBigFile")</td></tr> } case _ if diff.hasError => { <tr><td colspan=3>@Messages("code.unknownError")</td></tr> } case null => { <tr class="range"><td class="linenum"><div class="line-number" data-line-num="..."><span class="hidden">...</span></div></td><td class="linenum"><div class="line-number" data-line-num="..."><span class="hidden">...</span></div></td><td class="hunk">@@@@ -0,0 +1,@diff.b.size @@@@</td></tr> @if(isBinaryOverwritten ) { @renderCodeIsBinary("remove", "-") } @renderRawFile("add", diff.pathB, diff.b, CodeRange.Side.B, "+", threads) } } } @renderRemovedLines(diff: FileDiff, threads:Map[String, List[_ <: CodeCommentThread]], isOverwrittenByBinary: Boolean = false) = { @null match { case _ if diff.hasError(OTHERS_SIZE_EXCEEDED) => { <tr><td colspan=3>@Messages("code.skipDiff")</td></tr> } case _ if diff.hasError(A_SIZE_EXCEEDED) => { <tr><td colspan=3>@Messages("code.tooBigFile")</td></tr> } case _ if diff.hasError => { <tr><td colspan=3>@Messages("code.unknownError")</td></tr> } case _ => { <tr class="range"><td class="linenum"><div class="line-number" data-line-num="..."><span class="hidden">...</span></div></td><td class="linenum"><div class="line-number" data-line-num="..."><span class="hidden">...</span></div></td><td class="hunk">@@@@ -1,@diff.a.size +0,0 @@@@</td></tr> @renderRawFile("remove", diff.pathA, diff.a, CodeRange.Side.A, "-", threads) @if(isOverwrittenByBinary) { @renderCodeIsBinary("add", "+") } } } } @getShortenedCommitId(commitId:String) = @{ if(commitId.length < 7){ commitId } else { commitId.substring(0,7) } } @getFileHeadId(diff: FileDiff) = @{ defining(Option(diff.pathB).getOrElse(diff.pathA)) { path => path.replace("/", "-").replace(".", "-") } } @renderFile(diff: FileDiff, fileHeader: String, renderedLines: Html) = { <div id="@getFileHeadId(diff)" class="diff-partial-outer"> <div class="diff-partial-inner"> <div class="diff-partial-meta"> <div class="diff-partial-commit"> <div class="diff-partial-commit-id"> @if(diff.commitA != null && diff.pathA != null){ <a href="@routes.CodeApp.codeBrowserWithBranch(projectA.owner, projectA.name, diff.commitA, diff.pathA)" title="@diff.commitA" target="_blank">@getShortenedCommitId(diff.commitA)</a> } else { &nbsp; } </div> <div class="diff-partial-commit-id"> @if(diff.commitB != null && diff.pathB != null){ <a href="@routes.CodeApp.codeBrowserWithBranch(projectB.owner, projectB.name, diff.commitB, diff.pathB)" title="@diff.commitB" target="_blank">@getShortenedCommitId(diff.commitB)</a> } else { &nbsp; } </div> </div> <div class="diff-partial-file"> <span class="filename" >@fileHeader</span> </div> </div> <div class="diff-partial-code" data-hashcode="@diff.hashCode"> <div class="patch-header"> @if(StringUtils.isNotEmpty(diff.pathA)){<div class="path">--- @diff.pathA</div>} @if(StringUtils.isNotEmpty(diff.pathB)){<div class="path">+++ @diff.pathB</div>} </div> <table class="diff-container show-comments" data-path-a="@diff.pathA" data-path-b="@diff.pathB" data-commit-a="@diff.commitA" data-commit-b="@diff.commitB" data-file-path="@StringUtils.defaultIfEmpty(diff.pathB, diff.pathA)"> <tbody> @renderedLines </tbody> </table> </div> </div> </div> } @getPathPostfixedBinary(path:String, isBinary:Boolean) = @{ path + (if (isBinary) { " (Binary)" } else { "" } ) } @getFileHeaderMessage(headerType:DiffEntry.ChangeType, diff:FileDiff) = @{ headerType match { case DiffEntry.ChangeType.MODIFY => { getPathPostfixedBinary(diff.pathB, diff.isBinaryB) } case DiffEntry.ChangeType.ADD => { Messages("code.addedPath", getPathPostfixedBinary(diff.pathB, diff.isBinaryB)) } case DiffEntry.ChangeType.DELETE => { Messages("code.deletedPath", getPathPostfixedBinary(diff.pathA, diff.isBinaryA)) } case DiffEntry.ChangeType.RENAME => { Messages("code.renamedPath", getPathPostfixedBinary(diff.pathA, diff.isBinaryA), getPathPostfixedBinary(diff.pathB, diff.isBinaryB)) } case DiffEntry.ChangeType.COPY => { Messages("code.copiedPath", getPathPostfixedBinary(diff.pathA, diff.isBinaryA), getPathPostfixedBinary(diff.pathB, diff.isBinaryB)) } case _ => { "" } } } @renderCodeIsBinary(klass:String = "", prefix:String = "") = { <tr class="@klass"><td class='linenum'><div class='line-number'></div></td><td class='linenum'><div class='line-number'></div></td><td class="isBinary">@prefix@Messages("code.isBinary")</td></tr> } @getThreads(threads: java.util.List[_ <: CodeCommentThread]) = @{ if(threads != null){ threads.toList.filter(v => v.codeRange != null).groupBy((thread: CodeCommentThread) => threadKey(thread.codeRange.path, thread.codeRange.endSide, thread.codeRange.endLine)) } else { null } } @defining(getThreads(threads)) { threads => @diff.changeType match { case DiffEntry.ChangeType.MODIFY => { @(diff.isBinaryA, diff.isBinaryB) match { case (true, true) => { @renderFile(diff, getFileHeaderMessage(DiffEntry.ChangeType.MODIFY, diff), renderCodeIsBinary()) } case (true, false) => { @renderFile(diff, getFileHeaderMessage(DiffEntry.ChangeType.MODIFY, diff), renderAddedLines(diff, threads, true)) } case (false, true) => { @renderFile(diff, getFileHeaderMessage(DiffEntry.ChangeType.MODIFY, diff), renderRemovedLines(diff, threads, true)) } case (false, false) => { @renderFile(diff, diff.pathB, renderDiffLines(diff, threads)) } } } case DiffEntry.ChangeType.ADD => { @if(diff.isBinaryB){ @renderFile(diff, getFileHeaderMessage(DiffEntry.ChangeType.ADD, diff), renderCodeIsBinary()) } else { @renderFile(diff, getFileHeaderMessage(DiffEntry.ChangeType.ADD, diff), renderAddedLines(diff, threads)) } } case DiffEntry.ChangeType.DELETE => { @if(diff.isBinaryA){ @renderFile(diff, getFileHeaderMessage(DiffEntry.ChangeType.DELETE, diff), renderCodeIsBinary()) } else { @renderFile(diff, Messages("code.deletedPath", diff.pathA), renderRemovedLines(diff, threads)) } } case DiffEntry.ChangeType.RENAME => { @(diff.isBinaryA, diff.isBinaryB) match { case (true, true) => { @renderFile(diff, getFileHeaderMessage(DiffEntry.ChangeType.RENAME, diff), renderCodeIsBinary()) } case (true, false) => { @renderFile(diff, getFileHeaderMessage(DiffEntry.ChangeType.RENAME, diff), renderAddedLines(diff, threads, true)) } case (false, true) => { @renderFile(diff, getFileHeaderMessage(DiffEntry.ChangeType.RENAME, diff), renderRemovedLines(diff, threads, true)) } case (false, false) => { @renderFile(diff, Messages("code.renamedPath", diff.pathA, diff.pathB), renderDiffLines(diff, threads)) } } } case DiffEntry.ChangeType.COPY => { @if(diff.isBinaryB){ @renderFile(diff, getFileHeaderMessage(DiffEntry.ChangeType.COPY, diff), renderCodeIsBinary()) } else { @renderFile(diff, Messages("code.copiedPath", diff.pathA, diff.pathB), renderAddedLines(diff, threads)) } } } }

          
        
    
    
Copyright Yona authors & © NAVER Corp. & NAVER LABS Supported by NAVER CLOUD PLATFORM

or
login with Google Sign in with Google
Reset password | Sign up