repo

package
v3.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2017 License: MIT Imports: 20 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// Adds indicates the addition files in this visit.
	Adds = iota
	// Mods indicates the modification files in this visit.
	Mods
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Dir

type Dir string

Dir transforms path from absolute to relative and vice-versa, from the repository base dir perspective.

func (Dir) Abs

func (d Dir) Abs(path string) string

Abs returns the absolute path in the prepend the base dir. Returns "" if the given path is absolute but not on the base dir.

func (Dir) Rel

func (d Dir) Rel(path string) string

Rel returns the relative path for the given path, return same if path is already relative, if outside of the base dir return "".

func (Dir) URLPath

func (d Dir) URLPath(path string) string

URLPath returns the HTTP URL path at the application level. Basically, return the dir of the path relative to base dir. Any path outside of base dir or equal to base dir will return "".

type Doc

type Doc struct {
	Body       template.HTML `json:"-" yaml:"-"`
	Path       string        `json:"-" yaml:"-"`
	URL        string        `json:"url,omitempty" yaml:"-"`
	Title      string        `json:"title" yaml:",omitempty"`
	Tags       []string      `json:"tags"`
	Date       time.Time     `json:"date"`
	Weather    string        `json:"weather"`
	Summary    string        `json:"summary"`
	Location   string        `json:"location"`
	Background string        `json:"background"`
	License    string        `json:"license"`
	// Hide from the list, but still can get with URL.
	Hide  bool   `json:"hide"`
	Older string `json:"older,omitempty"`
	Newer string `json:"newer,omitempty"`
}

Doc representation of the document.

type DocParser

type DocParser struct {
}

DocParser parse the document.

func (*DocParser) Parse

func (p *DocParser) Parse(path string) (Doc, error)

Parse parse implementation.

type DocProcessor

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

DocProcessor render mark up documents as articles.

func (*DocProcessor) Process

func (p *DocProcessor) Process(paths ...string) Docs

Process the given for documents, either using callback or return value to receiving the results, or both.

type DocRepo

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

DocRepo documents repository implements.

func (*DocRepo) Batch

func (r *DocRepo) Batch(adds, mods, dels []string)

Batch additions, modifications and deletions into a single request.

func (*DocRepo) Del

func (r *DocRepo) Del(path string)

Del a document for the path.

func (*DocRepo) Get

func (r *DocRepo) Get(path string) (Doc, error)

Get a document for the path.

func (*DocRepo) List

func (r *DocRepo) List(since string, size int) Docs

List articles since a specific path, excluded.

func (*DocRepo) Post

func (r *DocRepo) Post(path string)

Post publish the path for documents. This method should be called when you start the application. Since it won't call the visitors let them do post process.

func (*DocRepo) Put

func (r *DocRepo) Put(path string)

Put revalidate a document.

type DocScanner

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

DocScanner scan a path for documents.

func (*DocScanner) Scan

func (s *DocScanner) Scan(path string) []string

Scan a path to find documents.

type Docs

type Docs []Doc

Docs a list of articles. Maybe a BST is faster, an list is fast enough for such a tiny program. Simplicity, generality and clarity is more important, however.

func (Docs) Len

func (d Docs) Len() int

Len _

func (Docs) Less

func (d Docs) Less(i, j int) bool

Less order by time Dec.

func (Docs) Swap

func (d Docs) Swap(i, j int)

Swap _

type GithubRenderer

type GithubRenderer struct {
	User, Repo     string
	Dir            Dir
	StripTitle     bool
	URLTransformer func(src string) string
}

GithubRenderer render a mark up document using the Github favored style.

func (*GithubRenderer) Render

func (r *GithubRenderer) Render(file string) (template.HTML, error)

Render a file in a repository of a Github user.

type NotFoundError

type NotFoundError string

NotFoundError indicates the requested doc is not existed.

func (NotFoundError) Error

func (s NotFoundError) Error() string

type Parser

type Parser interface {
	Parse(file string) (Doc, error)
}

Parser parse the raw document into application representation.

type Processor

type Processor interface {
	Process(paths ...string) Docs
}

Processor process a path, which could be a file or dir.

type Renderer

type Renderer interface {
	Render(path string) (template.HTML, error)
}

Renderer render a document into HTML.

func NewRenderer

func NewRenderer(user, repo string, dir Dir) Renderer

NewRenderer default Github renderer, the URL in the HTML will remain unchanged.

type Repo

type Repo interface {
	List(since string, size int) Docs
	Get(path string) (Doc, error)
	Del(path string)
	Put(path string)
	Post(path string)
	Batch(adds, mods, dels []string)
}

Repo the documents repository.

func NewRepo

func NewRepo(repoDir string, skipDirs, globDocs []string,
	user, repo string, vistors ...Visitor) Repo

NewRepo create a new article repository.

type Scanner

type Scanner interface {
	Scan(path string) []string
}

Scanner a location for documents.

type Visitor

type Visitor interface {
	Visit(docs Docs, cookie map[int]interface{})
}

Visitor post process the found documents.

Jump to

Keyboard shortcuts

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