gitea源码

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package middleware
  4. import (
  5. "context"
  6. "time"
  7. "code.gitea.io/gitea/modules/reqctx"
  8. "code.gitea.io/gitea/modules/setting"
  9. )
  10. const ContextDataKeySignedUser = "SignedUser"
  11. func GetContextData(c context.Context) reqctx.ContextData {
  12. if rc := reqctx.GetRequestDataStore(c); rc != nil {
  13. return rc.GetData()
  14. }
  15. return nil
  16. }
  17. func CommonTemplateContextData() reqctx.ContextData {
  18. return reqctx.ContextData{
  19. "IsLandingPageOrganizations": setting.LandingPageURL == setting.LandingPageOrganizations,
  20. "ShowRegistrationButton": setting.Service.ShowRegistrationButton,
  21. "ShowMilestonesDashboardPage": setting.Service.ShowMilestonesDashboardPage,
  22. "ShowFooterVersion": setting.Other.ShowFooterVersion,
  23. "DisableDownloadSourceArchives": setting.Repository.DisableDownloadSourceArchives,
  24. "EnableSwagger": setting.API.EnableSwagger,
  25. "EnableOpenIDSignIn": setting.Service.EnableOpenIDSignIn,
  26. "PageStartTime": time.Now(),
  27. "RunModeIsProd": setting.IsProd,
  28. }
  29. }