You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

single.go 2.0 kB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package repo
  5. import (
  6. "strings"
  7. "github.com/codegangsta/martini"
  8. "github.com/gogits/gogs/models"
  9. "github.com/gogits/gogs/modules/middleware"
  10. )
  11. func Single(ctx *middleware.Context, params martini.Params) {
  12. if !ctx.Repo.IsValid {
  13. return
  14. }
  15. if params["branchname"] == "" {
  16. params["branchname"] = "master"
  17. }
  18. treename := params["_1"]
  19. files, err := models.GetReposFiles(params["username"], params["reponame"],
  20. params["branchname"], treename)
  21. if err != nil {
  22. ctx.Handle(200, "repo.Single", err)
  23. return
  24. }
  25. ctx.Data["Username"] = params["username"]
  26. ctx.Data["Reponame"] = params["reponame"]
  27. ctx.Data["Branchname"] = params["branchname"]
  28. var treenames []string
  29. Paths := make([]string, 0)
  30. if len(treename) > 0 {
  31. treenames = strings.Split(treename, "/")
  32. for i, _ := range treenames {
  33. Paths = append(Paths, strings.Join(treenames[0:i+1], "/"))
  34. }
  35. }
  36. ctx.Data["Paths"] = Paths
  37. ctx.Data["Treenames"] = treenames
  38. ctx.Data["IsRepoToolbarSource"] = true
  39. ctx.Data["IsRepositoryOwner"] = strings.ToLower(params["username"]) == ctx.User.LowerName
  40. ctx.Data["Files"] = files
  41. ctx.Render.HTML(200, "repo/single", ctx.Data)
  42. }
  43. func Setting(ctx *middleware.Context, params martini.Params) {
  44. if !ctx.Repo.IsValid {
  45. return
  46. }
  47. var title string
  48. if t, ok := ctx.Data["Title"].(string); ok {
  49. title = t
  50. }
  51. ctx.Data["Title"] = title + " - settings"
  52. ctx.Data["IsRepoToolbarSetting"] = true
  53. ctx.Data["IsRepositoryOwner"] = strings.ToLower(params["username"]) == ctx.User.LowerName
  54. ctx.Render.HTML(200, "repo/setting", ctx.Data)
  55. }
  56. func Commits(ctx *middleware.Context) string {
  57. return "This is commits page"
  58. }
  59. func Issues(ctx *middleware.Context) string {
  60. return "This is issues page"
  61. }
  62. func Pulls(ctx *middleware.Context) string {
  63. return "This is pulls page"
  64. }