[CODE] valid frab xml with hard coded events from golang structs
This commit is contained in:
parent
7c7ea7f914
commit
7e5fbbe254
42
main.go
42
main.go
|
@ -8,6 +8,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type frabSchedule struct {
|
type frabSchedule struct {
|
||||||
|
@ -37,13 +38,14 @@ type room struct {
|
||||||
|
|
||||||
type event struct {
|
type event struct {
|
||||||
ID int
|
ID int
|
||||||
GUID string // here: $dayIndex-$eventID
|
GUID string // autogen UUID
|
||||||
|
|
||||||
Room string
|
Room string
|
||||||
Title string
|
Title string
|
||||||
Date string // timedate (RFC3339)
|
Date string // timedate (RFC3339)
|
||||||
Start string // time (hh:mm)
|
Start string // time (hh:mm)
|
||||||
Duration string // time (hh:mm)
|
Duration string // time (hh:mm)
|
||||||
|
Language string
|
||||||
|
|
||||||
Persons []person
|
Persons []person
|
||||||
}
|
}
|
||||||
|
@ -54,7 +56,7 @@ type person struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
fmt.Println("Conference Schedule CSV to Frab (Infobeamer) Converter")
|
fmt.Println("Conference Schedule: CSV to Frab (Infobeamer) Converter")
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Data Input
|
* Data Input
|
||||||
|
@ -78,26 +80,44 @@ func main() {
|
||||||
/*
|
/*
|
||||||
* Data Conversion
|
* Data Conversion
|
||||||
*/
|
*/
|
||||||
// new conference
|
timeDateFormat := "2006-01-02"
|
||||||
conf := conference{"Test Conference", "2018-11-20", "2018-11-24", 4}
|
// timeTimeFormat := "15:04"
|
||||||
|
|
||||||
// gather all rooms
|
// new conference
|
||||||
|
cmdTitle := "Test Conference" // TODO: get from command line
|
||||||
|
cmdStart := "2018-11-18" // TODO: get from command line
|
||||||
|
cmdEnd := "2018-11-19" // TODO: get from command line
|
||||||
|
|
||||||
|
cmdStartTime, _ := time.Parse(timeDateFormat, cmdStart)
|
||||||
|
cmdEndTime, _ := time.Parse(timeDateFormat, cmdEnd)
|
||||||
|
|
||||||
|
confDurationDays := int(cmdEndTime.Sub(cmdStartTime).Hours()/24) + 1
|
||||||
|
conf := conference{cmdTitle, cmdStart, cmdEnd, confDurationDays}
|
||||||
|
|
||||||
|
// gather all rooms and persons
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
// TODO: make room and day structs
|
// TODO: make room and day structs
|
||||||
|
|
||||||
// sort by room and day into structure
|
// sort by room and day into structure
|
||||||
// TODO
|
// TODO
|
||||||
|
// valid rooms: Heuckenlock, Heuckenlock {Ebbe, Flut}, Holzhafen, Raackmoor, Wohldorfer Wald
|
||||||
|
|
||||||
// assign the conference and days to the schedule
|
// assign the conference and days to the schedule
|
||||||
day1Room1Event1 := event{123, "1-123", "Room", "Title", "2018-11-20", "10:00", "1:00", nil}
|
speaker1 := person{1, "Frau Testperson"}
|
||||||
day1Room1Event2 := event{123, "1-123", "Room", "Title", "2018-11-20", "10:00", "0:30", nil}
|
|
||||||
|
day1Room1Event1 := event{123, "1-123", "Heuckenlock", "Opening Keynote", "2018-11-18T21:00:00+01:00", "21:00", "01:00", "", []person{speaker1}}
|
||||||
|
day1Room1Event2 := event{124, "1-124", "Heuckenlock", "Quartalszahlen", "2018-11-18T22:00:00+01:00", "22:00", "00:30", "de", []person{speaker1}}
|
||||||
day1Room1Events := []event{day1Room1Event1, day1Room1Event2}
|
day1Room1Events := []event{day1Room1Event1, day1Room1Event2}
|
||||||
|
day1Room1 := room{"Heuckenlock", day1Room1Events}
|
||||||
|
|
||||||
day1Room1 := room{"Room 1", day1Room1Events}
|
day1Room2Event1 := event{223, "", "Holzhafen", "Room 2 Talk 1", "2018-11-18T21:00:00+01:00", "21:00", "01:00", "", []person{speaker1}}
|
||||||
day1Rooms := []room{day1Room1}
|
day1Room2Event2 := event{224, "", "Holzhafen", "Room 2 Title 2", "2018-11-18T22:00:00+01:00", "22:00", "00:30", "", []person{speaker1}}
|
||||||
|
day1Room2Events := []event{day1Room2Event1, day1Room2Event2}
|
||||||
|
day1Room2 := room{"Holzhafen", day1Room2Events}
|
||||||
|
|
||||||
day1 := day{1, "2018-11-20", "2018-11-20T08:00", "2018-11-20T20:00", day1Rooms}
|
day1Rooms := []room{day1Room1, day1Room2}
|
||||||
|
day1 := day{1, "2018-11-18", "2018-11-18T00:00:00+01:00", "2018-11-19T00:00:00+01:00", day1Rooms}
|
||||||
|
|
||||||
days := []day{day1}
|
days := []day{day1}
|
||||||
sched := frabSchedule{conf, days}
|
sched := frabSchedule{conf, days}
|
||||||
|
@ -105,8 +125,6 @@ func main() {
|
||||||
/*
|
/*
|
||||||
* Data Export
|
* Data Export
|
||||||
*/
|
*/
|
||||||
fmt.Println(sched)
|
|
||||||
|
|
||||||
// open output file
|
// open output file
|
||||||
xmlOutput, err := os.Create("schedule.xml")
|
xmlOutput, err := os.Create("schedule.xml")
|
||||||
defer xmlOutput.Close()
|
defer xmlOutput.Close()
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
Titel, Raum, Von, Bis, Speaker
|
Titel, Raum, Von, Bis, Speaker, Sprache (DE/EN)
|
||||||
Very good talk, Holzhafen, 19.11.2018 12:00, 19.11.2018 13:00:00,
|
Very good talk, Holzhafen, 19.11.2018 12:00, 19.11.2018 13:00:00, frab-user, de
|
||||||
Keynote, Heuckenlock Ebbe, 19.11.2018 12:00, 19.11.2018 13:00:00,
|
Keynote, Heuckenlock Ebbe, 19.11.2018 12:00, 19.11.2018 13:00:00, frab-user, de
|
||||||
|
|
|
|
@ -1,34 +1,35 @@
|
||||||
|
<?xml version='1.0' encoding='utf-8' ?>
|
||||||
|
<!-- Made with love by csv2frab -->
|
||||||
<schedule>
|
<schedule>
|
||||||
|
<version>1.0</version>
|
||||||
{{with .Conf}}<conference>
|
{{with .Conf}}<conference>
|
||||||
|
<acronym>WH</acronym>
|
||||||
<title>{{.Title}}</title>
|
<title>{{.Title}}</title>
|
||||||
<start>{{.Start}}</start>
|
<start>{{.Start}}</start>
|
||||||
<end>{{.End}}</end>
|
<end>{{.End}}</end>
|
||||||
<days>{{.Days}}</days>
|
<days>{{.Days}}</days>
|
||||||
<timeslot_duration>0:05</timeslot_duration>
|
<timeslot_duration>00:05</timeslot_duration>
|
||||||
<acronym></acronym>
|
|
||||||
</conference>{{end}}
|
</conference>{{end}}
|
||||||
|
{{range .Days}}<day index='{{.Index}}' date='{{.Date}}' start='{{.Start}}' end='{{.End}}'>
|
||||||
{{range .Days}}
|
{{range .Rooms}}<room name='{{.Name}}'>
|
||||||
<day index="{{.Index}}" date="{{.Date}}" start="{{.Start}}" end="{{.End}}">
|
{{range .Events}}<event guid='{{.GUID}}' id='{{.ID}}'>
|
||||||
{{range .Rooms}}
|
|
||||||
<room name="{{.Name}}">
|
|
||||||
{{range .Events}}
|
|
||||||
<event id="{{.ID}}" guid="{{.GUID}}">
|
|
||||||
<room>{{.Room}}</room>
|
|
||||||
<title>{{.Title}}</title>
|
|
||||||
<date>{{.Date}}</date>
|
<date>{{.Date}}</date>
|
||||||
<start>{{.Start}}</start>
|
<start>{{.Start}}</start>
|
||||||
<duration>{{.Duration}}</duration>
|
<duration>{{.Duration}}</duration>
|
||||||
|
<room>{{.Room}}</room>
|
||||||
<persons>{{range .Persons}}<person id="{{.ID}}">{{.Name}}</person>{{end}}</persons>
|
<title>{{.Title}}</title>
|
||||||
<abstract></abstract>
|
<persons>{{range .Persons}}
|
||||||
<description></description>
|
<person id='{{.ID}}'>{{.Name}}</person>{{end}}
|
||||||
|
</persons>
|
||||||
|
<language>{{.Language}}</language>
|
||||||
|
<type>Talk</type>
|
||||||
<slug></slug>
|
<slug></slug>
|
||||||
<type></type>
|
<url></url>
|
||||||
<language></language>
|
|
||||||
<recording><license></license><optout>false</optout></recording>
|
<recording><license></license><optout>false</optout></recording>
|
||||||
<subtitle></subtitle>
|
<subtitle></subtitle>
|
||||||
<track></track>
|
<track></track>
|
||||||
|
<abstract></abstract>
|
||||||
|
<description></description>
|
||||||
<links></links>
|
<links></links>
|
||||||
</event>
|
</event>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Loading…
Reference in a new issue