commit
8c96091727
@ -0,0 +1,66 @@ |
||||
package repo |
||||
|
||||
import ( |
||||
"net/http" |
||||
|
||||
"github.com/codegangsta/martini" |
||||
"github.com/gogits/gogs/models" |
||||
"github.com/gogits/gogs/modules/auth" |
||||
"github.com/gogits/gogs/modules/base" |
||||
"github.com/martini-contrib/render" |
||||
"github.com/martini-contrib/sessions" |
||||
"github.com/qiniu/log" |
||||
) |
||||
|
||||
func Single(params martini.Params, req *http.Request, r render.Render, data base.TmplData, session sessions.Session) { |
||||
var ( |
||||
user *models.User |
||||
err error |
||||
) |
||||
// get repository owner
|
||||
isOwner := (data["SignedUserName"] == params["username"]) |
||||
if !isOwner { |
||||
user, err = models.GetUserByName(params["username"]) |
||||
if err != nil { |
||||
data["ErrorMsg"] = err |
||||
//log.Error("repo.Single: %v", err)
|
||||
r.HTML(200, "base/error", data) |
||||
return |
||||
} |
||||
} else { |
||||
user = auth.SignedInUser(session) |
||||
} |
||||
if user == nil { |
||||
data["ErrorMsg"] = "invliad user account for single repository" |
||||
//log.Error("repo.Single: %v", err)
|
||||
r.HTML(200, "base/error", data) |
||||
return |
||||
} |
||||
data["IsRepositoryOwner"] = isOwner |
||||
|
||||
// get repository
|
||||
repo, err := models.GetRepositoryByName(user, params["reponame"]) |
||||
if err != nil { |
||||
data["ErrorMsg"] = err |
||||
//log.Error("repo.Single: %v", err)
|
||||
r.HTML(200, "base/error", data) |
||||
return |
||||
} |
||||
|
||||
data["Repository"] = repo |
||||
data["Owner"] = user |
||||
data["Title"] = user.Name + "/" + repo.Name |
||||
data["RepositoryLink"] = data["Title"] |
||||
data["IsRepoToolbarSource"] = true |
||||
|
||||
files, err := models.GetReposFiles(params["username"], params["reponame"], "HEAD", "/") |
||||
if err != nil { |
||||
data["ErrorMsg"] = err |
||||
log.Error("repo.List: %v", err) |
||||
r.HTML(200, "base/error", data) |
||||
return |
||||
} |
||||
|
||||
data["Files"] = files |
||||
r.HTML(200, "repo/single", data) |
||||
} |
@ -1,10 +0,0 @@ |
||||
{{template "base/head" .}} |
||||
{{template "base/navbar" .}} |
||||
<div class="container" id="gogs-body"> |
||||
<ul> |
||||
{{range .Files}} |
||||
<li>{{.Name}} - {{.Type}}</li> |
||||
{{end}} |
||||
</ul> |
||||
</div> |
||||
{{template "base/footer" .}} |
@ -0,0 +1,42 @@ |
||||
{{template "base/head" .}} |
||||
{{template "base/navbar" .}} |
||||
<div id="gogs-body-nav" class="gogs-repo-nav"> |
||||
<div class="container"> |
||||
<div class="gogs-repo-btns pull-right"> |
||||
<div class="btn-group" id="gogs-repo-watching"> |
||||
<button type="button" class="btn btn-default"><i class="fa fa-eye"></i>Watch {x}</button> |
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> |
||||
<span class="caret"></span> |
||||
<span class="sr-only">Toggle Dropdown</span> |
||||
</button> |
||||
<div class="dropdown-menu" role="menu"> |
||||
<div class="dropdown-item" data-val="not-watching"> |
||||
<h4 role="presentation" class="dropdown-header">Not Watching</h4> |
||||
<p class="description">You only receive notifications for conversations in which you participate or are @mentioned.</p> |
||||
<p class="divider"></p> |
||||
</div> |
||||
<div class="dropdown-item" data-val="watching"> |
||||
<h4 role="presentation" class="dropdown-header">Watching</h4> |
||||
<p class="description">You receive notifications for all conversations in this repository.</p> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div class="btn-group"> |
||||
<button type="button" class="btn btn-default"><i class="fa fa-star"></i>Star {{.Repository.NumStars}}</button> |
||||
</div> |
||||
<div class="btn-group"> |
||||
<button type="button" class="btn btn-default"><i class="fa fa-code-fork"></i>Fork {{.Repository.NumForks}}</button> |
||||
</div> |
||||
</div> |
||||
<h3><i class="fa fa-book fa-lg"></i><a href="/{{.Owner.Name}}/">{{.Owner.Name}}</a> / {{.Repository.Name}}</h3> |
||||
</div> |
||||
</div> |
||||
{{template "repo/toolbar" .}} |
||||
<div id="gogs-body" class="container"> |
||||
<ul> |
||||
{{range .Files}} |
||||
<li>{{.Name}} - {{.Type}}</li> |
||||
{{end}} |
||||
</ul> |
||||
</div> |
||||
{{template "base/footer" .}} |
@ -0,0 +1,41 @@ |
||||
<div id="gogs-repo-toolbar"> |
||||
<div class="container"> |
||||
<nav class="navbar navbar-toolbar navbar-default" role="navigation"> |
||||
<div class="container-fluid"> |
||||
<div class="collapse navbar-collapse"> |
||||
<ul class="nav navbar-nav"> |
||||
<li class="dropdown"> |
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Branches <b class="caret"></b></a> |
||||
<ul class="dropdown-menu"> |
||||
<li><a href="#">master</a></li> |
||||
<li><a href="#">develop</a></li> |
||||
</ul> |
||||
</li> |
||||
<li class="{{if .IsRepoToolbarSource}}active{{end}}"><a href="#">Source</a></li> |
||||
<li><a href="#">Commits</a></li> |
||||
<li><a href="#">Issues <span class="badge">42</span></a></li> |
||||
<li><a href="#">Pull Requests</a></li> |
||||
<li class="dropdown"> |
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">More <b class="caret"></b></a> |
||||
<ul class="dropdown-menu"> |
||||
<li><a href="#">Release</a></li> |
||||
<li><a href="#">Wiki</a></li> |
||||
</ul> |
||||
</li> |
||||
</ul> |
||||
<ul class="nav navbar-nav navbar-right"> |
||||
<li class="dropdown"> |
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Statics <b class="caret"></b></a> |
||||
<ul class="dropdown-menu"> |
||||
<li><a href="#">Graphic</a></li> |
||||
<li><a href="#">Pulse</a></li> |
||||
<li><a href="#">Network</a></li> |
||||
</ul> |
||||
</li>{{if .IsRepositoryOwner}} |
||||
<li class="{{if .IsRepoToolbarSetting}}active{{end}}"><a href="/{{.RepositoryLink}}/settings/">Settings</a></li>{{end}} |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
</nav> |
||||
</div> |
||||
</div> |
Loading…
Reference in new issue