[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"
|
||||
"os"
|
||||
"text/template"
|
||||
"time"
|
||||
)
|
||||
|
||||
type frabSchedule struct {
|
||||
|
@ -37,13 +38,14 @@ type room struct {
|
|||
|
||||
type event struct {
|
||||
ID int
|
||||
GUID string // here: $dayIndex-$eventID
|
||||
GUID string // autogen UUID
|
||||
|
||||
Room string
|
||||
Title string
|
||||
Date string // timedate (RFC3339)
|
||||
Start string // time (hh:mm)
|
||||
Duration string // time (hh:mm)
|
||||
Language string
|
||||
|
||||
Persons []person
|
||||
}
|
||||
|
@ -54,7 +56,7 @@ type person struct {
|
|||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println("Conference Schedule CSV to Frab (Infobeamer) Converter")
|
||||
fmt.Println("Conference Schedule: CSV to Frab (Infobeamer) Converter")
|
||||
|
||||
/*
|
||||
* Data Input
|
||||
|
@ -78,26 +80,44 @@ func main() {
|
|||
/*
|
||||
* Data Conversion
|
||||
*/
|
||||
// new conference
|
||||
conf := conference{"Test Conference", "2018-11-20", "2018-11-24", 4}
|
||||
timeDateFormat := "2006-01-02"
|
||||
// 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: make room and day structs
|
||||
|
||||
// sort by room and day into structure
|
||||
// TODO
|
||||
// valid rooms: Heuckenlock, Heuckenlock {Ebbe, Flut}, Holzhafen, Raackmoor, Wohldorfer Wald
|
||||
|
||||
// assign the conference and days to the schedule
|
||||
day1Room1Event1 := event{123, "1-123", "Room", "Title", "2018-11-20", "10:00", "1:00", nil}
|
||||
day1Room1Event2 := event{123, "1-123", "Room", "Title", "2018-11-20", "10:00", "0:30", nil}
|
||||
speaker1 := person{1, "Frau Testperson"}
|
||||
|
||||
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}
|
||||
day1Room1 := room{"Heuckenlock", day1Room1Events}
|
||||
|
||||
day1Room1 := room{"Room 1", day1Room1Events}
|
||||
day1Rooms := []room{day1Room1}
|
||||
day1Room2Event1 := event{223, "", "Holzhafen", "Room 2 Talk 1", "2018-11-18T21:00:00+01:00", "21:00", "01:00", "", []person{speaker1}}
|
||||
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}
|
||||
sched := frabSchedule{conf, days}
|
||||
|
@ -105,8 +125,6 @@ func main() {
|
|||
/*
|
||||
* Data Export
|
||||
*/
|
||||
fmt.Println(sched)
|
||||
|
||||
// open output file
|
||||
xmlOutput, err := os.Create("schedule.xml")
|
||||
defer xmlOutput.Close()
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
Titel, Raum, Von, Bis, Speaker
|
||||
Very good talk, Holzhafen, 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,
|
||||
Titel, Raum, Von, Bis, Speaker, Sprache (DE/EN)
|
||||
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, frab-user, de
|
||||
|
|
|
|
@ -1,34 +1,35 @@
|
|||
<?xml version='1.0' encoding='utf-8' ?>
|
||||
<!-- Made with love by csv2frab -->
|
||||
<schedule>
|
||||
<version>1.0</version>
|
||||
{{with .Conf}}<conference>
|
||||
<acronym>WH</acronym>
|
||||
<title>{{.Title}}</title>
|
||||
<start>{{.Start}}</start>
|
||||
<end>{{.End}}</end>
|
||||
<days>{{.Days}}</days>
|
||||
<timeslot_duration>0:05</timeslot_duration>
|
||||
<acronym></acronym>
|
||||
<timeslot_duration>00:05</timeslot_duration>
|
||||
</conference>{{end}}
|
||||
|
||||
{{range .Days}}
|
||||
<day index="{{.Index}}" date="{{.Date}}" start="{{.Start}}" end="{{.End}}">
|
||||
{{range .Rooms}}
|
||||
<room name="{{.Name}}">
|
||||
{{range .Events}}
|
||||
<event id="{{.ID}}" guid="{{.GUID}}">
|
||||
<room>{{.Room}}</room>
|
||||
<title>{{.Title}}</title>
|
||||
{{range .Days}}<day index='{{.Index}}' date='{{.Date}}' start='{{.Start}}' end='{{.End}}'>
|
||||
{{range .Rooms}}<room name='{{.Name}}'>
|
||||
{{range .Events}}<event guid='{{.GUID}}' id='{{.ID}}'>
|
||||
<date>{{.Date}}</date>
|
||||
<start>{{.Start}}</start>
|
||||
<duration>{{.Duration}}</duration>
|
||||
|
||||
<persons>{{range .Persons}}<person id="{{.ID}}">{{.Name}}</person>{{end}}</persons>
|
||||
<abstract></abstract>
|
||||
<description></description>
|
||||
<room>{{.Room}}</room>
|
||||
<title>{{.Title}}</title>
|
||||
<persons>{{range .Persons}}
|
||||
<person id='{{.ID}}'>{{.Name}}</person>{{end}}
|
||||
</persons>
|
||||
<language>{{.Language}}</language>
|
||||
<type>Talk</type>
|
||||
<slug></slug>
|
||||
<type></type>
|
||||
<language></language>
|
||||
<url></url>
|
||||
<recording><license></license><optout>false</optout></recording>
|
||||
<subtitle></subtitle>
|
||||
<track></track>
|
||||
<abstract></abstract>
|
||||
<description></description>
|
||||
<links></links>
|
||||
</event>
|
||||
{{end}}
|
||||
|
|
Loading…
Reference in a new issue