wildcard

package
v0.0.0-...-8fe0bd0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2015 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Overview

Structs for wildcard schema, documented here: http://www.trywildcard.com/docs/schema/

Index

Constants

This section is empty.

Variables

View Source
var TimeParseError = errors.New(`TimeParseError: should be a string formatted as "15:04:05"`)

Functions

This section is empty.

Types

type Article

type Article struct {
	Url             string   `json:"url"`
	AbstractContent string   `json:"abstract_content" ogtag:"og:description"`
	IsBreaking      bool     `json:"is_breaking,omitempty"`
	Contributors    []string `json:"contributors,omitempty"`
	Byline          string   `json:"byline,omitempty" ogtag:"byl"`
	GenericMetadata `ogtag:",squash"`
}

type ArticleCard

type ArticleCard struct {
	Card
	Article *Article `json:"article" ogtag:",fill"`
}

func NewArticleCard

func NewArticleCard(webUrl, articleUrl string) *ArticleCard

type Card

type Card struct {
	CardType CardType `json:"card_type"`
	WebUrl   string   `json:"web_url"`
}

Every card has these

type CardType

type CardType string
const (
	ArticleType       CardType = "article"
	ImageType         CardType = "image"
	LinkType          CardType = "link"
	PlaceType         CardType = "place"
	ProductSearchType CardType = "product_search"
	ProductType       CardType = "product"
	ReviewType        CardType = "review"
	VideoType         CardType = "video"
)

type GenericMetadata

type GenericMetadata struct {
	Title           string     `json:"title,omitempty" ogtag:"og:title"`
	PublicationDate *time.Time `json:"publication_date,omitempty" ogtag:"article:published_time"`
	Source          string     `json:"source,omitempty" ogtag:"og:site_name"`
	Keywords        []string   `json:"keywords,omitempty"`

	// Our own addition, wildcard has a neutered version
	AppLink *applink.AppLink `json:"app_link,omitempty" ogtag:",fill"`

	// Our own addition, is usually the favicon
	SourceIcon string `json:"source_icon,omitempty" ogtag:"favicon"`

	// Our own addition since why wouldn't everything have an image?
	Image *ImageDetails `json:"image,omitempty" ogtag:",fill"`
}

Metadata that pretty much every topic has

type GeoCoordinates

type GeoCoordinates struct {
	Latitude  *float64 `json:"latitude"`
	Longitude *float64 `json:"longitude"`
	Elevation *float64 `json:"elevation,omitempty"`
}

type Hours

type Hours struct {
	Days []time.Weekday `json:"days"`
	// The indexes in the Open field match the indexes in the Days field.
	// Together they map when the place is open.
	Open []TimeRange `json:"open"`
}

This is mostly borrowed from foursquare, not schema.org

type ImageCard

type ImageCard struct {
	Card
	Media *ImageMedia `json:"media"`
}

func NewImageCard

func NewImageCard(originalUrl, src string) *ImageCard

type ImageDetails

type ImageDetails struct {
	ImageUrl string `json:"image_url" ogtag:"og:image"`
	Width    int    `json:"width,omitempty" ogtag:"og:image:width"`
	Height   int    `json:"height,omitempty" ogtag:"og:image:height"`

	// Added by us
	ImageContentType string `json:"image_content_type,omitempty"`
}

type ImageMedia

type ImageMedia struct {
	Type MediaType `json:"type"`
	ImageDetails

	//Optional
	ImageCaption string `json:"image_caption,omitempty"`
	Author       string `json:"author,omitempty"`
	GenericMetadata
}

type LinkCard

type LinkCard struct {
	Card
	Target *LinkTarget `json:"target" ogtag:",fill"`
}

func NewLinkCard

func NewLinkCard(originalUrl, linkUrl string) *LinkCard

type LinkTarget

type LinkTarget struct {
	Url             string `json:"url"`
	Description     string `json:"description,omitempty" ogtag:"og:description"`
	GenericMetadata `ogtag:",squash"`
}

