aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gopmfile1
-rw-r--r--README.md2
-rw-r--r--gogs.go2
-rw-r--r--models/git_diff.go118
-rw-r--r--models/git_diff_test.go70
-rw-r--r--modules/base/markdown.go94
-rwxr-xr-xpublic/css/gogs.css11
-rw-r--r--public/less/_repository.less16
-rw-r--r--routers/api/v1/api.go4
-rw-r--r--routers/repo/commit.go6
-rw-r--r--routers/user/profile.go12
-rw-r--r--templates/.VERSION2
-rw-r--r--templates/repo/diff_box.tmpl16
-rw-r--r--templates/user/profile.tmpl2
14 files changed, 280 insertions, 76 deletions
diff --git a/.gopmfile b/.gopmfile
index ddd76170..ed7e5957 100644
--- a/.gopmfile
+++ b/.gopmfile
@@ -31,6 +31,7 @@ github.com/microcosm-cc/bluemonday = commit:4ac6f27
github.com/msteinert/pam = commit:02ccfbf
github.com/nfnt/resize = commit:dc93e1b98c
github.com/russross/blackfriday = commit:d18b67a
+github.com/sergi/go-diff =
github.com/shurcooL/sanitized_anchor_name = commit:10ef21a
github.com/Unknwon/cae = commit:7f5e046
github.com/Unknwon/com = commit:28b053d
diff --git a/README.md b/README.md
index 29496932..ba3ad35a 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
-##### Current version: 0.8.17
+##### Current version: 0.8.18
| Web | UI | Preview |
|:-------------:|:-------:|:-------:|
diff --git a/gogs.go b/gogs.go
index d2413016..006a272e 100644
--- a/gogs.go
+++ b/gogs.go
@@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
-const APP_VER = "0.8.17.0107"
+const APP_VER = "0.8.18.0109"
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
diff --git a/models/git_diff.go b/models/git_diff.go
index 22075ef7..1913ec46 100644
--- a/models/git_diff.go
+++ b/models/git_diff.go
@@ -8,6 +8,8 @@ import (
"bufio"
"bytes"
"fmt"
+ "html"
+ "html/template"
"io"
"io/ioutil"
"os"
@@ -15,6 +17,7 @@ import (
"strings"
"github.com/Unknwon/com"
+ "github.com/sergi/go-diff/diffmatchpatch"
"golang.org/x/net/html/charset"
"golang.org/x/text/transform"
@@ -25,30 +28,34 @@ import (
"github.com/gogits/gogs/modules/process"
)
-// Diff line types.
+type DiffLineType uint8
+
const (
- DIFF_LINE_PLAIN = iota + 1
+ DIFF_LINE_PLAIN DiffLineType = iota + 1
DIFF_LINE_ADD
DIFF_LINE_DEL
DIFF_LINE_SECTION
)
+type DiffFileType uint8
+
const (
- DIFF_FILE_ADD = iota + 1
+ DIFF_FILE_ADD DiffFileType = iota + 1
DIFF_FILE_CHANGE
DIFF_FILE_DEL
DIFF_FILE_RENAME
)
type DiffLine struct {
- LeftIdx int
- RightIdx int
- Type int
- Content string
+ LeftIdx int
+ RightIdx int
+ Type DiffLineType
+ Content string
+ ParsedContent template.HTML
}
-func (d DiffLine) GetType() int {
- return d.Type
+func (d *DiffLine) GetType() int {
+ return int(d.Type)
}
type DiffSection struct {
@@ -56,12 +63,99 @@ type DiffSection struct {
Lines []*DiffLine
}
+var (
+ addedCodePrefix = []byte("<span class=\"added-code\">")
+ removedCodePrefix = []byte("<span class=\"removed-code\">")
+ codeTagSuffix = []byte("</span>")
+)
+
+func diffToHTML(diffs []diffmatchpatch.Diff, lineType DiffLineType) template.HTML {
+ var buf bytes.Buffer
+ for i := range diffs {
+ if diffs[i].Type == diffmatchpatch.DiffInsert && lineType == DIFF_LINE_ADD {
+ buf.Write(addedCodePrefix)
+ buf.WriteString(html.EscapeString(diffs[i].Text))
+ buf.Write(codeTagSuffix)
+ } else if diffs[i].Type == diffmatchpatch.DiffDelete && lineType == DIFF_LINE_DEL {
+ buf.Write(removedCodePrefix)
+ buf.WriteString(html.EscapeString(diffs[i].Text))
+ buf.Write(codeTagSuffix)
+ } else if diffs[i].Type == diffmatchpatch.DiffEqual {
+ buf.WriteString(html.EscapeString(diffs[i].Text))
+ }
+ }
+
+ return template.HTML(buf.Bytes())
+}
+
+// get an specific line by type (add or del) and file line number
+func (diffSection *DiffSection) GetLine(lineType DiffLineType, idx int) *DiffLine {
+ difference := 0
+
+ for _, diffLine := range diffSection.Lines {
+ if diffLine.Type == DIFF_LINE_PLAIN {
+ // get the difference of line numbers between ADD and DEL versions
+ difference = diffLine.RightIdx - diffLine.LeftIdx
+ continue
+ }
+
+ if lineType == DIFF_LINE_DEL {
+ if diffLine.RightIdx == 0 && diffLine.LeftIdx == idx-difference {
+ return diffLine
+ }
+ } else if lineType == DIFF_LINE_ADD {
+ if diffLine.LeftIdx == 0 && diffLine.RightIdx == idx+difference {
+ return diffLine
+ }
+ }
+ }
+ return nil
+}
+
+// computes diff of each diff line and set the HTML on diffLine.ParsedContent
+func (diffSection *DiffSection) ComputeLinesDiff() {
+ for _, diffLine := range diffSection.Lines {
+ var compareDiffLine *DiffLine
+ var diff1, diff2 string
+
+ diffLine.ParsedContent = template.HTML(html.EscapeString(diffLine.Content[1:]))
+
+ // just compute diff for adds and removes
+ if diffLine.Type != DIFF_LINE_ADD && diffLine.Type != DIFF_LINE_DEL {
+ continue
+ }
+
+ // try to find equivalent diff line. ignore, otherwise
+ if diffLine.Type == DIFF_LINE_ADD {
+ compareDiffLine = diffSection.GetLine(DIFF_LINE_DEL, diffLine.RightIdx)
+ if compareDiffLine == nil {
+ continue
+ }
+ diff1 = compareDiffLine.Content
+ diff2 = diffLine.Content
+ } else {
+ compareDiffLine = diffSection.GetLine(DIFF_LINE_ADD, diffLine.LeftIdx)
+ if compareDiffLine == nil {
+ continue
+ }
+ diff1 = diffLine.Content
+ diff2 = compareDiffLine.Content
+ }
+
+ dmp := diffmatchpatch.New()
+ diffRecord := dmp.DiffMain(diff1[1:], diff2[1:], true)
+ diffRecord = dmp.DiffCleanupSemantic(diffRecord)
+
+ diffLine.ParsedContent = diffToHTML(diffRecord, diffLine.Type)
+ }
+}
+
type DiffFile struct {
Name string
OldName string
Index int
Addition, Deletion int
- Type int
+ Type DiffFileType
IsCreated bool
IsDeleted bool
IsBin bool
@@ -69,6 +163,10 @@ type DiffFile struct {
Sections []*DiffSection
}
+func (diffFile *DiffFile) GetType() int {
+ return int(diffFile.Type)
+}
+
type Diff struct {
TotalAddition, TotalDeletion int
Files []*DiffFile
diff --git a/models/git_diff_test.go b/models/git_diff_test.go
new file mode 100644
index 00000000..4084814e
--- /dev/null
+++ b/models/git_diff_test.go
@@ -0,0 +1,70 @@
+package models
+
+import (
+ dmp "github.com/sergi/go-diff/diffmatchpatch"
+ "html/template"
+ "testing"
+)
+
+func assertEqual(t *testing.T, s1 string, s2 template.HTML) {
+ if s1 != string(s2) {
+ t.Errorf("%s should be equal %s", s2, s1)
+ }
+}
+
+func assertLineEqual(t *testing.T, d1 *DiffLine, d2 *DiffLine) {
+ if d1 != d2 {
+ t.Errorf("%v should be equal %v", d1, d2)
+ }
+}
+
+func TestDiffToHTML(t *testing.T) {
+ assertEqual(t, "foo <span class=\"added-code\">bar</span> biz", diffToHTML([]dmp.Diff{
+ dmp.Diff{dmp.DiffEqual, "foo "},
+ dmp.Diff{dmp.DiffInsert, "bar"},
+ dmp.Diff{dmp.DiffDelete, " baz"},
+ dmp.Diff{dmp.DiffEqual, " biz"},
+ }, DIFF_LINE_ADD))
+
+ assertEqual(t, "foo <span class=\"removed-code\">bar</span> biz", diffToHTML([]dmp.Diff{
+ dmp.Diff{dmp.DiffEqual, "foo "},
+ dmp.Diff{dmp.DiffDelete, "bar"},
+ dmp.Diff{dmp.DiffInsert, " baz"},
+ dmp.Diff{dmp.DiffEqual, " biz"},
+ }, DIFF_LINE_DEL))
+}
+
+// test if GetLine is return the correct lines
+func TestGetLine(t *testing.T) {
+ ds := DiffSection{Lines: []*DiffLine{
+ &DiffLine{LeftIdx: 28, RightIdx: 28, Type: DIFF_LINE_PLAIN},
+ &DiffLine{LeftIdx: 29, RightIdx: 29, Type: DIFF_LINE_PLAIN},
+ &DiffLine{LeftIdx: 30, RightIdx: 30, Type: DIFF_LINE_PLAIN},
+ &DiffLine{LeftIdx: 31, RightIdx: 0, Type: DIFF_LINE_DEL},
+ &DiffLine{LeftIdx: 0, RightIdx: 31, Type: DIFF_LINE_ADD},
+ &DiffLine{LeftIdx: 0, RightIdx: 32, Type: DIFF_LINE_ADD},
+ &DiffLine{LeftIdx: 32, RightIdx: 33, Type: DIFF_LINE_PLAIN},
+ &DiffLine{LeftIdx: 33, RightIdx: 0, Type: DIFF_LINE_DEL},
+ &DiffLine{LeftIdx: 34, RightIdx: 0, Type: DIFF_LINE_DEL},
+ &DiffLine{LeftIdx: 35, RightIdx: 0, Type: DIFF_LINE_DEL},
+ &DiffLine{LeftIdx: 36, RightIdx: 0, Type: DIFF_LINE_DEL},
+ &DiffLine{LeftIdx: 0, RightIdx: 34, Type: DIFF_LINE_ADD},
+ &DiffLine{LeftIdx: 0, RightIdx: 35, Type: DIFF_LINE_ADD},
+ &DiffLine{LeftIdx: 0, RightIdx: 36, Type: DIFF_LINE_ADD},
+ &DiffLine{LeftIdx: 0, RightIdx: 37, Type: DIFF_LINE_ADD},
+ &DiffLine{LeftIdx: 37, RightIdx: 38, Type: DIFF_LINE_PLAIN},
+ &DiffLine{LeftIdx: 38, RightIdx: 39, Type: DIFF_LINE_PLAIN},
+ }}
+
+ assertLineEqual(t, ds.GetLine(DIFF_LINE_ADD, 31), ds.Lines[4])
+ assertLineEqual(t, ds.GetLine(DIFF_LINE_DEL, 31), ds.Lines[3])
+
+ assertLineEqual(t, ds.GetLine(DIFF_LINE_ADD, 33), ds.Lines[11])
+ assertLineEqual(t, ds.GetLine(DIFF_LINE_ADD, 34), ds.Lines[12])
+ assertLineEqual(t, ds.GetLine(DIFF_LINE_ADD, 35), ds.Lines[13])
+ assertLineEqual(t, ds.GetLine(DIFF_LINE_ADD, 36), ds.Lines[14])
+ assertLineEqual(t, ds.GetLine(DIFF_LINE_DEL, 34), ds.Lines[7])
+ assertLineEqual(t, ds.GetLine(DIFF_LINE_DEL, 35), ds.Lines[8])
+ assertLineEqual(t, ds.GetLine(DIFF_LINE_DEL, 36), ds.Lines[9])
+ assertLineEqual(t, ds.GetLine(DIFF_LINE_DEL, 37), ds.Lines[10])
+}
diff --git a/modules/base/markdown.go b/modules/base/markdown.go
index 04547786..a3d3a7ca 100644
--- a/modules/base/markdown.go
+++ b/modules/base/markdown.go
@@ -83,21 +83,63 @@ func IsReadmeFile(name string) bool {
return false
}
+var (
+ MentionPattern = regexp.MustCompile(`(\s|^)@[0-9a-zA-Z_\.]+`)
+ commitPattern = regexp.MustCompile(`(\s|^)https?.*commit/[0-9a-zA-Z]+(#+[0-9a-zA-Z-]*)?`)
+ issueFullPattern = regexp.MustCompile(`(\s|^)https?.*issues/[0-9]+(#+[0-9a-zA-Z-]*)?`)
+ issueIndexPattern = regexp.MustCompile(`( |^|\()#[0-9]+\b`)
+ sha1CurrentPattern = regexp.MustCompile(`\b[0-9a-f]{40}\b`)
+)
+
type CustomRender struct {
blackfriday.Renderer
urlPrefix string
}
-func (options *CustomRender) Link(out *bytes.Buffer, link []byte, title []byte, content []byte) {
+func (r *CustomRender) Link(out *bytes.Buffer, link []byte, title []byte, content []byte) {
if len(link) > 0 && !isLink(link) {
if link[0] == '#' {
// link = append([]byte(options.urlPrefix), link...)
} else {
- link = []byte(path.Join(options.urlPrefix, string(link)))
+ link = []byte(path.Join(r.urlPrefix, string(link)))
+ }
+ }
+
+ r.Renderer.Link(out, link, title, content)
+}
+
+func (r *CustomRender) AutoLink(out *bytes.Buffer, link []byte, kind int) {
+ if kind != 1 {
+ r.Renderer.AutoLink(out, link, kind)
+ return
+ }
+
+ // This method could only possibly serve one link at a time, no need to find all.
+ m := commitPattern.Find(link)
+ if m != nil {
+ m = bytes.TrimSpace(m)
+ i := strings.Index(string(m), "commit/")
+ j := strings.Index(string(m), "#")
+ if j == -1 {
+ j = len(m)
+ }
+ out.WriteString(fmt.Sprintf(` <code><a href="%s">%s</a></code>`, m, ShortSha(string(m[i+7:j]))))
+ return
+ }
+
+ m = issueFullPattern.Find(link)
+ if m != nil {
+ m = bytes.TrimSpace(m)
+ i := strings.Index(string(m), "issues/")
+ j := strings.Index(string(m), "#")
+ if j == -1 {
+ j = len(m)
}
+ out.WriteString(fmt.Sprintf(` <a href="%s">#%s</a>`, m, ShortSha(string(m[i+7:j]))))
+ return
}
- options.Renderer.Link(out, link, title, content)
+ r.Renderer.AutoLink(out, link, kind)
}
var (
@@ -105,13 +147,13 @@ var (
svgSuffixWithMark = []byte(".svg?")
)
-func (options *CustomRender) Image(out *bytes.Buffer, link []byte, title []byte, alt []byte) {
- prefix := strings.Replace(options.urlPrefix, "/src/", "/raw/", 1)
+func (r *CustomRender) Image(out *bytes.Buffer, link []byte, title []byte, alt []byte) {
+ prefix := strings.Replace(r.urlPrefix, "/src/", "/raw/", 1)
if len(link) > 0 {
if isLink(link) {
// External link with .svg suffix usually means CI status.
if bytes.HasSuffix(link, svgSuffix) || bytes.Contains(link, svgSuffixWithMark) {
- options.Renderer.Image(out, link, title, alt)
+ r.Renderer.Image(out, link, title, alt)
return
}
} else {
@@ -125,18 +167,10 @@ func (options *CustomRender) Image(out *bytes.Buffer, link []byte, title []byte,
out.WriteString(`<a href="`)
out.Write(link)
out.WriteString(`">`)
- options.Renderer.Image(out, link, title, alt)
+ r.Renderer.Image(out, link, title, alt)
out.WriteString("</a>")
}
-var (
- MentionPattern = regexp.MustCompile(`(\s|^)@[0-9a-zA-Z_\.]+`)
- commitPattern = regexp.MustCompile(`(\s|^)https?.*commit/[0-9a-zA-Z]+(#+[0-9a-zA-Z-]*)?`)
- issueFullPattern = regexp.MustCompile(`(\s|^)https?.*issues/[0-9]+(#+[0-9a-zA-Z-]*)?`)
- issueIndexPattern = regexp.MustCompile(`( |^|\()#[0-9]+\b`)
- sha1CurrentPattern = regexp.MustCompile(`\b[0-9a-f]{40}\b`)
-)
-
func cutoutVerbosePrefix(prefix string) string {
count := 0
for i := 0; i < len(prefix); i++ {
@@ -229,33 +263,6 @@ var (
var noEndTags = []string{"img", "input", "br", "hr"}
-// PreProcessMarkdown renders full links of commits, issues and pulls to shorter version.
-func PreProcessMarkdown(rawHTML []byte, urlPrefix string) []byte {
- ms := commitPattern.FindAll(rawHTML, -1)
- for _, m := range ms {
- m = bytes.TrimSpace(m)
- i := strings.Index(string(m), "commit/")
- j := strings.Index(string(m), "#")
- if j == -1 {
- j = len(m)
- }
- rawHTML = bytes.Replace(rawHTML, m, []byte(fmt.Sprintf(
- ` <code><a href="%s">%s</a></code>`, m, ShortSha(string(m[i+7:j])))), -1)
- }
- ms = issueFullPattern.FindAll(rawHTML, -1)
- for _, m := range ms {
- m = bytes.TrimSpace(m)
- i := strings.Index(string(m), "issues/")
- j := strings.Index(string(m), "#")
- if j == -1 {
- j = len(m)
- }
- rawHTML = bytes.Replace(rawHTML, m, []byte(fmt.Sprintf(
- ` <a href="%s">#%s</a>`, m, ShortSha(string(m[i+7:j])))), -1)
- }
- return rawHTML
-}
-
// PostProcessMarkdown treats different types of HTML differently,
// and only renders special links for plain text blocks.
func PostProcessMarkdown(rawHtml []byte, urlPrefix string, metas map[string]string) []byte {
@@ -327,8 +334,7 @@ OUTER_LOOP:
}
func RenderMarkdown(rawBytes []byte, urlPrefix string, metas map[string]string) []byte {
- result := PreProcessMarkdown(rawBytes, urlPrefix)
- result = RenderRawMarkdown(result, urlPrefix)
+ result := RenderRawMarkdown(rawBytes, urlPrefix)
result = PostProcessMarkdown(result, urlPrefix, metas)
result = Sanitizer.SanitizeBytes(result)
return result
diff --git a/public/css/gogs.css b/public/css/gogs.css
index 0160c5d9..0a7daaf0 100755
--- a/public/css/gogs.css
+++ b/public/css/gogs.css
@@ -2306,9 +2306,10 @@ footer .container .links > *:first-child {
}
.repository .diff-box .count {
margin-right: 12px;
+ font-size: 13px;
}
.repository .diff-box .count .bar {
- background-color: #e75316;
+ background-color: #bd2c00 ;
height: 12px;
width: 40px;
display: inline-block;
@@ -2316,7 +2317,7 @@ footer .container .links > *:first-child {
vertical-align: text-top;
}
.repository .diff-box .count .bar .add {
- background-color: #77c64a;
+ background-color: #55a532;
height: 12px;
}
.repository .diff-box .file {
@@ -2387,6 +2388,12 @@ footer .container .links > *:first-child {
.repository .diff-file-box .code-diff tbody tr.add-code td.halfwidth {
width: 50%;
}
+.repository .diff-file-box .code-diff tbody tr .removed-code {
+ background-color: #ff9999;
+}
+.repository .diff-file-box .code-diff tbody tr .added-code {
+ background-color: #99ff99;
+}
.repository .diff-file-box.file-content img {
max-width: 100%;
padding: 5px 5px 0 5px;
diff --git a/public/less/_repository.less b/public/less/_repository.less
index 441832da..124b2b29 100644
--- a/public/less/_repository.less
+++ b/public/less/_repository.less
@@ -641,15 +641,17 @@
.diff-box {
.count {
margin-right: 12px;
+ font-size: 13px;
+
.bar {
- background-color: #e75316;
+ background-color: #bd2c00 ;
height: 12px;
width: 40px;
display: inline-block;
margin: 2px 4px 0 4px;
vertical-align: text-top;
.add {
- background-color: #77c64a;
+ background-color: #55a532;
height: 12px;
}
}
@@ -716,6 +718,7 @@
// }
// }
&.del-code {
+ // Duplicate here to enforce add code color.
td.add-code {
background-color: #eaffea !important;
border-color: #c1e9c1 !important;
@@ -749,6 +752,13 @@
// background-color: #ffffdd !important;
// }
}
+
+ .removed-code {
+ background-color: #ff9999;
+ }
+ .added-code {
+ background-color: #99ff99;
+ }
}
}
}
@@ -1217,3 +1227,5 @@
width: 100%!important;
}
}
+
+
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index e1a23f0d..6fe11a07 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -194,7 +194,7 @@ func RegisterRoutes(m *macaron.Macaron) {
}, ReqToken())
// Organizations
- m.Get("/user/orgs", org.ListMyOrgs)
+ m.Get("/user/orgs", ReqToken(), org.ListMyOrgs)
m.Get("/users/:username/orgs", org.ListUserOrgs)
m.Combo("/orgs/:orgname").Get(org.Get).Patch(bind(api.EditOrgOption{}), org.Edit)
@@ -209,7 +209,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Group("/:username", func() {
m.Combo("").Patch(bind(api.EditUserOption{}), admin.EditUser).
Delete(admin.DeleteUser)
- m.Post("/keys", admin.CreatePublicKey)
+ m.Post("/keys", bind(api.CreateKeyOption{}), admin.CreatePublicKey)
m.Post("/orgs", bind(api.CreateOrgOption{}), admin.CreateOrg)
m.Post("/repos", bind(api.CreateRepoOption{}), admin.CreateRepo)
})
diff --git a/routers/repo/commit.go b/routers/repo/commit.go
index c3fc4d17..9e46c2e8 100644
--- a/routers/repo/commit.go
+++ b/routers/repo/commit.go
@@ -168,6 +168,12 @@ func Diff(ctx *middleware.Context) {
}
}
+ for _, diffFile := range diff.Files {
+ for _, diffSection := range diffFile.Sections {
+ diffSection.ComputeLinesDiff()
+ }
+ }
+
ctx.Data["IsSplitStyle"] = ctx.Query("style") == "split"
ctx.Data["Username"] = userName
ctx.Data["Reponame"] = repoName
diff --git a/routers/user/profile.go b/routers/user/profile.go
index 9007ab32..915cf86c 100644
--- a/routers/user/profile.go
+++ b/routers/user/profile.go
@@ -21,9 +21,8 @@ const (
STARS base.TplName = "user/meta/stars"
)
-// GetUserByParams returns user whose name is presented in URL paramenter.
-func GetUserByParams(ctx *middleware.Context) *models.User {
- user, err := models.GetUserByName(ctx.Params(":username"))
+func GetUserByName(ctx *middleware.Context, name string) *models.User {
+ user, err := models.GetUserByName(name)
if err != nil {
if models.IsErrUserNotExist(err) {
ctx.Error(404)
@@ -35,6 +34,11 @@ func GetUserByParams(ctx *middleware.Context) *models.User {
return user
}
+// GetUserByParams returns user whose name is presented in URL paramenter.
+func GetUserByParams(ctx *middleware.Context) *models.User {
+ return GetUserByName(ctx, ctx.Params(":username"))
+}
+
func Profile(ctx *middleware.Context) {
uname := ctx.Params(":username")
// Special handle for FireFox requests favicon.ico.
@@ -51,7 +55,7 @@ func Profile(ctx *middleware.Context) {
isShowKeys = true
}
- u := GetUserByParams(ctx)
+ u := GetUserByName(ctx, strings.TrimSuffix(uname, ".keys"))
if ctx.Written() {
return
}
diff --git a/templates/.VERSION b/templates/.VERSION
index a1a3a849..861f2d9a 100644
--- a/templates/.VERSION
+++ b/templates/.VERSION
@@ -1 +1 @@
-0.8.17.0107 \ No newline at end of file
+0.8.18.0109 \ No newline at end of file
diff --git a/templates/repo/diff_box.tmpl b/templates/repo/diff_box.tmpl
index a12f4de4..da512ebf 100644
--- a/templates/repo/diff_box.tmpl
+++ b/templates/repo/diff_box.tmpl
@@ -26,7 +26,7 @@
{{end}}
</div>
<!-- todo finish all file status, now modify, add, delete and rename -->
- <span class="status {{DiffTypeToStr .Type}} poping up" data-content="{{DiffTypeToStr .Type}}" data-variation="inverted tiny" data-position="right center">&nbsp;</span>
+ <span class="status {{DiffTypeToStr .GetType}} poping up" data-content="{{DiffTypeToStr .GetType}}" data-variation="inverted tiny" data-position="right center">&nbsp;</span>
<a class="file" href="#diff-{{.Index}}">{{.Name}}</a>
</li>
{{end}}
@@ -71,18 +71,18 @@
{{if $.IsSplitStyle}}
{{range $j, $section := .Sections}}
{{range $k, $line := .Lines}}
- <tr class="{{DiffLineTypeToStr .Type}}-code nl-{{$k}} ol-{{$k}}">
+ <tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}">
<td class="lines-num lines-num-old">
<span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}">{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}</span>
</td>
<td class="lines-code halfwidth">
- <pre class="wrap">{{if $line.LeftIdx}}{{$line.Content}}{{end}}</pre>
+ <pre class="wrap">{{if $line.LeftIdx}}{{$line.ParsedContent}}{{end}}</pre>
</td>
<td class="lines-num lines-num-new">
<span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}">{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}</span>
</td>
<td class="lines-code halfwidth">
- <pre class="wrap">{{if $line.RightIdx}}{{$line.Content}}{{end}}</pre>
+ <pre class="wrap">{{if $line.RightIdx}}{{$line.ParsedContent}}{{end}}</pre>
</td>
</tr>
{{end}}
@@ -90,10 +90,10 @@
{{else}}
{{range $j, $section := .Sections}}
{{range $k, $line := .Lines}}
- <tr class="{{DiffLineTypeToStr .Type}}-code nl-{{$k}} ol-{{$k}}">
- {{if eq .Type 4}}
+ <tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}">
+ {{if eq .GetType 4}}
<td colspan="2" class="lines-num">
- {{if gt $j 0}}<span class="fold octicon octicon-fold"></span>{{end}}
+ {{/* {{if gt $j 0}}<span class="fold octicon octicon-fold"></span>{{end}} */}}
</td>
{{else}}
<td class="lines-num lines-num-old">
@@ -104,7 +104,7 @@
</td>
{{end}}
<td class="lines-code">
- <pre>{{$line.Content}}</pre>
+ <pre>{{$line.ParsedContent}}</pre>
</td>
</tr>
{{end}}
diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl
index cceaa0de..741d0c12 100644
--- a/templates/user/profile.tmpl
+++ b/templates/user/profile.tmpl
@@ -4,7 +4,7 @@
<div class="ui grid">
<div class="ui five wide column">
<div class="ui card">
- {{if and (or .Owner.UseCustomAvatar .DisableGravatar) (eq .SignedUserName .Owner.Name)}}
+ {{if and (or .Owner.UseCustomAvatar DisableGravatar) (eq .SignedUserName .Owner.Name)}}
<a class="image poping up" href="{{AppSubUrl}}/user/settings" id="profile-avatar" data-content="{{.i18n.Tr "user.change_custom_avatar"}}" data-variation="inverted tiny" data-position="bottom center">
<img src="{{.Owner.AvatarLink}}?s=290" title="{{.Owner.Name}}"/>
</a>