dashboard.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 routers
  5. import (
  6. "github.com/gogits/gogs/models"
  7. "github.com/gogits/gogs/modules/base"
  8. "github.com/gogits/gogs/modules/middleware"
  9. "github.com/gogits/gogs/routers/user"
  10. )
  11. func Home(ctx *middleware.Context) {
  12. if ctx.IsSigned {
  13. user.Dashboard(ctx)
  14. return
  15. }
  16. // Check auto-login.
  17. userName := ctx.GetCookie(base.CookieUserName)
  18. if len(userName) != 0 {
  19. ctx.Redirect("/user/login")
  20. return
  21. }
  22. repos, _ := models.GetRecentUpdatedRepositories()
  23. for _, repo := range repos {
  24. repo.Owner, _ = models.GetUserById(repo.OwnerId)
  25. }
  26. ctx.Data["Repos"] = repos
  27. ctx.Data["PageIsHome"] = true
  28. ctx.HTML(200, "home")
  29. }
  30. func Help(ctx *middleware.Context) {
  31. ctx.Data["PageIsHelp"] = true
  32. ctx.Data["Title"] = "Help"
  33. ctx.HTML(200, "help")
  34. }
  35. func NotFound(ctx *middleware.Context) {
  36. ctx.Data["PageIsNotFound"] = true
  37. ctx.Data["Title"] = "Page Not Found"
  38. ctx.Handle(404, "home.NotFound", nil)
  39. }