sitemap

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetStaticSitemap

func GetStaticSitemap(filename string) ([]byte, error)

func LoadStaticSitemap

func LoadStaticSitemap(cfg *config.Config, oldSitemapName, staticSitemapName, dpOnsURLHostName, dpOnsURLHostNameAlt, altLang string, store FileStore) error

Types

type Adder

type Adder interface {
	Add(oldSitemap io.Reader, url *URL) (file string, size int, err error)
}

type AlternateURL

type AlternateURL struct {
	XMLName xml.Name `xml:"xhtml:link,omitempty"`
	Rel     string   `xml:"rel,omitempty,attr"`
	Lang    string   `xml:"hreflang,omitempty,attr"`
	Link    string   `xml:"href,omitempty,attr"`
}

type AlternateURLReader

type AlternateURLReader struct {
	XMLName xml.Name `xml:"link,omitempty"`
	Rel     string   `xml:"rel,omitempty,attr"`
	Lang    string   `xml:"hreflang,omitempty,attr"`
	Link    string   `xml:"href,omitempty,attr"`
}

type DefaultAdder

type DefaultAdder struct{}

func (*DefaultAdder) Add

func (a *DefaultAdder) Add(oldSitemap io.Reader, url *URL) (fileName string, size int, err error)

type ElasticFetcher

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

func NewElasticFetcher

func NewElasticFetcher(scroll Scroll, cfg *config.Config, zc clients.ZebedeeClient) *ElasticFetcher

func (*ElasticFetcher) GetFullSitemap

func (f *ElasticFetcher) GetFullSitemap(ctx context.Context) (fileNames Files, err error)

func (*ElasticFetcher) GetPageInfo

func (f *ElasticFetcher) GetPageInfo(ctx context.Context, path string) (*PageInfo, error)

func (*ElasticFetcher) HasWelshContent

func (f *ElasticFetcher) HasWelshContent(ctx context.Context, path string) bool

func (*ElasticFetcher) URLVersion

func (f *ElasticFetcher) URLVersion(ctx context.Context, path, lastmod, lang string) *URL

func (*ElasticFetcher) URLVersions

func (f *ElasticFetcher) URLVersions(ctx context.Context, path, lastmod string) (en, cy *URL)

type ElasticHit

type ElasticHit struct {
	Index  string           `json:"_index"`
	Type   string           `json:"_type"`
	ID     string           `json:"_id"`
	Score  interface{}      `json:"_score"`
	Source ElasticHitSource `json:"_source"`
	Sort   []string         `json:"sort"`
}

type ElasticHitSource

type ElasticHitSource struct {
	Type            string      `json:"type"`
	URI             string      `json:"uri"`
	JobID           string      `json:"job_id"`
	SearchIndex     string      `json:"search_index"`
	Cdid            string      `json:"cdid"`
	DatasetID       string      `json:"dataset_id"`
	Edition         string      `json:"edition"`
	Keywords        []string    `json:"keywords"`
	MetaDescription string      `json:"meta_description"`
	ReleaseDate     time.Time   `json:"release_date"`
	Summary         string      `json:"summary"`
	Title           string      `json:"title"`
	Topics          interface{} `json:"topics"`
	Cancelled       bool        `json:"cancelled"`
	Finalised       bool        `json:"finalised"`
	Published       bool        `json:"published"`
	CanonicalTopic  string      `json:"canonical_topic"`
}

type ElasticResult

type ElasticResult struct {
	ScrollID string `json:"_scroll_id"`
	Took     int    `json:"took"`
	TimedOut bool   `json:"timed_out"`
	Shards   struct {
		Total      int `json:"total"`
		Successful int `json:"successful"`
		Skipped    int `json:"skipped"`
		Failed     int `json:"failed"`
	} `json:"_shards"`
	Hits struct {
		Total struct {
			Value    int    `json:"value"`
			Relation string `json:"relation"`
		} `json:"total"`
		MaxScore interface{}  `json:"max_score"`
		Hits     []ElasticHit `json:"hits"`
	} `json:"hits"`
}

type ElasticScroll

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

func NewElasticScroll

func NewElasticScroll(elastic *es710.Client, cfg *config.Config) *ElasticScroll

func (*ElasticScroll) GetScroll

func (f *ElasticScroll) GetScroll(ctx context.Context, id string, result interface{}) error

func (*ElasticScroll) StartScroll

func (f *ElasticScroll) StartScroll(ctx context.Context, result interface{}) error

type Fetcher

type Fetcher interface {
	GetFullSitemap(ctx context.Context) (Files, error)
	HasWelshContent(ctx context.Context, path string) bool
	URLVersions(ctx context.Context, path string, lastmod string) (en, cy *URL)
	URLVersion(ctx context.Context, path, lastmod, lang string) *URL
	GetPageInfo(ctx context.Context, path string) (*PageInfo, error)
}

