From 1d30f545d65fe2d7fe6e0a88fbb693ca68e9417e Mon Sep 17 00:00:00 2001 From: lunny <xiaolunwen@gmail.com> Date: Mon, 24 Mar 2014 14:28:20 +0000 Subject: [PATCH 01/21] Init commit --- .gitignore | 22 ++++++++++++++++++++++ LICENSE | 27 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..6cd1df2b7a --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# 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 \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..3af16b0724 --- /dev/null +++ b/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the {organization} nor the names of its + contributors may be used to endorse or promote products derived from + 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. \ No newline at end of file From 3473aa9e42b670aecaf328c8d281d91b0f7f8923 Mon Sep 17 00:00:00 2001 From: FuXiaoHei <fuxiaohei@hexiaz.com> Date: Mon, 24 Mar 2014 23:30:02 +0800 Subject: [PATCH 02/21] repo single file raw button --- templates/repo/single_file.tmpl | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/repo/single_file.tmpl b/templates/repo/single_file.tmpl index 40ef44eb1b..2a28f0b54a 100644 --- a/templates/repo/single_file.tmpl +++ b/templates/repo/single_file.tmpl @@ -5,6 +5,7 @@ {{else}} <i class="icon fa fa-file-text-o"></i> {{end}}{{.FileName}} + <a class="btn btn-default pull-right" href="#">Raw</a> </div> {{if .FileIsLarge}} <div class="panel-footer"> From 40b22822fcc082164b200d075708f00d977df67a Mon Sep 17 00:00:00 2001 From: Unknown <joe2010xtmf@163.com> Date: Mon, 24 Mar 2014 11:44:47 -0400 Subject: [PATCH 03/21] Update README --- README.md | 1 + README_ZH.md | 1 + models/repo.go | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 104b7eab55..a39a92a322 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ There are two ways to install Gogs: - 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). - Usage and modification from [beego](http://beego.me) modules. +- Thanks [gobuild.io](http://gobuild.io) for providing binary compile and download service. ## Contributors diff --git a/README_ZH.md b/README_ZH.md index 838e30a0ef..440f952f86 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -49,6 +49,7 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依 - 基于 [GoBlog](https://github.com/fuxiaohei/goblog) 修改的系统监视状态。 - [beego](http://beego.me) 模块的使用与修改。 - [martini](http://martini.codegangsta.io/) 的路由与中间件机制。 +- 感谢 [gobuild.io](http://gobuild.io) 提供二进制编译与下载服务。 ## 贡献成员 diff --git a/models/repo.go b/models/repo.go index a76966b057..ff9090df36 100644 --- a/models/repo.go +++ b/models/repo.go @@ -109,7 +109,7 @@ func IsRepositoryExist(user *User, repoName string) (bool, error) { var ( // 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. From 92a6058e29eb5f9cd655c3b1f8f43fd6d46fe5a4 Mon Sep 17 00:00:00 2001 From: FuXiaoHei <fuxiaohei@hexiaz.com> Date: Mon, 24 Mar 2014 23:53:26 +0800 Subject: [PATCH 04/21] zip download button, repo single file buttons --- public/js/app.js | 2 +- templates/repo/nav.tmpl | 4 ++++ templates/repo/single.tmpl | 2 +- templates/repo/single_file.tmpl | 8 +++++++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index 9a58a6f2f2..f98fd03f82 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -291,7 +291,7 @@ function initRepository() { $clone.find('button[data-link]').on("click",function (e) { var $this = $(this); 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'); $url.val($this.data("link")); $clone.find('span.clone-url').text($this.data('link')); diff --git a/templates/repo/nav.tmpl b/templates/repo/nav.tmpl index 080cb72e57..2770328cb1 100644 --- a/templates/repo/nav.tmpl +++ b/templates/repo/nav.tmpl @@ -30,6 +30,10 @@ </span> </div> <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 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"> diff --git a/templates/repo/single.tmpl b/templates/repo/single.tmpl index a1c3cfbb26..56e6746c76 100644 --- a/templates/repo/single.tmpl +++ b/templates/repo/single.tmpl @@ -9,7 +9,7 @@ {{else}} <div class="source-toolbar"> {{ $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"> <a href="#" class="btn btn-success dropdown-toggle" data-toggle="dropdown"><i class="fa fa-chain"></i>{{.Branchname}} <b class="caret"></b></a> diff --git a/templates/repo/single_file.tmpl b/templates/repo/single_file.tmpl index 2a28f0b54a..7f07033703 100644 --- a/templates/repo/single_file.tmpl +++ b/templates/repo/single_file.tmpl @@ -3,9 +3,15 @@ {{if .ReadmeExist}} <i class="icon fa fa-book"></i> {{else}} + <div class="btn-group pull-right"> + <a class="btn btn-default hidden" href="#">Edit</a> + <a class="btn btn-default" href="#">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> <i class="icon fa fa-file-text-o"></i> {{end}}{{.FileName}} - <a class="btn btn-default pull-right" href="#">Raw</a> </div> {{if .FileIsLarge}} <div class="panel-footer"> From ff362484191d08db2e2bda238934b780139b9048 Mon Sep 17 00:00:00 2001 From: slene <vslene@gmail.com> Date: Mon, 24 Mar 2014 23:56:32 +0800 Subject: [PATCH 05/21] raw download --- modules/base/markdown.go | 9 ++++ routers/repo/repo.go | 74 ++++++++++++++++++++++++++------- templates/repo/single_file.tmpl | 12 +++--- web.go | 2 + 4 files changed, 77 insertions(+), 20 deletions(-) diff --git a/modules/base/markdown.go b/modules/base/markdown.go index 05ce0c833c..c722f04b2e 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -6,6 +6,7 @@ package base import ( "bytes" + "net/http" "path" "path/filepath" "strings" @@ -42,6 +43,14 @@ func IsMarkdownFile(name string) bool { 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 { name = strings.ToLower(name) if len(name) < 6 { diff --git a/routers/repo/repo.go b/routers/repo/repo.go index a055b416c2..76d55554bc 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -6,11 +6,11 @@ package repo import ( "path" + "path/filepath" "strings" "github.com/codegangsta/martini" - "github.com/gogits/git" "github.com/gogits/webdav" "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"] + rawLink := "/" + ctx.Repo.Owner.LowerName + "/" + ctx.Repo.Repository.Name + "/raw/" + params["branchname"] if len(treename) != 0 && repoFile == 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.Size > 1024*1024 || repoFile.Filemode != git.FileModeBlob { - ctx.Data["FileIsLarge"] = true - } else if blob, err := repoFile.LookupBlob(); err != nil { - //log.Error("repo.Single(repoFile.LookupBlob): %v", err) + if blob, err := repoFile.LookupBlob(); err != nil { ctx.Handle(404, "repo.Single(repoFile.LookupBlob)", err) } else { + ctx.Data["FileSize"] = repoFile.Size ctx.Data["IsFile"] = true ctx.Data["FileName"] = repoFile.Name ext := path.Ext(repoFile.Name) @@ -116,13 +115,20 @@ func Single(ctx *middleware.Context, params martini.Params) { ext = ext[1:] } 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) ctx.Data["ReadmeExist"] = readmeExist if readmeExist { - ctx.Data["FileContent"] = string(base.RenderMarkdown(blob.Contents(), "")) + ctx.Data["FileContent"] = string(base.RenderMarkdown(data, "")) } else { - ctx.Data["FileContent"] = string(blob.Contents()) + if isTextFile { + ctx.Data["FileContent"] = string(data) + } } } @@ -151,17 +157,19 @@ func Single(ctx *middleware.Context, params martini.Params) { if readmeFile != nil { ctx.Data["ReadmeExist"] = true - // if file large than 1M not show it - if readmeFile.Size > 1024*1024 || readmeFile.Filemode != git.FileModeBlob { - ctx.Data["FileIsLarge"] = true - } else if blob, err := readmeFile.LookupBlob(); err != nil { + if blob, err := readmeFile.LookupBlob(); err != nil { ctx.Handle(404, "repo.Single(readmeFile.LookupBlob)", err) return } 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["FileContent"] = string(base.RenderMarkdown(blob.Contents(), branchLink)) + if isTextFile { + ctx.Data["FileContent"] = string(base.RenderMarkdown(data, branchLink)) + } } } } @@ -201,6 +209,44 @@ func Single(ctx *middleware.Context, params martini.Params) { 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) { /*if !ctx.Repo.IsValid { return diff --git a/templates/repo/single_file.tmpl b/templates/repo/single_file.tmpl index 7f07033703..9755812285 100644 --- a/templates/repo/single_file.tmpl +++ b/templates/repo/single_file.tmpl @@ -5,17 +5,17 @@ {{else}} <div class="btn-group pull-right"> <a class="btn btn-default hidden" href="#">Edit</a> - <a class="btn btn-default" href="#">Raw</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> <i class="icon fa fa-file-text-o"></i> - {{end}}{{.FileName}} + {{end}}{{.FileName}} {{FileSize .FileSize}} </div> - {{if .FileIsLarge}} - <div class="panel-footer"> - Large file size 1000kb + {{if not .FileIsText}} + <div class="panel-footer text-center"> + <a href="{{.FileLink}}" class="btn btn-default">View Raw</a> </div> {{else}} {{if .ReadmeExist}} @@ -28,7 +28,7 @@ <tbody> <tr> <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> </tbody> </table> diff --git a/web.go b/web.go index 9717c9384a..e4c8eb5536 100644 --- a/web.go +++ b/web.go @@ -152,6 +152,7 @@ func runWeb(*cli.Context) { r.Get("/branches", repo.Branches) 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) }, ignSignIn, middleware.RepoAssignment(true)) @@ -161,6 +162,7 @@ func runWeb(*cli.Context) { m.Get("/:username/:reponame/commit/:commitid", ignSignIn, middleware.RepoAssignment(true), repo.Diff) m.Group("/:username", func(r martini.Router) { + r.Get("/:reponame", middleware.RepoAssignment(true), repo.Single) r.Get("/:reponame", middleware.RepoAssignment(true), repo.Single) r.Any("/:reponame/**", repo.Http) }, ignSignIn) From 6337d3bf193491aeb9f6a03b260e7c7089c59f76 Mon Sep 17 00:00:00 2001 From: Unknown <joe2010xtmf@163.com> Date: Mon, 24 Mar 2014 11:58:46 -0400 Subject: [PATCH 06/21] Show dashbard --- modules/base/conf.go | 4 ++-- serve.go | 2 +- web.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/base/conf.go b/modules/base/conf.go index b4e0de97bd..d3122a5339 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -100,7 +100,7 @@ func newService() { Service.EnableCacheAvatar = Cfg.MustBool("service", "ENABLE_CACHE_AVATAR", false) } -func NewLogService() { +func newLogService() { // Get and check log mode. LogMode = Cfg.MustValue("log", "MODE", "console") modeSec := "log." + LogMode @@ -296,7 +296,7 @@ func NewConfigContext() { func NewServices() { newService() - NewLogService() + newLogService() newCacheService() newSessionService() newMailService() diff --git a/serve.go b/serve.go index 06815b65df..c3eb233c76 100644 --- a/serve.go +++ b/serve.go @@ -45,6 +45,7 @@ gogs serv provide access auth for repositories`, } func init() { + os.MkdirAll("log", os.ModePerm) log.NewLogger(10000, "file", fmt.Sprintf(`{"filename":"%s"}`, "log/serv.log")) } @@ -72,7 +73,6 @@ func runServ(k *cli.Context) { base.NewConfigContext() models.LoadModelsConfig() models.NewEngine() - base.NewLogService() keys := strings.Split(os.Args[2], "-") if len(keys) != 2 { diff --git a/web.go b/web.go index 9717c9384a..70da899a79 100644 --- a/web.go +++ b/web.go @@ -89,7 +89,7 @@ func runWeb(*cli.Context) { reqSignOut := middleware.Toggle(&middleware.ToggleOptions{SignOutRequire: true}) // Routers. - m.Get("/", reqSignIn, routers.Home) + m.Get("/", ignSignIn, routers.Home) m.Get("/issues", reqSignIn, user.Issues) m.Get("/pulls", reqSignIn, user.Pulls) m.Get("/stars", reqSignIn, user.Stars) From 52959c988c5613dfa0473f3d56442f46b98a665c Mon Sep 17 00:00:00 2001 From: slene <vslene@gmail.com> Date: Mon, 24 Mar 2014 23:59:27 +0800 Subject: [PATCH 07/21] fix --- templates/repo/single_file.tmpl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/templates/repo/single_file.tmpl b/templates/repo/single_file.tmpl index 9755812285..d00bffa956 100644 --- a/templates/repo/single_file.tmpl +++ b/templates/repo/single_file.tmpl @@ -2,7 +2,10 @@ <div class="panel-heading file-head"> {{if .ReadmeExist}} <i class="icon fa fa-book"></i> + {{.FileName}} {{else}} + <i class="icon fa fa-file-text-o"></i> + {{.FileName}} {{FileSize .FileSize}} <div class="btn-group pull-right"> <a class="btn btn-default hidden" href="#">Edit</a> <a class="btn btn-default" href="{{.FileLink}}">Raw</a> @@ -10,8 +13,7 @@ <a class="btn btn-default hidden" href="#">History</a> <a class="btn btn-danger hidden" href="#">Delete</a> </div> - <i class="icon fa fa-file-text-o"></i> - {{end}}{{.FileName}} {{FileSize .FileSize}} + {{end}} </div> {{if not .FileIsText}} <div class="panel-footer text-center"> From 62b05c1e228f1a570a97e6957c45e018262f812f Mon Sep 17 00:00:00 2001 From: FuXiaoHei <fuxiaohei@hexiaz.com> Date: Tue, 25 Mar 2014 00:02:16 +0800 Subject: [PATCH 08/21] top-nav sign-up btn change to text link --- templates/base/navbar.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/base/navbar.tmpl b/templates/base/navbar.tmpl index 2c18b038a3..90e90f296f 100644 --- a/templates/base/navbar.tmpl +++ b/templates/base/navbar.tmpl @@ -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> {{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> - <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> </div> </div> From 79633ab1fbb823ca2f6267e99bb8912ce227d293 Mon Sep 17 00:00:00 2001 From: FuXiaoHei <fuxiaohei@hexiaz.com> Date: Tue, 25 Mar 2014 00:09:58 +0800 Subject: [PATCH 09/21] file size and file raw style update --- public/css/gogs.css | 6 ++++++ templates/repo/single_file.tmpl | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/public/css/gogs.css b/public/css/gogs.css index 434af03590..8b031d6ed3 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -676,6 +676,12 @@ html, body { margin: 0 .5em 0 0; } +.file-content .file-head .file-size{ + font-size: 13px; + color: #888; + margin-left: 1em; +} + .file-content .file-body { padding: 30px 30px 50px; border: none; diff --git a/templates/repo/single_file.tmpl b/templates/repo/single_file.tmpl index d00bffa956..45586012ba 100644 --- a/templates/repo/single_file.tmpl +++ b/templates/repo/single_file.tmpl @@ -5,7 +5,7 @@ {{.FileName}} {{else}} <i class="icon fa fa-file-text-o"></i> - {{.FileName}} {{FileSize .FileSize}} + {{.FileName}} <span class="file-size">{{FileSize .FileSize}}</span> <div class="btn-group pull-right"> <a class="btn btn-default hidden" href="#">Edit</a> <a class="btn btn-default" href="{{.FileLink}}">Raw</a> @@ -17,7 +17,7 @@ </div> {{if not .FileIsText}} <div class="panel-footer text-center"> - <a href="{{.FileLink}}" class="btn btn-default">View Raw</a> + <a href="{{.FileLink}}" class="btn btn-default btn-lg">View Raw</a> </div> {{else}} {{if .ReadmeExist}} From 123c7b44e81ce5e51448a01965843516b586e3e0 Mon Sep 17 00:00:00 2001 From: slene <vslene@gmail.com> Date: Tue, 25 Mar 2014 00:42:57 +0800 Subject: [PATCH 10/21] fix --- routers/repo/repo.go | 1 + templates/repo/single_file.tmpl | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 76d55554bc..cd28d52caa 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -156,6 +156,7 @@ func Single(ctx *middleware.Context, params martini.Params) { } if readmeFile != nil { + ctx.Data["ReadmeInSingle"] = true ctx.Data["ReadmeExist"] = true if blob, err := readmeFile.LookupBlob(); err != nil { ctx.Handle(404, "repo.Single(readmeFile.LookupBlob)", err) diff --git a/templates/repo/single_file.tmpl b/templates/repo/single_file.tmpl index 45586012ba..cf398595e5 100644 --- a/templates/repo/single_file.tmpl +++ b/templates/repo/single_file.tmpl @@ -2,22 +2,28 @@ <div class="panel-heading file-head"> {{if .ReadmeExist}} <i class="icon fa fa-book"></i> + {{if .ReadmeInSingle}} {{.FileName}} + {{else}} + {{.FileName}} <span class="file-size">{{FileSize .FileSize}}</span> + {{end}} {{else}} <i class="icon fa fa-file-text-o"></i> {{.FileName}} <span class="file-size">{{FileSize .FileSize}}</span> - <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> + {{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> {{end}} </div> {{if not .FileIsText}} <div class="panel-footer text-center"> - <a href="{{.FileLink}}" class="btn btn-default btn-lg">View Raw</a> + <a href="{{.FileLink}}" class="btn btn-default">View Raw</a> </div> {{else}} {{if .ReadmeExist}} From 743fee60158edb5815b86504db29b268f29e1cbf Mon Sep 17 00:00:00 2001 From: Unknown <joe2010xtmf@163.com> Date: Mon, 24 Mar 2014 12:43:51 -0400 Subject: [PATCH 11/21] Fix --- routers/dashboard.go | 9 +++++++++ templates/repo/single_file.tmpl | 14 +++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/routers/dashboard.go b/routers/dashboard.go index 76ecc3f676..2c81cf23c1 100644 --- a/routers/dashboard.go +++ b/routers/dashboard.go @@ -5,6 +5,7 @@ package routers import ( + "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/middleware" "github.com/gogits/gogs/routers/user" ) @@ -14,6 +15,14 @@ func Home(ctx *middleware.Context) { user.Dashboard(ctx) return } + + // Check auto-login. + userName := ctx.GetCookie(base.CookieUserName) + if len(userName) != 0 { + ctx.Redirect("/user/login") + return + } + ctx.Data["PageIsHome"] = true ctx.HTML(200, "home") } diff --git a/templates/repo/single_file.tmpl b/templates/repo/single_file.tmpl index 45586012ba..6c7e5650a3 100644 --- a/templates/repo/single_file.tmpl +++ b/templates/repo/single_file.tmpl @@ -6,14 +6,14 @@ {{else}} <i class="icon fa fa-file-text-o"></i> {{.FileName}} <span class="file-size">{{FileSize .FileSize}}</span> - <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> {{end}} + <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 not .FileIsText}} <div class="panel-footer text-center"> From 7f6126dd04142c23fe5565a4c1f8cd8c93158460 Mon Sep 17 00:00:00 2001 From: FuXiaoHei <fuxiaohei@hexiaz.com> Date: Tue, 25 Mar 2014 16:51:42 +0800 Subject: [PATCH 12/21] install sample page --- modules/base/conf.go | 2 +- public/css/gogs.css | 11 ++++++- routers/install.go | 13 ++++++++ templates/install.tmpl | 70 ++++++++++++++++++++++++++++++++++++++++++ web.go | 1 + 5 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 routers/install.go create mode 100644 templates/install.tmpl diff --git a/modules/base/conf.go b/modules/base/conf.go index d3122a5339..90b3547642 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -243,7 +243,7 @@ func newNotifyMailService() { } func NewConfigContext() { - var err error + //var err error workDir, err := exeDir() if err != nil { fmt.Printf("Fail to get work directory: %s\n", err) diff --git a/public/css/gogs.css b/public/css/gogs.css index 8b031d6ed3..2254ef5a24 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -224,6 +224,15 @@ html, body { line-height: 30px; } +#gogs-install-card{ + width: 800px; +} + +#gogs-install-card .form-group { + margin-left: 0; + margin-right: 0; +} + .gogs-card .btn { cursor: pointer; margin-right: 1.2em; @@ -676,7 +685,7 @@ html, body { margin: 0 .5em 0 0; } -.file-content .file-head .file-size{ +.file-content .file-head .file-size { font-size: 13px; color: #888; margin-left: 1em; diff --git a/routers/install.go b/routers/install.go new file mode 100644 index 0000000000..d7d5159efc --- /dev/null +++ b/routers/install.go @@ -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") +} diff --git a/templates/install.tmpl b/templates/install.tmpl new file mode 100644 index 0000000000..a13f219088 --- /dev/null +++ b/templates/install.tmpl @@ -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" .}} \ No newline at end of file diff --git a/web.go b/web.go index 0747f224b7..6538c61f19 100644 --- a/web.go +++ b/web.go @@ -90,6 +90,7 @@ func runWeb(*cli.Context) { // Routers. m.Get("/", ignSignIn, routers.Home) + m.Get("/install",routers.Install) m.Get("/issues", reqSignIn, user.Issues) m.Get("/pulls", reqSignIn, user.Pulls) m.Get("/stars", reqSignIn, user.Stars) From d24a4a142e5de9b2d9701ae93892234122e8b89b Mon Sep 17 00:00:00 2001 From: Lunny Xiao <xiaolunwen@gmail.com> Date: Tue, 25 Mar 2014 17:11:13 +0800 Subject: [PATCH 13/21] bug fixed --- serve.go | 57 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/serve.go b/serve.go index c3eb233c76..f9e915ed84 100644 --- a/serve.go +++ b/serve.go @@ -109,20 +109,25 @@ func runServ(k *cli.Context) { repoName = repoName[:len(repoName)-4] } + isWrite := In(verb, COMMANDS_WRITE) + isRead := In(verb, COMMANDS_READONLY) + repo, err := models.GetRepositoryByName(user.Id, repoName) var isExist bool = true if err != nil { if err == models.ErrRepoNotExist { isExist = false + if isRead { + println("Repository", user.Name+"/"+repoName, "is not exist") + return + } } else { - println("Unavilable repository", err) + println("Get repository error:", err) return } } - isWrite := In(verb, COMMANDS_WRITE) - isRead := In(verb, COMMANDS_READONLY) - + // access check switch { case isWrite: has, err := models.HasAccess(user.Name, repoName, models.AU_WRITABLE) @@ -156,12 +161,11 @@ func runServ(k *cli.Context) { return } + var rep *git.Repository + repoPath := models.RepoPath(user.Name, repoName) if !isExist { - if isRead { - println("Repository", user.Name+"/"+repoName, "is not exist") - return - } else if isWrite { - _, err := models.CreateRepository(user, repoName, "", "", "", false, true) + if isWrite { + _, err = models.CreateRepository(user, repoName, "", "", "", false, true) if err != nil { println("Create repository failed") return @@ -169,11 +173,11 @@ func runServ(k *cli.Context) { } } - rep, err := git.OpenRepository(models.RepoPath(user.Name, repoName)) - if err != nil { - println(err.Error()) - return - } + rep, err = git.OpenRepository(repoPath) + if err != nil { + println(err.Error()) + return + } refs, err := rep.AllReferencesMap() if err != nil { @@ -194,17 +198,14 @@ func runServ(k *cli.Context) { if err = gitcmd.Run(); err != nil { println("execute command error:", err.Error()) - } - - if !strings.HasPrefix(cmd, "git-receive-pack") { return } - // update - //w, _ := os.Create("serve.log") - //defer w.Close() - //log.SetOutput(w) + if isRead { + return + } + // find push reference name var t = "ok refs/heads/" var i int var refname string @@ -220,12 +221,17 @@ func runServ(k *cli.Context) { refname = l[idx+len(t):] } } + if refname == "" { + println("No find any reference name:", b.String()) + return + } + var ref *git.Reference var ok bool - var l *list.List //log.Info("----", refname, "-----") if ref, ok = refs[refname]; !ok { + // for new branch refs, err = rep.AllReferencesMap() if err != nil { println(err.Error()) @@ -280,13 +286,8 @@ func runServ(k *cli.Context) { repo.Id, repoName, refname, &base.PushCommits{l.Len(), commits}); err != nil { log.Error("runUpdate.models.CommitRepoAction: %v", err, commits) } else { - //log.Info("refname", refname) - //log.Info("Listen: %v", cmd) - //fmt.Println("...", cmd) - - //runUpdate(k) c := exec.Command("git", "update-server-info") - c.Dir = models.RepoPath(user.Name, repoName) + c.Dir = repoPath err := c.Run() if err != nil { log.Error("update-server-info: %v", err) From c61fa28f49f9bed8e198f0ef8b2b18afec921ae5 Mon Sep 17 00:00:00 2001 From: xiaoxiao <xiaoxiao@gmail.com> Date: Tue, 25 Mar 2014 17:17:34 +0800 Subject: [PATCH 14/21] Init commit --- .gitignore | 22 ++++++++++++++++++++++ LICENSE | 27 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..6cd1df2b7a --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# 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 \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..3af16b0724 --- /dev/null +++ b/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the {organization} nor the names of its + contributors may be used to endorse or promote products derived from + 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. \ No newline at end of file From 649bc91057398e6c7cd31b41f15fafeffba167ef Mon Sep 17 00:00:00 2001 From: xiaoxiao <xiaoxiao@gmail.com> Date: Tue, 25 Mar 2014 17:25:55 +0800 Subject: [PATCH 15/21] Init commit --- .gitignore | 22 ++++++++++++++++++++++ LICENSE | 27 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..6cd1df2b7a --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# 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 \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..3af16b0724 --- /dev/null +++ b/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the {organization} nor the names of its + contributors may be used to endorse or promote products derived from + 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. \ No newline at end of file From a80603727db5a6871a833310bb47431e97628109 Mon Sep 17 00:00:00 2001 From: Lunny Xiao <xiaolunwen@gmail.com> Date: Tue, 25 Mar 2014 17:52:03 +0800 Subject: [PATCH 16/21] add log --- serve.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/serve.go b/serve.go index 480b122f3b..8d9fd69cda 100644 --- a/serve.go +++ b/serve.go @@ -48,6 +48,7 @@ gogs serv provide access auth for repositories`, func init() { os.MkdirAll("log", os.ModePerm) log.NewLogger(10000, "file", fmt.Sprintf(`{"filename":"%s"}`, "log/serv.log")) + log.Info("start logging...") } func parseCmd(cmd string) (string, string) { @@ -124,6 +125,7 @@ func runServ(k *cli.Context) { } } else { println("Get repository error:", err) + log.Error(err.Error()) return } } @@ -134,6 +136,7 @@ func runServ(k *cli.Context) { has, err := models.HasAccess(user.Name, repoName, models.AU_WRITABLE) if err != nil { println("Inernel error:", err) + log.Error(err.Error()) return } if !has { @@ -144,12 +147,14 @@ func runServ(k *cli.Context) { has, err := models.HasAccess(user.Name, repoName, models.AU_READABLE) if err != nil { println("Inernel error") + log.Error(err.Error()) return } if !has { has, err = models.HasAccess(user.Name, repoName, models.AU_WRITABLE) if err != nil { println("Inernel error") + log.Error(err.Error()) return } } @@ -169,6 +174,7 @@ func runServ(k *cli.Context) { _, err = models.CreateRepository(user, repoName, "", "", "", false, true) if err != nil { println("Create repository failed") + log.Error(err.Error()) return } } @@ -177,12 +183,14 @@ func runServ(k *cli.Context) { rep, err = git.OpenRepository(repoPath) if err != nil { println(err.Error()) + log.Error(err.Error()) return } refs, err := rep.AllReferencesMap() if err != nil { println(err.Error()) + log.Error(err.Error()) return } @@ -199,6 +207,7 @@ func runServ(k *cli.Context) { if err = gitcmd.Run(); err != nil { println("execute command error:", err.Error()) + log.Error(err.Error()) return } @@ -238,15 +247,17 @@ func runServ(k *cli.Context) { refs, err = rep.AllReferencesMap() if err != nil { println(err.Error()) + log.Error(err.Error()) return } if ref, ok = refs[refname]; !ok { - log.Trace("unknow reference name -", refname, "-", b.String()) + log.Error("unknow reference name -", refname, "-", b.String()) return } l, err = ref.AllCommits() if err != nil { println(err.Error()) + log.Error(err.Error()) return } } else { @@ -256,12 +267,14 @@ func runServ(k *cli.Context) { last, err = ref.LastCommit() if err != nil { println(err.Error()) + log.Error(err.Error()) return } ref2, err := rep.LookupReference(ref.Name) if err != nil { println(err.Error()) + log.Error(err.Error()) return } @@ -269,6 +282,7 @@ func runServ(k *cli.Context) { before, err := ref2.LastCommit() if err != nil { println(err.Error()) + log.Error(err.Error()) return } //log.Info("----", before.Id(), "-----", last.Id()) From d8b859ec86560844fd230542e7958cd3912c0b1e Mon Sep 17 00:00:00 2001 From: xiaoxiao <xiaoxiao@gmail.com> Date: Tue, 25 Mar 2014 17:53:03 +0800 Subject: [PATCH 17/21] Init commit --- .gitignore | 22 ++++++++++++++++++++++ LICENSE | 27 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..6cd1df2b7a --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# 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 \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..3af16b0724 --- /dev/null +++ b/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the {organization} nor the names of its + contributors may be used to endorse or promote products derived from + 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. \ No newline at end of file From 2856bee02201677f362dc587441970eeba219da2 Mon Sep 17 00:00:00 2001 From: xiaoxiao <xiaoxiao@gmail.com> Date: Tue, 25 Mar 2014 18:12:51 +0800 Subject: [PATCH 18/21] Init commit --- .gitignore | 22 ++++++++++++++++++++++ LICENSE | 27 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..6cd1df2b7a --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# 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 \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..3af16b0724 --- /dev/null +++ b/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the {organization} nor the names of its + contributors may be used to endorse or promote products derived from + 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. \ No newline at end of file From 19b7f74b75caf8cef50c687d422d761ca74b3b90 Mon Sep 17 00:00:00 2001 From: Lunny Xiao <xiaolunwen@gmail.com> Date: Tue, 25 Mar 2014 18:26:30 +0800 Subject: [PATCH 19/21] add log --- serve.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/serve.go b/serve.go index 6add5a9bd8..acdcb877ff 100644 --- a/serve.go +++ b/serve.go @@ -183,14 +183,14 @@ func runServ(k *cli.Context) { rep, err = git.OpenRepository(repoPath) if err != nil { - println(err.Error()) + println("OpenRepository failed:", err.Error()) log.Error(err.Error()) return } refs, err := rep.AllReferencesMap() if err != nil { - println(err.Error()) + println("Get All References failed:", err.Error()) log.Error(err.Error()) return } @@ -247,7 +247,7 @@ func runServ(k *cli.Context) { // for new branch refs, err = rep.AllReferencesMap() if err != nil { - println(err.Error()) + println("Get All References failed:", err.Error()) log.Error(err.Error()) return } @@ -257,7 +257,7 @@ func runServ(k *cli.Context) { } l, err = ref.AllCommits() if err != nil { - println(err.Error()) + println("Get All Commits failed:", err.Error()) log.Error(err.Error()) return } @@ -267,14 +267,14 @@ func runServ(k *cli.Context) { //log.Info("00000", ref.Oid.String()) last, err = ref.LastCommit() if err != nil { - println(err.Error()) + println("Get last commit failed:", err.Error()) log.Error(err.Error()) return } ref2, err := rep.LookupReference(ref.Name) if err != nil { - println(err.Error()) + println("look up reference failed:", err.Error()) log.Error(err.Error()) return } @@ -282,7 +282,7 @@ func runServ(k *cli.Context) { //log.Info("11111", ref2.Oid.String()) before, err := ref2.LastCommit() if err != nil { - println(err.Error()) + println("Get last commit failed:", err.Error()) log.Error(err.Error()) return } From 01b3b7004dfd7d70770ccd09a335db36c681a207 Mon Sep 17 00:00:00 2001 From: xiaoxiao <xiaoxiao@gmail.com> Date: Tue, 25 Mar 2014 18:26:58 +0800 Subject: [PATCH 20/21] Init commit --- .gitignore | 22 ++++++++++++++++++++++ LICENSE | 27 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..6cd1df2b7a --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# 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 \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..3af16b0724 --- /dev/null +++ b/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the {organization} nor the names of its + contributors may be used to endorse or promote products derived from + 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. \ No newline at end of file From 6e33e54e71cdb6a100b9048bd6d9567fea2e7c91 Mon Sep 17 00:00:00 2001 From: FuXiaoHei <fuxiaohei@hexiaz.com> Date: Tue, 25 Mar 2014 18:27:29 +0800 Subject: [PATCH 21/21] add issue-create template file --- routers/repo/issue.go | 1 + templates/issue/create.tmpl | 10 ++++++++++ templates/repo/issues.tmpl | 1 + 3 files changed, 12 insertions(+) create mode 100644 templates/issue/create.tmpl diff --git a/routers/repo/issue.go b/routers/repo/issue.go index e03f115e24..d54582a2a0 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -45,6 +45,7 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat } ctx.Data["Title"] = "Create issue" + ctx.Data["IsRepoToolbarIssues"] = true if ctx.Req.Method == "GET" { ctx.HTML(200, "issue/create") diff --git a/templates/issue/create.tmpl b/templates/issue/create.tmpl new file mode 100644 index 0000000000..e71843e6f0 --- /dev/null +++ b/templates/issue/create.tmpl @@ -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" .}} \ No newline at end of file diff --git a/templates/repo/issues.tmpl b/templates/repo/issues.tmpl index daacc089c3..bf23ff83ff 100644 --- a/templates/repo/issues.tmpl +++ b/templates/repo/issues.tmpl @@ -4,6 +4,7 @@ {{template "repo/toolbar" .}} <div id="gogs-body" class="container"> <div id="gogs-source"> + issues </div> </div> {{template "base/footer" .}} \ No newline at end of file