home.go 796 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. ctx.Data["PageIsHome"] = true
  26. ctx.HTML(200, HOME)
  27. }
  28. func NotFound(ctx *middleware.Context) {
  29. ctx.Data["Title"] = "Page Not Found"
  30. ctx.Handle(404, "home.NotFound", nil)
  31. }