single.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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["Files"] = files
  40. ctx.Render.HTML(200, "repo/single", ctx.Data)
  41. }
  42. func Setting(ctx *middleware.Context) {
  43. if !ctx.Repo.IsValid {
  44. return
  45. }
  46. var title string
  47. if t, ok := ctx.Data["Title"].(string); ok {
  48. title = t
  49. }
  50. ctx.Data["Title"] = title + " - settings"
  51. ctx.Data["IsRepoToolbarSetting"] = true
  52. ctx.Render.HTML(200, "repo/setting", ctx.Data)
  53. }
  54. func Commits(ctx *middleware.Context) string {
  55. return "This is commits page"
  56. }
  57. func Issues(ctx *middleware.Context) string {
  58. return "This is issues page"
  59. }
  60. func Pulls(ctx *middleware.Context) string {
  61. return "This is pulls page"
  62. }