aboutsummaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorAndrzej Ressel <jereksel@gmail.com>2019-04-20 04:47:00 +0200
committertechknowlogick <matti@mdranta.net>2019-04-19 22:47:00 -0400
commit469d9b7d9ac3714a146d8e745618641dbe03fafa (patch)
tree7c29b6eddde19222196702d1c47919e4b4a9394d /templates
parentb9d1fb6de32613ada3869d2a9692cb078ed48534 (diff)
downloadgitea-469d9b7d9ac3714a146d8e745618641dbe03fafa.tar.gz
gitea-469d9b7d9ac3714a146d8e745618641dbe03fafa.zip
Add option to blame files (#5721)
Diffstat (limited to 'templates')
-rw-r--r--templates/repo/blame.tmpl51
-rw-r--r--templates/repo/home.tmpl4
-rw-r--r--templates/repo/view_file.tmpl3
3 files changed, 57 insertions, 1 deletions
diff --git a/templates/repo/blame.tmpl b/templates/repo/blame.tmpl
new file mode 100644
index 0000000000..012f630203
--- /dev/null
+++ b/templates/repo/blame.tmpl
@@ -0,0 +1,51 @@
+<div class="tab-size-8 non-diff-file-content">
+
+ <h4 class="ui top attached header" id="repo-read-file">
+ <div class="ui stackable grid">
+ <div class="ten wide column">
+ <i class="file text outline icon ui left"></i>
+ <strong>{{.FileName}}</strong> <span class="text grey normal">{{FileSize .FileSize}}{{if .IsLFSFile}} ({{.i18n.Tr "repo.stored_lfs"}}){{end}}</span>
+ </div>
+ <div class="six wide right aligned column">
+ <div class="ui right file-actions">
+ <div class="ui buttons">
+ {{if not .IsViewCommit}}
+ <a class="ui button" href="{{.RepoLink}}/src/commit/{{.CommitID}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.file_permalink"}}</a>
+ {{end}}
+ <a class="ui button" href="{{.RepoLink}}/src/{{EscapePound .BranchNameSubURL}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.normal_view"}}</a>
+ <a class="ui button" href="{{.RepoLink}}/commits/{{EscapePound .BranchNameSubURL}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.file_history"}}</a>
+ <a class="ui button" href="{{EscapePound $.RawFileLink}}">{{.i18n.Tr "repo.file_raw"}}</a>
+ </div>
+ {{if .Repository.CanEnableEditor}}
+ {{if .CanEditFile}}
+ <a href="{{.RepoLink}}/_edit/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}"><i class="octicon octicon-pencil btn-octicon poping up" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i></a>
+ {{else}}
+ <i class="octicon octicon-pencil btn-octicon poping up disabled" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i>
+ {{end}}
+ {{if .CanDeleteFile}}
+ <a href="{{.RepoLink}}/_delete/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}"><i class="octicon octicon-trashcan btn-octicon btn-octicon-danger poping up" data-content="{{.DeleteFileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i></a>
+ {{else}}
+ <i class="octicon octicon-trashcan btn-octicon poping up disabled" data-content="{{.DeleteFileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i>
+ {{end}}
+ {{end}}
+ </div>
+ </div>
+ </div>
+ </h4>
+
+ <div class="ui attached table unstackable segment">
+ <div class="file-view code-view has-emoji">
+ <table>
+ <tbody>
+ <tr>
+ <td class="lines-commit">{{.BlameCommitInfo}}</td>
+ <td class="lines-num">{{.BlameLineNums}}</td>
+ <td class="lines-code"><pre><code class="{{.HighlightClass}}"><ol class="linenums">{{.BlameContent}}</ol></code></pre></td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
+
+
+</div> \ No newline at end of file
diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl
index f94f0f2104..b23e851139 100644
--- a/templates/repo/home.tmpl
+++ b/templates/repo/home.tmpl
@@ -86,7 +86,7 @@
</a>
{{end}}
{{end}}
- {{if and (ne $n 0) (not .IsViewFile)}}
+ {{if and (ne $n 0) (not .IsViewFile) (not .IsBlame) }}
<a href="{{.RepoLink}}/commits/{{EscapePound .BranchNameSubURL}}/{{EscapePound .TreePath}}" class="ui button">
{{.i18n.Tr "repo.file_history"}}
</a>
@@ -132,6 +132,8 @@
</div>
{{if .IsViewFile}}
{{template "repo/view_file" .}}
+ {{else if .IsBlame}}
+ {{template "repo/blame" .}}
{{else}}
{{template "repo/view_list" .}}
{{end}}
diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl
index 07d1075b13..a6d47b15d6 100644
--- a/templates/repo/view_file.tmpl
+++ b/templates/repo/view_file.tmpl
@@ -21,6 +21,9 @@
{{if not .IsViewCommit}}
<a class="ui button" href="{{.RepoLink}}/src/commit/{{.CommitID}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.file_permalink"}}</a>
{{end}}
+ {{if .IsTextFile}}
+ <a class="ui button" href="{{.RepoLink}}/blame/{{EscapePound .BranchNameSubURL}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.blame"}}</a>
+ {{end}}
<a class="ui button" href="{{.RepoLink}}/commits/{{EscapePound .BranchNameSubURL}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.file_history"}}</a>
<a class="ui button" href="{{EscapePound $.RawFileLink}}">{{.i18n.Tr "repo.file_raw"}}</a>
</div>