@@ -12,8 +12,8 @@ import (
1212)
1313
1414type PictureStruct struct {
15- DisableGravatar * config.Value [bool ]
16- EnableFederatedAvatar * config.Value [bool ]
15+ DisableGravatar * config.Option [bool ]
16+ EnableFederatedAvatar * config.Option [bool ]
1717}
1818
1919type OpenWithEditorApp struct {
@@ -23,6 +23,9 @@ type OpenWithEditorApp struct {
2323
2424type OpenWithEditorAppsType []OpenWithEditorApp
2525
26+ // ToTextareaString is only used in templates, for help prompt only
27+ // TODO: OPEN-WITH-EDITOR-APP-JSON: Because there is no "rich UI", a plain text editor is used to manage the list of apps
28+ // Maybe we can use some better formats like Yaml in the future, then a simple textarea can manage the config clearly
2629func (t OpenWithEditorAppsType ) ToTextareaString () string {
2730 var ret strings.Builder
2831 for _ , app := range t {
@@ -31,7 +34,7 @@ func (t OpenWithEditorAppsType) ToTextareaString() string {
3134 return ret .String ()
3235}
3336
34- func DefaultOpenWithEditorApps () OpenWithEditorAppsType {
37+ func openWithEditorAppsDefaultValue () OpenWithEditorAppsType {
3538 return OpenWithEditorAppsType {
3639 {
3740 DisplayName : "VS Code" ,
@@ -49,13 +52,14 @@ func DefaultOpenWithEditorApps() OpenWithEditorAppsType {
4952}
5053
5154type RepositoryStruct struct {
52- OpenWithEditorApps * config.Value [OpenWithEditorAppsType ]
53- GitGuideRemoteName * config.Value [string ]
55+ OpenWithEditorApps * config.Option [OpenWithEditorAppsType ]
56+ GitGuideRemoteName * config.Option [string ]
5457}
5558
5659type ConfigStruct struct {
5760 Picture * PictureStruct
5861 Repository * RepositoryStruct
62+ Instance * InstanceStruct
5963}
6064
6165var (
@@ -67,12 +71,16 @@ func initDefaultConfig() {
6771 config .SetCfgSecKeyGetter (& cfgSecKeyGetter {})
6872 defaultConfig = & ConfigStruct {
6973 Picture : & PictureStruct {
70- DisableGravatar : config.ValueJSON [bool ]("picture.disable_gravatar" ).WithFileConfig (config.CfgSecKey {Sec : "picture" , Key : "DISABLE_GRAVATAR" }),
71- EnableFederatedAvatar : config.ValueJSON [bool ]("picture.enable_federated_avatar" ).WithFileConfig (config.CfgSecKey {Sec : "picture" , Key : "ENABLE_FEDERATED_AVATAR" }),
74+ DisableGravatar : config.NewOption [bool ]("picture.disable_gravatar" ). WithDefaultSimple ( true ).WithFileConfig (config.CfgSecKey {Sec : "picture" , Key : "DISABLE_GRAVATAR" }),
75+ EnableFederatedAvatar : config.NewOption [bool ]("picture.enable_federated_avatar" ).WithFileConfig (config.CfgSecKey {Sec : "picture" , Key : "ENABLE_FEDERATED_AVATAR" }),
7276 },
7377 Repository : & RepositoryStruct {
74- OpenWithEditorApps : config.ValueJSON [OpenWithEditorAppsType ]("repository.open-with.editor-apps" ),
75- GitGuideRemoteName : config.ValueJSON [string ]("repository.git-guide-remote-name" ).WithDefault ("origin" ),
78+ OpenWithEditorApps : config.NewOption [OpenWithEditorAppsType ]("repository.open-with.editor-apps" ).WithEmptyAsDefault ().WithDefaultFunc (openWithEditorAppsDefaultValue ),
79+ GitGuideRemoteName : config.NewOption [string ]("repository.git-guide-remote-name" ).WithEmptyAsDefault ().WithDefaultSimple ("origin" ),
80+ },
81+ Instance : & InstanceStruct {
82+ WebBanner : config.NewOption [WebBannerType ]("instance.web_banner" ),
83+ MaintenanceMode : config.NewOption [MaintenanceModeType ]("instance.maintenance_mode" ),
7684 },
7785 }
7886}
0 commit comments