mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 13:51:35 +01:00 
			
		
		
		
	Merge branch 'master' of github.com:gogits/gogs
This commit is contained in:
		
						commit
						f0352789cd
					
				
							
								
								
									
										25
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										25
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -1,3 +1,5 @@ | |||||||
|  | 
 | ||||||
|  | 
 | ||||||
| gogs | gogs | ||||||
| *.exe | *.exe | ||||||
| *.exe~ | *.exe~ | ||||||
| @ -10,3 +12,26 @@ data/ | |||||||
| .idea/ | .idea/ | ||||||
| *.iml | *.iml | ||||||
| public/img/avatar/ | public/img/avatar/ | ||||||
|  | 
 | ||||||
|  | # Compiled Object files, Static and Dynamic libs (Shared Objects) | ||||||
|  | *.o | ||||||
|  | *.a | ||||||
|  | *.so | ||||||
|  | 
 | ||||||
|  | # Folders | ||||||
|  | _obj | ||||||
|  | _test | ||||||
|  | 
 | ||||||
|  | # Architecture specific extensions/prefixes | ||||||
|  | *.[568vq] | ||||||
|  | [568vq].out | ||||||
|  | 
 | ||||||
|  | *.cgo1.go | ||||||
|  | *.cgo2.c | ||||||
|  | _cgo_defun.c | ||||||
|  | _cgo_gotypes.go | ||||||
|  | _cgo_export.* | ||||||
|  | 
 | ||||||
|  | _testmain.go | ||||||
|  | 
 | ||||||
|  | *.exe | ||||||
							
								
								
									
										40
									
								
								LICENSE
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								LICENSE
									
									
									
									
									
								
							| @ -1,19 +1,27 @@ | |||||||
| Copyright (c) 2011 Dmitriy Zaporozhets | Copyright (c) 2014 | ||||||
|  | All rights reserved. | ||||||
| 
 | 
 | ||||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | Redistribution and use in source and binary forms, with or without | ||||||
| of this software and associated documentation files (the "Software"), to deal | modification, are permitted provided that the following conditions are met: | ||||||
| in the Software without restriction, including without limitation the rights |  | ||||||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |  | ||||||
| copies of the Software, and to permit persons to whom the Software is |  | ||||||
| furnished to do so, subject to the following conditions: |  | ||||||
| 
 | 
 | ||||||
| The above copyright notice and this permission notice shall be included in | * Redistributions of source code must retain the above copyright notice, this | ||||||
| all copies or substantial portions of the Software. |   list of conditions and the following disclaimer. | ||||||
| 
 | 
 | ||||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | * Redistributions in binary form must reproduce the above copyright notice, | ||||||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |   this list of conditions and the following disclaimer in the documentation | ||||||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |   and/or other materials provided with the distribution. | ||||||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
 | ||||||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | * Neither the name of the {organization} nor the names of its | ||||||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |   contributors may be used to endorse or promote products derived from | ||||||
| THE SOFTWARE. |   this software without specific prior written permission. | ||||||
|  | 
 | ||||||
