|
|
|
@ -7,7 +7,6 @@ import (
|
|
|
|
|
"code.gitea.io/gitea/modules/markup/markdown" |
|
|
|
|
"reflect" |
|
|
|
|
"regexp" |
|
|
|
|
"strings" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func SaveRepoAndRenderContent(ctx *context.Context, colName string) (string, error) { |
|
|
|
@ -28,7 +27,13 @@ func SaveRepoAndRenderContent(ctx *context.Context, colName string) (string, err
|
|
|
|
|
if err != nil { |
|
|
|
|
return "", err |
|
|
|
|
} |
|
|
|
|
fieldName := upCase(colName) |
|
|
|
|
|
|
|
|
|
fieldNames := map[string]string{ |
|
|
|
|
"resources": "Resources", |
|
|
|
|
"competences": "Competences", |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fieldName := fieldNames[colName] |
|
|
|
|
reflectedRepo := reflect.ValueOf(repo) |
|
|
|
|
reflectedRepo.Elem().FieldByName(fieldName).SetString(trimmedToggledContent) |
|
|
|
|
err = repo_model.UpdateRepositoryCols(repo, colName) |
|
|
|
@ -40,19 +45,10 @@ func SaveRepoAndRenderContent(ctx *context.Context, colName string) (string, err
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func trimSearchLinks(content string) (string, error) { |
|
|
|
|
regExp, err := regexp.Compile(`\s*\[найти\]\(.+\s*\)`) |
|
|
|
|
regExp, err := regexp.Compile(`\s+\[найти\]\(.+\s*\)`) |
|
|
|
|
if err != nil { |
|
|
|
|
return "", err |
|
|
|
|
} |
|
|
|
|
trimmedSearchLink := regExp.ReplaceAllString(content, "") |
|
|
|
|
return trimmedSearchLink, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func upCase(str string) string { |
|
|
|
|
ch := rune(str[0]) |
|
|
|
|
ch -= 'a' - 'A' |
|
|
|
|
var upCasedSB strings.Builder |
|
|
|
|
upCasedSB.WriteRune(ch) |
|
|
|
|
upCasedSB.WriteString(str[1:]) |
|
|
|
|
return upCasedSB.String() |
|
|
|
|
} |
|
|
|
|