type FileStore

type FileStore interface {
	SaveFile(name string, body io.Reader) error
	GetFile(name string) (body io.ReadCloser, err error)
	CopyFile(src io.Reader, dest io.Writer) error
	CreateFile(name string) (io.ReadWriteCloser, error)
	DeleteFile(name string) error
}

type Files

type Files map[config.Language]string

type Generator

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

func NewGenerator

func NewGenerator(opts ...GeneratorOptions) *Generator

func (*Generator) AppendURL

func (g *Generator) AppendURL(ctx context.Context, sitemap io.ReadCloser, url *URL, destination string) (int, error)

func (*Generator) MakeFullSitemap

func (g *Generator) MakeFullSitemap(ctx context.Context) error

func (*Generator) MakePublishingSitemap

func (g *Generator) MakePublishingSitemap(ctx context.Context, url URL) error

func (*Generator) TruncatePublishingSitemap

func (g *Generator) TruncatePublishingSitemap(ctx context.Context) error

type GeneratorOptions

type GeneratorOptions func(*Generator) *Generator

func WithAdder

func WithAdder(a Adder) GeneratorOptions

func WithFetcher

func WithFetcher(f Fetcher) GeneratorOptions

func WithFileStore

func WithFileStore(s FileStore) GeneratorOptions

func WithFullSitemapFiles

func WithFullSitemapFiles(f Files) GeneratorOptions

func WithPublishingSitemapFile

func WithPublishingSitemapFile(f string) GeneratorOptions

func WithPublishingSitemapMaxSize

func WithPublishingSitemapMaxSize(size int, callback func()) GeneratorOptions

type LocalStore

type LocalStore struct{}

func (*LocalStore) CopyFile

func (s *LocalStore) CopyFile(src io.Reader, dest io.Writer) error

func (*LocalStore) CreateFile

func (s *LocalStore) CreateFile(name string) (io.ReadWriteCloser, error)

func (*LocalStore) DeleteFile added in v0.2.1

func (s *LocalStore) DeleteFile(name string) error

func (*LocalStore) GetFile

func (s *LocalStore) GetFile(name string) (body io.ReadCloser, err error)

func (*LocalStore) SaveFile

func (s *LocalStore) SaveFile(name string, body io.Reader) error

type PageInfo

type PageInfo struct {
	ReleaseDate string
	URLs        map[config.Language]*URL
}

type S3Client

type S3Client interface {
	Upload(input *s3manager.UploadInput, options ...func(*s3manager.Uploader)) (*s3manager.UploadOutput, error)
	Get(key string) (io.ReadCloser, *int64, error)
	BucketName() string
}

type S3Store

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

func NewS3Store

func NewS3Store(client S3Client) *S3Store

func (*S3Store) CopyFile

func (s *S3Store) CopyFile(_ io.Reader, _ io.Writer) error

func (*S3Store) CreateFile

func (s *S3Store) CreateFile(_ string) (io.ReadWriteCloser, error)

func (*S3Store) DeleteFile added in v0.2.1

func (s *S3Store) DeleteFile(_ string) error

func (*S3Store) GetFile

func (s *S3Store) GetFile(name string) (body io.ReadCloser, err error)

func (*S3Store) SaveFile

func (s *S3Store) SaveFile(name string, body io.Reader) error

type Scroll

type Scroll interface {
	StartScroll(ctx context.Context, result interface{}) error
	GetScroll(ctx context.Context, id string, result interface{}) error
}

type StaticURL

type StaticURL struct {
	URL         string `json:"url"`
	ReleaseDate string `json:"releaseDate"`
	HasAltLang  bool   `json:"hasAltLang"`
}

type URL

type URL struct {
	XMLName   xml.Name      `xml:"url"`
	Loc       string        `xml:"loc"`
	Lastmod   string        `xml:"lastmod"`
	Alternate *AlternateURL `xml:"xhtml:link,omitempty"`
}

type URLReader

type URLReader struct {
	XMLName   xml.Name            `xml:"url"`
	Loc       string              `xml:"loc"`
	Lastmod   string              `xml:"lastmod"`
	Alternate *AlternateURLReader `xml:"link,omitempty"`
}

type Urlset

type Urlset struct {
	XMLName xml.Name `xml:"urlset"`
	Xmlns   string   `xml:"xmlns,attr"`
	Xhtml   string   `xml:"xmlns:xhtml,attr"`
	URL     []URL    `xml:"url"`
}

type UrlsetReader

type UrlsetReader struct {
	XMLName xml.Name    `xml:"urlset"`
	Xmlns   string      `xml:"xmlns,attr"`
	Xhtml   string      `xml:"xmlns:xhtml,attr"`
	URL     []URLReader `xml:"url"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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