diff --git a/go.mod b/go.mod index 7b78359ca..b689e33ed 100644 --- a/go.mod +++ b/go.mod @@ -44,7 +44,7 @@ require ( github.com/jgautheron/goconst v0.0.0-20170703170152-9740945f5dcb github.com/labstack/echo/v4 v4.1.5 github.com/labstack/gommon v0.2.8 - github.com/laurent22/ical-go v0.1.0 + github.com/laurent22/ical-go v0.1.1-0.20181107184520-7e5d6ade8eef github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983 // indirect github.com/mattn/go-oci8 v0.0.0-20181130072307-052f5d97b9b6 // indirect github.com/mattn/go-runewidth v0.0.4 // indirect diff --git a/go.sum b/go.sum index 248330641..baf8436ea 100644 --- a/go.sum +++ b/go.sum @@ -27,7 +27,6 @@ github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMe github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/cweill/gotests v1.5.3 h1:k3t4wW/x/YNixWZJhUIn+mivmK5iV1tJVOwVYkx0UcU= github.com/d4l3k/messagediff v1.2.1 h1:ZcAIMYsUg0EAp9X+tt8/enBE/Q8Yd5kzPynLyKptt9U= github.com/d4l3k/messagediff v1.2.1/go.mod h1:Oozbb1TVXFac9FtSIxHBMnBCq2qeH/2KkEQxENCrlLo= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -122,8 +121,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/labstack/gommon v0.2.8 h1:JvRqmeZcfrHC5u6uVleB4NxxNbzx6gpbJiQknDbKQu0= github.com/labstack/gommon v0.2.8/go.mod h1:/tj9csK2iPSBvn+3NLM9e52usepMtrd5ilFYA+wQNJ4= -github.com/laurent22/ical-go v0.1.0 h1:4vZHBD3/+ne+IN+c3B+v6d9Ff8+70pzTjCWsjfDRvL0= -github.com/laurent22/ical-go v0.1.0/go.mod h1:4LATl0uhhtytR6p9n1AlktDyIz4u2iUnWEdI3L/hXiw= +github.com/laurent22/ical-go v0.1.1-0.20181107184520-7e5d6ade8eef h1:RZnRnSID1skF35j/15KJ6hKZkdIC/teQClJK5wP5LU4= +github.com/laurent22/ical-go v0.1.1-0.20181107184520-7e5d6ade8eef/go.mod h1:4LATl0uhhtytR6p9n1AlktDyIz4u2iUnWEdI3L/hXiw= github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= diff --git a/pkg/routes/caldav/parsing.go b/pkg/routes/caldav/parsing.go index 1b3fee7b3..088525e91 100644 --- a/pkg/routes/caldav/parsing.go +++ b/pkg/routes/caldav/parsing.go @@ -20,7 +20,7 @@ import ( "code.vikunja.io/api/pkg/caldav" "code.vikunja.io/api/pkg/log" "code.vikunja.io/api/pkg/models" - "github.com/laurent22/ical-go/ical" + "github.com/laurent22/ical-go" "strconv" "time" ) diff --git a/vendor/github.com/laurent22/ical-go/LICENSE b/vendor/github.com/laurent22/ical-go/LICENSE new file mode 100644 index 000000000..aeaa712de --- /dev/null +++ b/vendor/github.com/laurent22/ical-go/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Laurent Cozic + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/laurent22/ical-go/README.md b/vendor/github.com/laurent22/ical-go/README.md new file mode 100644 index 000000000..1abe54830 --- /dev/null +++ b/vendor/github.com/laurent22/ical-go/README.md @@ -0,0 +1,25 @@ +# ical-go + +iCal package for Go (Golang) + +## Installation + + go get github.com/laurent22/ical-go + +## Status + +Currently, the package doesn't support the full iCal specification. It's still a work in progress towards that goal. + +The most useful function in the package is: + +```go +func ParseCalendar(data string) (*Node, error) +``` +Parses a VCALENDAR string, unwrap and unfold lines, etc. and put all this into a usable structure (a collection of `Node`s with name, value, type, etc.). + +With the `Node` in hand, you can use several of its functions to, e.g., find specific parameters, children, etc. + + +## License + +MIT diff --git a/vendor/github.com/laurent22/ical-go/ical/calendar.go b/vendor/github.com/laurent22/ical-go/calendar.go similarity index 90% rename from vendor/github.com/laurent22/ical-go/ical/calendar.go rename to vendor/github.com/laurent22/ical-go/calendar.go index b857f5892..3a246674f 100644 --- a/vendor/github.com/laurent22/ical-go/ical/calendar.go +++ b/vendor/github.com/laurent22/ical-go/calendar.go @@ -7,7 +7,7 @@ type Calendar struct { func (this *Calendar) Serialize() string { serializer := calSerializer{ calendar: this, - buffer: new(strBuffer), + buffer: new(strBuffer), } return serializer.serialize() } diff --git a/vendor/github.com/laurent22/ical-go/ical/calendar_event.go b/vendor/github.com/laurent22/ical-go/calendar_event.go similarity index 77% rename from vendor/github.com/laurent22/ical-go/ical/calendar_event.go rename to vendor/github.com/laurent22/ical-go/calendar_event.go index 52c958052..34955ee08 100644 --- a/vendor/github.com/laurent22/ical-go/ical/calendar_event.go +++ b/vendor/github.com/laurent22/ical-go/calendar_event.go @@ -5,14 +5,15 @@ import ( ) type CalendarEvent struct { - Id string - Summary string - Description string - Location string - CreatedAtUTC *time.Time + Id string + Summary string + Description string + Location string + URL string + CreatedAtUTC *time.Time ModifiedAtUTC *time.Time - StartAt *time.Time - EndAt *time.Time + StartAt *time.Time + EndAt *time.Time } func (this *CalendarEvent) StartAtUTC() *time.Time { @@ -34,7 +35,7 @@ func (this *CalendarEvent) ToICS() string { func (this *CalendarEvent) serializeWithBuffer(buffer *strBuffer) string { serializer := calEventSerializer{ - event: this, + event: this, buffer: buffer, } return serializer.serialize() diff --git a/vendor/github.com/laurent22/ical-go/ical/properties.go b/vendor/github.com/laurent22/ical-go/ical/properties.go deleted file mode 100644 index 44acf9aff..000000000 --- a/vendor/github.com/laurent22/ical-go/ical/properties.go +++ /dev/null @@ -1,9 +0,0 @@ -package ical - -const ( - VCALENDAR = "VCALENDAR" - VEVENT = "VEVENT" - DTSTART = "DTSTART" - DTEND = "DTEND" - DURATION = "DURATION" -) diff --git a/vendor/github.com/laurent22/ical-go/ical/lib.go b/vendor/github.com/laurent22/ical-go/lib.go similarity index 57% rename from vendor/github.com/laurent22/ical-go/ical/lib.go rename to vendor/github.com/laurent22/ical-go/lib.go index 4230c097d..aa33292ad 100644 --- a/vendor/github.com/laurent22/ical-go/ical/lib.go +++ b/vendor/github.com/laurent22/ical-go/lib.go @@ -1,18 +1,18 @@ package ical import ( - "fmt" - "bytes" + "bytes" + "fmt" ) type strBuffer struct { - buffer bytes.Buffer + buffer bytes.Buffer } func (b *strBuffer) Write(format string, elem ...interface{}) { - b.buffer.WriteString(fmt.Sprintf(format, elem...)) + b.buffer.WriteString(fmt.Sprintf(format, elem...)) } func (b *strBuffer) String() string { - return b.buffer.String() + return b.buffer.String() } diff --git a/vendor/github.com/laurent22/ical-go/ical/node.go b/vendor/github.com/laurent22/ical-go/node.go similarity index 80% rename from vendor/github.com/laurent22/ical-go/ical/node.go rename to vendor/github.com/laurent22/ical-go/node.go index 252fe523d..f3de690f5 100644 --- a/vendor/github.com/laurent22/ical-go/ical/node.go +++ b/vendor/github.com/laurent22/ical-go/node.go @@ -1,17 +1,17 @@ package ical import ( - "time" "regexp" "strconv" + "time" ) type Node struct { - Name string - Value string - Type int // 1 = Object, 0 = Name/Value + Name string + Value string + Type int // 1 = Object, 0 = Name/Value Parameters map[string]string - Children []*Node + Children []*Node } func (this *Node) ChildrenByName(name string) []*Node { @@ -44,19 +44,28 @@ func (this *Node) PropString(name string, defaultValue string) string { func (this *Node) PropDate(name string, defaultValue time.Time) time.Time { node := this.ChildByName(name) - if node == nil { return defaultValue } + if node == nil { + return defaultValue + } tzid := node.Parameter("TZID", "") + allDay := node.Parameter("VALUE", "") == "DATE" var output time.Time var err error if tzid != "" { loc, err := time.LoadLocation(tzid) - if err != nil { panic(err) } + if err != nil { + panic(err) + } output, err = time.ParseInLocation("20060102T150405", node.Value, loc) + } else if allDay { + output, err = time.Parse("20060102", node.Value) } else { output, err = time.Parse("20060102T150405Z", node.Value) } - if err != nil { panic(err) } + if err != nil { + panic(err) + } return output } @@ -86,29 +95,37 @@ func (this *Node) PropDuration(name string) time.Duration { min := strToDuration(matches[2]) sec := strToDuration(matches[3]) - return hours * time.Hour + min * time.Minute + sec * time.Second + return hours*time.Hour + min*time.Minute + sec*time.Second } func (this *Node) PropInt(name string, defaultValue int) int { n := this.PropString(name, "") - if n == "" { return defaultValue } + if n == "" { + return defaultValue + } output, err := strconv.Atoi(n) - if err != nil { panic(err) } + if err != nil { + panic(err) + } return output } -func (this *Node) DigProperty(propPath... string) (string, bool) { +func (this *Node) DigProperty(propPath ...string) (string, bool) { return this.dig("prop", propPath...) } func (this *Node) Parameter(name string, defaultValue string) string { - if len(this.Parameters) <= 0 { return defaultValue } + if len(this.Parameters) <= 0 { + return defaultValue + } v, ok := this.Parameters[name] - if !ok { return defaultValue } + if !ok { + return defaultValue + } return v } -func (this *Node) DigParameter(paramPath... string) (string, bool) { +func (this *Node) DigParameter(paramPath ...string) (string, bool) { return this.dig("param", paramPath...) } @@ -120,7 +137,7 @@ func (this *Node) DigParameter(paramPath... string) (string, bool) { // Example: // dig("param", "VCALENDAR", "VEVENT", "DTEND", "TYPE") -> It will search for "VCALENDAR" node, // then a "VEVENT" node, then a "DTEND" note, then finally the "TYPE" param. -func (this *Node) dig(valueType string, valuePath... string) (string, bool) { +func (this *Node) dig(valueType string, valuePath ...string) (string, bool) { current := this lastIndex := len(valuePath) - 1 for _, v := range valuePath[:lastIndex] { diff --git a/vendor/github.com/laurent22/ical-go/ical/parsers.go b/vendor/github.com/laurent22/ical-go/parsers.go similarity index 91% rename from vendor/github.com/laurent22/ical-go/ical/parsers.go rename to vendor/github.com/laurent22/ical-go/parsers.go index 5ad3c7bdc..fa0a8252d 100644 --- a/vendor/github.com/laurent22/ical-go/ical/parsers.go +++ b/vendor/github.com/laurent22/ical-go/parsers.go @@ -1,8 +1,8 @@ package ical import ( - "log" "errors" + "log" "regexp" "strings" ) @@ -10,7 +10,7 @@ import ( func ParseCalendar(data string) (*Node, error) { r := regexp.MustCompile("([\r|\t| ]*\n[\r|\t| ]*)+") lines := r.Split(strings.TrimSpace(data), -1) - node, _, err, _ := parseCalendarNode(lines, 0) + node, _, err, _ := parseCalendarNode(lines, 0) return node, err } @@ -30,11 +30,13 @@ func parseCalendarNode(lines []string, lineIndex int) (*Node, bool, error, int) parameters = make(map[string]string) for i := 1; i < len(splitted); i++ { p := strings.Split(splitted[i], "=") - if len(p) != 2 { panic("Invalid parameter format: " + name) } + if len(p) != 2 { + panic("Invalid parameter format: " + name) + } parameters[p[0]] = p[1] } } - value := line[colonIndex+1:len(line)] + value := line[colonIndex+1 : len(line)] if name == "BEGIN" { node := new(Node) @@ -76,7 +78,7 @@ func parseCalendarNode(lines []string, lineIndex int) (*Node, bool, error, int) func parseTextType(lines []string, lineIndex int) (string, int) { line := lines[lineIndex] colonIndex := strings.Index(line, ":") - output := strings.TrimSpace(line[colonIndex+1:len(line)]) + output := strings.TrimSpace(line[colonIndex+1 : len(line)]) lineIndex++ for { line := lines[lineIndex] diff --git a/vendor/github.com/laurent22/ical-go/properties.go b/vendor/github.com/laurent22/ical-go/properties.go new file mode 100644 index 000000000..65f5d2514 --- /dev/null +++ b/vendor/github.com/laurent22/ical-go/properties.go @@ -0,0 +1,9 @@ +package ical + +const ( + VCALENDAR = "VCALENDAR" + VEVENT = "VEVENT" + DTSTART = "DTSTART" + DTEND = "DTEND" + DURATION = "DURATION" +) diff --git a/vendor/github.com/laurent22/ical-go/ical/serializers.go b/vendor/github.com/laurent22/ical-go/serializers.go similarity index 93% rename from vendor/github.com/laurent22/ical-go/ical/serializers.go rename to vendor/github.com/laurent22/ical-go/serializers.go index 12c0070ce..524a199fb 100644 --- a/vendor/github.com/laurent22/ical-go/ical/serializers.go +++ b/vendor/github.com/laurent22/ical-go/serializers.go @@ -1,13 +1,13 @@ package ical import ( - "time" - "strings" + "strings" + "time" ) type calSerializer struct { calendar *Calendar - buffer *strBuffer + buffer *strBuffer } func (this *calSerializer) serialize() string { @@ -41,7 +41,7 @@ func (this *calSerializer) items() { } type calEventSerializer struct { - event *CalendarEvent + event *CalendarEvent buffer *strBuffer } @@ -62,8 +62,9 @@ func (this *calEventSerializer) serializeEvent() { this.dtstart() this.dtend() this.summary() - this.description() + this.description() this.location() + this.url() this.end() } @@ -91,6 +92,10 @@ func (this *calEventSerializer) location() { this.serializeStringProp("LOCATION", this.event.Location) } +func (this *calEventSerializer) url() { + this.serializeStringProp("URL", this.event.URL) +} + func (this *calEventSerializer) dtstart() { this.serializeTimeProp("DTSTART", this.event.StartAtUTC()) } diff --git a/vendor/github.com/laurent22/ical-go/ical/todo.go b/vendor/github.com/laurent22/ical-go/todo.go similarity index 100% rename from vendor/github.com/laurent22/ical-go/ical/todo.go rename to vendor/github.com/laurent22/ical-go/todo.go diff --git a/vendor/modules.txt b/vendor/modules.txt index bb2015f01..ae46d9b27 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -88,8 +88,8 @@ github.com/labstack/gommon/log github.com/labstack/gommon/color github.com/labstack/gommon/bytes github.com/labstack/gommon/random -# github.com/laurent22/ical-go v0.1.0 -github.com/laurent22/ical-go/ical +# github.com/laurent22/ical-go v0.1.1-0.20181107184520-7e5d6ade8eef +github.com/laurent22/ical-go # github.com/magiconair/properties v1.8.0 github.com/magiconair/properties # github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983