type MediaType

type MediaType string
const (
	ImageMediaType MediaType = "image"
	VideoMediaType MediaType = "video"
)

type Place

type Place struct {
	Url         string `json:"url,omitempty"`
	Description string `json:"description,omitempty"`

	// Despite the "PostalAddress" type, this should be a physical address.
	Address              *PostalAddress  `json:"address,omitempty"`
	Location             *GeoCoordinates `json:"location,omitempty"`
	Rating               *Rating         `json:"rating,omitempty"`
	Hours                *Hours          `json:"hours,omitempty"`
	PhoneNumber          string          `json:"phone_number,omitempty"`
	FormattedPhoneNumber string          `json:"formatted_phone_number,omitempty"`
	GenericMetadata      `ogtag:",squash"`
}

func (*Place) HasLocation

func (p *Place) HasLocation() bool

type PlaceCard

type PlaceCard struct {
	Card
	Place *Place `json:"place"`
}

func NewPlaceCard

func NewPlaceCard(webUrl string) *PlaceCard

type PostalAddress

type PostalAddress struct {
	StreetAddress       string `json:"street_address"`
	PostOfficeBoxNumber string `json:"post_office_box_number,omitempty"`
	// In the US, this is the city
	Locality string `json:"locality,omitempty"`
	// In the US, this is the state
	Region     string `json:"region,omitempty"`
	PostalCode string `json:"postal_code,omitempty"`
	Country    string `json:"country,omitempty"`
}

Like, where to send snail mail. Quite possibly a physical address.

func (*PostalAddress) Formatted

func (a *PostalAddress) Formatted() string

Returns the address as a nicely formatted string on a single line. TODO: Make this deal with missing data better

func (*PostalAddress) MultiLineFormatted

func (a *PostalAddress) MultiLineFormatted() string

TODO: Make this deal with missing data better

type Rating

type Rating struct {
	// What this is actually rated.
	Value string `json:"value"`

	// If this thing is perfect, this is what it would be rated.
	BestRating string `json:"best_rating,omitempty"`

	// This is almost always 1 (and should be assumed to be 1 if it's missing),
	// but it's the minimum rating.
	WorstRating string `json:"worst_rating,omitempty"`

	// Using an int32 here even though it limits things to 4 billion ratings.
	RatingCount int32 `json:"rating_count,omitempty"`
	ReviewCount int32 `json:"review_count,omitempty"`

	// An image that can be used to represent this rating.
	ImageUrl string `json:"image_url,omitempty"`
}

type Time

type Time struct {
	time.Time
}

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

type TimeRange

type TimeRange [2]Time

type VideoCard

type VideoCard struct {
	Card
	Media *VideoMedia `json:"media" ogtag:",fill"`
}

func NewVideoCard

func NewVideoCard(originalUrl string) *VideoCard

type VideoMedia

type VideoMedia struct {
	Type MediaType `json:"type"`

	// XXX: Perhaps pull these out for other embed types
	EmbeddedUrl       string `json:"embedded_url"`
	EmbeddedUrlWidth  string `json:"embedded_url_width" ogtag:"og:video:width"`
	EmbeddedUrlHeight string `json:"embedded_url_height" ogtag:"og:video:height"`

	// Optional
	Description       string `json:"description,omitempty" ogtag:"og:description"`
	StreamUrl         string `json:"stream_url,omitempty" ogtag:"og:video:url"`
	StreamContentType string `json:"stream_content_type,omitempty" ogtag:"og:video:type"`
	PosterImageUrl    string `json:"poster_image_url,omitempty" ogtag:"og:image:url"`
	Creator           string `json:"creator,omitempty"`
	GenericMetadata   `ogtag:",squash"`
}

type Wildcard

type Wildcard interface{}

Every card must implement this interface

Jump to

Keyboard shortcuts

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