Add authors in themes
This commit is contained in:
parent
e628e7931c
commit
859dbc68cb
4 changed files with 24 additions and 17 deletions
|
|
@ -23,7 +23,8 @@ type exportedExercice struct {
|
|||
}
|
||||
|
||||
type exportedTheme struct {
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name"`
|
||||
Authors string `json:"authors"`
|
||||
Exercices map[string]exportedExercice `json:"exercices"`
|
||||
}
|
||||
|
||||
|
|
@ -46,6 +47,7 @@ func exportThemes() (interface{}, error) {
|
|||
}
|
||||
ret[fmt.Sprintf("%d", theme.Id)] = exportedTheme{
|
||||
theme.Name,
|
||||
theme.Authors,
|
||||
exos,
|
||||
}
|
||||
}
|
||||
|
|
@ -108,7 +110,8 @@ func listTheme(args []string, body []byte) (interface{}, error) {
|
|||
}
|
||||
|
||||
type uploadedTheme struct {
|
||||
Name string
|
||||
Name string
|
||||
Authors string
|
||||
}
|
||||
|
||||
func creationTheme(args []string, body []byte) (interface{}, error) {
|
||||
|
|
@ -129,7 +132,7 @@ func creationTheme(args []string, body []byte) (interface{}, error) {
|
|||
return nil, errors.New("Theme's name not filled")
|
||||
}
|
||||
|
||||
return fic.CreateTheme(ut.Name)
|
||||
return fic.CreateTheme(ut.Name, ut.Authors)
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ CLOUDPASS=fic:'f>t\nV33R|(+?$i*'
|
|||
|
||||
new_theme() {
|
||||
NAME=`echo $1 | sed 's/"/\\\\"/g'`
|
||||
curl -f -s -d "{\"name\": \"$NAME\"}" "${BASEURL}/api/themes/" |
|
||||
AUTHORS=`echo $2 | sed 's/"/\\\\"/g'`
|
||||
curl -f -s -d "{\"name\": \"$NAME\", \"authors\": \"$AUTHORS\"}" "${BASEURL}/api/themes/" |
|
||||
grep -Eo '"id":[0-9]+,' | grep -Eo "[0-9]+"
|
||||
}
|
||||
|
||||
|
|
@ -43,10 +44,12 @@ new_key() {
|
|||
}
|
||||
|
||||
# Theme
|
||||
curl -f -s -X PROPFIND -u "${CLOUDPASS}" "${BASEURI}" | xmllint --format - | grep 'd:href' | sed -E 's/^.*>(.*)<.*$/\1/' | sed 1d | while read f; do basename "$f"; done | while read THEME_URI
|
||||
curl -f -s -X PROPFIND -u "${CLOUDPASS}" "${BASEURI}" | xmllint --format - | grep 'd:href' | sed -E 's/^.*>(.*)<.*$/\1/' | sed 1d | tac | while read f; do basename "$f"; done | while read THEME_URI
|
||||
do
|
||||
THM_BASEURI="/${THEME_URI}/"
|
||||
THEME_NAME=$(echo "${THEME_URI}" | sed -E 's/%20/ /g' | sed -E 's/%c3%a9/é/g' | sed -E 's/%c3%a8/è/g')
|
||||
THEME_ID=`new_theme "$THEME_NAME"`
|
||||
THEME_AUTHORS=$(curl -f -s -u "${CLOUDPASS}" "${BASEURI}${THM_BASEURI}/AUTHORS.txt" | sed 's/$/,/' | xargs)
|
||||
THEME_ID=`new_theme "$THEME_NAME" "$THEME_AUTHORS"`
|
||||
if [ -z "$THEME_ID" ]; then
|
||||
echo -e "\e[31;01m!!! An error occured during theme add\e[00m"
|
||||
continue
|
||||
|
|
@ -56,7 +59,6 @@ do
|
|||
|
||||
LAST=null
|
||||
EXO_NUM=0
|
||||
THM_BASEURI="/${THEME_URI}/"
|
||||
curl -f -s -X PROPFIND -u "${CLOUDPASS}" "${BASEURI}${THM_BASEURI}" | xmllint --format - | grep 'd:href' | sed -E 's/^.*>(.*)<.*$/\1/' | sed -E 's/%20/ /g' | sed -E 's/%c3%a9/é/g' | sed -E 's/%c3%a8/è/g' | sed 1d | while read f; do basename "$f"; done | while read EXO_NAME
|
||||
do
|
||||
if ! echo $EXO_NAME | grep Exercice > /dev/null
|
||||
|
|
|
|||
Reference in a new issue