Browse Source

Отображение столбцов в поля структуры доверительных свойств сделано более явно #128

pull/150/head
Artur Galyamov 2 years ago
parent
commit
aa6d260ca1
  1. 20
      services/trust_props/trust_props.go

20
services/trust_props/trust_props.go

@ -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()
}

Loading…
Cancel
Save