Documentation ¶
Index ¶
- Constants
- Variables
- func CanonicalPage(doc *html.Node) (string, error)
- func HtmlMarkdown(src string) template.HTML
- func StableVersion(n *html.Node) (string, string)
- func TextMarkdown(src string) string
- func Title(page string) string
- func Titles(pages []string) []string
- func WikiBasePage(href string) string
- type Curated
- type DB
- type ErrNoVersion
- type ErrNotFound
- type ErrRedirect
- type Link
- type Memory
- func (m *Memory) CreateCurated() (string, error)
- func (m *Memory) CuratedSetPages(id string, pages []string) error
- func (m *Memory) CuratedSetTitle(id string, title string) error
- func (m *Memory) CuratedSetUsed(id string) error
- func (m *Memory) Current(limit int, order SortBy) ([]Page, error)
- func (m *Memory) CurrentIn(pages ...string) ([]Page, error)
- func (m *Memory) History(pages ...string) ([]Page, error)
- func (m *Memory) Known() ([]string, error)
- func (m *Memory) Last(page string) (*Page, error)
- func (m *Memory) LoadCurated(id string) (*Curated, error)
- func (m *Memory) Store(p Page) error
- type Page
- type Postgres
- func (p *Postgres) CreateCurated() (string, error)
- func (p *Postgres) CuratedSetPages(id string, pages []string) error
- func (p *Postgres) CuratedSetTitle(id, title string) error
- func (p *Postgres) CuratedSetUsed(id string) error
- func (p *Postgres) Current(limit int, order SortBy) ([]Page, error)
- func (p *Postgres) CurrentIn(pages ...string) ([]Page, error)
- func (p *Postgres) History(pages ...string) ([]Page, error)
- func (p *Postgres) Known() ([]string, error)
- func (p *Postgres) Last(page string) (*Page, error)
- func (p *Postgres) LoadCurated(id string) (*Curated, error)
- func (p *Postgres) Store(e Page) error
- func (p *Postgres) StoreCurated(cur Curated) error
- type SortBy
- type Spider
- type SpiderCache
- type Table
- type WikipediaSpider
Constants ¶
View Source
const ( DefaultUserAgent = "verssion_bot/1.0 (https://verssion.one)" MaxConcurrency = 5 )
View Source
const (
CacheOK = 6 * time.Hour
)
View Source
const DBURL = "postgresql:///w"
Variables ¶
View Source
var ErrCuratedNotFound = errors.New("curated ID not found")
Functions ¶
func WikiBasePage ¶
given a full wikipedia url returns the page name also works with parts of the wikipedia url
Types ¶
type Curated ¶
type Curated struct { CustomTitle string Created time.Time LastUsed time.Time LastUpdated time.Time Pages []string }
func (*Curated) DefaultTitle ¶
type DB ¶
type DB interface { Last(string) (*Page, error) // Last spider Current(limit int, order SortBy) ([]Page, error) CurrentIn(...string) ([]Page, error) History(...string) ([]Page, error) // Newest first Store(Page) error Known() ([]string, error) CreateCurated() (string, error) LoadCurated(string) (*Curated, error) // will return (nil, nil) on not found CuratedSetPages(string, []string) error CuratedSetUsed(string) error CuratedSetTitle(string, string) error }
type ErrNoVersion ¶
type ErrNoVersion struct {
Page string
}
func (ErrNoVersion) Error ¶
func (e ErrNoVersion) Error() string
type ErrNotFound ¶
type ErrNotFound struct {
Page string
}
func (ErrNotFound) Error ¶
func (e ErrNotFound) Error() string
type ErrRedirect ¶
type ErrRedirect struct {
Page, To string
}
func (ErrRedirect) Error ¶
func (e ErrRedirect) Error() string
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
func (*Memory) CreateCurated ¶
func (*Memory) CuratedSetUsed ¶
type Postgres ¶
type Postgres struct {
// contains filtered or unexported fields
}
func NewPostgres ¶
func (*Postgres) CreateCurated ¶
func (*Postgres) CuratedSetPages ¶
pages must be unique
func (*Postgres) CuratedSetTitle ¶
func (*Postgres) CuratedSetUsed ¶
func (*Postgres) StoreCurated ¶
type SpiderCache ¶
type SpiderCache struct {
// contains filtered or unexported fields
}
SpiderCache wraps a Spider implementation
func NewSpiderCache ¶
func NewSpiderCache(spider Spider) *SpiderCache
type WikipediaSpider ¶
type WikipediaSpider struct { URL func(string) string UserAgent string // contains filtered or unexported fields }
func NewWikipediaSpider ¶
func NewWikipediaSpider(url func(string) string) *WikipediaSpider
NewWikipediaSpider makes a spider. url makes a URL from a page.
Click to show internal directories.
Click to hide internal directories.