You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.5 KiB

  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. // Adapted from encoding/xml/read_test.go.
  5. // Package atom defines XML data structures for an Atom feed.
  6. package atom // import "golang.org/x/tools/blog/atom"
  7. import (
  8. "encoding/xml"
  9. "time"
  10. )
  11. type Feed struct {
  12. XMLName xml.Name `xml:"http://www.w3.org/2005/Atom feed"`
  13. Title string `xml:"title"`
  14. ID string `xml:"id"`
  15. Link []Link `xml:"link"`
  16. Updated TimeStr `xml:"updated"`
  17. Author *Person `xml:"author"`
  18. Entry []*Entry `xml:"entry"`
  19. }
  20. type Entry struct {
  21. Title string `xml:"title"`
  22. ID string `xml:"id"`
  23. Link []Link `xml:"link"`
  24. Published TimeStr `xml:"published"`
  25. Updated TimeStr `xml:"updated"`
  26. Author *Person `xml:"author"`
  27. Summary *Text `xml:"summary"`
  28. Content *Text `xml:"content"`
  29. }
  30. type Link struct {
  31. Rel string `xml:"rel,attr,omitempty"`
  32. Href string `xml:"href,attr"`
  33. Type string `xml:"type,attr,omitempty"`
  34. HrefLang string `xml:"hreflang,attr,omitempty"`
  35. Title string `xml:"title,attr,omitempty"`
  36. Length uint `xml:"length,attr,omitempty"`
  37. }
  38. type Person struct {
  39. Name string `xml:"name"`
  40. URI string `xml:"uri,omitempty"`
  41. Email string `xml:"email,omitempty"`
  42. InnerXML string `xml:",innerxml"`
  43. }
  44. type Text struct {
  45. Type string `xml:"type,attr"`
  46. Body string `xml:",chardata"`
  47. }
  48. type TimeStr string
  49. func Time(t time.Time) TimeStr {
  50. return TimeStr(t.Format("2006-01-02T15:04:05-07:00"))
  51. }