sync: parse complex AUTHORS.txt as described in README

This commit is contained in:
nemunaire 2018-08-19 22:40:08 +02:00 committed by Pierre-Olivier Mercier
parent 2a941a4fc7
commit da2a88a3a6
3 changed files with 17 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package sync
import ( import (
"fmt" "fmt"
"path" "path"
"regexp"
"strings" "strings"
"srs.epita.fr/fic-server/libfic" "srs.epita.fr/fic-server/libfic"
@ -32,7 +33,17 @@ func getAuthors(i Importer, tname string) ([]string, error) {
if authors, err := getFileContent(i, path.Join(tname, "AUTHORS.txt")); err != nil { if authors, err := getFileContent(i, path.Join(tname, "AUTHORS.txt")); err != nil {
return nil, err return nil, err
} else { } else {
return strings.Split(strings.TrimSpace(authors), "\n"), nil var ret []string
re := regexp.MustCompile("^([^<]+)(?: +<(.*)>)?$")
for _, a := range strings.Split(strings.TrimSpace(authors), "\n") {
grp := re.FindStringSubmatch(a)
if len(grp) < 2 || grp[2] == "" {
ret = append(ret, a)
} else {
ret = append(ret, fmt.Sprintf("<a href=\"%s\">%s</a>", grp[2], grp[1]))
}
}
return ret, nil
} }
} }

View File

@ -126,6 +126,10 @@ a:hover .teamname {
text-shadow: 0px 0px 10px #888888; text-shadow: 0px 0px 10px #888888;
} }
.authors a {
color: #3A3F44;
}
.heading { .heading {
font-style: italic; font-style: italic;
margin-top: -7px; margin-top: -7px;

View File

@ -92,7 +92,7 @@
<div class="container" style="margin-top: 5px;"> <div class="container" style="margin-top: 5px;">
<div class="page-header text-primary" ng-cloak> <div class="page-header text-primary" ng-cloak>
<h1 ng-if="(current_theme)">{{ themes[current_theme].name }} <small class="authors" ng-if="themes[current_theme].authors">{{ themes[current_theme].authors }}</small></h1> <h1 ng-if="(current_theme)">{{ themes[current_theme].name }} <small class="authors" ng-if="themes[current_theme].authors" ng-bind-html="themes[current_theme].authors"></small></h1>
<h1 ng-if="(!current_theme && title)" ng-cloak>{{ title }} <small class="authors" ng-if="authors">{{ authors }}</small></h1> <h1 ng-if="(!current_theme && title)" ng-cloak>{{ title }} <small class="authors" ng-if="authors">{{ authors }}</small></h1>
<h1 ng-if="(!current_theme && !title)">{{ settings.title }} <small class="authors">{{ settings.authors }}</small></h1> <h1 ng-if="(!current_theme && !title)">{{ settings.title }} <small class="authors">{{ settings.authors }}</small></h1>
</div> </div>