Debian Codegraph @

config/configProvider.go

raw
1 // Copyright 2019 The Hugo Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13
14 package config
15
16 import (
17 "time"
18
19 "github.com/gohugoio/hugo/common/hmaps"
20 "github.com/gohugoio/hugo/common/paths"
21 "github.com/gohugoio/hugo/common/types"
22 "github.com/gohugoio/hugo/common/urls"
23 "github.com/gohugoio/hugo/hugolib/sitesmatrix"
24 "github.com/gohugoio/hugo/identity"
25 )
26
27 // AllProvider is a sub set of all config settings.
28 type AllProvider interface {
29 Language() any
30 LanguageIndex() int
31 Languages() any
32 LanguagePrefix() string
33 BaseURL() urls.BaseURL
34 BaseURLLiveReload() urls.BaseURL
35 PathParser() *paths.PathParser
36 Environment() string
37 IsMultihost() bool
38 IsMultilingual() bool
39 NoBuildLock() bool
40 BaseConfig() BaseConfig
41 Dirs() CommonDirs
42 Quiet() bool
43 DirsBase() CommonDirs
44 FileCaches() any
45 ContentTypes() ContentTypesProvider
46 GetConfigSection(string) any
47 GetConfig() any
48 CanonifyURLs() bool
49 DisablePathToLower() bool
50 RemovePathAccents() bool
51 IsUglyURLs(section string) bool
52 DefaultContentLanguage() string
53 DefaultContentLanguageInSubdir() bool
54 DefaultContentRoleInSubdir() bool
55 DefaultContentVersionInSubdir() bool
56 DefaultContentsitesMatrix() *sitesmatrix.IntSets
57 AllSitesMatrix() *sitesmatrix.IntSets
58 IsKindEnabled(string) bool
59 IsLangDisabled(string) bool
60 SummaryLength() int
61 Pagination() Pagination
62 BuildExpired() bool
63 BuildFuture() bool
64 BuildDrafts() bool
65 Running() bool
66 Watching() bool
67 NewIdentityManager(opts ...identity.ManagerOption) identity.Manager
68 FastRenderMode() bool
69 PrintUnusedTemplates() bool
70 EnableMissingTranslationPlaceholders() bool
71 TemplateMetrics() bool
72 TemplateMetricsHints() bool
73 PrintI18nWarnings() bool
74 CreateTitle(s string) string
75 IgnoreFile(s string) bool
76 NewContentEditor() string
77 Timeout() time.Duration
78 StaticDirs() []string
79 IgnoredLogs() map[string]bool
80 WorkingDir() string
81 EnableEmoji() bool
82 ConfiguredDimensions() *sitesmatrix.ConfiguredDimensions
83 CacheDirMisc() string
84 }
85
86 // We cannot import the media package as that would create a circular dependency.
87 // This interface defines a subset of what media.ContentTypes provides.
88 type ContentTypesProvider interface {
89 IsContentSuffix(suffix string) bool
90 IsContentFile(filename string) bool
91 IsIndexContentFile(filename string) bool
92 IsHTMLSuffix(suffix string) bool
93 }
94
95 // Provider provides the configuration settings for Hugo.
96 type Provider interface {
97 GetString(key string) string
98 GetInt(key string) int
99 GetBool(key string) bool
100 GetParams(key string) hmaps.Params
101 GetStringMap(key string) map[string]any
102 GetStringMapString(key string) map[string]string
103 GetStringSlice(key string) []string
104 Get(key string) any
105 Set(key string, value any)
106 Keys() []string
107 Merge(key string, value any)
108 SetDefaults(params hmaps.Params)
109 SetDefaultMergeStrategy()
110 WalkParams(walkFn func(params ...hmaps.KeyParams) bool)
111 IsSet(key string) bool
112 }
113
114 // GetStringSlicePreserveString returns a string slice from the given config and key.
115 // It differs from the GetStringSlice method in that if the config value is a string,
116 // we do not attempt to split it into fields.
117 func GetStringSlicePreserveString(cfg Provider, key string) []string {
118 sd := cfg.Get(key)
119 return types.ToStringSlicePreserveString(sd)
120 }
121
122 /*func (cd ConfiguredDimensions) Language(v sitesmatrix.Vector) ConfiguredDimension {
123 }*/