home.go 918 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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/modules/base"
  7. "github.com/gogits/gogs/modules/middleware"
  8. "github.com/gogits/gogs/modules/setting"
  9. "github.com/gogits/gogs/routers/user"
  10. )
  11. const (
  12. HOME base.TplName = "home"
  13. )
  14. func Home(ctx *middleware.Context) {
  15. if ctx.IsSigned {
  16. user.Dashboard(ctx)
  17. return
  18. }
  19. // Check auto-login.
  20. uname := ctx.GetCookie(setting.CookieUserName)
  21. if len(uname) != 0 {
  22. ctx.Redirect("/user/login")
  23. return
  24. }
  25. if setting.OauthService != nil {
  26. ctx.Data["OauthEnabled"] = true
  27. ctx.Data["OauthService"] = setting.OauthService
  28. }
  29. ctx.Data["PageIsHome"] = true
  30. ctx.HTML(200, HOME)
  31. }
  32. func NotFound(ctx *middleware.Context) {
  33. ctx.Data["Title"] = "Page Not Found"
  34. ctx.Handle(404, "home.NotFound", nil)
  35. }