aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskyblue <ssx205@gmail.com>2014-03-25 18:35:15 +0800
committerskyblue <ssx205@gmail.com>2014-03-25 18:35:15 +0800
commitf0352789cd1e5c3ee35ed685e29421f0bc02f336 (patch)
treee3c0454dcba62f689221d5a97efcef342c06ffd2
parent7048ea45279cd96f88845d83fe7cef6fbb545fcf (diff)
parent4e88ae19d1e2e91e4d3168304c06fcbce73c31bf (diff)
downloadgitea-f0352789cd1e5c3ee35ed685e29421f0bc02f336.tar.gz
gitea-f0352789cd1e5c3ee35ed685e29421f0bc02f336.zip
Merge branch 'master' of github.com:gogits/gogs
-rw-r--r--.gitignore27
-rw-r--r--LICENSE40
-rw-r--r--README.md1
-rw-r--r--README_ZH.md1
-rw-r--r--models/repo.go2
-rw-r--r--modules/base/conf.go6
-rw-r--r--modules/base/markdown.go9
-rwxr-xr-xpublic/css/gogs.css15
-rw-r--r--public/js/app.js2
-rw-r--r--routers/dashboard.go9
-rw-r--r--routers/install.go13
-rw-r--r--routers/repo/issue.go1
-rw-r--r--routers/repo/repo.go75
-rw-r--r--serve.go89
-rw-r--r--templates/base/navbar.tmpl2
-rw-r--r--templates/install.tmpl70
-rw-r--r--templates/issue/create.tmpl10
-rw-r--r--templates/repo/issues.tmpl1
-rw-r--r--templates/repo/nav.tmpl4
-rw-r--r--templates/repo/single.tmpl2
-rw-r--r--templates/repo/single_file.tmpl25
-rw-r--r--web.go5
22 files changed, 330 insertions, 79 deletions
diff --git a/.gitignore b/.gitignore
index 425f227c1a..eab518bb53 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
+
+
gogs
*.exe
*.exe~
@@ -9,4 +11,27 @@ data/
.vendor/
.idea/
*.iml
-public/img/avatar/ \ No newline at end of file
+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 \ No newline at end of file
diff --git a/LICENSE b/LICENSE
index 7cecc2485f..3af16b0724 100644
--- a/LICENSE
+++ b/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
-of this software and associated documentation files (the "Software"), to deal
-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:
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+* 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
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 6cbfaf1059..d5f9be72ac 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.
diff --git a/modules/base/conf.go b/modules/base/conf.go
index b4e0de97bd..90b3547642 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
@@ -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)
@@ -296,7 +296,7 @@ func NewConfigContext() {
func NewServices() {
newService()
- NewLogService()
+ newLogService()
newCacheService()
newSessionService()
newMailService()
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/public/css/gogs.css b/public/css/gogs.css
index 434af03590..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,6 +685,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/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/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/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/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/routers/repo/repo.go b/routers/repo/repo.go
index a055b416c2..cd28d52caa 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)
+ }
}
}
@@ -150,18 +156,21 @@ func Single(ctx *middleware.Context, params martini.Params) {
}
if readmeFile != nil {
+ ctx.Data["ReadmeInSingle"] = true
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 +210,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/serve.go b/serve.go
index 06815b65df..acdcb877ff 100644
--- a/serve.go
+++ b/serve.go
@@ -13,6 +13,7 @@ import (
"os/exec"
"strconv"
"strings"
+ "time"
"github.com/codegangsta/cli"
"github.com/gogits/gogs/modules/log"
@@ -45,7 +46,10 @@ gogs serv provide access auth for repositories`,
}
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) {
@@ -72,7 +76,6 @@ func runServ(k *cli.Context) {
base.NewConfigContext()
models.LoadModelsConfig()
models.NewEngine()
- base.NewLogService()
keys := strings.Split(os.Args[2], "-")
if len(keys) != 2 {
@@ -109,25 +112,32 @@ 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)
+ log.Error(err.Error())
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)
if err != nil {
println("Inernel error:", err)
+ log.Error(err.Error())
return
}
if !has {
@@ -138,12 +148,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
}
}
@@ -156,28 +168,30 @@ 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")
+ log.Error(err.Error())
return
}
}
}
- 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("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
}
@@ -194,17 +208,17 @@ func runServ(k *cli.Context) {
if err = gitcmd.Run(); err != nil {
println("execute command error:", err.Error())
+ log.Error(err.Error())
+ return
}
- if !strings.HasPrefix(cmd, "git-receive-pack") {
+ if isRead {
return
}
- // update
- //w, _ := os.Create("serve.log")
- //defer w.Close()
- //log.SetOutput(w)
+ time.Sleep(time.Second)
+ // find push reference name
var t = "ok refs/heads/"
var i int
var refname string
@@ -220,24 +234,31 @@ 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())
+ println("Get All References failed:", 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())
+ println("Get All Commits failed:", err.Error())
+ log.Error(err.Error())
return
}
} else {
@@ -246,20 +267,23 @@ 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
}
//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
}
//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 {
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)
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>
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/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
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}}&nbsp;&nbsp;
<b class="caret"></b></a>
diff --git a/templates/repo/single_file.tmpl b/templates/repo/single_file.tmpl
index 40ef44eb1b..cf398595e5 100644
--- a/templates/repo/single_file.tmpl
+++ b/templates/repo/single_file.tmpl
@@ -2,13 +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>
- {{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>
+ {{end}}
</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}}
@@ -21,7 +36,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..6538c61f19 100644
--- a/web.go
+++ b/web.go
@@ -89,7 +89,8 @@ func runWeb(*cli.Context) {
reqSignOut := middleware.Toggle(&middleware.ToggleOptions{SignOutRequire: true})
// Routers.
- m.Get("/", reqSignIn, routers.Home)
+ 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)
@@ -152,6 +153,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))
@@ -162,6 +164,7 @@ func runWeb(*cli.Context) {
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)