| 1 | // Copyright 2009 The Go Authors. All rights reserved. |
|---|---|
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | // Adapted from encoding/xml/read_test.go. |
| 6 | |
| 7 | // Package atom defines XML data structures for an Atom feed. |
| 8 | package atom // import "golang.org/x/tools/blog/atom" |
| 9 | |
| 10 | import ( |
| 11 | "encoding/xml" |
| 12 | "time" |
| 13 | ) |
| 14 | |
| 15 | type Feed struct { |
| 16 | XMLName xml.Name `xml:"http://www.w3.org/2005/Atom feed"` |
| 17 | Title string `xml:"title"` |
| 18 | ID string `xml:"id"` |
| 19 | Link []Link `xml:"link"` |
| 20 | Updated TimeStr `xml:"updated"` |
| 21 | Author *Person `xml:"author"` |
| 22 | Entry []*Entry `xml:"entry"` |
| 23 | } |
| 24 | |
| 25 | type Entry struct { |
| 26 | Title string `xml:"title"` |
| 27 | ID string `xml:"id"` |
| 28 | Link []Link `xml:"link"` |
| 29 | Published TimeStr `xml:"published"` |
| 30 | Updated TimeStr `xml:"updated"` |
| 31 | Author *Person `xml:"author"` |
| 32 | Summary *Text `xml:"summary"` |
| 33 | Content *Text `xml:"content"` |
| 34 | } |
| 35 | |
| 36 | type Link struct { |
| 37 | Rel string `xml:"rel,attr,omitempty"` |
| 38 | Href string `xml:"href,attr"` |
| 39 | Type string `xml:"type,attr,omitempty"` |
| 40 | HrefLang string `xml:"hreflang,attr,omitempty"` |
| 41 | Title string `xml:"title,attr,omitempty"` |
| 42 | Length uint `xml:"length,attr,omitempty"` |
| 43 | } |
| 44 | |
| 45 | type Person struct { |
| 46 | Name string `xml:"name"` |
| 47 | URI string `xml:"uri,omitempty"` |
| 48 | Email string `xml:"email,omitempty"` |
| 49 | InnerXML string `xml:",innerxml"` |
| 50 | } |
| 51 | |
| 52 | type Text struct { |
| 53 | Type string `xml:"type,attr"` |
| 54 | Body string `xml:",chardata"` |
| 55 | } |
| 56 | |
| 57 | type TimeStr string |
| 58 | |
| 59 | func Time(t time.Time) TimeStr { |
| 60 | return TimeStr(t.Format("2006-01-02T15:04:05-07:00")) |
| 61 | } |
| 62 |
Members