Documentation ¶
Overview ¶
Configuration for Icarus instance.
Utilities for preprocessing Markdown from the Python style to the new, different style...
Specifically:
1. strip out [TOC] since there is no support here, 2. call out to pygments to render code blocks starting with :::<lang>
TODO: move this into its own module w/its own namespace
Handling templates and such.
Index ¶
- Constants
- Variables
- func BuildAtomFeed(cfg *Config, ps []*Page) (*feeds.Feed, error)
- func ConfigRedis(cfg *Config) error
- func ConfigSearch(cfg *Config) error
- func ConfigTemplates(cfg *Config) error
- func CurrentTimestamp() int64
- func GetIP(r *http.Request) string
- func GetRedisClient() (*redis.Client, error)
- func IndexPage(p *Page) error
- func IndexPages(pgs []*Page) error
- func IsRateLimited(key string) bool
- func PagesInList(list string) (int, error)
- func PutRedisClient(rc *redis.Client)
- func Referrer(r *http.Request) string
- func RegisterPage(p *Page) error
- func RegisterPageTag(p *Page, tag string) error
- func ReindexAll() error
- func Search(qs string) ([]string, error)
- func Serve(cfg *Config)
- func ShouldIgnore(p *Page, r *http.Request) bool
- func SlugsForList(list string, offset int, count int, reverse bool) ([]string, error)
- func Track(p *Page, r *http.Request) error
- func UnindexPage(p *Page) error
- func UnregisterPage(p *Page) error
- func UnregisterPageTag(p *Page, tag string) error
- type BlogConfig
- type Config
- type NoSuchPagesError
- type Page
- func PageFromRedis(slug string) (*Page, error)
- func PagesForList(list string, offset int, count int, reverse bool) ([]*Page, error)
- func PagesFromRedis(slugs []string) ([]*Page, error)
- func ReadHeaders(content string) (*Page, string, error)
- func RecentPages(offset int, count int) ([]*Page, error)
- func Render(filename string, content string) (*Page, error)
- func RenderHTML(content string) (*Page, error)
- func RenderMarkdown(content string) (*Page, error)
- func SimilarPages(p *Page, offset int, count int) ([]*Page, error)
- func Surrounding(p *Page, num int, reverse bool) ([]*Page, error)
- func TrendingPages(offset int, count int) ([]*Page, error)
- type PageOpt
- type Paginator
- type RSSConfig
- type RedisConfig
- type ServerConfig
- type Tag
Constants ¶
const AnalyticsBackoff = "analytics.backoff.%v"
const DaySeconds = 60 * 60 * 24
const DirectReferrer = "DIRECT"
const HistoricalReferrer = "imported from Google Analytics"
const PageReferrers = "analytics.refer.%v"
const PageString = "page.%v"
const PageViewBonus = 60 * 60 * 24
const PageViewBucket = "analytics.pv_bucket"
const PageViewPageBucket = "analytics.pv_bucket.%v"
const PageViews = "analytics.pv"
const PageZsetByTime = "pages_by_time"
const PageZsetByTrend = "pages_by_trend"
const PagesInModules = 3
TODO: move this to Config
const RateLimitPeriod = 60
const Referrers = "analytics.refer"
const SimilarPagesByTrend = "similar_pages.%v"
const SimilarPagesExpire = 60 * 60 * 24
const TagPagesZsetByTime = "tag_pages_by_time.%v"
const TagPagesZsetByTrend = "tag_pages_by_trend.%v"
const TagZsetByPages = "tags_by_pages"
const TagZsetByTime = "tags_by_times"
const UserAgents = "analytics.useragent"
Variables ¶
var BotAgents = []string{
"-",
"facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)",
"mozilla/5.0 (compatible; yahoo! slurp; http://help.yahoo.com/help/us/ysearch/slurp)",
"disqus/1.0",
"sogou web spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07)",
"baiduspider+(+http://www.baidu.com/search/spider.htm)",
"baiduspider+(+http://www.baidu.jp/spider/)",
"ichiro/4.0 (http://help.goo.ne.jp/door/crawler.html)",
"java/1.6.0_24",
"python-urllib/2.6",
"ia_archiver (+http://www.alexa.com/site/help/webmasters; crawler@alexa.com)",
"mozilla/5.0 (compatible; topblogsInfo/2.0; +topblogsinfo@gmail.com)",
"mozilla/5.0 (compatible; baiduspider/2.0; +http://www.baidu.com/search/spider.html)",
}
var FilteredRefs = []string{ "www.google.com", "lethain.com", "dev.lethain.com", "DIRECT", HistoricalReferrer, }
Functions ¶
func ConfigRedis ¶
func ConfigSearch ¶
func ConfigTemplates ¶
func CurrentTimestamp ¶
func CurrentTimestamp() int64
func GetRedisClient ¶
func IndexPages ¶
func IsRateLimited ¶
func PagesInList ¶
func PutRedisClient ¶
func RegisterPage ¶
func RegisterPageTag ¶
func ReindexAll ¶
func ReindexAll() error
func SlugsForList ¶
func UnindexPage ¶
func UnregisterPage ¶
func UnregisterPageTag ¶
Types ¶
type BlogConfig ¶
type BlogConfig struct { Name string ResultsPerPage int `json:"results_per_page"` PagesInPaginator int `json:"pages_in_paginator"` TemplateDir string `json:"template_dir"` StaticDir string `json:"static_dir"` }
.BlogName -> .Blog.Name .ListCount -> .Blog.ResultsPerPage .NumPages -> .Blog.PagesInPaginator
type Config ¶
type Config struct { Server ServerConfig RSS RSSConfig Blog BlogConfig Redis RedisConfig }
func NewConfigFromFile ¶
Build a new configuration file from disk.
type NoSuchPagesError ¶
type NoSuchPagesError struct { Slugs []string // contains filtered or unexported fields }
func (*NoSuchPagesError) Error ¶
func (e *NoSuchPagesError) Error() string
type Page ¶
type Page struct { Slug string `json:"slug"` Tags []string `json:"tags"` Title string `json:"title"` Summary string `json:"summary"` Content string `json:"html"` Draft bool `json:"draft"` PubDateStr int64 `json:"pub_date"` EditDateStr int64 `json:"edit_date"` }
func PagesForList ¶
func PagesFromRedis ¶
Retrieve a list of slugs from Redis.
func ReadHeaders ¶
Create a new Page with the headers stripped out of it.
Headers look like this:
"tags": ["python", "redis"], "title": "Storing Bounded Timeboxes in Redis", "summary": "This is the summary...", "slug": "storing-bounded-timeboxes-in-redis",
Including a \n\n (outside of string) to designate the end of the section. In general, you can describe the header as a JSON dictionary without the opening or closing {}s.
func RenderHTML ¶
func RenderMarkdown ¶
func Surrounding ¶
Get up to N preceeding or following pages.
func (*Page) EnsureEditDate ¶
func (p *Page) EnsureEditDate()
func (*Page) EnsurePubDate ¶
func (p *Page) EnsurePubDate()
func (*Page) InitEditDate ¶
func (p *Page) InitEditDate()
func (*Page) InitPubDate ¶
func (p *Page) InitPubDate()