diff options
Diffstat (limited to 'vendor/github.com')
23 files changed, 0 insertions, 2229 deletions
diff --git a/vendor/github.com/Xe/asarfs/asarfs.go b/vendor/github.com/Xe/asarfs/asarfs.go deleted file mode 100644 index 7d18949..0000000 --- a/vendor/github.com/Xe/asarfs/asarfs.go +++ /dev/null @@ -1,117 +0,0 @@ -package asarfs - -import ( - "io" - "mime" - "net/http" - "os" - "path/filepath" - "strings" - - "layeh.com/asar" -) - -// ASARfs serves the contents of an asar archive as an HTTP handler. -type ASARfs struct { - fin *os.File - ar *asar.Entry - notFound http.Handler -} - -// Close closes the underlying file used for the asar archive. -func (a *ASARfs) Close() error { - return a.fin.Close() -} - -// Open satisfies the http.FileSystem interface for ASARfs. -func (a *ASARfs) Open(name string) (http.File, error) { - if name == "/" { - name = "/index.html" - } - - e := a.ar.Find(strings.Split(name, "/")[1:]...) - if e == nil { - return nil, os.ErrNotExist - } - - f := &file{ - Entry: e, - r: e.Open(), - } - - return f, nil -} - -// ServeHTTP satisfies the http.Handler interface for ASARfs. -func (a *ASARfs) ServeHTTP(w http.ResponseWriter, r *http.Request) { - if r.RequestURI == "/" { - r.RequestURI = "/index.html" - } - - f := a.ar.Find(strings.Split(r.RequestURI, "/")[1:]...) - if f == nil { - a.notFound.ServeHTTP(w, r) - return - } - - ext := filepath.Ext(f.Name) - mimeType := mime.TypeByExtension(ext) - - w.Header().Add("Content-Type", mimeType) - f.WriteTo(w) -} - -// New creates a new ASARfs pointer based on the filepath to the archive and -// a HTTP handler to hit when a file is not found. -func New(archivePath string, notFound http.Handler) (*ASARfs, error) { - fin, err := os.Open(archivePath) - if err != nil { - return nil, err - } - - root, err := asar.Decode(fin) - if err != nil { - return nil, err - } - - a := &ASARfs{ - fin: fin, - ar: root, - notFound: notFound, - } - - return a, nil -} - -// file is an internal shim that mimics http.File for an asar entry. -type file struct { - *asar.Entry - r io.ReadSeeker -} - -func (f *file) Close() error { - f.r = nil - return nil -} - -func (f *file) Read(buf []byte) (n int, err error) { - return f.r.Read(buf) -} - -func (f *file) Seek(offset int64, whence int) (int64, error) { - return f.r.Seek(offset, whence) -} - -func (f *file) Readdir(count int) ([]os.FileInfo, error) { - result := []os.FileInfo{} - - for _, e := range f.Entry.Children { - result = append(result, e.FileInfo()) - } - - return result, nil -} - -func (f *file) Stat() (os.FileInfo, error) { - return f.Entry.FileInfo(), nil -} diff --git a/vendor/github.com/Xe/asarfs/bench_test.go b/vendor/github.com/Xe/asarfs/bench_test.go deleted file mode 100644 index fd332d5..0000000 --- a/vendor/github.com/Xe/asarfs/bench_test.go +++ /dev/null @@ -1,156 +0,0 @@ -// +build go1.8 - -package asarfs - -import ( - "fmt" - "io" - "io/ioutil" - "math/rand" - "net" - "net/http" - "os" - "testing" -) - -func BenchmarkHTTPFileSystem(b *testing.B) { - fs := http.FileServer(http.Dir(".")) - - l, s, err := setupHandler(fs) - if err != nil { - b.Fatal(err) - } - defer l.Close() - defer s.Close() - - url := fmt.Sprintf("http://%s", l.Addr()) - - for n := 0; n < b.N; n++ { - testHandler(url) - } -} - -func BenchmarkASARfs(b *testing.B) { - fs, err := New("./static.asar", http.HandlerFunc(do404)) - if err != nil { - b.Fatal(err) - } - - l, s, err := setupHandler(fs) - if err != nil { - b.Fatal(err) - } - defer l.Close() - defer s.Close() - - url := fmt.Sprintf("http://%s", l.Addr()) - - for n := 0; n < b.N; n++ { - testHandler(url) - } -} - -func BenchmarkPreloadedASARfs(b *testing.B) { - for n := 0; n < b.N; n++ { - testHandler(asarfsurl) - } -} - -func BenchmarkASARfsHTTPFilesystem(b *testing.B) { - fs, err := New("./static.asar", http.HandlerFunc(do404)) - if err != nil { - b.Fatal(err) - } - - l, s, err := setupHandler(http.FileServer(fs)) - if err != nil { - b.Fatal(err) - } - defer l.Close() - defer s.Close() - - url := fmt.Sprintf("http://%s", l.Addr()) - - for n := 0; n < b.N; n++ { - testHandler(url) - } -} - -func BenchmarkPreloadedASARfsHTTPFilesystem(b *testing.B) { - for n := 0; n < b.N; n++ { - testHandler(asarfshttpfsurl) - } -} - -func do404(w http.ResponseWriter, r *http.Request) { - http.Error(w, "Not found", http.StatusNotFound) -} - -func setupHandler(h http.Handler) (net.Listener, *http.Server, error) { - l, err := net.Listen("tcp", ":0") - if err != nil { - panic(err) - } - defer l.Close() - - s := &http.Server{ - Handler: h, - } - go s.ListenAndServe() - - return l, s, nil -} - -func testHandler(u string) error { - num := rand.Intn(9) - num++ - sub := rand.Intn(99) - - fname := fmt.Sprintf("/static/%d/%d%d.json", num, num, sub) - - resp, err := http.Get(u + fname) - if err != nil { - return err - } - defer resp.Body.Close() - - _, err = io.Copy(ioutil.Discard, resp.Body) - if err != nil { - panic(err) - } - - return nil -} - -var ( - asarfsurl string - asarfshttpfsurl string -) - -func TestMain(m *testing.M) { - go func() { - fs, err := New("./static.asar", http.HandlerFunc(do404)) - if err != nil { - } - - l, _, err := setupHandler(fs) - if err != nil { - } - - asarfsurl = fmt.Sprintf("http://%s", l.Addr().String()) - }() - - go func() { - fs, err := New("./static.asar", http.HandlerFunc(do404)) - if err != nil { - } - - l, _, err := setupHandler(http.FileServer(fs)) - if err != nil { - } - - asarfshttpfsurl = fmt.Sprintf("http://%s", l.Addr().String()) - }() - - os.Exit(m.Run()) -} diff --git a/vendor/github.com/Xe/asarfs/runtest.go b/vendor/github.com/Xe/asarfs/runtest.go deleted file mode 100644 index 4b839de..0000000 --- a/vendor/github.com/Xe/asarfs/runtest.go +++ /dev/null @@ -1,24 +0,0 @@ -// +build ignore - -package main - -import ( - "log" - "net/http" - "os" - - "github.com/Xe/asarfs" -) - -func do404(w http.ResponseWriter, r *http.Request) { - http.Error(w, "Not found", http.StatusNotFound) -} - -func main() { - fs, err := asarfs.New("./static.asar", http.HandlerFunc(do404)) - if err != nil { - log.Fatal(err) - } - - http.ListenAndServe(":"+os.Getenv("PORT"), fs) -} diff --git a/vendor/github.com/Xe/gopreload/doc.go b/vendor/github.com/Xe/gopreload/doc.go deleted file mode 100644 index 720c5c1..0000000 --- a/vendor/github.com/Xe/gopreload/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -/* -Package gopreload is a bit of a hack to emulate the behavior of LD_PRELOAD [ld-preload]. -This allows you to have automatically starting instrumentation, etc. - -[ld-preload]: http://man7.org/linux/man-pages/man8/ld.so.8.html (see LD_PRELOAD section) -*/ -package gopreload diff --git a/vendor/github.com/Xe/gopreload/preload.go b/vendor/github.com/Xe/gopreload/preload.go deleted file mode 100644 index 1b5a0c9..0000000 --- a/vendor/github.com/Xe/gopreload/preload.go +++ /dev/null @@ -1,26 +0,0 @@ -//+build linux,go1.8 - -package gopreload - -import ( - "log" - "os" - "plugin" - "strings" -) - -func init() { - gpv := os.Getenv("GO_PRELOAD") - if gpv == "" { - return - } - - for _, elem := range strings.Split(gpv, ",") { - log.Printf("gopreload: trying to open: %s", elem) - _, err := plugin.Open(elem) - if err != nil { - log.Printf("%v from GO_PRELOAD cannot be loaded: %v", elem, err) - continue - } - } -} diff --git a/vendor/github.com/Xe/ln/filter.go b/vendor/github.com/Xe/ln/filter.go deleted file mode 100644 index 586efef..0000000 --- a/vendor/github.com/Xe/ln/filter.go +++ /dev/null @@ -1,66 +0,0 @@ -package ln - -import ( - "io" - "sync" -) - -// Filter interface for defining chain filters -type Filter interface { - Apply(Event) bool - Run() - Close() -} - -// FilterFunc allows simple functions to implement the Filter interface -type FilterFunc func(e Event) bool - -// Apply implements the Filter interface -func (ff FilterFunc) Apply(e Event) bool { - return ff(e) -} - -// Run implements the Filter interface -func (ff FilterFunc) Run() {} - -// Close implements the Filter interface -func (ff FilterFunc) Close() {} - -// WriterFilter implements a filter, which arbitrarily writes to an io.Writer -type WriterFilter struct { - sync.Mutex - Out io.Writer - Formatter Formatter -} - -// NewWriterFilter creates a filter to add to the chain -func NewWriterFilter(out io.Writer, format Formatter) *WriterFilter { - if format == nil { - format = DefaultFormatter - } - return &WriterFilter{ - Out: out, - Formatter: format, - } -} - -// Apply implements the Filter interface -func (w *WriterFilter) Apply(e Event) bool { - output, err := w.Formatter.Format(e) - if err == nil { - w.Lock() - w.Out.Write(output) - w.Unlock() - } - - return true -} - -// Run implements the Filter interface -func (w *WriterFilter) Run() {} - -// Close implements the Filter interface -func (w *WriterFilter) Close() {} - -// NilFilter is safe to return as a Filter, but does nothing -var NilFilter = FilterFunc(func(e Event) bool { return true }) diff --git a/vendor/github.com/Xe/ln/formatter.go b/vendor/github.com/Xe/ln/formatter.go deleted file mode 100644 index 9d67139..0000000 --- a/vendor/github.com/Xe/ln/formatter.go +++ /dev/null @@ -1,100 +0,0 @@ -package ln - -import ( - "bytes" - "fmt" - "time" -) - -var ( - // DefaultTimeFormat represents the way in which time will be formatted by default - DefaultTimeFormat = time.RFC3339 -) - -// Formatter defines the formatting of events -type Formatter interface { - Format(Event) ([]byte, error) -} - -// DefaultFormatter is the default way in which to format events -var DefaultFormatter Formatter - -func init() { - DefaultFormatter = NewTextFormatter() -} - -// TextFormatter formats events as key value pairs. -// Any remaining text not wrapped in an instance of `F` will be -// placed at the end. -type TextFormatter struct { - TimeFormat string -} - -// NewTextFormatter returns a Formatter that outputs as text. -func NewTextFormatter() Formatter { - return &TextFormatter{TimeFormat: DefaultTimeFormat} -} - -// Format implements the Formatter interface -func (t *TextFormatter) Format(e Event) ([]byte, error) { - var writer bytes.Buffer - - writer.WriteString("time=\"") - writer.WriteString(e.Time.Format(t.TimeFormat)) - writer.WriteString("\"") - - for k, v := range e.Data { - writer.WriteByte(' ') - if shouldQuote(k) { - writer.WriteString(fmt.Sprintf("%q", k)) - } else { - writer.WriteString(k) - } - - writer.WriteByte('=') - - switch v.(type) { - case string: - vs, _ := v.(string) - if shouldQuote(vs) { - fmt.Fprintf(&writer, "%q", vs) - } else { - writer.WriteString(vs) - } - case error: - tmperr, _ := v.(error) - es := tmperr.Error() - - if shouldQuote(es) { - fmt.Fprintf(&writer, "%q", es) - } else { - writer.WriteString(es) - } - case time.Time: - tmptime, _ := v.(time.Time) - writer.WriteString(tmptime.Format(time.RFC3339)) - default: - fmt.Fprint(&writer, v) - } - } - - if len(e.Message) > 0 { - fmt.Fprintf(&writer, " _msg=%q", e.Message) - } - - writer.WriteByte('\n') - return writer.Bytes(), nil -} - -func shouldQuote(s string) bool { - for _, b := range s { - if !((b >= 'A' && b <= 'Z') || - (b >= 'a' && b <= 'z') || - (b >= '0' && b <= '9') || - (b == '-' || b == '.' || b == '#' || - b == '/' || b == '_')) { - return true - } - } - return false -} diff --git a/vendor/github.com/Xe/ln/logger.go b/vendor/github.com/Xe/ln/logger.go deleted file mode 100644 index cdfe89e..0000000 --- a/vendor/github.com/Xe/ln/logger.go +++ /dev/null @@ -1,141 +0,0 @@ -package ln - -import ( - "fmt" - "os" - "time" - - "github.com/pkg/errors" -) - -// Logger holds the current priority and list of filters -type Logger struct { - Filters []Filter -} - -// DefaultLogger is the default implementation of Logger -var DefaultLogger *Logger - -func init() { - var defaultFilters []Filter - - // Default to STDOUT for logging, but allow LN_OUT to change it. - out := os.Stdout - if os.Getenv("LN_OUT") == "<stderr>" { - out = os.Stderr - } - - defaultFilters = append(defaultFilters, NewWriterFilter(out, nil)) - - DefaultLogger = &Logger{ - Filters: defaultFilters, - } - -} - -// F is a key-value mapping for structured data. -type F map[string]interface{} - -type Fer interface { - F() map[string]interface{} -} - -// Event represents an event -type Event struct { - Time time.Time - Data F - Message string -} - -// Log is the generic logging method. -func (l *Logger) Log(xs ...interface{}) { - var bits []interface{} - event := Event{Time: time.Now()} - - addF := func(bf F) { - if event.Data == nil { - event.Data = bf - } else { - for k, v := range bf { - event.Data[k] = v - } - } - } - - // Assemble the event - for _, b := range xs { - if bf, ok := b.(F); ok { - addF(bf) - } else if fer, ok := b.(Fer); ok { - addF(F(fer.F())) - } else { - bits = append(bits, b) - } - } - - event.Message = fmt.Sprint(bits...) - - if os.Getenv("LN_DEBUG_ALL_EVENTS") == "1" { - frame := callersFrame() - if event.Data == nil { - event.Data = make(F) - } - event.Data["_lineno"] = frame.lineno - event.Data["_function"] = frame.function - event.Data["_filename"] = frame.filename - } - - l.filter(event) -} - -func (l *Logger) filter(e Event) { - for _, f := range l.Filters { - if !f.Apply(e) { - return - } - } -} - -// Error logs an error and information about the context of said error. -func (l *Logger) Error(err error, xs ...interface{}) { - data := F{} - frame := callersFrame() - - data["_lineno"] = frame.lineno - data["_function"] = frame.function - data["_filename"] = frame.filename - data["err"] = err - - cause := errors.Cause(err) - if cause != nil { - data["cause"] = cause.Error() - } - - xs = append(xs, data) - - l.Log(xs...) -} - -// Fatal logs this set of values, then exits with status code 1. -func (l *Logger) Fatal(xs ...interface{}) { - l.Log(xs...) - - os.Exit(1) -} - -// Default Implementation - -// Log is the generic logging method. -func Log(xs ...interface{}) { - DefaultLogger.Log(xs...) -} - -// Error logs an error and information about the context of said error. -func Error(err error, xs ...interface{}) { - DefaultLogger.Error(err, xs...) -} - -// Fatal logs this set of values, then exits with status code 1. -func Fatal(xs ...interface{}) { - DefaultLogger.Fatal(xs...) -} diff --git a/vendor/github.com/Xe/ln/stack.go b/vendor/github.com/Xe/ln/stack.go deleted file mode 100644 index 1cf1e7a..0000000 --- a/vendor/github.com/Xe/ln/stack.go +++ /dev/null @@ -1,44 +0,0 @@ -package ln - -import ( - "os" - "runtime" - "strings" -) - -type frame struct { - filename string - function string - lineno int -} - -// skips 2 frames, since Caller returns the current frame, and we need -// the caller's caller. -func callersFrame() frame { - var out frame - pc, file, line, ok := runtime.Caller(3) - if !ok { - return out - } - srcLoc := strings.LastIndex(file, "/src/") - if srcLoc >= 0 { - file = file[srcLoc+5:] - } - out.filename = file - out.function = functionName(pc) - out.lineno = line - - return out -} - -func functionName(pc uintptr) string { - fn := runtime.FuncForPC(pc) - if fn == nil { - return "???" - } - name := fn.Name() - beg := strings.LastIndex(name, string(os.PathSeparator)) - return name[beg+1:] - // end := strings.LastIndex(name, string(os.PathSeparator)) - // return name[end+1 : len(name)] -} diff --git a/vendor/github.com/gernest/front/front.go b/vendor/github.com/gernest/front/front.go deleted file mode 100644 index f4c6f25..0000000 --- a/vendor/github.com/gernest/front/front.go +++ /dev/null @@ -1,144 +0,0 @@ -// Package front is a frontmatter extraction library. -package front - -import ( - "bufio" - "bytes" - "encoding/json" - "errors" - "io" - "strings" - - "gopkg.in/yaml.v2" -) - -var ( - //ErrIsEmpty is an error indicating no front matter was found - ErrIsEmpty = errors.New("front: an empty file") - - //ErrUnknownDelim is returned when the delimiters are not known by the - //FrontMatter implementation. - ErrUnknownDelim = errors.New("front: unknown delim") -) - -type ( - //HandlerFunc is an interface for a function that process front matter text. - HandlerFunc func(string) (map[string]interface{}, error) -) - -//Matter is all what matters here. -type Matter struct { - handlers map[string]HandlerFunc -} - -//NewMatter creates a new Matter instance -func NewMatter() *Matter { - return &Matter{handlers: make(map[string]HandlerFunc)} -} - -//Handle registers a handler for the given frontmatter delimiter -func (m *Matter) Handle(delim string, fn HandlerFunc) { - m.handlers[delim] = fn -} - -// Parse parses the input and extract the frontmatter -func (m *Matter) Parse(input io.Reader) (front map[string]interface{}, body string, err error) { - return m.parse(input) -} -func (m *Matter) parse(input io.Reader) (front map[string]interface{}, body string, err error) { - var getFront = func(f string) string { - return strings.TrimSpace(f[3:]) - } - f, body, err := m.splitFront(input) - if err != nil { - return nil, "", err - } - h := m.handlers[f[:3]] - front, err = h(getFront(f)) - if err != nil { - return nil, "", err - } - return front, body, nil - -} -func sniffDelim(input []byte) (string, error) { - if len(input) < 4 { - return "", ErrIsEmpty - } - return string(input[:3]), nil -} - -func (m *Matter) splitFront(input io.Reader) (front, body string, err error) { - bufsize := 1024 * 1024 - buf := make([]byte, bufsize) - - s := bufio.NewScanner(input) - // Necessary so we can handle larger than default 4096b buffer - s.Buffer(buf, bufsize) - - rst := make([]string, 2) - s.Split(m.split) - n := 0 - for s.Scan() { - if n == 0 { - rst[0] = s.Text() - } else if n == 1 { - rst[1] = s.Text() - } - n++ - } - if err = s.Err(); err != nil { - return - } - return rst[0], rst[1], nil -} - -//split implements bufio.SplitFunc for spliting fron matter from the body text. -func (m *Matter) split(data []byte, atEOF bool) (advance int, token []byte, err error) { - if atEOF && len(data) == 0 { - return 0, nil, nil - } - delim, err := sniffDelim(data) - if err != nil { - return 0, nil, err - } - if _, ok := m.handlers[delim]; !ok { - return 0, nil, ErrUnknownDelim - } - if x := bytes.Index(data, []byte(delim)); x >= 0 { - // check the next delim index - if next := bytes.Index(data[x+len(delim):], []byte(delim)); next > 0 { - return next + len(delim), dropSpace(data[:next+len(delim)]), nil - } - return len(data), dropSpace(data[x+len(delim):]), nil - } - if atEOF { - return len(data), data, nil - } - return 0, nil, nil -} - -func dropSpace(d []byte) []byte { - return bytes.TrimSpace(d) -} - -//JSONHandler implements HandlerFunc interface. It extracts front matter data from the given -// string argument by interpreting it as a json string. -func JSONHandler(front string) (map[string]interface{}, error) { - var rst interface{} - err := json.Unmarshal([]byte(front), &rst) - if err != nil { - return nil, err - } - return rst.(map[string]interface{}), nil -} - -//YAMLHandler decodes ymal string into a go map[string]interface{} -func YAMLHandler(front string) (map[string]interface{}, error) { - out := make(map[string]interface{}) - err := yaml.Unmarshal([]byte(front), out) - if err != nil { - return nil, err - } - return out, nil -} diff --git a/vendor/github.com/gorilla/feeds/atom.go b/vendor/github.com/gorilla/feeds/atom.go deleted file mode 100644 index 512976b..0000000 --- a/vendor/github.com/gorilla/feeds/atom.go +++ /dev/null @@ -1,163 +0,0 @@ -package feeds - -import ( - "encoding/xml" - "fmt" - "net/url" - "strconv" - "time" -) - -// Generates Atom feed as XML - -const ns = "http://www.w3.org/2005/Atom" - -type AtomPerson struct { - Name string `xml:"name,omitempty"` - Uri string `xml:"uri,omitempty"` - Email string `xml:"email,omitempty"` -} - -type AtomSummary struct { - XMLName xml.Name `xml:"summary"` - Content string `xml:",chardata"` - Type string `xml:"type,attr"` -} - -type AtomContent struct { - XMLName xml.Name `xml:"content"` - Content string `xml:",chardata"` - Type string `xml:"type,attr"` -} - -type AtomAuthor struct { - XMLName xml.Name `xml:"author"` - AtomPerson -} - -type AtomContributor struct { - XMLName xml.Name `xml:"contributor"` - AtomPerson -} - -type AtomEntry struct { - XMLName xml.Name `xml:"entry"` - Xmlns string `xml:"xmlns,attr,omitempty"` - Title string `xml:"title"` // required - Updated string `xml:"updated"` // required - Id string `xml:"id"` // required - Category string `xml:"category,omitempty"` - Content *AtomContent - Rights string `xml:"rights,omitempty"` - Source string `xml:"source,omitempty"` - Published string `xml:"published,omitempty"` - Contributor *AtomContributor - Link *AtomLink // required if no child 'content' elements - Summary *AtomSummary // required if content has src or content is base64 - Author *AtomAuthor // required if feed lacks an author -} - -type AtomLink struct { - //Atom 1.0 <link rel="enclosure" type="audio/mpeg" title="MP3" href="http://www.example.org/myaudiofile.mp3" length="1234" /> - XMLName xml.Name `xml:"link"` - Href string `xml:"href,attr"` - Rel string `xml:"rel,attr,omitempty"` - Type string `xml:"type,attr,omitempty"` - Length string `xml:"length,attr,omitempty"` -} - -type AtomFeed struct { - XMLName xml.Name `xml:"feed"` - Xmlns string `xml:"xmlns,attr"` - Title string `xml:"title"` // required - Id string `xml:"id"` // required - Updated string `xml:"updated"` // required - Category string `xml:"category,omitempty"` - Icon string `xml:"icon,omitempty"` - Logo string `xml:"logo,omitempty"` - Rights string `xml:"rights,omitempty"` // copyright used - Subtitle string `xml:"subtitle,omitempty"` - Link *AtomLink - Author *AtomAuthor `xml:"author,omitempty"` - Contributor *AtomContributor - Entries []*AtomEntry -} - -type Atom struct { - *Feed -} - -func newAtomEntry(i *Item) *AtomEntry { - id := i.Id - // assume the description is html - c := &AtomContent{Content: i.Description, Type: "html"} - - if len(id) == 0 { - // if there's no id set, try to create one, either from data or just a uuid - if len(i.Link.Href) > 0 && (!i.Created.IsZero() || !i.Updated.IsZero()) { - dateStr := anyTimeFormat("2006-01-02", i.Updated, i.Created) - host, path := i.Link.Href, "/invalid.html" - if url, err := url.Parse(i.Link.Href); err == nil { - host, path = url.Host, url.Path - } - id = fmt.Sprintf("tag:%s,%s:%s", host, dateStr, path) - } else { - id = "urn:uuid:" + NewUUID().String() - } - } - var name, email string - if i.Author != nil { - name, email = i.Author.Name, i.Author.Email - } - - x := &AtomEntry{ - Title: i.Title, - Link: &AtomLink{Href: i.Link.Href, Rel: i.Link.Rel, Type: i.Link.Type}, - Content: c, - Id: id, - Updated: anyTimeFormat(time.RFC3339, i.Updated, i.Created), - } - - intLength, err := strconv.ParseInt(i.Link.Length, 10, 64) - - if err == nil && (intLength > 0 || i.Link.Type != "") { - i.Link.Rel = "enclosure" - x.Link = &AtomLink{Href: i.Link.Href, Rel: i.Link.Rel, Type: i.Link.Type, Length: i.Link.Length} - } - - if len(name) > 0 || len(email) > 0 { - x.Author = &AtomAuthor{AtomPerson: AtomPerson{Name: name, Email: email}} - } - return x -} - -// create a new AtomFeed with a generic Feed struct's data -func (a *Atom) AtomFeed() *AtomFeed { - updated := anyTimeFormat(time.RFC3339, a.Updated, a.Created) - feed := &AtomFeed{ - Xmlns: ns, - Title: a.Title, - Link: &AtomLink{Href: a.Link.Href, Rel: a.Link.Rel}, - Subtitle: a.Description, - Id: a.Link.Href, - Updated: updated, - Rights: a.Copyright, - } - if a.Author != nil { - feed.Author = &AtomAuthor{AtomPerson: AtomPerson{Name: a.Author.Name, Email: a.Author.Email}} - } - for _, e := range a.Items { - feed.Entries = append(feed.Entries, newAtomEntry(e)) - } - return feed -} - -// return an XML-Ready object for an Atom object -func (a *Atom) FeedXml() interface{} { - return a.AtomFeed() -} - -// return an XML-ready object for an AtomFeed object -func (a *AtomFeed) FeedXml() interface{} { - return a -} diff --git a/vendor/github.com/gorilla/feeds/doc.go b/vendor/github.com/gorilla/feeds/doc.go deleted file mode 100644 index 5b005ea..0000000 --- a/vendor/github.com/gorilla/feeds/doc.go +++ /dev/null @@ -1,70 +0,0 @@ -/* -Syndication (feed) generator library for golang. - -Installing - - go get github.com/gorilla/feeds - -Feeds provides a simple, generic Feed interface with a generic Item object as well as RSS and Atom specific RssFeed and AtomFeed objects |
