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 1.3 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
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package repo
  2. import (
  3. "strings"
  4. "github.com/codegangsta/martini"
  5. "github.com/gogits/gogs/models"
  6. "github.com/gogits/gogs/modules/middleware"
  7. )
  8. func Single(ctx *middleware.Context, params martini.Params) {
  9. if !ctx.Data["IsRepositoryValid"].(bool) {
  10. return
  11. }
  12. if params["branchname"] == "" {
  13. params["branchname"] = "master"
  14. }
  15. treename := params["_1"]
  16. files, err := models.GetReposFiles(params["username"], params["reponame"],
  17. params["branchname"], treename)
  18. if err != nil {
  19. ctx.Handle(200, "repo.Single", err)
  20. return
  21. }
  22. ctx.Data["Username"] = params["username"]
  23. ctx.Data["Reponame"] = params["reponame"]
  24. ctx.Data["Branchname"] = params["branchname"]
  25. var treenames []string
  26. Paths := make([]string, 0)
  27. if len(treename) > 0 {
  28. treenames = strings.Split(treename, "/")
  29. for i, _ := range treenames {
  30. Paths = append(Paths, strings.Join(treenames[0:i+1], "/"))
  31. }
  32. }
  33. ctx.Data["Paths"] = Paths
  34. ctx.Data["Treenames"] = treenames
  35. ctx.Data["IsRepoToolbarSource"] = true
  36. ctx.Data["Files"] = files
  37. ctx.Render.HTML(200, "repo/single", ctx.Data)
  38. }
  39. func Setting(ctx *middleware.Context) {
  40. if !ctx.Data["IsRepositoryValid"].(bool) {
  41. return
  42. }
  43. ctx.Data["Title"] = ctx.Data["Title"].(string) + " - settings"
  44. ctx.Data["IsRepoToolbarSetting"] = true
  45. ctx.Render.HTML(200, "repo/setting", ctx.Data)
  46. }