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

56 lines
1.3 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  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. // Show recent updated repositoires for new visiters.
  23. repos, err := models.GetRecentUpdatedRepositories()
  24. if err != nil {
  25. ctx.Handle(500, "dashboard.Home(GetRecentUpdatedRepositories)", err)
  26. return
  27. }
  28. for _, repo := range repos {
  29. repo.Owner, err = models.GetUserById(repo.OwnerId)
  30. if err != nil {
  31. ctx.Handle(500, "dashboard.Home(GetUserById)", err)
  32. return
  33. }
  34. }
  35. ctx.Data["Repos"] = repos
  36. ctx.Data["PageIsHome"] = true
  37. ctx.HTML(200, "home")
  38. }
  39. func Help(ctx *middleware.Context) {
  40. ctx.Data["PageIsHelp"] = true
  41. ctx.Data["Title"] = "Help"
  42. ctx.HTML(200, "help")
  43. }
  44. func NotFound(ctx *middleware.Context) {
  45. ctx.Data["PageIsNotFound"] = true
  46. ctx.Data["Title"] = "Page Not Found"
  47. ctx.Handle(404, "home.NotFound", nil)
  48. }