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.

46 lines
1.0 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
  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. }