From c9bf526be74a29a9f2e620cbcd06989a40597531 Mon Sep 17 00:00:00 2001 From: slene Date: Sun, 16 Mar 2014 23:25:01 +0800 Subject: markdown & code style --- templates/base/head.tmpl | 2 ++ templates/repo/single.tmpl | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'templates') diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 715f54ef..da100975 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -11,10 +11,12 @@ + + {{if .Title}}{{.Title}} - {{end}}{{AppName}} diff --git a/templates/repo/single.tmpl b/templates/repo/single.tmpl index c8372344..b5207d08 100644 --- a/templates/repo/single.tmpl +++ b/templates/repo/single.tmpl @@ -79,11 +79,11 @@
-
- README.md +
+ README.md
-
- httplib +
+ markdown content
-- cgit v1.2.3 From ec65be79f0337b11c01121eae9fd54fe49bee830 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 16 Mar 2014 12:07:35 -0400 Subject: Fix commit feed ui --- gogs.go | 2 +- modules/base/tool.go | 17 ++++++++++------- public/css/gogs.css | 6 ++++++ routers/user/user.go | 2 +- templates/user/profile.tmpl | 3 ++- 5 files changed, 20 insertions(+), 10 deletions(-) (limited to 'templates') diff --git a/gogs.go b/gogs.go index 9d1f2032..2d5283f3 100644 --- a/gogs.go +++ b/gogs.go @@ -20,7 +20,7 @@ import ( // Test that go1.1 tag above is included in builds. main.go refers to this definition. const go11tag = true -const APP_VER = "0.0.8.0316.1" +const APP_VER = "0.0.9.0316.1" func init() { base.AppVer = APP_VER diff --git a/modules/base/tool.go b/modules/base/tool.go index 5746cc8f..10b3fee3 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -5,6 +5,7 @@ package base import ( + "bytes" "crypto/md5" "encoding/hex" "encoding/json" @@ -253,16 +254,14 @@ func ActionIcon(opType int) string { } const ( - TPL_CREATE_REPO = `%s created repository %s` - TPL_COMMIT_REPO = `%s pushed to %s at %s/%s -
    -
  • %s %s
  • -
` + TPL_CREATE_REPO = `%s created repository %s` + TPL_COMMIT_REPO = `%s pushed to %s at %s/%s%s` + TPL_COMMIT_REPO_LI = `
user-avatar %s %s
` ) // ActionDesc accepts int that represents action operation type // and returns the description. -func ActionDesc(act Actioner) string { +func ActionDesc(act Actioner, avatarLink string) string { actUserName := act.GetActUserName() repoName := act.GetRepoName() content := act.GetContent() @@ -274,8 +273,12 @@ func ActionDesc(act Actioner) string { if err := json.Unmarshal([]byte(content), &commits); err != nil { return err.Error() } + buf := bytes.NewBuffer([]byte("\n")) + for _, commit := range commits { + buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, avatarLink, actUserName, repoName, commit[0], commit[0][:7], commit[1]) + "\n") + } return fmt.Sprintf(TPL_COMMIT_REPO, actUserName, actUserName, actUserName, repoName, "master", "master", actUserName, repoName, actUserName, repoName, - actUserName, repoName, commits[0][0], commits[0][0][:7], commits[0][1]) + buf.String()) default: return "invalid type" } diff --git a/public/css/gogs.css b/public/css/gogs.css index 89da6055..45ce5d21 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -228,6 +228,12 @@ html, body { border-radius: 6px; } +#gogs-user-avatar-commit { + width: 16px; + height: 16px; + border-radius: 2px; +} + #gogs-user-name { margin-top: 20px; font-size: 1.6em; diff --git a/routers/user/user.go b/routers/user/user.go index 0ff5058d..c43cf84a 100644 --- a/routers/user/user.go +++ b/routers/user/user.go @@ -195,7 +195,7 @@ func Feeds(ctx *middleware.Context, form auth.FeedsForm) { feeds := make([]string, len(actions)) for i := range actions { feeds[i] = fmt.Sprintf(feedTpl, base.ActionIcon(actions[i].OpType), - base.TimeSince(actions[i].Created), base.ActionDesc(actions[i])) + base.TimeSince(actions[i].Created), base.ActionDesc(actions[i], ctx.User.AvatarLink())) } ctx.Render.JSON(200, &feeds) } diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index 84d3b13c..24ae76fe 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -32,10 +32,11 @@ {{if eq .TabName "activity"}}
    + {{$avatarLink := .Owner.AvatarLink}} {{range .Feeds}}
  • -
    {{TimeSince .Created}}
    {{ActionDesc . | str2html}}
    +
    {{TimeSince .Created}}
    {{ActionDesc . $avatarLink | str2html}}
  • {{else}} -- cgit v1.2.3 From 685631627e5c4db881160bfc9b39dc45143989f6 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 16 Mar 2014 23:43:22 -0400 Subject: Show branches in repo viewer --- README.md | 2 +- bee.json | 3 ++- models/repo2.go | 24 ++++++++++++++++++++---- routers/repo/single.go | 7 +++++++ templates/repo/single.tmpl | 18 ++++++++++-------- 5 files changed, 40 insertions(+), 14 deletions(-) (limited to 'templates') diff --git a/README.md b/README.md index f4250a47..d0a0c205 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Gogs(Go Git Service) is a GitHub-like clone in the Go Programming Language. Since we choose to use pure Go implmentation of Git manipulation, Gogs certainly supports **ALL platforms** that Go supports, including Linux, Max OS X, and Windows with **ZERO** dependency. -##### Current version: 0.0.8 Alpha +##### Current version: 0.0.9 Alpha ## Purpose diff --git a/bee.json b/bee.json index de211f72..19efcbc2 100644 --- a/bee.json +++ b/bee.json @@ -12,7 +12,8 @@ "models": "", "others": [ "modules", - "$GOPATH/src/github.com/gogits/binding" + "$GOPATH/src/github.com/gogits/binding", + "$GOPATH/src/github.com/gogits/git" ] }, "cmd_args": [ diff --git a/models/repo2.go b/models/repo2.go index e3fdc278..a8dbc44d 100644 --- a/models/repo2.go +++ b/models/repo2.go @@ -8,7 +8,7 @@ import ( "path" "time" - git "github.com/gogits/git" + "github.com/gogits/git" ) type RepoFile struct { @@ -19,10 +19,26 @@ type RepoFile struct { Size int64 } -func GetReposFiles(userName, reposName, branchName, rpath string) ([]*RepoFile, error) { - f := RepoPath(userName, reposName) +func GetBranches(userName, reposName string) ([]string, error) { + repo, err := git.OpenRepository(RepoPath(userName, reposName)) + if err != nil { + return nil, err + } + + refs, err := repo.AllReferences() + if err != nil { + return nil, err + } + + brs := make([]string, len(refs)) + for i, ref := range refs { + brs[i] = ref.Name + } + return brs, nil +} - repo, err := git.OpenRepository(f) +func GetReposFiles(userName, reposName, branchName, rpath string) ([]*RepoFile, error) { + repo, err := git.OpenRepository(RepoPath(userName, reposName)) if err != nil { return nil, err } diff --git a/routers/repo/single.go b/routers/repo/single.go index 6bf03ca2..fd4d5290 100644 --- a/routers/repo/single.go +++ b/routers/repo/single.go @@ -33,6 +33,13 @@ func Single(ctx *middleware.Context, params martini.Params) { ctx.Data["Reponame"] = params["reponame"] ctx.Data["Branchname"] = params["branchname"] + brs, err := models.GetBranches(params["username"], params["reponame"]) + if err != nil { + ctx.Handle(200, "repo.Single", err) + return + } + ctx.Data["Branches"] = brs + var treenames []string Paths := make([]string, 0) diff --git a/templates/repo/single.tmpl b/templates/repo/single.tmpl index b5207d08..e1fb05bd 100644 --- a/templates/repo/single.tmpl +++ b/templates/repo/single.tmpl @@ -5,21 +5,23 @@
    + {{ $username := .Username}} + {{ $reponame := .Reponame}} + {{ $branchname := .Branchname}} + {{ $treenames := .Treenames}} + {{ $repoLink := .RepositoryLink}} + {{ $n := len $treenames}} {{$paths := .Paths}} - {{ $username := .Username}} - {{ $reponame := .Reponame}} - {{ $branchname := .Branchname}} - {{ $treenames := .Treenames}} - {{ $n := len $treenames}} {{ $l := Subtract $n 1}}
    - Merge branch 'release/1.1.1' + {{.LatestCommit.Message}}
    - slene authored 4 days ago + {{.LatestCommit.Author}} {{TimeSince .LatestCommit.Date}}
    -- cgit v1.2.3 From c101471bdfd0a802e66adfb7402dbd980812da30 Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Mon, 17 Mar 2014 13:12:28 +0800 Subject: ui update, repo-assignment panic bug fix --- modules/middleware/repo.go | 2 +- public/css/gogs.css | 1 + routers/repo/single.go | 2 -- templates/base/head.tmpl | 4 +++- templates/repo/toolbar.tmpl | 3 ++- 5 files changed, 7 insertions(+), 5 deletions(-) (limited to 'templates') diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index 8cdc6df7..7a415736 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -24,7 +24,6 @@ func RepoAssignment(redirect bool) martini.Handler { // get repository owner ctx.Repo.IsOwner = ctx.IsSigned && ctx.User.LowerName == params["username"] - ctx.Data["IsRepositoryOwner"] = ctx.Repo.IsOwner if !ctx.Repo.IsOwner { user, err = models.GetUserByName(params["username"]) @@ -70,5 +69,6 @@ func RepoAssignment(redirect bool) martini.Handler { ctx.Data["Owner"] = user ctx.Data["Title"] = user.Name + "/" + repo.Name ctx.Data["RepositoryLink"] = ctx.Data["Title"] + ctx.Data["IsRepositoryOwner"] = ctx.Repo.IsOwner } } diff --git a/public/css/gogs.css b/public/css/gogs.css index 2c05d27e..f98cf7a1 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -10,6 +10,7 @@ body { html, body { height: 100%; + font-family: Helvetica, Arial, sans-serif; } /* override bs3 */ diff --git a/routers/repo/single.go b/routers/repo/single.go index 6bf03ca2..3541dac9 100644 --- a/routers/repo/single.go +++ b/routers/repo/single.go @@ -46,7 +46,6 @@ func Single(ctx *middleware.Context, params martini.Params) { ctx.Data["Paths"] = Paths ctx.Data["Treenames"] = treenames ctx.Data["IsRepoToolbarSource"] = true - ctx.Data["IsRepositoryOwner"] = strings.ToLower(params["username"]) == ctx.User.LowerName ctx.Data["Files"] = files ctx.Render.HTML(200, "repo/single", ctx.Data) } @@ -63,7 +62,6 @@ func Setting(ctx *middleware.Context, params martini.Params) { ctx.Data["Title"] = title + " - settings" ctx.Data["IsRepoToolbarSetting"] = true - ctx.Data["IsRepositoryOwner"] = strings.ToLower(params["username"]) == ctx.User.LowerName ctx.Render.HTML(200, "repo/setting", ctx.Data) } diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index da100975..f02ea095 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -3,7 +3,9 @@ - + + + diff --git a/templates/repo/toolbar.tmpl b/templates/repo/toolbar.tmpl index 4a0b60ad..3729edaf 100644 --- a/templates/repo/toolbar.tmpl +++ b/templates/repo/toolbar.tmpl @@ -5,8 +5,9 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +{{template "base/footer" .}} \ No newline at end of file diff --git a/templates/repo/single.tmpl b/templates/repo/single.tmpl index 4c6c7dd9..153910f7 100644 --- a/templates/repo/single.tmpl +++ b/templates/repo/single.tmpl @@ -24,13 +24,15 @@ {{$paths := .Paths}} {{ $l := Subtract $n 1}}
@@ -43,20 +45,21 @@
- - - - - - + + + + + + - {{range .Files}} - - - + + - + - + - - {{end}} + + + {{end}} diff --git a/templates/repo/toolbar.tmpl b/templates/repo/toolbar.tmpl index 3729edaf..49a37ef4 100644 --- a/templates/repo/toolbar.tmpl +++ b/templates/repo/toolbar.tmpl @@ -4,10 +4,10 @@