Mirror bug fix on downloading zip

release/v1.15
Unknown 2014-04-15 20:01:20 -04:00
parent 67426534ef
commit c3a52f7dd0
9 changed files with 29 additions and 15 deletions

View File

@ -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.

View File

@ -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) 文件中。

View File

@ -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
}

View File

@ -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")

View File

@ -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))
}

View File

@ -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"/>

View File

@ -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>

View File

@ -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)}}

2
web.go
View File

@ -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) {