|  | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||||||
|  | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||||
|  | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||||||
|  | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||||||
|  | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||||
|  | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||||||
|  | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||||||
|  | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||||||
|  | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||||
|  | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
| @ -53,6 +53,7 @@ There are two ways to install Gogs: | |||||||
| - Mail Service, modules design is inspired by [WeTalk](https://github.com/beego/wetalk). | - Mail Service, modules design is inspired by [WeTalk](https://github.com/beego/wetalk). | ||||||
| - System Monitor Status is inspired by [GoBlog](https://github.com/fuxiaohei/goblog). | - System Monitor Status is inspired by [GoBlog](https://github.com/fuxiaohei/goblog). | ||||||
| - Usage and modification from [beego](http://beego.me) modules. | - Usage and modification from [beego](http://beego.me) modules. | ||||||
|  | - Thanks [gobuild.io](http://gobuild.io) for providing binary compile and download service. | ||||||
| 
 | 
 | ||||||
| ## Contributors | ## Contributors | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -49,6 +49,7 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依 | |||||||
| - 基于 [GoBlog](https://github.com/fuxiaohei/goblog) 修改的系统监视状态。 | - 基于 [GoBlog](https://github.com/fuxiaohei/goblog) 修改的系统监视状态。 | ||||||
| - [beego](http://beego.me) 模块的使用与修改。 | - [beego](http://beego.me) 模块的使用与修改。 | ||||||
| - [martini](http://martini.codegangsta.io/) 的路由与中间件机制。 | - [martini](http://martini.codegangsta.io/) 的路由与中间件机制。 | ||||||
|  | - 感谢 [gobuild.io](http://gobuild.io) 提供二进制编译与下载服务。 | ||||||
| 
 | 
 | ||||||
| ## 贡献成员 | ## 贡献成员 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -109,7 +109,7 @@ func IsRepositoryExist(user *User, repoName string) (bool, error) { | |||||||
| 
 | 
 | ||||||
| var ( | var ( | ||||||
| 	// Define as all lower case!! | 	// Define as all lower case!! | ||||||
| 	illegalPatterns = []string{"[.][Gg][Ii][Tt]", "user", "help", "stars", "issues", "pulls", "commits", "admin", "repo", "template", "admin"} | 	illegalPatterns = []string{"[.][Gg][Ii][Tt]", "raw", "user", "help", "stars", "issues", "pulls", "commits", "admin", "repo", "template", "admin"} | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // IsLegalName returns false if name contains illegal characters. | // IsLegalName returns false if name contains illegal characters. | ||||||
|  | |||||||
| @ -100,7 +100,7 @@ func newService() { | |||||||
| 	Service.EnableCacheAvatar = Cfg.MustBool("service", "ENABLE_CACHE_AVATAR", false) | 	Service.EnableCacheAvatar = Cfg.MustBool("service", "ENABLE_CACHE_AVATAR", false) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func NewLogService() { | func newLogService() { | ||||||
| 	// Get and check log mode. | 	// Get and check log mode. | ||||||
| 	LogMode = Cfg.MustValue("log", "MODE", "console") | 	LogMode = Cfg.MustValue("log", "MODE", "console") | ||||||
| 	modeSec := "log." + LogMode | 	modeSec := "log." + LogMode | ||||||
| @ -243,7 +243,7 @@ func newNotifyMailService() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func NewConfigContext() { | func NewConfigContext() { | ||||||
| 	var err error | 	//var err error | ||||||
| 	workDir, err := exeDir() | 	workDir, err := exeDir() | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		fmt.Printf("Fail to get work directory: %s\n", err) | 		fmt.Printf("Fail to get work directory: %s\n", err) | ||||||
| @ -296,7 +296,7 @@ func NewConfigContext() { | |||||||
| 
 | 
 | ||||||
| func NewServices() { | func NewServices() { | ||||||
| 	newService() | 	newService() | ||||||
| 	NewLogService() | 	newLogService() | ||||||
| 	newCacheService() | 	newCacheService() | ||||||
| 	newSessionService() | 	newSessionService() | ||||||
| 	newMailService() | 	newMailService() | ||||||
|  | |||||||
| @ -6,6 +6,7 @@ package base | |||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"bytes" | 	"bytes" | ||||||
|  | 	"net/http" | ||||||
| 	"path" | 	"path" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"strings" | 	"strings" | ||||||
| @ -42,6 +43,14 @@ func IsMarkdownFile(name string) bool { | |||||||
| 	return false | 	return false | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func IsTextFile(data []byte) (string, bool) { | ||||||
|  | 	contentType := http.DetectContentType(data) | ||||||
|  | 	if strings.Index(contentType, "text/") != -1 { | ||||||
|  | 		return contentType, true | ||||||
|  | 	} | ||||||
|  | 	return contentType, false | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func IsReadmeFile(name string) bool { | func IsReadmeFile(name string) bool { | ||||||
| 	name = strings.ToLower(name) | 	name = strings.ToLower(name) | ||||||
| 	if len(name) < 6 { | 	if len(name) < 6 { | ||||||
|  | |||||||
| @ -224,6 +224,15 @@ html, body { | |||||||
|     line-height: 30px; |     line-height: 30px; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #gogs-install-card{ | ||||||
|  |     width: 800px; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #gogs-install-card .form-group { | ||||||
|  |     margin-left: 0; | ||||||
|  |     margin-right: 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| .gogs-card .btn { | .gogs-card .btn { | ||||||
|     cursor: pointer; |     cursor: pointer; | ||||||
|     margin-right: 1.2em; |     margin-right: 1.2em; | ||||||
| @ -676,6 +685,12 @@ html, body { | |||||||
|     margin: 0 .5em 0 0; |     margin: 0 .5em 0 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | .file-content .file-head .file-size { | ||||||
|  |     font-size: 13px; | ||||||
|  |     color: #888; | ||||||
|  |     margin-left: 1em; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| .file-content .file-body { | .file-content .file-body { | ||||||
|     padding: 30px 30px 50px; |     padding: 30px 30px 50px; | ||||||
|     border: none; |     border: none; | ||||||
|  | |||||||
| @ -291,7 +291,7 @@ function initRepository() { | |||||||
|             $clone.find('button[data-link]').on("click",function (e) { |             $clone.find('button[data-link]').on("click",function (e) { | ||||||
|                 var $this = $(this); |                 var $this = $(this); | ||||||
|                 if (!$this.hasClass('btn-primary')) { |                 if (!$this.hasClass('btn-primary')) { | ||||||
|                     $clone.find('.btn-primary').removeClass('btn-primary').addClass("btn-default"); |                     $clone.find('.input-group-btn .btn-primary').removeClass('btn-primary').addClass("btn-default"); | ||||||
|                     $(this).addClass('btn-primary').removeClass('btn-default'); |                     $(this).addClass('btn-primary').removeClass('btn-default'); | ||||||
|                     $url.val($this.data("link")); |                     $url.val($this.data("link")); | ||||||
|                     $clone.find('span.clone-url').text($this.data('link')); |                     $clone.find('span.clone-url').text($this.data('link')); | ||||||
|  | |||||||
| @ -5,6 +5,7 @@ | |||||||
| package routers | package routers | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
|  | 	"github.com/gogits/gogs/modules/base" | ||||||
| 	"github.com/gogits/gogs/modules/middleware" | 	"github.com/gogits/gogs/modules/middleware" | ||||||
| 	"github.com/gogits/gogs/routers/user" | 	"github.com/gogits/gogs/routers/user" | ||||||
| ) | ) | ||||||
| @ -14,6 +15,14 @@ func Home(ctx *middleware.Context) { | |||||||
| 		user.Dashboard(ctx) | 		user.Dashboard(ctx) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
|  | 	// Check auto-login. | ||||||
|  | 	userName := ctx.GetCookie(base.CookieUserName) | ||||||
|  | 	if len(userName) != 0 { | ||||||
|  | 		ctx.Redirect("/user/login") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	ctx.Data["PageIsHome"] = true | 	ctx.Data["PageIsHome"] = true | ||||||
| 	ctx.HTML(200, "home") | 	ctx.HTML(200, "home") | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										13
									
								
								routers/install.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								routers/install.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,13 @@ | |||||||
|  | // Copyright 2014 The Gogs Authors. All rights reserved. | ||||||
|  | // Use of this source code is governed by a MIT-style | ||||||
|  | // license that can be found in the LICENSE file. | ||||||
|  | 
 | ||||||
|  | package routers | ||||||
|  | 
 | ||||||
|  | import "github.com/gogits/gogs/modules/middleware" | ||||||
|  | 
 | ||||||
|  | func Install(ctx *middleware.Context){ | ||||||
|  | 	ctx.Data["PageIsInstall"] = true | ||||||
|  | 	ctx.Data["Title"] = "Install" | ||||||
|  | 	ctx.HTML(200,"install") | ||||||
|  | } | ||||||
| @ -45,6 +45,7 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	ctx.Data["Title"] = "Create issue" | 	ctx.Data["Title"] = "Create issue" | ||||||
|  | 	ctx.Data["IsRepoToolbarIssues"] = true | ||||||
| 
 | 
 | ||||||
| 	if ctx.Req.Method == "GET" { | 	if ctx.Req.Method == "GET" { | ||||||
| 		ctx.HTML(200, "issue/create") | 		ctx.HTML(200, "issue/create") | ||||||
|  | |||||||
| @ -6,11 +6,11 @@ package repo | |||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"path" | 	"path" | ||||||
|  | 	"path/filepath" | ||||||
| 	"strings" | 	"strings" | ||||||
| 
 | 
 | ||||||
| 	"github.com/codegangsta/martini" | 	"github.com/codegangsta/martini" | ||||||
| 
 | 
 | ||||||
| 	"github.com/gogits/git" |  | ||||||
| 	"github.com/gogits/webdav" | 	"github.com/gogits/webdav" | ||||||
| 
 | 
 | ||||||
| 	"github.com/gogits/gogs/models" | 	"github.com/gogits/gogs/models" | ||||||
| @ -96,6 +96,7 @@ func Single(ctx *middleware.Context, params martini.Params) { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	branchLink := "/" + ctx.Repo.Owner.LowerName + "/" + ctx.Repo.Repository.Name + "/src/" + params["branchname"] | 	branchLink := "/" + ctx.Repo.Owner.LowerName + "/" + ctx.Repo.Repository.Name + "/src/" + params["branchname"] | ||||||
|  | 	rawLink := "/" + ctx.Repo.Owner.LowerName + "/" + ctx.Repo.Repository.Name + "/raw/" + params["branchname"] | ||||||
| 
 | 
 | ||||||
| 	if len(treename) != 0 && repoFile == nil { | 	if len(treename) != 0 && repoFile == nil { | ||||||
| 		ctx.Handle(404, "repo.Single", nil) | 		ctx.Handle(404, "repo.Single", nil) | ||||||
| @ -103,12 +104,10 @@ func Single(ctx *middleware.Context, params martini.Params) { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if repoFile != nil && repoFile.IsFile() { | 	if repoFile != nil && repoFile.IsFile() { | ||||||
| 		if repoFile.Size > 1024*1024 || repoFile.Filemode != git.FileModeBlob { | 		if blob, err := repoFile.LookupBlob(); err != nil { | ||||||
| 			ctx.Data["FileIsLarge"] = true |  | ||||||
| 		} else if blob, err := repoFile.LookupBlob(); err != nil { |  | ||||||
| 			//log.Error("repo.Single(repoFile.LookupBlob): %v", err) |  | ||||||
| 			ctx.Handle(404, "repo.Single(repoFile.LookupBlob)", err) | 			ctx.Handle(404, "repo.Single(repoFile.LookupBlob)", err) | ||||||
| 		} else { | 		} else { | ||||||
|  | 			ctx.Data["FileSize"] = repoFile.Size | ||||||
| 			ctx.Data["IsFile"] = true | 			ctx.Data["IsFile"] = true | ||||||
| 			ctx.Data["FileName"] = repoFile.Name | 			ctx.Data["FileName"] = repoFile.Name | ||||||
| 			ext := path.Ext(repoFile.Name) | 			ext := path.Ext(repoFile.Name) | ||||||
| @ -116,13 +115,20 @@ func Single(ctx *middleware.Context, params martini.Params) { | |||||||
| 				ext = ext[1:] | 				ext = ext[1:] | ||||||
| 			} | 			} | ||||||
| 			ctx.Data["FileExt"] = ext | 			ctx.Data["FileExt"] = ext | ||||||
|  | 			ctx.Data["FileLink"] = rawLink + "/" + treename | ||||||
|  | 
 | ||||||
|  | 			data := blob.Contents() | ||||||
|  | 			_, isTextFile := base.IsTextFile(data) | ||||||
|  | 			ctx.Data["FileIsText"] = isTextFile | ||||||
| 
 | 
 | ||||||
| 			readmeExist := base.IsMarkdownFile(repoFile.Name) || base.IsReadmeFile(repoFile.Name) | 			readmeExist := base.IsMarkdownFile(repoFile.Name) || base.IsReadmeFile(repoFile.Name) | ||||||
| 			ctx.Data["ReadmeExist"] = readmeExist | 			ctx.Data["ReadmeExist"] = readmeExist | ||||||
| 			if readmeExist { | 			if readmeExist { | ||||||
| 				ctx.Data["FileContent"] = string(base.RenderMarkdown(blob.Contents(), "")) | 				ctx.Data["FileContent"] = string(base.RenderMarkdown(data, "")) | ||||||
| 			} else { | 			} else { | ||||||
| 				ctx.Data["FileContent"] = string(blob.Contents()) | 				if isTextFile { | ||||||
|  | 					ctx.Data["FileContent"] = string(data) | ||||||
|  | 				} | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| @ -150,18 +156,21 @@ func Single(ctx *middleware.Context, params martini.Params) { | |||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if readmeFile != nil { | 		if readmeFile != nil { | ||||||
|  | 			ctx.Data["ReadmeInSingle"] = true | ||||||
| 			ctx.Data["ReadmeExist"] = true | 			ctx.Data["ReadmeExist"] = true | ||||||
| 			// if file large than 1M not show it | 			if blob, err := readmeFile.LookupBlob(); err != nil { | ||||||
| 			if readmeFile.Size > 1024*1024 || readmeFile.Filemode != git.FileModeBlob { |  | ||||||
| 				ctx.Data["FileIsLarge"] = true |  | ||||||
| 			} else if blob, err := readmeFile.LookupBlob(); err != nil { |  | ||||||
| 				ctx.Handle(404, "repo.Single(readmeFile.LookupBlob)", err) | 				ctx.Handle(404, "repo.Single(readmeFile.LookupBlob)", err) | ||||||
| 				return | 				return | ||||||
| 			} else { | 			} else { | ||||||
| 				// current repo branch link | 				ctx.Data["FileSize"] = readmeFile.Size | ||||||
| 
 | 				ctx.Data["FileLink"] = rawLink + "/" + treename | ||||||
|  | 				data := blob.Contents() | ||||||
|  | 				_, isTextFile := base.IsTextFile(data) | ||||||
|  | 				ctx.Data["FileIsText"] = isTextFile | ||||||
| 				ctx.Data["FileName"] = readmeFile.Name | 				ctx.Data["FileName"] = readmeFile.Name | ||||||
| 				ctx.Data["FileContent"] = string(base.RenderMarkdown(blob.Contents(), branchLink)) | 				if isTextFile { | ||||||
|  | 					ctx.Data["FileContent"] = string(base.RenderMarkdown(data, branchLink)) | ||||||
|  | 				} | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @ -201,6 +210,44 @@ func Single(ctx *middleware.Context, params martini.Params) { | |||||||
| 	ctx.HTML(200, "repo/single") | 	ctx.HTML(200, "repo/single") | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func SingleDownload(ctx *middleware.Context, params martini.Params) { | ||||||
|  | 	if !ctx.Repo.IsValid { | ||||||
|  | 		ctx.Handle(404, "repo.SingleDownload", nil) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	if len(params["branchname"]) == 0 { | ||||||
|  | 		params["branchname"] = "master" | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	// Get tree path | ||||||
|  | 	treename := params["_1"] | ||||||
|  | 
 | ||||||
|  | 	repoFile, err := models.GetTargetFile(params["username"], params["reponame"], | ||||||
|  | 		params["branchname"], params["commitid"], treename) | ||||||
|  | 
 | ||||||
|  | 	if err != nil { | ||||||
|  | 		ctx.Handle(404, "repo.SingleDownload(GetTargetFile)", err) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	blob, err := repoFile.LookupBlob() | ||||||
|  | 	if err != nil { | ||||||
|  | 		ctx.Handle(404, "repo.SingleDownload(LookupBlob)", err) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	data := blob.Contents() | ||||||
|  | 	contentType, isTextFile := base.IsTextFile(data) | ||||||
|  | 	ctx.Res.Header().Set("Content-Type", contentType) | ||||||
|  | 	if !isTextFile { | ||||||
|  | 		ctx.Res.Header().Set("Content-Type", contentType) | ||||||
|  | 		ctx.Res.Header().Set("Content-Disposition", "attachment; filename="+filepath.Base(treename)) | ||||||
|  | 		ctx.Res.Header().Set("Content-Transfer-Encoding", "binary") | ||||||
|  | 	} | ||||||
|  | 	ctx.Res.Write(data) | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func Http(ctx *middleware.Context, params martini.Params) { | func Http(ctx *middleware.Context, params martini.Params) { | ||||||
| 	/*if !ctx.Repo.IsValid { | 	/*if !ctx.Repo.IsValid { | ||||||
| 		return | 		return | ||||||
|  | |||||||
							
								
								
									
										87
									
								
								serve.go
									
									
									
									
									
								
							
							
						
						
									
										87
									
								
								serve.go
									
									
									
									
									
								
							| @ -13,6 +13,7 @@ import ( | |||||||
| 	"os/exec" | 	"os/exec" | ||||||
| 	"strconv" | 	"strconv" | ||||||
| 	"strings" | 	"strings" | ||||||
|  | 	"time" | ||||||
| 
 | 
 | ||||||
| 	"github.com/codegangsta/cli" | 	"github.com/codegangsta/cli" | ||||||
| 	"github.com/gogits/gogs/modules/log" | 	"github.com/gogits/gogs/modules/log" | ||||||
| @ -45,7 +46,10 @@ gogs serv provide access auth for repositories`, | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func init() { | func init() { | ||||||
| 	log.NewLogger(10000, "file", fmt.Sprintf(`{"filename":"%s"}`, "log/serv.log")) | 	level := "0" | ||||||
|  | 	os.MkdirAll("log", os.ModePerm) | ||||||
|  | 	log.NewLogger(10000, "file", fmt.Sprintf(`{"level":%s,"filename":"%s"}`, level, "log/serv.log")) | ||||||
|  | 	log.Info("start logging...") | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func parseCmd(cmd string) (string, string) { | func parseCmd(cmd string) (string, string) { | ||||||
| @ -72,7 +76,6 @@ func runServ(k *cli.Context) { | |||||||
| 	base.NewConfigContext() | 	base.NewConfigContext() | ||||||
| 	models.LoadModelsConfig() | 	models.LoadModelsConfig() | ||||||
| 	models.NewEngine() | 	models.NewEngine() | ||||||
| 	base.NewLogService() |  | ||||||
| 
 | 
 | ||||||
| 	keys := strings.Split(os.Args[2], "-") | 	keys := strings.Split(os.Args[2], "-") | ||||||
| 	if len(keys) != 2 { | 	if len(keys) != 2 { | ||||||
| @ -109,25 +112,32 @@ func runServ(k *cli.Context) { | |||||||
| 		repoName = repoName[:len(repoName)-4] | 		repoName = repoName[:len(repoName)-4] | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	isWrite := In(verb, COMMANDS_WRITE) | ||||||
|  | 	isRead := In(verb, COMMANDS_READONLY) | ||||||
|  | 
 | ||||||
| 	repo, err := models.GetRepositoryByName(user.Id, repoName) | 	repo, err := models.GetRepositoryByName(user.Id, repoName) | ||||||
| 	var isExist bool = true | 	var isExist bool = true | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		if err == models.ErrRepoNotExist { | 		if err == models.ErrRepoNotExist { | ||||||
| 			isExist = false | 			isExist = false | ||||||
|  | 			if isRead { | ||||||
|  | 				println("Repository", user.Name+"/"+repoName, "is not exist") | ||||||
|  | 				return | ||||||
|  | 			} | ||||||
| 		} else { | 		} else { | ||||||
| 			println("Unavilable repository", err) | 			println("Get repository error:", err) | ||||||
|  | 			log.Error(err.Error()) | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	isWrite := In(verb, COMMANDS_WRITE) | 	// access check | ||||||
| 	isRead := In(verb, COMMANDS_READONLY) |  | ||||||
| 
 |  | ||||||
| 	switch { | 	switch { | ||||||
| 	case isWrite: | 	case isWrite: | ||||||
| 		has, err := models.HasAccess(user.Name, repoName, models.AU_WRITABLE) | 		has, err := models.HasAccess(user.Name, repoName, models.AU_WRITABLE) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			println("Inernel error:", err) | 			println("Inernel error:", err) | ||||||
|  | 			log.Error(err.Error()) | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 		if !has { | 		if !has { | ||||||
| @ -138,12 +148,14 @@ func runServ(k *cli.Context) { | |||||||
| 		has, err := models.HasAccess(user.Name, repoName, models.AU_READABLE) | 		has, err := models.HasAccess(user.Name, repoName, models.AU_READABLE) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			println("Inernel error") | 			println("Inernel error") | ||||||
|  | 			log.Error(err.Error()) | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 		if !has { | 		if !has { | ||||||
| 			has, err = models.HasAccess(user.Name, repoName, models.AU_WRITABLE) | 			has, err = models.HasAccess(user.Name, repoName, models.AU_WRITABLE) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				println("Inernel error") | 				println("Inernel error") | ||||||
|  | 				log.Error(err.Error()) | ||||||
| 				return | 				return | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| @ -156,28 +168,30 @@ func runServ(k *cli.Context) { | |||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	var rep *git.Repository | ||||||
|  | 	repoPath := models.RepoPath(user.Name, repoName) | ||||||
| 	if !isExist { | 	if !isExist { | ||||||
| 		if isRead { | 		if isWrite { | ||||||
| 			println("Repository", user.Name+"/"+repoName, "is not exist") | 			_, err = models.CreateRepository(user, repoName, "", "", "", false, true) | ||||||
| 			return |  | ||||||
| 		} else if isWrite { |  | ||||||
| 			_, err := models.CreateRepository(user, repoName, "", "", "", false, true) |  | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				println("Create repository failed") | 				println("Create repository failed") | ||||||
|  | 				log.Error(err.Error()) | ||||||
| 				return | 				return | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	rep, err := git.OpenRepository(models.RepoPath(user.Name, repoName)) | 		rep, err = git.OpenRepository(repoPath) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 		println(err.Error()) | 			println("OpenRepository failed:", err.Error()) | ||||||
|  | 			log.Error(err.Error()) | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 	refs, err := rep.AllReferencesMap() | 	refs, err := rep.AllReferencesMap() | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		println(err.Error()) | 		println("Get All References failed:", err.Error()) | ||||||
|  | 		log.Error(err.Error()) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| @ -194,17 +208,17 @@ func runServ(k *cli.Context) { | |||||||
| 
 | 
 | ||||||
| 	if err = gitcmd.Run(); err != nil { | 	if err = gitcmd.Run(); err != nil { | ||||||
| 		println("execute command error:", err.Error()) | 		println("execute command error:", err.Error()) | ||||||
| 	} | 		log.Error(err.Error()) | ||||||
| 
 |  | ||||||
| 	if !strings.HasPrefix(cmd, "git-receive-pack") { |  | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// update | 	if isRead { | ||||||
| 	//w, _ := os.Create("serve.log") | 		return | ||||||
| 	//defer w.Close() | 	} | ||||||
| 	//log.SetOutput(w) |  | ||||||
| 
 | 
 | ||||||
|  | 	time.Sleep(time.Second) | ||||||
|  | 
 | ||||||
|  | 	// find push reference name | ||||||
| 	var t = "ok refs/heads/" | 	var t = "ok refs/heads/" | ||||||
| 	var i int | 	var i int | ||||||
| 	var refname string | 	var refname string | ||||||
| @ -220,24 +234,31 @@ func runServ(k *cli.Context) { | |||||||
| 			refname = l[idx+len(t):] | 			refname = l[idx+len(t):] | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | 	if refname == "" { | ||||||
|  | 		println("No find any reference name:", b.String()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	var ref *git.Reference | 	var ref *git.Reference | ||||||
| 	var ok bool | 	var ok bool | ||||||
| 
 |  | ||||||
| 	var l *list.List | 	var l *list.List | ||||||
| 	//log.Info("----", refname, "-----") | 	//log.Info("----", refname, "-----") | ||||||
| 	if ref, ok = refs[refname]; !ok { | 	if ref, ok = refs[refname]; !ok { | ||||||
|  | 		// for new branch | ||||||
| 		refs, err = rep.AllReferencesMap() | 		refs, err = rep.AllReferencesMap() | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			println(err.Error()) | 			println("Get All References failed:", err.Error()) | ||||||
|  | 			log.Error(err.Error()) | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 		if ref, ok = refs[refname]; !ok { | 		if ref, ok = refs[refname]; !ok { | ||||||
| 			log.Trace("unknow reference name -", refname, "-", b.String()) | 			log.Error("unknow reference name -", refname, "-", b.String()) | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 		l, err = ref.AllCommits() | 		l, err = ref.AllCommits() | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			println(err.Error()) | 			println("Get All Commits failed:", err.Error()) | ||||||
|  | 			log.Error(err.Error()) | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 	} else { | 	} else { | ||||||
| @ -246,20 +267,23 @@ func runServ(k *cli.Context) { | |||||||
| 		//log.Info("00000", ref.Oid.String()) | 		//log.Info("00000", ref.Oid.String()) | ||||||
| 		last, err = ref.LastCommit() | 		last, err = ref.LastCommit() | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			println(err.Error()) | 			println("Get last commit failed:", err.Error()) | ||||||
|  | 			log.Error(err.Error()) | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		ref2, err := rep.LookupReference(ref.Name) | 		ref2, err := rep.LookupReference(ref.Name) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			println(err.Error()) | 			println("look up reference failed:", err.Error()) | ||||||
|  | 			log.Error(err.Error()) | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		//log.Info("11111", ref2.Oid.String()) | 		//log.Info("11111", ref2.Oid.String()) | ||||||
| 		before, err := ref2.LastCommit() | 		before, err := ref2.LastCommit() | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			println(err.Error()) | 			println("Get last commit failed:", err.Error()) | ||||||
|  | 			log.Error(err.Error()) | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 		//log.Info("----", before.Id(), "-----", last.Id()) | 		//log.Info("----", before.Id(), "-----", last.Id()) | ||||||
| @ -280,13 +304,8 @@ func runServ(k *cli.Context) { | |||||||
| 		repo.Id, repoName, refname, &base.PushCommits{l.Len(), commits}); err != nil { | 		repo.Id, repoName, refname, &base.PushCommits{l.Len(), commits}); err != nil { | ||||||
| 		log.Error("runUpdate.models.CommitRepoAction: %v", err, commits) | 		log.Error("runUpdate.models.CommitRepoAction: %v", err, commits) | ||||||
| 	} else { | 	} else { | ||||||
| 		//log.Info("refname", refname) |  | ||||||
| 		//log.Info("Listen: %v", cmd) |  | ||||||
| 		//fmt.Println("...", cmd) |  | ||||||
| 
 |  | ||||||
| 		//runUpdate(k) |  | ||||||
| 		c := exec.Command("git", "update-server-info") | 		c := exec.Command("git", "update-server-info") | ||||||
| 		c.Dir = models.RepoPath(user.Name, repoName) | 		c.Dir = repoPath | ||||||
| 		err := c.Run() | 		err := c.Run() | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			log.Error("update-server-info: %v", err) | 			log.Error("update-server-info: %v", err) | ||||||
|  | |||||||
| @ -12,7 +12,7 @@ | |||||||
|             <a class="navbar-right gogs-nav-item{{if .PageIsUserSetting}} active{{end}}" href="/user/setting"  data-toggle="tooltip" data-placement="bottom" title="Setting"><i class="fa fa-cogs fa-lg"></i></a> |             <a class="navbar-right gogs-nav-item{{if .PageIsUserSetting}} active{{end}}" href="/user/setting"  data-toggle="tooltip" data-placement="bottom" title="Setting"><i class="fa fa-cogs fa-lg"></i></a> | ||||||
|             {{if .IsAdmin}}<a class="navbar-right gogs-nav-item{{if .PageIsAdmin}} active{{end}}" href="/admin"  data-toggle="tooltip" data-placement="bottom" title="Admin"><i class="fa fa-gear fa-lg"></i></a>{{end}} |             {{if .IsAdmin}}<a class="navbar-right gogs-nav-item{{if .PageIsAdmin}} active{{end}}" href="/admin"  data-toggle="tooltip" data-placement="bottom" title="Admin"><i class="fa fa-gear fa-lg"></i></a>{{end}} | ||||||
|             {{else}}<a id="gogs-nav-signin" class="gogs-nav-item navbar-right navbar-btn btn btn-danger" href="/user/login/">Sign In</a> |             {{else}}<a id="gogs-nav-signin" class="gogs-nav-item navbar-right navbar-btn btn btn-danger" href="/user/login/">Sign In</a> | ||||||
|             <a id="gogs-nav-signup" class="gogs-nav-item navbar-right navbar-btn btn btn-info" href="/user/sign_up/">Sign Up</a>{{end}} |             <a id="gogs-nav-signup" class="gogs-nav-item navbar-right" href="/user/sign_up/">Sign Up</a>{{end}} | ||||||
|         </nav> |         </nav> | ||||||
|     </div> |     </div> | ||||||
| </div> | </div> | ||||||
|  | |||||||
							
								
								
									
										70
									
								
								templates/install.tmpl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								templates/install.tmpl
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,70 @@ | |||||||
|  | {{template "base/head" .}} | ||||||
|  | <div id="gogs-body" class="container"> | ||||||
|  |     <form action="/install" method="post" class="form-horizontal gogs-card" id="gogs-install-card"> | ||||||
|  |         {{.CsrfTokenHtml}} | ||||||
|  |         <h3>Install Steps</h3> | ||||||
|  |         <div class="alert alert-danger form-error{{if .HasError}}{{else}} hidden{{end}}">{{.ErrorMsg}}</div> | ||||||
|  |         <p class="help-block text-center">GoGits need MySQL or PostgreSQL server</p> | ||||||
|  |         <div class="form-group {{if .Err_User}}has-error has-feedback{{end}}"> | ||||||
|  |             <label class="col-md-3 control-label"><strong>MySQL </strong>Host: </label> | ||||||
|  |             <div class="col-md-8"> | ||||||
|  |                 <input name="host" class="form-control" placeholder="Type mysql server ip or domain" value="localhost" required="required"> | ||||||
|  |             </div> | ||||||
|  |         </div> | ||||||
|  |         <div class="form-group {{if .Err_User}}has-error has-feedback{{end}}"> | ||||||
|  |             <label class="col-md-3 control-label">Port: </label> | ||||||
|  |             <div class="col-md-8"> | ||||||
|  |                 <input name="port" class="form-control" placeholder="Type mysql server port" value="3306" required="required"> | ||||||
|  |             </div> | ||||||
|  |         </div> | ||||||
|  |         <div class="form-group {{if .Err_User}}has-error has-feedback{{end}}"> | ||||||
|  |             <label class="col-md-3 control-label">User: </label> | ||||||
|  |             <div class="col-md-8"> | ||||||
|  |                 <input name="user" class="form-control" placeholder="Type mysql username" required="required"> | ||||||
|  |             </div> | ||||||
|  |         </div> | ||||||
|  |         <div class="form-group {{if .Err_Password}}has-error has-feedback{{end}}"> | ||||||
|  |             <label class="col-md-3 control-label">Password: </label> | ||||||
|  |             <div class="col-md-8"> | ||||||
|  |                 <input name="passwd" type="password" class="form-control" placeholder="Type mysql password" required="required"> | ||||||
|  |             </div> | ||||||
|  |         </div> | ||||||
|  |         <div class="form-group {{if .Err_Password}}has-error has-feedback{{end}}"> | ||||||
|  |             <label class="col-md-3 control-label">Database: </label> | ||||||
|  |             <div class="col-md-8"> | ||||||
|  |                 <input name="database" type="text" class="form-control" placeholder="Type mysql database name" value="gogs" required="required"> | ||||||
|  |                 <p class="help-block">Recommend use INNODB engine with utf8_general_ci charset.</p> | ||||||
|  |             </div> | ||||||
|  |         </div> | ||||||
|  | 
 | ||||||
|  |         <div class="form-group"> | ||||||
|  |             <div class="col-md-8 col-md-offset-3"> | ||||||
|  |                    <button class="btn btn-sm btn-info">Test Connection</button> | ||||||
|  |             </div> | ||||||
|  |         </div> | ||||||
|  | 
 | ||||||
|  |         <hr/> | ||||||
|  | 
 | ||||||
|  |         <p class="help-block text-center">General settings for GoGits</p> | ||||||
|  | 
 | ||||||
|  |         <div class="form-group {{if .Err_Password}}has-error has-feedback{{end}}"> | ||||||
|  |             <label class="col-md-3 control-label">Repository Path: </label> | ||||||
|  |             <div class="col-md-8"> | ||||||
|  |                 <input name="repo-path" type="text" class="form-control" placeholder="Type your repository directory" value="/var/gogs/repostiory" required="required"> | ||||||
|  |                 <p class="help-block">The git copy of each repository is saved in this directory.</p> | ||||||
|  |             </div> | ||||||
|  |         </div> | ||||||
|  |         <div class="form-group {{if .Err_Password}}has-error has-feedback{{end}}"> | ||||||
|  |             <label class="col-md-3 control-label">System User: </label> | ||||||
|  |             <div class="col-md-8"> | ||||||
|  |                 <input name="system-user" type="text" class="form-control" placeholder="Type mysql password" value="root" required="required"> | ||||||
|  |                 <p class="help-block">The user has access to visit and run GoGits.</p> | ||||||
|  |             </div> | ||||||
|  |         </div> | ||||||
|  |         <hr/> | ||||||
|  |         <div class="form-group text-center"> | ||||||
|  |             <a class="btn btn-danger btn-lg">Install GoGits</a> | ||||||
|  |         </div> | ||||||
|  |     </form> | ||||||
|  | </div> | ||||||
|  | {{template "base/footer" .}} | ||||||
							
								
								
									
										10
									
								
								templates/issue/create.tmpl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								templates/issue/create.tmpl
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | |||||||
|  | {{template "base/head" .}} | ||||||
|  | {{template "base/navbar" .}} | ||||||
|  | {{template "repo/nav" .}} | ||||||
|  | {{template "repo/toolbar" .}} | ||||||
|  | <div id="gogs-body" class="container"> | ||||||
|  |     <div id="gogs-source"> | ||||||
|  |         new-issues | ||||||
|  |     </div> | ||||||
|  | </div> | ||||||
|  | {{template "base/footer" .}} | ||||||
| @ -4,6 +4,7 @@ | |||||||
| {{template "repo/toolbar" .}} | {{template "repo/toolbar" .}} | ||||||
| <div id="gogs-body" class="container"> | <div id="gogs-body" class="container"> | ||||||
|     <div id="gogs-source"> |     <div id="gogs-source"> | ||||||
|  |         issues | ||||||
|     </div> |     </div> | ||||||
| </div> | </div> | ||||||
| {{template "base/footer" .}} | {{template "base/footer" .}} | ||||||
| @ -30,6 +30,10 @@ | |||||||
|                             </span> |                             </span> | ||||||
|                         </div> |                         </div> | ||||||
|                         <p class="help-block text-center">Need help cloning? Visit <a href="#">Help</a>!</p> |                         <p class="help-block text-center">Need help cloning? Visit <a href="#">Help</a>!</p> | ||||||
|  |                         <hr/> | ||||||
|  |                         <div class="clone-zip text-center"> | ||||||
|  |                             <a class="btn btn-success btn-lg" href="#"><i class="fa fa-suitcase"></i>Download ZIP</a> | ||||||
|  |                         </div> | ||||||
|                     </div> |                     </div> | ||||||
|                 </div> |                 </div> | ||||||
|                 <div class="btn-group {{if .IsRepositoryWatching}}watching{{else}}no-watching{{end}}" id="gogs-repo-watching" data-watch="/{{.Owner.Name}}/{{.Repository.Name}}/action/watch" data-unwatch="/{{.Owner.Name}}/{{.Repository.Name}}/action/unwatch"> |                 <div class="btn-group {{if .IsRepositoryWatching}}watching{{else}}no-watching{{end}}" id="gogs-repo-watching" data-watch="/{{.Owner.Name}}/{{.Repository.Name}}/action/watch" data-unwatch="/{{.Owner.Name}}/{{.Repository.Name}}/action/unwatch"> | ||||||
|  | |||||||
| @ -9,7 +9,7 @@ | |||||||
|         {{else}} |         {{else}} | ||||||
|         <div class="source-toolbar"> |         <div class="source-toolbar"> | ||||||
|             {{ $n := len .Treenames}} |             {{ $n := len .Treenames}} | ||||||
|             {{if not .IsFile}}<button class="btn btn-default pull-right"><i class="fa fa-plus-square"></i>Add File</button>{{end}} |             {{if not .IsFile}}<button class="btn btn-default pull-right hidden"><i class="fa fa-plus-square"></i>Add File</button>{{end}} | ||||||
|             <div class="dropdown branch-switch"> |             <div class="dropdown branch-switch"> | ||||||
|                 <a href="#" class="btn btn-success dropdown-toggle" data-toggle="dropdown"><i class="fa fa-chain"></i>{{.Branchname}}   |                 <a href="#" class="btn btn-success dropdown-toggle" data-toggle="dropdown"><i class="fa fa-chain"></i>{{.Branchname}}   | ||||||
|                     <b class="caret"></b></a> |                     <b class="caret"></b></a> | ||||||
|  | |||||||
| @ -2,13 +2,28 @@ | |||||||
|     <div class="panel-heading file-head"> |     <div class="panel-heading file-head"> | ||||||
|         {{if .ReadmeExist}} |         {{if .ReadmeExist}} | ||||||
|             <i class="icon fa fa-book"></i> |             <i class="icon fa fa-book"></i> | ||||||
|  |             {{if .ReadmeInSingle}} | ||||||
|  |             {{.FileName}} | ||||||
|  |             {{else}} | ||||||
|  |             {{.FileName}} <span class="file-size">{{FileSize .FileSize}}</span> | ||||||
|  |             {{end}} | ||||||
|         {{else}} |         {{else}} | ||||||
|             <i class="icon fa fa-file-text-o"></i> |             <i class="icon fa fa-file-text-o"></i> | ||||||
|         {{end}}{{.FileName}} |             {{.FileName}} <span class="file-size">{{FileSize .FileSize}}</span> | ||||||
|  |         {{end}} | ||||||
|  |         {{if not .ReadmeInSingle}} | ||||||
|  |         <div class="btn-group pull-right"> | ||||||
|  |             <a class="btn btn-default hidden" href="#">Edit</a> | ||||||
|  |             <a class="btn btn-default" href="{{.FileLink}}">Raw</a> | ||||||
|  |             <a class="btn btn-default hidden" href="#">Blame</a> | ||||||
|  |             <a class="btn btn-default hidden" href="#">History</a> | ||||||
|  |             <a class="btn btn-danger hidden" href="#">Delete</a> | ||||||
|         </div> |         </div> | ||||||
|     {{if .FileIsLarge}} |         {{end}} | ||||||
|         <div class="panel-footer"> |     </div> | ||||||
|             Large file size 1000kb |     {{if not .FileIsText}} | ||||||
|  |         <div class="panel-footer text-center"> | ||||||
|  |             <a href="{{.FileLink}}" class="btn btn-default">View Raw</a> | ||||||
|         </div> |         </div> | ||||||
|     {{else}} |     {{else}} | ||||||
|         {{if .ReadmeExist}} |         {{if .ReadmeExist}} | ||||||
| @ -21,7 +36,7 @@ | |||||||
|                     <tbody> |                     <tbody> | ||||||
|                         <tr> |                         <tr> | ||||||
|                             <td class="lines-num"></td> |                             <td class="lines-num"></td> | ||||||
|                             <td class="lines-code markdown"><pre class="prettyprint linenums lang-{{.FileExt}}">{{.FileContent}}</pre></td> |                             <td class="lines-code markdown"><pre class="prettyprint linenums{{if .FileExt}} lang-{{.FileExt}}{{end}}">{{.FileContent}}</pre></td> | ||||||
|                         </tr> |                         </tr> | ||||||
|                     </tbody> |                     </tbody> | ||||||
|                 </table> |                 </table> | ||||||
|  | |||||||
							
								
								
									
										5
									
								
								web.go
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								web.go
									
									
									
									
									
								
							| @ -89,7 +89,8 @@ func runWeb(*cli.Context) { | |||||||
| 	reqSignOut := middleware.Toggle(&middleware.ToggleOptions{SignOutRequire: true}) | 	reqSignOut := middleware.Toggle(&middleware.ToggleOptions{SignOutRequire: true}) | ||||||
| 
 | 
 | ||||||
| 	// Routers. | 	// Routers. | ||||||
| 	m.Get("/", reqSignIn, routers.Home) | 	m.Get("/", ignSignIn, routers.Home) | ||||||
|  | 	m.Get("/install",routers.Install) | ||||||
| 	m.Get("/issues", reqSignIn, user.Issues) | 	m.Get("/issues", reqSignIn, user.Issues) | ||||||
| 	m.Get("/pulls", reqSignIn, user.Pulls) | 	m.Get("/pulls", reqSignIn, user.Pulls) | ||||||
| 	m.Get("/stars", reqSignIn, user.Stars) | 	m.Get("/stars", reqSignIn, user.Stars) | ||||||
| @ -152,6 +153,7 @@ func runWeb(*cli.Context) { | |||||||
| 		r.Get("/branches", repo.Branches) | 		r.Get("/branches", repo.Branches) | ||||||
| 		r.Get("/src/:branchname", repo.Single) | 		r.Get("/src/:branchname", repo.Single) | ||||||
| 		r.Get("/src/:branchname/**", repo.Single) | 		r.Get("/src/:branchname/**", repo.Single) | ||||||
|  | 		r.Get("/raw/:branchname/**", repo.SingleDownload) | ||||||
| 		r.Get("/commits/:branchname", repo.Commits) | 		r.Get("/commits/:branchname", repo.Commits) | ||||||
| 		r.Get("/commits/:branchname", repo.Commits) | 		r.Get("/commits/:branchname", repo.Commits) | ||||||
| 	}, ignSignIn, middleware.RepoAssignment(true)) | 	}, ignSignIn, middleware.RepoAssignment(true)) | ||||||
| @ -161,6 +163,7 @@ func runWeb(*cli.Context) { | |||||||
| 	m.Get("/:username/:reponame/commit/:commitid", ignSignIn, middleware.RepoAssignment(true), repo.Diff) | 	m.Get("/:username/:reponame/commit/:commitid", ignSignIn, middleware.RepoAssignment(true), repo.Diff) | ||||||
| 
 | 
 | ||||||
| 	m.Group("/:username", func(r martini.Router) { | 	m.Group("/:username", func(r martini.Router) { | ||||||
|  | 		r.Get("/:reponame", middleware.RepoAssignment(true), repo.Single) | ||||||
| 		r.Get("/:reponame", middleware.RepoAssignment(true), repo.Single) | 		r.Get("/:reponame", middleware.RepoAssignment(true), repo.Single) | ||||||
| 		r.Any("/:reponame/**", repo.Http) | 		r.Any("/:reponame/**", repo.Http) | ||||||
| 	}, ignSignIn) | 	}, ignSignIn) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user