mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-01 07:09:21 +01:00
1d8bca07f3
Adds `[repository].DOWNLOAD_OR_CLONE_METHODS` (defaulting to "download-zip,download-targz,download-bundle,vscode-clone"), which lets an instance administrator override the additional clone methods displayed on the repository home view. This is purely display-only, the clone methods not listed here are still available, unless disabled elsewhere. They're just not displayed. Fixes #710. Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu> (cherry picked from commit2aadcf4946
) (cherry picked from commit42ac34fbf9
) (cherry picked from commitbd231b0245
) (cherry picked from commit3d3366dbbe
) (cherry picked from commit0157fb9b88
) (cherry picked from commitbee88f6a83
)
64 lines
1.6 KiB
Go
64 lines
1.6 KiB
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package middleware
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"code.gitea.io/gitea/modules/setting"
|
|
)
|
|
|
|
// ContextDataStore represents a data store
|
|
type ContextDataStore interface {
|
|
GetData() ContextData
|
|
}
|
|
|
|
type ContextData map[string]any
|
|
|
|
func (ds ContextData) GetData() ContextData {
|
|
return ds
|
|
}
|
|
|
|
func (ds ContextData) MergeFrom(other ContextData) ContextData {
|
|
for k, v := range other {
|
|
ds[k] = v
|
|
}
|
|
return ds
|
|
}
|
|
|
|
const ContextDataKeySignedUser = "SignedUser"
|
|
|
|
type contextDataKeyType struct{}
|
|
|
|
var contextDataKey contextDataKeyType
|
|
|
|
func WithContextData(c context.Context) context.Context {
|
|
return context.WithValue(c, contextDataKey, make(ContextData, 10))
|
|
}
|
|
|
|
func GetContextData(c context.Context) ContextData {
|
|
if ds, ok := c.Value(contextDataKey).(ContextData); ok {
|
|
return ds
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func CommonTemplateContextData() ContextData {
|
|
return ContextData{
|
|
"IsLandingPageOrganizations": setting.LandingPageURL == setting.LandingPageOrganizations,
|
|
|
|
"ShowRegistrationButton": setting.Service.ShowRegistrationButton,
|
|
"ShowMilestonesDashboardPage": setting.Service.ShowMilestonesDashboardPage,
|
|
"ShowFooterVersion": setting.Other.ShowFooterVersion,
|
|
"DisableDownloadSourceArchives": setting.Repository.DisableDownloadSourceArchives,
|
|
"DownloadOrCloneMethods": setting.Repository.DownloadOrCloneMethods,
|
|
|
|
"EnableSwagger": setting.API.EnableSwagger,
|
|
"EnableOpenIDSignIn": setting.Service.EnableOpenIDSignIn,
|
|
"PageStartTime": time.Now(),
|
|
|
|
"RunModeIsProd": setting.IsProd,
|
|
}
|
|
}
|