go-sitemap-generator: github.com/ikeikeikeike/go-sitemap-generator/stm Index | Files

package stm

import "github.com/ikeikeikeike/go-sitemap-generator/stm"

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

Package Files

adapter.go adapter_buffer.go adapter_file.go builder.go builder_file.go builder_indexfile.go builder_indexurl.go builder_url.go consts.go doc.go location.go namer.go options.go ping.go sitemap.go utils.go

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 = []byte("" /* 321 byte string literal not displayed */)

    IndexXMLFooter = []byte("</sitemapindex>")
)
var (
    XMLHeader = []byte("" /* 337 byte string literal not displayed */+
        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.

func MergeMap Uses

func MergeMap(src, dst [][]interface{}) [][]interface{}

MergeMap TODO: Slow function: It wants to change fast function

func PingSearchEngines Uses

func PingSearchEngines(opts *Options, urls ...string)

PingSearchEngines requests some ping server from it calls Sitemap.PingSearchEngines.

func SetBuilderElementValue Uses

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 Uses

func ToLowerString(befores []string) (afters []string)

ToLowerString converts lower strings from including capital or upper strings.

func URLJoin Uses

func URLJoin(src string, joins ...string) string

URLJoin TODO: Too slowly

type Adapter Uses

type Adapter interface {
    Write(loc *Location, data []byte)
    Bytes() [][]byte
}

Adapter provides interface for writes some kind of sitemap.

type Attr Uses

type Attr map[string]string

Attr defines for xml attribute.

type Attrs Uses

type Attrs []interface{}

Attrs defines for xml attribute.

type BufferAdapter Uses

type BufferAdapter struct {
    // contains filtered or unexported fields
}

BufferAdapter provides implementation for the Adapter interface.

func NewBufferAdapter Uses

func NewBufferAdapter() *BufferAdapter

NewBufferAdapter returns the created the BufferAdapter's pointer

func (*BufferAdapter) Bytes Uses

func (adp *BufferAdapter) Bytes() [][]byte

Bytes gets written content.

func (*BufferAdapter) Write Uses

func (adp *BufferAdapter) Write(loc *Location, data []byte)

Write will create sitemap xml file into the file systems.

type BufferPool Uses

type BufferPool struct {
    sync.Pool
}

BufferPool is

func NewBufferPool Uses

func NewBufferPool() *BufferPool

NewBufferPool is

func (*BufferPool) Get Uses

func (bp *BufferPool) Get() *bytes.Buffer

Get is

func (*BufferPool) Put Uses

func (bp *BufferPool) Put(b *bytes.Buffer)

Put is

type Builder Uses

type Builder interface {
    XMLContent() []byte
    Content() []byte
    Add(interface{}) BuilderError
    Write()
}

Builder provides interface for adds some kind of url sitemap.

type BuilderError Uses

type BuilderError interface {
    error
    FullError() bool
}

BuilderError provides interface for it can confirm the error in some difference.

type BuilderFile Uses

type BuilderFile struct {
    // contains filtered or unexported fields
}

BuilderFile provides implementation for the Builder interface.

func NewBuilderFile Uses

func NewBuilderFile(opts *Options, loc *Location) *BuilderFile

NewBuilderFile returns the created the BuilderFile's pointer

func (*BuilderFile) Add Uses

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 Uses

func (b *BuilderFile) Content() []byte

Content will return pooled bytes on content attribute.

func (*BuilderFile) Write Uses

func (b *BuilderFile) Write()

Write will write pooled bytes with header and footer to Location path for output sitemap file.

func (*BuilderFile) XMLContent Uses

func (b *BuilderFile) XMLContent() []byte

XMLContent will return an XML of the sitemap built

type BuilderIndexfile Uses

type BuilderIndexfile struct {
    // contains filtered or unexported fields
}

BuilderIndexfile provides implementation for the Builder interface.

func NewBuilderIndexfile Uses

func NewBuilderIndexfile(opts *Options, loc *Location) *BuilderIndexfile

NewBuilderIndexfile returns the created the BuilderIndexfile's pointer

func (*BuilderIndexfile) Add Uses

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 Uses

func (b *BuilderIndexfile) Content() []byte

Content and BuilderFile.Content are almost the same behavior.

func (*BuilderIndexfile) Write Uses

func (b *BuilderIndexfile) Write()

Write and Builderfile.Write are almost the same behavior.

func (*BuilderIndexfile) XMLContent Uses

func (b *BuilderIndexfile) XMLContent() []byte

XMLContent and BuilderFile.XMLContent share almost the same behavior.

type FileAdapter Uses

type FileAdapter struct{}

FileAdapter provides implementation for the Adapter interface.

func NewFileAdapter Uses

func NewFileAdapter() *FileAdapter

NewFileAdapter returns the created the FileAdapter's pointer

func (*FileAdapter) Bytes Uses

func (adp *FileAdapter) Bytes() [][]byte

Bytes gets written content.

func (*FileAdapter) Write Uses

func (adp *FileAdapter) Write(loc *Location, data []byte)

Write will create sitemap xml file into the file systems.

type Location Uses

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 Uses

func NewLocation(opts *Options) *Location

NewLocation returns created the Location's pointer

func (*Location) Directory Uses

func (loc *Location) Directory() string

Directory returns path to combine publicPath and sitemapsPath on file systems. It also indicates where sitemap files are.

func (*Location) Filename Uses

func (loc *Location) Filename() string

Filename returns sitemap filename.

func (*Location) Filesize Uses

func (loc *Location) Filesize() int64

Filesize returns file size this struct has.

func (*Location) IsReservedName Uses

func (loc *Location) IsReservedName() bool

IsReservedName confirms that keeps filename on Location.filename.

func (*Location) IsVerbose Uses

func (loc *Location) IsVerbose() bool

IsVerbose returns boolean about verbosed summary.

func (*Location) Namer Uses

func (loc *Location) Namer() *Namer

Namer returns the Namer's pointer that Options struct has.

func (*Location) Path Uses

func (loc *Location) Path() string

Path returns path to combine publicPath, sitemapsPath and Filename on file systems. It also indicates where sitemap name is.

func (*Location) PathInPublic Uses

func (loc *Location) PathInPublic() string

PathInPublic returns path to combine sitemapsPath and Filename on website. It also indicates where url file path is.

func (*Location) ReserveName Uses

func (loc *Location) ReserveName() string

ReserveName returns that sets filename if this struct didn't keep filename and it returns reserved filename if this struct keeps filename also.

func (*Location) Summary Uses

func (loc *Location) Summary(linkCount int) string

Summary outputs to generated file summary for console.

func (*Location) URL Uses

func (loc *Location) URL() string

URL returns path to combine SitemapsHost, sitemapsPath and Filename on website with it uses ResolveReference.

func (*Location) Write Uses

func (loc *Location) Write(data []byte, linkCount int)

Write writes sitemap and index files that used from Adapter interface.

type NOpts Uses

type NOpts struct {
    // contains filtered or unexported fields
}

NOpts Namer's option

type Namer Uses

type Namer struct {
    // contains filtered or unexported fields
}

Namer provides sitemap's filename as a file number counter.

func NewNamer Uses

func NewNamer(opts *NOpts) *Namer

NewNamer returns created the Namer's pointer

func (*Namer) IsStart Uses

func (n *Namer) IsStart() bool

IsStart confirms that this struct has zero value.

func (*Namer) Next Uses

func (n *Namer) Next() *Namer

Next is going to go to next index for filename.

func (*Namer) Previous Uses

func (n *Namer) Previous() *Namer

Previous is going to go to previous index for filename.

func (*Namer) Reset Uses

func (n *Namer) Reset()

Reset will initialize to zero value on Namer's counter.

func (*Namer) String Uses

func (n *Namer) String() string

String returns that combines filename base and file extension.

type Options Uses

type Options struct {
    // contains filtered or unexported fields
}

Options exists for the Sitemap struct.

func NewOptions Uses

func NewOptions() *Options

NewOptions returns the created the Options's pointer

func (*Options) Clone Uses

func (opts *Options) Clone() *Options

Clone method returns it copied myself.

func (*Options) IndexLocation Uses

func (opts *Options) IndexLocation() *Location

IndexLocation returns the Location's pointer with set option to arguments for BuilderIndexfile struct.

func (*Options) Location Uses

func (opts *Options) Location() *Location

Location returns the Location's pointer with set option to arguments for Builderfile struct.

func (*Options) Namer Uses

func (opts *Options) Namer() *Namer

Namer returns Namer's pointer cache. If didn't create that yet, It also returns created Namer's pointer.

func (*Options) SetAdapter Uses

func (opts *Options) SetAdapter(adp Adapter)

SetAdapter sets that arg from Sitemap.SetAdapter method

func (*Options) SetCompress Uses

func (opts *Options) SetCompress(compress bool)

SetCompress sets that arg from Sitemap.SetCompress method

func (*Options) SetDefaultHost Uses

func (opts *Options) SetDefaultHost(host string)

SetDefaultHost sets that arg from Sitemap.Finalize method

func (*Options) SetFilename Uses

func (opts *Options) SetFilename(filename string)

SetFilename sets that arg from Sitemap.SetFilename method

func (*Options) SetPretty Uses

func (opts *Options) SetPretty(pretty bool)

SetPretty option sets pretty option to Options struct which allows pretty formatting to output files.

func (*Options) SetPublicPath Uses

func (opts *Options) SetPublicPath(path string)

SetPublicPath sets that arg from Sitemap.SetPublicPath method

func (*Options) SetSitemapsHost Uses

func (opts *Options) SetSitemapsHost(host string)

SetSitemapsHost sets that arg from Sitemap.SetSitemapsHost method

func (*Options) SetSitemapsPath Uses

func (opts *Options) SetSitemapsPath(path string)

SetSitemapsPath sets that arg from Sitemap.SetSitemapsPath method.

func (*Options) SetVerbose Uses

func (opts *Options) SetVerbose(verbose bool)

SetVerbose sets that arg from Sitemap.SetVerbose method

func (*Options) SitemapsHost Uses

func (opts *Options) SitemapsHost() string

SitemapsHost sets that arg from Sitemap.SitemapsHost method

type Sitemap Uses

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 Uses

func NewSitemap(maxProc int) *Sitemap

NewSitemap returns the created the Sitemap's pointer

func (*Sitemap) Add Uses

func (sm *Sitemap) Add(url interface{}) *Sitemap

Add Should call this after call to Create method on this struct.

func (*Sitemap) Create Uses

func (sm *Sitemap) Create() *Sitemap

Create method must be that calls first this method in that before call to Add method on this struct.

func (*Sitemap) Finalize Uses

func (sm *Sitemap) Finalize() *Sitemap

Finalize writes sitemap and index files if it had some specific condition in BuilderFile struct.

func (*Sitemap) PingSearchEngines Uses

func (sm *Sitemap) PingSearchEngines(urls ...string)

PingSearchEngines requests some ping server. It also has that includes PingSearchEngines function.

func (*Sitemap) SetAdapter Uses

func (sm *Sitemap) SetAdapter(adp Adapter)

SetAdapter can switch output file storage. We have S3Adapter and FileAdapter (default: FileAdapter)

func (*Sitemap) SetCompress Uses

func (sm *Sitemap) SetCompress(compress bool)

SetCompress can switch compress for the output file.

func (*Sitemap) SetDefaultHost Uses

func (sm *Sitemap) SetDefaultHost(host string)

SetDefaultHost is your website's host name

func (*Sitemap) SetFilename Uses

func (sm *Sitemap) SetFilename(filename string)

SetFilename can apply any name in this method if you wants to change output file name

func (*Sitemap) SetPretty Uses

func (sm *Sitemap) SetPretty(pretty bool)

SetPretty option allows pretty formating to the output files.

func (*Sitemap) SetPublicPath Uses

func (sm *Sitemap) SetPublicPath(path string)

SetPublicPath is the directory to write sitemaps to locally

func (*Sitemap) SetSitemapsHost Uses

func (sm *Sitemap) SetSitemapsHost(host string)

SetSitemapsHost is the remote host where your sitemaps will be hosted

func (*Sitemap) SetSitemapsPath Uses

func (sm *Sitemap) SetSitemapsPath(path string)

SetSitemapsPath sets this to a directory/path if you don't want to upload to the root of your `SitemapsHost`

func (*Sitemap) SetVerbose Uses

func (sm *Sitemap) SetVerbose(verbose bool)

SetVerbose can switch verbose output to console.

func (*Sitemap) XMLContent Uses

func (sm *Sitemap) XMLContent() []byte

XMLContent returns the XML content of the sitemap

type SitemapURL Uses

type SitemapURL interface {
    XML() []byte
}

SitemapURL provides generated xml interface.

func NewSitemapIndexURL Uses

func NewSitemapIndexURL(opts *Options, url URL) SitemapURL

NewSitemapIndexURL and NewSitemapURL are almost the same behavior.

func NewSitemapURL Uses

func NewSitemapURL(opts *Options, url URL) (SitemapURL, error)

NewSitemapURL returns the created the SitemapURL's pointer and it validates URL types error.

type URL Uses

type URL [][]interface{}

URL User should use this typedef in main func.

func (*URL) BungURLJoinBy Uses

func (u *URL) BungURLJoinBy(key string, joins ...string)

BungURLJoinBy that's convenient. Though, this is Bung method.

func (URL) URLJoinBy Uses

func (u URL) URLJoinBy(key string, joins ...string) URL

URLJoinBy that's convenient.

type URLModel Uses

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

Package stm imports 16 packages (graph) and is imported by 40 packages. Updated 2019-03-26. Refresh now. Tools for package owners.