home.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2015 - Present, The Gogs Authors. All rights reserved.
  2. // Copyright 2018 - Present, Gitote. All rights reserved.
  3. //
  4. // This source code is licensed under the MIT license found in the
  5. // LICENSE file in the root directory of this source tree.
  6. package routes
  7. import (
  8. "gitote/gitote/pkg/context"
  9. "gitote/gitote/pkg/setting"
  10. "gitote/gitote/routes/user"
  11. )
  12. const (
  13. // HomeTPL page template
  14. HomeTPL = "home"
  15. )
  16. // Home shows the home page
  17. func Home(c *context.Context) {
  18. if c.IsLogged {
  19. if !c.User.IsActive && setting.Service.RegisterEmailConfirm {
  20. c.Data["Title"] = c.Tr("auth.active_your_account")
  21. c.Success(user.ActivateTPL)
  22. } else {
  23. user.Dashboard(c)
  24. }
  25. return
  26. }
  27. // Check auto-login.
  28. uname := c.GetCookie(setting.CookieUserName)
  29. if len(uname) != 0 {
  30. c.Redirect(setting.AppSubURL + "/login")
  31. return
  32. }
  33. c.Data["PageIsHome"] = true
  34. c.Success(HomeTPL)
  35. }
  36. // NotFound renders 404 page if page not found
  37. func NotFound(c *context.Context) {
  38. c.Data["Title"] = "Page Not Found"
  39. c.NotFound()
  40. }