Documentation ¶
Index ¶
- Constants
- func FilterMap[T comparable, V any](m map[T]V, f func(T) bool) map[T]V
- func FilterSlice[T any](s []T, f func(T) bool) []T
- func GenPath(url string, config *Config) string
- func Md2Html(md []byte, title string, templatePath, renderCommand string) (html []byte, err error)
- func PathMatch(path string, matcher ...GitIgnorer) bool
- func RenderDir(path string, hide, private GitIgnorer, blogRouter, blogPath string) (md []byte, err error)
- func SimplifyPath(path string) string
- func TransformLinks(oldhtml []byte, config *Config) []byte
- type BlogIndex
- type BlogIndexer
- type BlogItem
- type BlogLoader
- type Cache
- type Config
- type GitIgnorer
- type Meta
- type Searcher
- func NewSearchByContentMatch(name, brief string, spider fspider.Spider, cache Cache, blogLoader *BlogLoader) Searcher
- func NewSearcherByBleve(name, brief string, blogIndexer BlogIndexer) Searcher
- func NewSearcherByKeywork(name, brief string, spider fspider.Spider, cache Cache, blogLoader *BlogLoader) Searcher
- func NewSearcherByPlugin(plugin SearcherPlugin, loader *BlogLoader, config *Config) Searcher
- func NewSearcherByTitle(name, brief string, spider fspider.Spider, loader *BlogLoader) Searcher
- type SearcherPlugin
Constants ¶
View Source
const ( BLOG_ITEM_KIND_DIR = 1 << iota BLOG_ITEM_KIND_MD BLOG_ITEM_KIND_OTHER )
Variables ¶
This section is empty.
Functions ¶
func FilterMap ¶
func FilterMap[T comparable, V any](m map[T]V, f func(T) bool) map[T]V
编写一个泛型函数,用来去除一个map中的不符合要求的函数,返回一个新的map
func FilterSlice ¶
编写一个泛型函数,用来去除一个slice中不符合要求的函数,返回修改后的结果,这是一个新的slice
func RenderDir ¶
func RenderDir(path string, hide, private GitIgnorer, blogRouter, blogPath string) (md []byte, err error)
load md
func TransformLinks ¶
Types ¶
type BlogIndexer ¶
type BlogIndexer interface { // 加入对一个博客内容的索引 Add(blog *BlogItem) error // 删除对一个博客内容的索引 Delete(blog *BlogItem) error // 搜索博客内容 Search(keyword string, num int) ([]string, error) // 把对博客内容建立的索引保存到文件 Close() error }
使用bleve 对博客建立索引
func NewBlogIndexer ¶
func NewBlogIndexer(indexPath string) BlogIndexer
type BlogLoader ¶
type BlogLoader struct { *sync.RWMutex BlogPath, BlogRouter string TemplatePath, RenderCommand string Hide, Private GitIgnorer }
func NewBlogLoader ¶
func NewBlogLoader(config *Config) *BlogLoader
func (*BlogLoader) Path2Url ¶
func (loader *BlogLoader) Path2Url(path string) string
func (*BlogLoader) Update ¶
func (loader *BlogLoader) Update(config *Config)
func (*BlogLoader) Url2Path ¶
func (loader *BlogLoader) Url2Path(url string) string
type Cache ¶
type Config ¶
type Config struct { sync.RWMutex `yaml:"-" toml:"-" json:"-"` PORT int BLOG_ROUTER string API_ROUTER string BLOG_PATH string GEN_PATH string NOT_GEN bool HIDE_PATHS []string PRIVATE_PATHS []string TEMPLATE_PATH string APP_DATA_PATH string SEARCH_NUM int SEARCH_PLUGINS []SearcherPlugin RENDER_COMMAND string // for visit limit RATE_LIMITE_SECOND int RATE_LIMITE_MINUTE int RATE_LIMITE_HOUR int }
func LoadConfig ¶
type GitIgnorer ¶
type GitIgnorer interface { AddPatterns(patterns ...string) GitIgnorer UpdatePatterns(patterns ...string) GitIgnorer Match(path string) bool }
func NewBlogIgnorer ¶
func NewBlogIgnorer() GitIgnorer
type Meta ¶
type Meta struct { Title string `yaml:"title"` KeyWords []string `yaml:"keywords"` Description string `yaml:"description"` }
=== meta data for md ===
type Searcher ¶
type Searcher interface { Search(keyword string, num int) ([]string, error) Name() string Brief() string }
func NewSearchByContentMatch ¶
func NewSearchByContentMatch(name, brief string, spider fspider.Spider, cache Cache, blogLoader *BlogLoader) Searcher
according to the times of keyword in {content, title, meta}
func NewSearcherByBleve ¶
func NewSearcherByBleve(name, brief string, blogIndexer BlogIndexer) Searcher
searcher according to bleve file index engine
func NewSearcherByKeywork ¶
func NewSearcherByKeywork(name, brief string, spider fspider.Spider, cache Cache, blogLoader *BlogLoader) Searcher
searcher according to search-keyword and keywords in meta
func NewSearcherByPlugin ¶
func NewSearcherByPlugin(plugin SearcherPlugin, loader *BlogLoader, config *Config) Searcher
searcher according to plugin ; this func is not thread-safe
func NewSearcherByTitle ¶
func NewSearcherByTitle(name, brief string, spider fspider.Spider, loader *BlogLoader) Searcher
searcher according to title edit distance
Source Files ¶
Click to show internal directories.
Click to hide internal directories.