tokarchuk/v1.17
Unknwon 9 years ago
parent 21d7b5acaf
commit 86bce4a2ae
  1. 1
      .gopmfile
  2. 2
      README.md
  3. 2
      gogs.go
  4. 43
      models/git_diff.go
  5. 17
      public/css/gogs.css
  6. 20
      public/less/_repository.less
  7. 2
      templates/.VERSION

@ -31,6 +31,7 @@ github.com/microcosm-cc/bluemonday = commit:4ac6f27
github.com/msteinert/pam = commit:02ccfbf github.com/msteinert/pam = commit:02ccfbf
github.com/nfnt/resize = commit:dc93e1b98c github.com/nfnt/resize = commit:dc93e1b98c
github.com/russross/blackfriday = commit:d18b67a github.com/russross/blackfriday = commit:d18b67a
github.com/sergi/go-diff =
github.com/shurcooL/sanitized_anchor_name = commit:10ef21a github.com/shurcooL/sanitized_anchor_name = commit:10ef21a
github.com/Unknwon/cae = commit:7f5e046 github.com/Unknwon/cae = commit:7f5e046
github.com/Unknwon/com = commit:28b053d github.com/Unknwon/com = commit:28b053d

@ -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) ![](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 | | Web | UI | Preview |
|:-------------:|:-------:|:-------:| |:-------------:|:-------:|:-------:|

@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/modules/setting"
) )
const APP_VER = "0.8.17.0109" const APP_VER = "0.8.18.0109"
func init() { func init() {
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())

@ -8,18 +8,18 @@ import (
"bufio" "bufio"
"bytes" "bytes"
"fmt" "fmt"
"html"
"html/template"
"io" "io"
"io/ioutil" "io/ioutil"
"os" "os"
"os/exec" "os/exec"
"strings" "strings"
"html/template"
"html"
"github.com/Unknwon/com" "github.com/Unknwon/com"
"github.com/sergi/go-diff/diffmatchpatch"
"golang.org/x/net/html/charset" "golang.org/x/net/html/charset"
"golang.org/x/text/transform" "golang.org/x/text/transform"
"github.com/sergi/go-diff/diffmatchpatch"
"github.com/gogits/git-module" "github.com/gogits/git-module"
@ -63,18 +63,29 @@ type DiffSection struct {
Lines []*DiffLine Lines []*DiffLine
} }
func diffToHtml(diffRecord []diffmatchpatch.Diff, lineType DiffLineType) template.HTML { var (
result := "" addedCodePrefix = []byte("<span class=\"added-code\">")
for _, s := range diffRecord { removedCodePrefix = []byte("<span class=\"removed-code\">")
if s.Type == diffmatchpatch.DiffInsert && lineType == DIFF_LINE_ADD { codeTagSuffix = []byte("</span>")
result = result + "<span class=\"added-code\">"+html.EscapeString(s.Text)+"</span>" )
} else if s.Type == diffmatchpatch.DiffDelete && lineType == DIFF_LINE_DEL {
result = result + "<span class=\"removed-code\">"+html.EscapeString(s.Text)+"</span>" func diffToHTML(diffs []diffmatchpatch.Diff, lineType DiffLineType) template.HTML {
} else if s.Type == diffmatchpatch.DiffEqual { var buf bytes.Buffer
result = result + html.EscapeString(s.Text) 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(result)
return template.HTML(buf.Bytes())
} }
// get an specific line by type (add or del) and file line number // get an specific line by type (add or del) and file line number
@ -107,11 +118,9 @@ func (diffSection *DiffSection) ComputeLinesDiff() {
var compareDiffLine *DiffLine var compareDiffLine *DiffLine
var diff1, diff2 string var diff1, diff2 string
// default content: as is
diffLine.ParsedContent = template.HTML(html.EscapeString(diffLine.Content[1:]))
// just compute diff for adds and removes // just compute diff for adds and removes
if diffLine.Type != DIFF_LINE_ADD && diffLine.Type != DIFF_LINE_DEL { if diffLine.Type != DIFF_LINE_ADD && diffLine.Type != DIFF_LINE_DEL {
diffLine.ParsedContent = template.HTML(html.EscapeString(diffLine.Content[1:]))
continue continue
} }
@ -136,7 +145,7 @@ func (diffSection *DiffSection) ComputeLinesDiff() {
diffRecord := dmp.DiffMain(diff1[1:], diff2[1:], true) diffRecord := dmp.DiffMain(diff1[1:], diff2[1:], true)
diffRecord = dmp.DiffCleanupSemantic(diffRecord) diffRecord = dmp.DiffCleanupSemantic(diffRecord)
diffLine.ParsedContent = diffToHtml(diffRecord, diffLine.Type) diffLine.ParsedContent = diffToHTML(diffRecord, diffLine.Type)
} }
} }

@ -2306,9 +2306,10 @@ footer .container .links > *:first-child {
} }
.repository .diff-box .count { .repository .diff-box .count {
margin-right: 12px; margin-right: 12px;
font-size: 13px;
} }
.repository .diff-box .count .bar { .repository .diff-box .count .bar {
background-color: #e75316; background-color: #bd2c00 ;
height: 12px; height: 12px;
width: 40px; width: 40px;
display: inline-block; display: inline-block;
@ -2316,7 +2317,7 @@ footer .container .links > *:first-child {
vertical-align: text-top; vertical-align: text-top;
} }
.repository .diff-box .count .bar .add { .repository .diff-box .count .bar .add {
background-color: #77c64a; background-color: #55a532;
height: 12px; height: 12px;
} }
.repository .diff-box .file { .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 { .repository .diff-file-box .code-diff tbody tr.add-code td.halfwidth {
width: 50%; 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 { .repository .diff-file-box.file-content img {
max-width: 100%; max-width: 100%;
padding: 5px 5px 0 5px; padding: 5px 5px 0 5px;
@ -2764,12 +2771,6 @@ footer .container .links > *:first-child {
#delete-repo-modal .ui.message { #delete-repo-modal .ui.message {
width: 100%!important; width: 100%!important;
} }
.removed-code {
background-color: #ff9999;
}
.added-code {
background-color: #99ff99;
}
.organization { .organization {
padding-top: 15px; padding-top: 15px;
padding-bottom: 80px; padding-bottom: 80px;

@ -641,15 +641,17 @@
.diff-box { .diff-box {
.count { .count {
margin-right: 12px; margin-right: 12px;
font-size: 13px;
.bar { .bar {
background-color: #e75316; background-color: #bd2c00 ;
height: 12px; height: 12px;
width: 40px; width: 40px;
display: inline-block; display: inline-block;
margin: 2px 4px 0 4px; margin: 2px 4px 0 4px;
vertical-align: text-top; vertical-align: text-top;
.add { .add {
background-color: #77c64a; background-color: #55a532;
height: 12px; height: 12px;
} }
} }
@ -716,6 +718,7 @@
// } // }
// } // }
&.del-code { &.del-code {
// Duplicate here to enforce add code color.
td.add-code { td.add-code {
background-color: #eaffea !important; background-color: #eaffea !important;
border-color: #c1e9c1 !important; border-color: #c1e9c1 !important;
@ -749,6 +752,13 @@
// background-color: #ffffdd !important; // background-color: #ffffdd !important;
// } // }
} }
.removed-code {
background-color: #ff9999;
}
.added-code {
background-color: #99ff99;
}
} }
} }
} }
@ -1218,10 +1228,4 @@
} }
} }
.removed-code {
background-color: #ff9999;
}
.added-code {
background-color: #99ff99;
}

@ -1 +1 @@
0.8.17.0109 0.8.18.0109
Loading…
Cancel
Save