sitemap

package
v1.11.13 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package sitemap generates a complete list of pages available on the website. The generated list is formatted as an XML document and can be saved to a file stored in webroot of the site for search engine bot parsing.

Index

Constants

View Source
const (
	// Location is the URL of the website.
	Location = "https://defacto2.net"

	// DockerLoc is the URL for the developer hosted on a Docker container.
	DockerLoc = "http://localhost:8560"

	// Namespace is the XML name space.
	Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9"

	// limit the number of urls as permitted by Bing and Google search engines.
	Limit = 50000
)
View Source
const (
	// TitleSuffix is the string normally appended to most browser tabs.
	TitleSuffix = " | Defacto2"
)

Variables

View Source
var ErrNoIDs = errors.New("no ids to randomise")
View Source
var ErrPointer = errors.New("pointer value cannot be nil")

Functions

func AbsPaths added in v1.10.0

func AbsPaths(base string) ([28]string, error)

AbsPaths returns all the static URLs used by the sitemap.

func AbsPathsH3 added in v1.10.0

func AbsPathsH3(db *sql.DB, base string) ([]string, error)

AbsPaths returns all the HTML3 static URLs used by the sitemap.

func Color404 added in v1.10.0

func Color404(i int) string

Color404 applies a success checkmark and color when i matches status code 404.

func ColorCode added in v1.10.0

func ColorCode(i int) string

ColorCode applies a success checkmark and color when i matches status code 200.

func Create

func Create(db *sql.DB, w io.Writer, dir string) error

Create generates and prints the sitemap.

func FileList added in v1.10.0

func FileList(base string) ([]string, error)

FileList returns a complete list of URL query strings for the file lists.

func FindTitle added in v1.10.0

func FindTitle(b []byte) string

FindTitle returns the string value of the HTML <title> element.

func GetTitle added in v1.10.0

func GetTitle(trimSuffix bool, url string) (string, int, error)

GetTitle returns the string value of the HTML <title> element and status code of a URL.

func Outputs added in v1.10.0

func Outputs() []string

func Platforms added in v1.10.0

func Platforms(db *sql.DB) ([]string, error)

Platforms lists the operating systems required by the files.

func Sections added in v1.10.0

func Sections(db *sql.DB) ([]string, error)

Sections lists the categories of files.

func Sorts added in v1.10.0

func Sorts() []string

Types

type IDs added in v1.10.0

type IDs []int

IDs are the primary keys of the file records.

func GetBlocked added in v1.10.0

func GetBlocked(db *sql.DB) (IDs, error)

GetBlocked returns all the primary keys of the records with blocked file downloads.

func GetKeys added in v1.10.0

func GetKeys(db *sql.DB) (IDs, error)

GetKeys returns all the primary keys of the file records that are public.

func GetSoftDeleteKeys added in v1.10.0

func GetSoftDeleteKeys(db *sql.DB) (IDs, error)

GetSoftDeleteKeys returns all the primary keys of the file records that are not public and hidden.

func RandBlocked added in v1.10.0

func RandBlocked(db *sql.DB, count int) (int, IDs, error)

RandBlocked returns a randomized count of primary keys for records with blocked file downloads.

func RandDeleted added in v1.10.0

func RandDeleted(db *sql.DB, count int) (int, IDs, error)

RandDeleted returns a randomized count of primary keys for hidden file records.

func RandIDs added in v1.10.0

func RandIDs(db *sql.DB, count int) (int, IDs, error)

RandBlocked returns a randomized count of primary keys for public file records.

func (*IDs) Contains added in v1.10.0

func (ids *IDs) Contains(x int) bool

Contains returns true whenever IDs contains x.

func (IDs) JoinPaths added in v1.10.0

func (ids IDs) JoinPaths(base string, r Root) []string

JoinPaths return the URL strings of the IDs.

func (IDs) Randomize added in v1.10.0

func (ids IDs) Randomize(x int) (IDs, error)

Randomize the IDs and returns the first x results.

type Options added in v1.10.0

type Options struct {
	Output   string `url:"output"`
	Platform string `url:"platform"`
	Section  string `url:"section"`
	Sort     string `url:"sort"`
}

type Root added in v1.10.0

type Root int

Root URL element.

const (
	File     Root = iota // File URL element.
	Download             // Download URL element.
)

func (Root) String added in v1.10.0

func (r Root) String() string

type Style added in v1.10.0

type Style int

Style the result of a link and its status code.

const (
	LinkNotFound Style = iota // LinkNotFound first prints the link and expects 404 status codes.
	LinkSuccess               // LinkSuccess first prints the link and expects 200 status codes.
	NotFound                  // NotFound expects 404 status codes.
	Success                   // Success expects 200 status codes.
)

func (Style) Range added in v1.10.0

func (p Style) Range(w io.Writer, urls []string)

Range over the file URLs.

func (Style) RangeFiles added in v1.10.0

func (p Style) RangeFiles(w io.Writer, urls []string)

RangeFiles ranges over the file download URLs.

Directories

Path Synopsis
internal
urlset
Package urlset handles creation of XML formatted URLs.
Package urlset handles creation of XML formatted URLs.

Jump to

Keyboard shortcuts

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