diff options
author | Unknown <joe2010xtmf@163.com> | 2014-04-15 20:01:20 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-04-15 20:01:20 -0400 |
commit | c3a52f7dd075f1f3cf7fb935b7489629760837ab (patch) | |
tree | ab27cc4a5cc1d10c366bcfd04585f02fccb8176b | |
parent | 67426534ef9f0ceba49330cbc0b7676f4009a6e1 (diff) | |
download | gitea-c3a52f7dd075f1f3cf7fb935b7489629760837ab.tar.gz gitea-c3a52f7dd075f1f3cf7fb935b7489629760837ab.zip |
Mirror bug fix on downloading zip
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | README_ZH.md | 3 | ||||
-rw-r--r-- | models/git_diff.go | 13 | ||||
-rw-r--r-- | modules/avatar/avatar.go | 5 | ||||
-rw-r--r-- | routers/repo/repo.go | 4 | ||||
-rw-r--r-- | templates/base/navbar.tmpl | 4 | ||||
-rw-r--r-- | templates/repo/commits.tmpl | 2 | ||||
-rw-r--r-- | templates/repo/diff.tmpl | 8 | ||||
-rw-r--r-- | web.go | 2 |
9 files changed, 29 insertions, 15 deletions
@@ -66,6 +66,9 @@ There are 3 ways to install Gogs: This project was launched by [Unknown](https://github.com/Unknwon) and [lunny](https://github.com/lunny); [fuxiaohei](https://github.com/fuxiaohei), [slene](https://github.com/slene) and [codeskyblue](https://github.com/codeskyblue) joined the team soon after. See [contributors page](https://github.com/gogits/gogs/graphs/contributors) for full list of contributors. +[![Clone in Koding](http://learn.koding.com/btn/clone_d.png)][koding] +[koding]: https://koding.com/Teamwork?import=https://github.com/gogits/gogs/archive/master.zip&c=git1 + ## License Gogs is under the MIT License. See the [LICENSE](https://github.com/gogits/gogs/blob/master/LICENSE) file for the full license text. diff --git a/README_ZH.md b/README_ZH.md index be191bc04e..ecfb7700a2 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -57,6 +57,9 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依 本项目最初由 [Unknown](https://github.com/Unknwon) 和 [lunny](https://github.com/lunny) 发起,随后 [fuxiaohei](https://github.com/fuxiaohei)、[slene](https://github.com/slene) 以及 [codeskyblue](https://github.com/codeskyblue) 加入到开发团队。您可以通过查看 [贡献者页面](https://github.com/gogits/gogs/graphs/contributors) 获取完整的贡献者列表。 +[![Clone in Koding](http://learn.koding.com/btn/clone_d.png)][koding] +[koding]: https://koding.com/Teamwork?import=https://github.com/gogits/gogs/archive/master.zip&c=git1 + ## 授权许可 Gogs 采用 MIT 开源授权许可证,完整的授权说明已放置在 [LICENSE](https://github.com/gogits/gogs/blob/master/LICENSE) 文件中。
\ No newline at end of file diff --git a/models/git_diff.go b/models/git_diff.go index de9d1de7b1..cf93af6959 100644 --- a/models/git_diff.go +++ b/models/git_diff.go @@ -51,6 +51,7 @@ type DiffFile struct { Name string Addition, Deletion int Type int + IsBin bool Sections []*DiffSection } @@ -96,13 +97,15 @@ func ParsePatch(reader io.Reader) (*Diff, error) { if line == "" { continue } - if line[0] == ' ' { + + switch { + case line[0] == ' ': diffLine := &DiffLine{Type: DIFF_LINE_PLAIN, Content: line, LeftIdx: leftLine, RightIdx: rightLine} leftLine++ rightLine++ curSection.Lines = append(curSection.Lines, diffLine) continue - } else if line[0] == '@' { + case line[0] == '@': curSection = &DiffSection{} curFile.Sections = append(curFile.Sections, curSection) ss := strings.Split(line, "@@") @@ -114,14 +117,14 @@ func ParsePatch(reader io.Reader) (*Diff, error) { leftLine, _ = base.StrTo(strings.Split(ranges[0], ",")[0][1:]).Int() rightLine, _ = base.StrTo(strings.Split(ranges[1], ",")[0]).Int() continue - } else if line[0] == '+' { + case line[0] == '+': curFile.Addition++ diff.TotalAddition++ diffLine := &DiffLine{Type: DIFF_LINE_ADD, Content: line, RightIdx: rightLine} rightLine++ curSection.Lines = append(curSection.Lines, diffLine) continue - } else if line[0] == '-' { + case line[0] == '-': curFile.Deletion++ diff.TotalDeletion++ diffLine := &DiffLine{Type: DIFF_LINE_DEL, Content: line, LeftIdx: leftLine} @@ -129,6 +132,8 @@ func ParsePatch(reader io.Reader) (*Diff, error) { leftLine++ } curSection.Lines = append(curSection.Lines, diffLine) + case strings.HasPrefix(line, "Binary"): + curFile.IsBin = true continue } diff --git a/modules/avatar/avatar.go b/modules/avatar/avatar.go index edeb256ffe..5ed5d16a62 100644 --- a/modules/avatar/avatar.go +++ b/modules/avatar/avatar.go @@ -157,9 +157,9 @@ func (this *service) ServeHTTP(w http.ResponseWriter, r *http.Request) { avatar := New(hash, this.cacheDir) avatar.AlterImage = this.altImage if avatar.Expired() { - err := avatar.UpdateTimeout(time.Millisecond * 500) - if err != nil { + if err := avatar.UpdateTimeout(time.Millisecond * 1000); err != nil { log.Trace("avatar update error: %v", err) + return } } if modtime, err := avatar.Modtime(); err == nil { @@ -250,6 +250,7 @@ func (this *thunderTask) Fetch() { var client = &http.Client{} func (this *thunderTask) fetch() error { + log.Debug("avatar.fetch(fetch new avatar): %s", this.Url) req, _ := http.NewRequest("GET", this.Url, nil) req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/jpeg,image/png,*/*;q=0.8") req.Header.Set("Accept-Encoding", "deflate,sdch") diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 14a3c7622c..6422f0a324 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -153,7 +153,7 @@ func Single(ctx *middleware.Context, params martini.Params) { } else { ctx.Data["FileSize"] = blob.Size() ctx.Data["IsFile"] = true - ctx.Data["FileName"] = blob.Name + ctx.Data["FileName"] = blob.Name() ext := path.Ext(blob.Name()) if len(ext) > 0 { ext = ext[1:] @@ -226,7 +226,7 @@ func Single(ctx *middleware.Context, params martini.Params) { ctx.Data["FileLink"] = rawLink + "/" + treename _, isTextFile := base.IsTextFile(data) ctx.Data["FileIsText"] = isTextFile - ctx.Data["FileName"] = readmeFile.Name + ctx.Data["FileName"] = readmeFile.Name() if isTextFile { ctx.Data["FileContent"] = string(base.RenderMarkdown(data, branchLink)) } diff --git a/templates/base/navbar.tmpl b/templates/base/navbar.tmpl index cd3f2b83a9..e5b22192f5 100644 --- a/templates/base/navbar.tmpl +++ b/templates/base/navbar.tmpl @@ -4,7 +4,7 @@ <a id="nav-logo" class="nav-item pull-left{{if .PageIsHome}} active{{end}}" href="/"><img src="/img/favicon.png" alt="Gogs Logo" id="logo"></a> <a class="nav-item pull-left{{if .PageIsUserDashboard}} active{{end}}" href="/">Dashboard</a> <a class="nav-item pull-left{{if .PageIsHelp}} active{{end}}" href="https://github.com/gogits/gogs/wiki">Help</a>{{if .IsSigned}} - {{if .HasAccess}}<form class="nav-item pull-left{{if .PageIsNewRepo}} active{{end}}" id="nav-search-form"> + {{if .HasAccess}}<!-- <form class="nav-item pull-left{{if .PageIsNewRepo}} active{{end}}" id="nav-search-form"> <div class="input-group"> <div class="input-group-btn"> <button type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown">{{if .Repository}}This Repository{{else}}All Repositories{{end}} <span class="caret"></span></button> @@ -16,7 +16,7 @@ </div> <input type="search" class="form-control input-sm" name="q" placeholder="search code, commits and issues"/> </div> - </form>{{end}} + </form> -->{{end}} <a id="nav-out" class="nav-item navbar-right navbar-btn btn btn-danger" href="/user/logout/"><i class="fa fa-power-off fa-lg"></i></a> <a id="nav-avatar" class="nav-item navbar-right{{if .PageIsUserProfile}} active{{end}}" href="{{.SignedUser.HomeLink}}" data-toggle="tooltip" data-placement="bottom" title="{{.SignedUserName}}"> <img src="{{.SignedUser.AvatarLink}}?s=28" alt="user-avatar" title="username"/> diff --git a/templates/repo/commits.tmpl b/templates/repo/commits.tmpl index 8125fedaa8..b14c6bc8c6 100644 --- a/templates/repo/commits.tmpl +++ b/templates/repo/commits.tmpl @@ -32,7 +32,7 @@ {{range $r}} <tr> <td class="author"><img class="avatar" src="{{AvatarLink .Author.Email}}" alt=""/><a href="/user/email2user?email={{.Author.Email}}">{{.Author.Name}}</a></td> - <td class="sha"><a class="label label-success" href="/{{$username}}/{{$reponame}}/commit/{{.Id}} ">{{SubStr .Id.String 0 10}} </a></td> + <td class="sha"><a rel="nofollow" class="label label-success" href="/{{$username}}/{{$reponame}}/commit/{{.Id}} ">{{SubStr .Id.String 0 10}} </a></td> <td class="message">{{.Message}} </td> <td class="date">{{TimeSince .Author.When}}</td> </tr> diff --git a/templates/repo/diff.tmpl b/templates/repo/diff.tmpl index f3d935aebe..0dce405337 100644 --- a/templates/repo/diff.tmpl +++ b/templates/repo/diff.tmpl @@ -5,7 +5,7 @@ <div id="source"> <div class="panel panel-info diff-box diff-head-box"> <div class="panel-heading"> - <a class="pull-right btn btn-primary btn-sm" href="{{.SourcePath}}">Browse Source</a> + <a class="pull-right btn btn-primary btn-sm" rel="nofollow" href="{{.SourcePath}}">Browse Source</a> <h4>{{.Commit.Message}}</h4> </div> <div class="panel-body"> @@ -33,7 +33,7 @@ {{range .Diff.Files}} <li> <div class="diff-counter count pull-right"> - {{if Add .Addition .Deletion}} + {{if not .IsBin}} <span class="add" data-line="{{.Addition}}">{{.Addition}}</span> <span class="bar"> <span class="pull-left add"></span> @@ -56,7 +56,7 @@ <div class="panel panel-default diff-file-box diff-box file-content" id="diff-2"> <div class="panel-heading"> <div class="diff-counter count pull-left"> - {{if Add .Addition .Deletion}} + {{if not .IsBin}} <span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span> <span class="bar"> <span class="pull-left add"></span> @@ -67,7 +67,7 @@ BIN {{end}} </div> - <a class="btn btn-default btn-sm pull-right" href="{{$.SourcePath}}/{{.Name}}">View File</a> + <a class="btn btn-default btn-sm pull-right" rel="nofollow" href="{{$.SourcePath}}/{{.Name}}">View File</a> <span class="file">{{.Name}}</span> </div> {{$isImage := (call $.IsImageFile .Name)}} @@ -8,6 +8,7 @@ import ( "fmt" "html/template" "net/http" + "os" "github.com/codegangsta/cli" "github.com/go-martini/martini" @@ -82,6 +83,7 @@ func runWeb(*cli.Context) { }) avt := avatar.CacheServer("public/img/avatar/", "public/img/avatar_default.jpg") + os.MkdirAll("public/img/avatar/", os.ModePerm) m.Get("/avatar/:hash", avt.ServeHTTP) m.Group("/user", func(r martini.Router) { |