opml

package
v0.0.0-...-a0a9867 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

package opml provides functionalities for parsing and writing OPML files.

It follows the OPML 2.0 specifications [1], but keeps only tags relevant to processing subscription lists. Elements relating to display settings, such as expansionState or vertScrollState, are omitted.

[1] http://opml.org/spec2.opml

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyPayload  = errors.New("byte payload is empty")
	ErrEmptyDocument = errors.New("OPML document is empty")
)

Functions

This section is empty.

Types

type Body

type Body struct {
	Outlines []*Outline `xml:"outline"`
}

Body is the <body> element of an OPML file.

type Categories

type Categories []string

func (*Categories) MarshalXMLAttr

func (c *Categories) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (*Categories) UnmarshalXMLAttr

func (c *Categories) UnmarshalXMLAttr(attr xml.Attr) error

type Doc

type Doc struct {
	XMLName xml.Name `xml:"opml"`
	Version string   `xml:"version,attr"`
	Head    Head     `xml:"head"`
	Body    Body     `xml:"body"`
}

Doc represents the minimal contents of an OPML file required to for storing a subscription list.

func New

func New(title string, created time.Time) *Doc

func Parse

func Parse(raw []byte) (*Doc, error)

Parse parses the given raw OPML document into an OPML struct. Only version 2.0 is supported.

func (*Doc) AddOutline

func (doc *Doc) AddOutline(outl Outliner) error

func (*Doc) Empty

func (doc *Doc) Empty() bool

func (*Doc) XML

func (doc *Doc) XML() ([]byte, error)
type Head struct {
	Title       *string    `xml:"title"`
	DateCreated *Timestamp `xml:"dateCreated"`
}

Head is the <head> element of an OPML file.

type Outline

type Outline struct {
	Text   string `xml:"text,attr"`
	Type   string `xml:"type,attr"`
	XMLURL string `xml:"xmlUrl,attr"`

	Categories  Categories `xml:"category,attr"`
	Description *string    `xml:"description,attr"`
	HTMLURL     *string    `xml:"htmlUrl,attr"`
	IsStarred   *bool      `xml:"https://github.com/bow/neon isStarred,attr,omitempty"`
}

Outline is a single outline item in the OPML body. It represents a single subscription / feed. Nesting is not supported.

type Outliner

type Outliner interface {
	Outline() (*Outline, error)
}

type Timestamp

type Timestamp time.Time

func (*Timestamp) MarshalXML

func (t *Timestamp) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Timestamp) Time

func (t *Timestamp) Time() time.Time

func (*Timestamp) UnmarshalXML

func (t *Timestamp) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL