mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-01 17:32:31 -05:00
[feature] configurable maximum thumbnail dimensions (#4258)
- adds configuration for thumbnail maximum dimensions with warning on exceeding recommendations - moves the media configuration vars into their own sub-struct - replaces the configuration flag funcs with simple string consts Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4258 Reviewed-by: tobi <kipvandenbos@noreply.codeberg.org> Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
This commit is contained in:
parent
1dc79c9586
commit
d7f967cbb5
17 changed files with 902 additions and 1099 deletions
|
|
@ -85,6 +85,7 @@ func main() {
|
|||
fprintf(output, "\t\"github.com/spf13/cast\"\n")
|
||||
fprintf(output, ")\n")
|
||||
fprintf(output, "\n")
|
||||
generateFlagConsts(output, fields)
|
||||
generateFlagRegistering(output, fields)
|
||||
generateMapMarshaler(output, fields)
|
||||
generateMapUnmarshaler(output, fields)
|
||||
|
|
@ -200,14 +201,14 @@ func loadConfigFields(pathPrefixes, flagPrefixes []string, t reflect.Type) []Con
|
|||
return out
|
||||
}
|
||||
|
||||
// func generateFlagConsts(out io.Writer, fields []ConfigField) {
|
||||
// fprintf(out, "const (\n")
|
||||
// for _, field := range fields {
|
||||
// name := strings.ReplaceAll(field.Path, ".", "")
|
||||
// fprintf(out, "\t%sFlag = \"%s\"\n", name, field.Flag())
|
||||
// }
|
||||
// fprintf(out, ")\n\n")
|
||||
// }
|
||||
func generateFlagConsts(out io.Writer, fields []ConfigField) {
|
||||
fprintf(out, "const (\n")
|
||||
for _, field := range fields {
|
||||
name := strings.ReplaceAll(field.Path, ".", "")
|
||||
fprintf(out, "\t%sFlag = \"%s\"\n", name, field.Flag())
|
||||
}
|
||||
fprintf(out, ")\n\n")
|
||||
}
|
||||
|
||||
func generateFlagRegistering(out io.Writer, fields []ConfigField) {
|
||||
fprintf(out, "func (cfg *Configuration) RegisterFlags(flags *pflag.FlagSet) {\n")
|
||||
|
|
@ -461,9 +462,6 @@ func generateGetSetters(out io.Writer, fields []ConfigField) {
|
|||
"config.", "",
|
||||
)
|
||||
|
||||
fprintf(out, "// %sFlag returns the flag name for the '%s' field\n", name, field.Path)
|
||||
fprintf(out, "func %sFlag() string { return \"%s\" }\n\n", name, field.Flag())
|
||||
|
||||
// ConfigState structure helper methods
|
||||
fprintf(out, "// Get%s safely fetches the Configuration value for state's '%s' field\n", name, field.Path)
|
||||
fprintf(out, "func (st *ConfigState) Get%s() (v %s) {\n", name, fieldType)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue