Documentation ¶
Overview ¶
Package stm has almost the same specific condition for sitemap xml.
sitemap guidelines: https://support.google.com/webmasters/answer/183668
Number of URLs = 50,000
File size ( uncompressed ) = 50MB
http://godoc.org/github.com/ikeikeikeike/go-sitemap-generator/stm
Index ¶
- Constants
- Variables
- func MergeMap(src, dst [][]interface{}) [][]interface{}
- func PingSearchEngines(opts *Options, urls ...string)
- func SetBuilderElementValue(elm *etree.Element, data [][]interface{}, basekey string) (*etree.Element, bool)
- func ToLowerString(befores []string) (afters []string)
- func URLJoin(src string, joins ...string) string
- type Adapter
- type Attr
- type Attrs
- type BufferPool
- type Builder
- type BuilderError
- type BuilderFile
- type BuilderIndexfile
- type FileAdapter
- type Location
- func (loc *Location) Directory() string
- func (loc *Location) Filename() string
- func (loc *Location) Filesize() int64
- func (loc *Location) IsReservedName() bool
- func (loc *Location) IsVerbose() bool
- func (loc *Location) Namer() *Namer
- func (loc *Location) Path() string
- func (loc *Location) PathInPublic() string
- func (loc *Location) ReserveName() string
- func (loc *Location) Summary(linkCount int) string
- func (loc *Location) URL() string
- func (loc *Location) Write(data []byte, linkCount int)
- type NOpts
- type Namer
- type Options
- func (opts *Options) Clone() *Options
- func (opts *Options) IndexLocation() *Location
- func (opts *Options) Location() *Location
- func (opts *Options) Namer() *Namer
- func (opts *Options) SetAdapter(adp Adapter)
- func (opts *Options) SetCompress(compress bool)
- func (opts *Options) SetDefaultHost(host string)
- func (opts *Options) SetFilename(filename string)
- func (opts *Options) SetPretty(pretty bool)
- func (opts *Options) SetPublicPath(path string)
- func (opts *Options) SetSitemapsHost(host string)
- func (opts *Options) SetSitemapsPath(path string)
- func (opts *Options) SetVerbose(verbose bool)
- func (opts *Options) SitemapsHost() string
- type Sitemap
- func (sm *Sitemap) Add(url interface{}) *Sitemap
- func (sm *Sitemap) Create() *Sitemap
- func (sm *Sitemap) Finalize() *Sitemap
- func (sm *Sitemap) PingSearchEngines(urls ...string)
- func (sm *Sitemap) SetAdapter(adp Adapter)
- func (sm *Sitemap) SetCompress(compress bool)
- func (sm *Sitemap) SetDefaultHost(host string)
- func (sm *Sitemap) SetFilename(filename string)
- func (sm *Sitemap) SetPretty(pretty bool)
- func (sm *Sitemap) SetPublicPath(path string)
- func (sm *Sitemap) SetSitemapsHost(host string)
- func (sm *Sitemap) SetSitemapsPath(path string)
- func (sm *Sitemap) SetVerbose(verbose bool)
- func (sm *Sitemap) XMLContent() []byte
- type SitemapURL
- type URL
- type URLModel
Constants ¶
const ( // MaxSitemapFiles defines max sitemap links per index file MaxSitemapFiles = 50000 // MaxSitemapLinks defines max links per sitemap MaxSitemapLinks = 50000 // MaxSitemapImages defines max images per url MaxSitemapImages = 1000 // MaxSitemapNews defines max news sitemap per index_file MaxSitemapNews = 1000 // MaxSitemapFilesize defines file size for sitemap. MaxSitemapFilesize = 50000000 // bytes )
const ( // SchemaGeo exists for geo sitemap SchemaGeo = "http://www.google.com/geo/schemas/sitemap/1.0" // SchemaImage exists for image sitemap SchemaImage = "http://www.google.com/schemas/sitemap-image/1.1" // SchemaMobile exists for mobile sitemap SchemaMobile = "http://www.google.com/schemas/sitemap-mobile/1.0" // SchemaNews exists for news sitemap SchemaNews = "http://www.google.com/schemas/sitemap-news/0.9" // SchemaPagemap exists for pagemap sitemap SchemaPagemap = "http://www.google.com/schemas/sitemap-pagemap/1.0" // SchemaVideo exists for video sitemap SchemaVideo = "http://www.google.com/schemas/sitemap-video/1.1" )
Variables ¶
var ( // IndexXMLHeader exists for create sitemap xml as a specific sitemap document. IndexXMLHeader = []byte(`<?xml version="1.0" encoding="UTF-8"?> <sitemapindex xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" >`) IndexXMLFooter = []byte("</sitemapindex>") )
var ( // XMLHeader exists for create sitemap xml as a specific sitemap document. XMLHeader = []byte(`<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="` + SchemaImage + `" xmlns:video="` + SchemaVideo + `" xmlns:geo="` + SchemaGeo + `" xmlns:news="` + SchemaNews + `" xmlns:mobile="` + SchemaMobile + `" xmlns:pagemap="` + SchemaPagemap + `" xmlns:xhtml="http://www.w3.org/1999/xhtml" >`) XMLFooter = []byte("</urlset>") )
var GzipPtn = regexp.MustCompile(".gz$")
GzipPtn determines gzip file.
Functions ¶
func MergeMap ¶
func MergeMap(src, dst [][]interface{}) [][]interface{}
MergeMap TODO: Slow function: It wants to change fast function
func PingSearchEngines ¶
PingSearchEngines requests some ping server from it calls Sitemap.PingSearchEngines.
func SetBuilderElementValue ¶
func SetBuilderElementValue(elm *etree.Element, data [][]interface{}, basekey string) (*etree.Element, bool)
SetBuilderElementValue if it will change to struct from map if the future's author is feeling a bothersome in this function.
func ToLowerString ¶
ToLowerString converts lower strings from including capital or upper strings.
Types ¶
type BufferPool ¶
BufferPool is
type Builder ¶
type Builder interface { XMLContent() []byte Content() []byte Add(interface{}) BuilderError Write() }
Builder provides interface for adds some kind of url sitemap.
type BuilderError ¶
BuilderError provides interface for it can confirm the error in some difference.
type BuilderFile ¶
type BuilderFile struct {
// contains filtered or unexported fields
}
BuilderFile provides implementation for the Builder interface.
func NewBuilderFile ¶
func NewBuilderFile(opts *Options, loc *Location) *BuilderFile
NewBuilderFile returns the created the BuilderFile's pointer
func (*BuilderFile) Add ¶
func (b *BuilderFile) Add(url interface{}) BuilderError
Add method joins old bytes with creates bytes by it calls from Sitemap.Add method.
func (*BuilderFile) Content ¶
func (b *BuilderFile) Content() []byte
Content will return pooled bytes on content attribute.
func (*BuilderFile) Write ¶
func (b *BuilderFile) Write()
Write will write pooled bytes with header and footer to Location path for output sitemap file.
func (*BuilderFile) XMLContent ¶
func (b *BuilderFile) XMLContent() []byte
XMLContent will return an XML of the sitemap built
type BuilderIndexfile ¶
type BuilderIndexfile struct {
// contains filtered or unexported fields
}
BuilderIndexfile provides implementation for the Builder interface.
func NewBuilderIndexfile ¶
func NewBuilderIndexfile(opts *Options, loc *Location) *BuilderIndexfile
NewBuilderIndexfile returns the created the BuilderIndexfile's pointer
func (*BuilderIndexfile) Add ¶
func (b *BuilderIndexfile) Add(link interface{}) BuilderError
Add method joins old bytes with creates bytes by it calls from Sitemap.Finalize method.
func (*BuilderIndexfile) Content ¶
func (b *BuilderIndexfile) Content() []byte
Content and BuilderFile.Content are almost the same behavior.
func (*BuilderIndexfile) Write ¶
func (b *BuilderIndexfile) Write()
Write and Builderfile.Write are almost the same behavior.
func (*BuilderIndexfile) XMLContent ¶
func (b *BuilderIndexfile) XMLContent() []byte
XMLContent and BuilderFile.XMLContent share almost the same behavior.
type FileAdapter ¶
type FileAdapter struct{}
FileAdapter provides implementation for the Adapter interface.
func NewFileAdapter ¶
func NewFileAdapter() *FileAdapter
NewFileAdapter returns the created the FileAdapter's pointer
func (*FileAdapter) Write ¶
func (adp *FileAdapter) Write(loc *Location, data []byte)
Write will create sitemap xml file into the file systems.
type Location ¶
type Location struct {
// contains filtered or unexported fields
}
Location provides sitemap's path and filename on file systems and it provides proxy for Adapter interface also.
func NewLocation ¶
NewLocation returns created the Location's pointer
func (*Location) Directory ¶
Directory returns path to combine publicPath and sitemapsPath on file systems. It also indicates where sitemap files are.
func (*Location) IsReservedName ¶
IsReservedName confirms that keeps filename on Location.filename.
func (*Location) Path ¶
Path returns path to combine publicPath, sitemapsPath and Filename on file systems. It also indicates where sitemap name is.
func (*Location) PathInPublic ¶
PathInPublic returns path to combine sitemapsPath and Filename on website. It also indicates where url file path is.
func (*Location) ReserveName ¶
ReserveName returns that sets filename if this struct didn't keep filename and it returns reserved filename if this struct keeps filename also.
type Namer ¶
type Namer struct {
// contains filtered or unexported fields
}
Namer provides sitemap's filename as a file number counter.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options exists for the Sitemap struct.
func (*Options) IndexLocation ¶
IndexLocation returns the Location's pointer with set option to arguments for BuilderIndexfile struct.
func (*Options) Location ¶
Location returns the Location's pointer with set option to arguments for Builderfile struct.
func (*Options) Namer ¶
Namer returns Namer's pointer cache. If didn't create that yet, It also returns created Namer's pointer.
func (*Options) SetAdapter ¶
SetAdapter sets that arg from Sitemap.SetAdapter method
func (*Options) SetCompress ¶
SetCompress sets that arg from Sitemap.SetCompress method
func (*Options) SetDefaultHost ¶
SetDefaultHost sets that arg from Sitemap.Finalize method
func (*Options) SetFilename ¶
SetFilename sets that arg from Sitemap.SetFilename method
func (*Options) SetPretty ¶
SetPretty option sets pretty option to Options struct which allows pretty formatting to output files.
func (*Options) SetPublicPath ¶
SetPublicPath sets that arg from Sitemap.SetPublicPath method
func (*Options) SetSitemapsHost ¶
SetSitemapsHost sets that arg from Sitemap.SetSitemapsHost method
func (*Options) SetSitemapsPath ¶
SetSitemapsPath sets that arg from Sitemap.SetSitemapsPath method.
func (*Options) SetVerbose ¶
SetVerbose sets that arg from Sitemap.SetVerbose method
func (*Options) SitemapsHost ¶
SitemapsHost sets that arg from Sitemap.SitemapsHost method
type Sitemap ¶
type Sitemap struct {
// contains filtered or unexported fields
}
Sitemap provides interface for create sitemap xml file and that has convenient interface. And also needs to use first this struct if it wants to use this package.
func NewSitemap ¶
NewSitemap returns the created the Sitemap's pointer
func (*Sitemap) Create ¶
Create method must be that calls first this method in that before call to Add method on this struct.
func (*Sitemap) Finalize ¶
Finalize writes sitemap and index files if it had some specific condition in BuilderFile struct.
func (*Sitemap) PingSearchEngines ¶
PingSearchEngines requests some ping server. It also has that includes PingSearchEngines function.
func (*Sitemap) SetAdapter ¶
SetAdapter can switch output file storage. We have S3Adapter and FileAdapter (default: FileAdapter)
func (*Sitemap) SetCompress ¶
SetCompress can switch compress for the output file.
func (*Sitemap) SetDefaultHost ¶
SetDefaultHost is your website's host name
func (*Sitemap) SetFilename ¶
SetFilename can apply any name in this method if you wants to change output file name
func (*Sitemap) SetPublicPath ¶
SetPublicPath is the directory to write sitemaps to locally
func (*Sitemap) SetSitemapsHost ¶
SetSitemapsHost is the remote host where your sitemaps will be hosted
func (*Sitemap) SetSitemapsPath ¶
SetSitemapsPath sets this to a directory/path if you don't want to upload to the root of your `SitemapsHost`
func (*Sitemap) SetVerbose ¶
SetVerbose can switch verbose output to console.
func (*Sitemap) XMLContent ¶
XMLContent returns the XML content of the sitemap
type SitemapURL ¶
type SitemapURL interface {
XML() []byte
}
SitemapURL provides generated xml interface.
func NewSitemapIndexURL ¶
func NewSitemapIndexURL(opts *Options, url URL) SitemapURL
NewSitemapIndexURL and NewSitemapURL are almost the same behavior.
func NewSitemapURL ¶
func NewSitemapURL(opts *Options, url URL) (SitemapURL, error)
NewSitemapURL returns the created the SitemapURL's pointer and it validates URL types error.
type URL ¶
type URL [][]interface{}
URL User should use this typedef in main func.
func (*URL) BungURLJoinBy ¶
BungURLJoinBy that's convenient. Though, this is Bung method.
type URLModel ¶
type URLModel struct { Priority float64 `valid:"float,length(0.0|1.0)"` Changefreq string `valid:"alpha(always|hourly|daily|weekly|monthly|yearly|never)"` Lastmod time.Time `valid:"-"` Expires time.Time `valid:"-"` Host string `valid:"ipv4"` Loc string `valid:"url"` Image string `valid:"url"` Video string `valid:"url"` Tag string `valid:""` Geo string `valid:""` News string `valid:"-"` Mobile bool `valid:"-"` Alternate string `valid:"-"` Alternates map[string]interface{} `valid:"-"` Pagemap map[string]interface{} `valid:"-"` }
URLModel is specific sample model for valuedate. http://www.sitemaps.org/protocol.html https://support.google.com/webmasters/answer/178636