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.

dashboard.go 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. if err = repo.GetOwner(); err != nil {
  30. ctx.Handle(500, "dashboard.Home(GetOwner)", err)
  31. return
  32. }
  33. }
  34. ctx.Data["Repos"] = repos
  35. ctx.Data["PageIsHome"] = true
  36. ctx.HTML(200, "home")
  37. }
  38. func NotFound(ctx *middleware.Context) {
  39. ctx.Data["PageIsNotFound"] = true
  40. ctx.Data["Title"] = "Page Not Found"
  41. ctx.Handle(404, "home.NotFound", nil)
  42. }