-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvertVolcamp2of.sh
More file actions
110 lines (82 loc) · 2.14 KB
/
convertVolcamp2of.sh
File metadata and controls
110 lines (82 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
DIR="_talks/"${1:-.}
OUTPUT="openfeedback.json"
if ! command -v yq >/dev/null 2>&1; then
echo "Erreur: 'yq' est requis."
exit 1
fi
# Début du JSON Openfeedback
echo "{" > "$OUTPUT"
# Début du JSON Sessions
echo "\"sessions\": {" >> "$OUTPUT"
first=true
for file in "$DIR"/*.md; do
[ -e "$file" ] || continue
echo "📄 Traitement : $file"
# Extraction du YAML
yaml=$(awk '/^---/{flag=!flag;next} flag' "$file")
# Variables extraites avec yq
id=$(echo "$yaml" | yq -r '.name')
title=$(echo "$yaml" | yq -r '.title')
speakers=$(echo "$yaml" | yq -o=json '.speakers')
room=$(echo "$yaml" | yq -r '.room')
date=$(echo "$yaml" | yq -r '.slot' | awk -F/ '{print $3 "-" $2 "-" $1}')
start=$(echo "$yaml" | yq -r '.time_start' | sed "s/h/:/")
end=$(echo "$yaml" | yq -r '.time_end' | sed "s/h/:/")
startTime="${date}T${start}:00+02:00"
endTime="${date}T${end}:00+02:00"
clean_title=$(echo "$title" | tr -d '"')
# Ajout à l'objet JSON
if [ "$first" = true ]; then
first=false
else
echo "," >> "$OUTPUT"
fi
cat >> "$OUTPUT" <<EOF
"$id": {
"speakers": $speakers,
"title": "$clean_title",
"id": "$id",
"startTime": "$startTime",
"endTime": "$endTime",
"trackTitle": "$room"
}
EOF
done
# Fin de Sessions
echo "}," >> "$OUTPUT"
# Début du JSON speakers
echo "\"speakers\": " >> "$OUTPUT"
DIR="_speakers/"${1:-.}
echo "{" >> "$OUTPUT"
first=true
for file in "$DIR"/*.md; do
[ -e "$file" ] || continue
echo "📄 Traitement : $file"
# Extraction du YAML
yaml=$(awk '/^---/{flag=!flag;next} flag' "$file")
# Variables extraites avec yq
title=$(echo "$yaml" | yq -r '.title')
# Nettoyage du titre (supprimer guillemets éventuels)
clean_title=$(echo "$title" | tr -d '"')
if [ "$clean_title" = "TBD" ]; then
continue
fi
# Ajout au JSON
if [ "$first" = true ]; then
first=false
else
echo "," >> "$OUTPUT"
fi
cat >> "$OUTPUT" <<EOF
"$clean_title": {
"name": "$clean_title",
"id": "$clean_title"
}
EOF
done
# Fin du JSON Speakers
echo "}" >> "$OUTPUT"
# Fin du JSON
echo "}" >> "$OUTPUT"
echo "Fichier global généré : $OUTPUT"