summaryrefslogtreecommitdiffstats
path: root/routers/repo
diff options
context:
space:
mode:
authorCirno the Strongest <1447794+CirnoT@users.noreply.github.com>2020-06-15 20:39:39 +0200
committerGitHub <noreply@github.com>2020-06-15 14:39:39 -0400
commitc8780984f8c211342acf6b133bd08b940cb9cba2 (patch)
treecc5cb7b4e09eb493cd6d51e9d755e1e77653baa8 /routers/repo
parenta7f7d1399f2f0c4ee9d13d595607c4fe2fd437e8 (diff)
downloadgitea-c8780984f8c211342acf6b133bd08b940cb9cba2.tar.gz
gitea-c8780984f8c211342acf6b133bd08b940cb9cba2.zip
Rework blame template and styling (#11885)
* Rework blame template and styling * cleanup template and add missing NumLines Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'routers/repo')
-rw-r--r--routers/repo/blame.go30
1 files changed, 8 insertions, 22 deletions
diff --git a/routers/repo/blame.go b/routers/repo/blame.go
index 00ef9a99ea..d353f3b5df 100644
--- a/routers/repo/blame.go
+++ b/routers/repo/blame.go
@@ -118,29 +118,15 @@ func RefBlame(ctx *context.Context) {
ctx.Data["IsBlame"] = true
- if ctx.Repo.CanEnableEditor() {
- // Check LFS Lock
- lfsLock, err := ctx.Repo.Repository.GetTreePathLock(ctx.Repo.TreePath)
- if err != nil {
- ctx.ServerError("GetTreePathLock", err)
- return
- }
- if lfsLock != nil && lfsLock.OwnerID != ctx.User.ID {
- ctx.Data["CanDeleteFile"] = false
- ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.this_file_locked")
- } else {
- ctx.Data["CanDeleteFile"] = true
- ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.delete_this_file")
- }
- } else if !ctx.Repo.IsViewBranch {
- ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.must_be_on_a_branch")
- } else if !ctx.Repo.CanWrite(models.UnitTypeCode) {
- ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.must_have_write_access")
- }
-
ctx.Data["FileSize"] = blob.Size()
ctx.Data["FileName"] = blob.Name()
+ ctx.Data["NumLines"], err = blob.GetBlobLineCount()
+ if err != nil {
+ ctx.NotFound("GetBlobLineCount", err)
+ return
+ }
+
blameReader, err := git.CreateBlameReader(models.RepoPath(userName, repoName), commitID, fileName)
if err != nil {
ctx.NotFound("CreateBlameReader", err)
@@ -245,9 +231,9 @@ func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames m
//Line number
if len(part.Lines)-1 == index && len(blameParts)-1 != pi {
- lineNumbers.WriteString(fmt.Sprintf(`<span id="L%d" class="bottom-line">%d</span>`, i, i))
+ lineNumbers.WriteString(fmt.Sprintf(`<span id="L%d" data-line-number="%d" class="bottom-line"></span>`, i, i))
} else {
- lineNumbers.WriteString(fmt.Sprintf(`<span id="L%d">%d</span>`, i, i))
+ lineNumbers.WriteString(fmt.Sprintf(`<span id="L%d" data-line-number="%d"></span>`, i, i))
}
//Code line