Documentation ¶
Index ¶
- Constants
- type ArticlePropParser
- type ImagePropParser
- type Parser
- func (ps *Parser) Article() *data.MarkupArticle
- func (ps *Parser) Author() string
- func (ps *Parser) Copyright() string
- func (ps *Parser) Description() string
- func (ps *Parser) Images() []data.MarkupImage
- func (ps *Parser) OptOut() bool
- func (ps *Parser) Publisher() string
- func (ps *Parser) Title() string
- func (ps *Parser) Type() string
- func (ps *Parser) URL() string
- type Prefix
- type PrefixNameList
- type ProfilePropParser
- type PropParser
Constants ¶
const ( TitleProp = "title" TypeProp = "type" ImageProp = "image" URLProp = "url" DescriptionProp = "description" SiteNameProp = "site_name" ImageStructPropPfx = "image:" ImageURLProp = "image:url" ImageSecureURLProp = "image:secure_url" ImageTypeProp = "image:type" ImageWidthProp = "image:width" ImageHeightProp = "image:height" ProfileFirstnameProp = "first_name" ProfileLastnameProp = "last_name" ArticleSectionProp = "section" ArticlePublishedTimeProp = "published_time" ArticleModifiedTimeProp = "modified_time" ArticleExpirationTimeProp = "expiration_time" ArticleAuthorProp = "author" ProfileObjtype = "profile" ArticleObjtype = "article" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArticlePropParser ¶
type ArticlePropParser struct { Authors []string // contains filtered or unexported fields }
type ImagePropParser ¶
type ImagePropParser struct {
ImageList []data.MarkupImage
}
func (*ImagePropParser) Parse ¶
func (pp *ImagePropParser) Parse(property, content string, propertyTable map[string]string) bool
func (*ImagePropParser) Verify ¶
func (pp *ImagePropParser) Verify()
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser recognizes and parses the Open Graph Protocol markup tags and returns the properties that matter to distilled content.
First, it extracts the prefix and/or xmlns attributes from the HTML or HEAD tags to determine the prefixes that will be used for the protocol. If no prefix is specified, we fall back to the commonly used ones, e.g. "og". Then, it scans the OpenGraph Protocol <meta> elements that we care about, extracts their content, and stores them semantically, i.e. taking into consideration arrays, structures, and object types. Callers call get* to access these properties.
The properties we care about are:
- 4 required properties: title, type, image, url.
- 2 optional properties: description, site_name.
- image structured properties: image:url, image:secure_url, image:type, image:width, image:height
- profile object properties: first_name, last_name
- article object properties: section, published_time, modified_time, expiration_time, author; each author is a URL to the author's profile.
func (*Parser) Article ¶
func (ps *Parser) Article() *data.MarkupArticle
Article returns the properties of the "article" object when value of "og:type" is "article". The properties are published_time, modified_time and expiration_time, section, and a list of URLs to each author's profile.
func (*Parser) Author ¶
Author returns the concatenated first_name and last_name (delimited by a whitespace) of the "profile" object when value of "og:type" is "profile".
func (*Parser) Description ¶
Description returns the optional "description" of the document.
func (*Parser) Images ¶
func (ps *Parser) Images() []data.MarkupImage
Images returns the structured properties of all "image" structures. Each "image" structure consists of image, image:url, image:secure_url, image:type, image:width, and image:height.
func (*Parser) OptOut ¶
OptOut returns false since OpenGraph not support it. While this is not directly supported, the page owner can simply omit the required tags and init() will return a null OpenGraphProtocolParser.
type PrefixNameList ¶
type ProfilePropParser ¶
type ProfilePropParser struct {
// contains filtered or unexported fields
}
func (*ProfilePropParser) GetFullName ¶
func (pp *ProfilePropParser) GetFullName(propertyTable map[string]string) string