From ba27d71abea437af2f0612a8960eea651ec2df59 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 28 Aug 2016 04:31:42 -0700 Subject: Web editor: improve edit file --- templates/repo/diff/box.tmpl | 152 +++++++++++++++++++++++++++++++ templates/repo/diff/page.tmpl | 45 +++++++++ templates/repo/diff/section_unified.tmpl | 23 +++++ 3 files changed, 220 insertions(+) create mode 100644 templates/repo/diff/box.tmpl create mode 100644 templates/repo/diff/page.tmpl create mode 100644 templates/repo/diff/section_unified.tmpl (limited to 'templates/repo/diff') diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl new file mode 100644 index 0000000000..4f6c70a328 --- /dev/null +++ b/templates/repo/diff/box.tmpl @@ -0,0 +1,152 @@ +{{if .DiffNotAvailable}} +

{{.i18n.Tr "repo.diff.data_not_available"}}

+{{else}} +
+
+ + {{.i18n.Tr "repo.diff.stats_desc" .Diff.NumFiles .Diff.TotalAddition .Diff.TotalDeletion | Str2html}} + +
+
    + {{range .Diff.Files}} +
  1. +
    + {{if not .IsBin}} + {{.Addition}} + + + + + {{.Deletion}} + {{else}} + {{$.i18n.Tr "repo.diff.bin"}} + {{end}} +
    + +   + {{.Name}} +
  2. + {{end}} +
+
+ + {{range $i, $file := .Diff.Files}} + {{if $file.IsIncomplete}} +
+

+ {{$.i18n.Tr "repo.diff.file_suppressed"}} +
+ {{if not $file.IsRenamed}} + + {{.Addition}} + + + + + - {{.Deletion}} + {{end}} +
+ {{$file.Name}} +

+
+ {{else}} +
+

+
+ {{if $file.IsBin}} + {{$.i18n.Tr "repo.diff.bin"}} + {{else if not $file.IsRenamed}} + + {{.Addition}} + + + + + - {{.Deletion}} + {{end}} +
+ {{if $file.IsRenamed}}{{$file.OldName}} → {{end}}{{$file.Name}} + {{if not $file.IsSubmodule}} +
+ {{if $file.IsDeleted}} + {{$.i18n.Tr "repo.diff.view_file"}} + {{else}} + {{$.i18n.Tr "repo.diff.view_file"}} + {{end}} +
+ {{end}} +

+
+ {{if not $file.IsRenamed}} + {{$isImage := (call $.IsImageFile $file.Name)}} + {{if and $isImage}} +
+ +
+ {{else}} +
+ + + {{if $.IsSplitStyle}} + {{$highlightClass := $file.GetHighlightClass}} + {{range $j, $section := $file.Sections}} + {{range $k, $line := $section.Lines}} + + + + + + + {{end}} + {{end}} + {{else}} + {{template "repo/diff/section_unified" .}} + {{end}} + +
+ {{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}} + +
{{if $line.LeftIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}
+
+ {{if $line.RightIdx}}{{$line.RightIdx}}{{end}} + +
{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}
+
+
+ {{end}} + {{end}} +
+
+ {{end}} +
+ {{end}} + + {{if .Diff.IsIncomplete}} +
+

+ {{$.i18n.Tr "repo.diff.too_many_files"}} +

+
+ {{end}} + + {{if .IsSplitStyle}} + + {{end}} +{{end}} diff --git a/templates/repo/diff/page.tmpl b/templates/repo/diff/page.tmpl new file mode 100644 index 0000000000..0a35a80427 --- /dev/null +++ b/templates/repo/diff/page.tmpl @@ -0,0 +1,45 @@ +{{template "base/head" .}} +
+ {{template "repo/header" .}} +
+ {{if .IsDiffCompare }} + {{template "repo/commits_table" .}} + {{else}} +
+ + {{.i18n.Tr "repo.diff.browse_source"}} + + {{RenderCommitMessage true .Commit.Message $.RepoLink $.Repository.ComposeMetas}} +
+
+ {{if .Author}} + + {{.Commit.Author.Name}} {{if .IsSigned}}<{{.Commit.Author.Email}}>{{end}} + {{else}} + + {{.Commit.Author.Name}} + {{end}} + {{TimeSince .Commit.Author.When $.Lang}} +
+
+ {{if .Parents}} +
+ {{.i18n.Tr "repo.diff.parent"}} +
+
+ {{range .Parents}} + {{ShortSha .}} + {{end}} +
+ {{end}} +
{{.i18n.Tr "repo.diff.commit"}}
+
{{ShortSha .CommitID}}
+
+
+
+ {{end}} + + {{template "repo/diff/box" .}} +
+
+{{template "base/footer" .}} diff --git a/templates/repo/diff/section_unified.tmpl b/templates/repo/diff/section_unified.tmpl new file mode 100644 index 0000000000..ee66b6dc9a --- /dev/null +++ b/templates/repo/diff/section_unified.tmpl @@ -0,0 +1,23 @@ +{{$file := .}} +{{$highlightClass := $file.GetHighlightClass}} +{{range $j, $section := $file.Sections}} + {{range $k, $line := $section.Lines}} + + {{if eq .GetType 4}} + + {{/* {{if gt $j 0}}{{end}} */}} + + {{else}} + + {{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}} + + + {{if $line.RightIdx}}{{$line.RightIdx}}{{end}} + + {{end}} + +
{{$section.GetComputedInlineDiffFor $line}}
+ + + {{end}} +{{end}} \ No newline at end of file -- cgit v1.2.3