diff options
author | Andrew Gerrand <adg@golang.org> | 2013-09-19 10:58:11 +1000 |
---|---|---|
committer | Andrew Gerrand <adg@golang.org> | 2013-09-19 10:58:11 +1000 |
commit | 2cac03d8054cba95e08cce0be103061c17cd257c (patch) | |
tree | 3137b8afb6bf3c2be59fdb9c4e7ec3a9d2e74cfb /blog | |
parent | 9fc516408c20780e497c274fc4ae016ca47955c7 (diff) | |
download | golang-x-tools-2cac03d8054cba95e08cce0be103061c17cd257c.tar.gz |
go.tools/blog/atom: move package from go.blog
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/13368058
Diffstat (limited to 'blog')
-rw-r--r-- | blog/atom/atom.go | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/blog/atom/atom.go b/blog/atom/atom.go new file mode 100644 index 000000000..bc114dd71 --- /dev/null +++ b/blog/atom/atom.go @@ -0,0 +1,57 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Adapted from encoding/xml/read_test.go. + +// Package atom defines XML data structures for an Atom feed. +package atom + +import ( + "encoding/xml" + "time" +) + +type Feed struct { + XMLName xml.Name `xml:"http://www.w3.org/2005/Atom feed"` + Title string `xml:"title"` + ID string `xml:"id"` + Link []Link `xml:"link"` + Updated TimeStr `xml:"updated"` + Author *Person `xml:"author"` + Entry []*Entry `xml:"entry"` +} + +type Entry struct { + Title string `xml:"title"` + ID string `xml:"id"` + Link []Link `xml:"link"` + Published TimeStr `xml:"published"` + Updated TimeStr `xml:"updated"` + Author *Person `xml:"author"` + Summary *Text `xml:"summary"` + Content *Text `xml:"content"` +} + +type Link struct { + Rel string `xml:"rel,attr"` + Href string `xml:"href,attr"` +} + +type Person struct { + Name string `xml:"name"` + URI string `xml:"uri,omitempty"` + Email string `xml:"email,omitempty"` + InnerXML string `xml:",innerxml"` +} + +type Text struct { + Type string `xml:"type,attr"` + Body string `xml:",chardata"` +} + +type TimeStr string + +func Time(t time.Time) TimeStr { + return TimeStr(t.Format("2006-01-02T15:04:05-07:00")) +} |