2021-01-26 15:36:53 +00:00
|
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
2022-11-27 18:20:29 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2021-01-26 15:36:53 +00:00
|
|
|
|
2021-01-30 08:55:53 +00:00
|
|
|
package middleware
|
2021-01-26 15:36:53 +00:00
|
|
|
|
2023-05-04 06:36:34 +00:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
|
2024-12-24 03:43:57 +00:00
|
|
|
"code.gitea.io/gitea/modules/reqctx"
|
2023-05-04 06:36:34 +00:00
|
|
|
"code.gitea.io/gitea/modules/setting"
|
|
|
|
)
|
|
|
|
|
|
|
|
const ContextDataKeySignedUser = "SignedUser"
|
|
|
|
|
2024-12-24 03:43:57 +00:00
|
|
|
func GetContextData(c context.Context) reqctx.ContextData {
|
|
|
|
if rc := reqctx.GetRequestDataStore(c); rc != nil {
|
|
|
|
return rc.GetData()
|
2023-05-04 06:36:34 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-12-24 03:43:57 +00:00
|
|
|
func CommonTemplateContextData() reqctx.ContextData {
|
|
|
|
return reqctx.ContextData{
|
2023-05-04 06:36:34 +00:00
|
|
|
"IsLandingPageOrganizations": setting.LandingPageURL == setting.LandingPageOrganizations,
|
|
|
|
|
|
|
|
"ShowRegistrationButton": setting.Service.ShowRegistrationButton,
|
|
|
|
"ShowMilestonesDashboardPage": setting.Service.ShowMilestonesDashboardPage,
|
|
|
|
"ShowFooterVersion": setting.Other.ShowFooterVersion,
|
|
|
|
"DisableDownloadSourceArchives": setting.Repository.DisableDownloadSourceArchives,
|
|
|
|
|
|
|
|
"EnableSwagger": setting.API.EnableSwagger,
|
|
|
|
"EnableOpenIDSignIn": setting.Service.EnableOpenIDSignIn,
|
|
|
|
"PageStartTime": time.Now(),
|
|
|
|
|
|
|
|
"RunModeIsProd": setting.IsProd,
|
|
|
|
}
|
2021-01-26 15:36:53 +00:00
|
|
|
}
|