From 02213402e81d4ff3425402a3299a7ac5d6c9d4bc Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Mon, 9 Nov 2015 07:45:37 -0700 Subject: [PATCH] Unexport internal types; improved markdown summaries --- caddy/caddy.go | 2 +- caddy/config.go | 14 +++++++------- middleware/markdown/page.go | 6 ++++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/caddy/caddy.go b/caddy/caddy.go index ba5a79be..5c6f7576 100644 --- a/caddy/caddy.go +++ b/caddy/caddy.go @@ -175,7 +175,7 @@ func Start(cdyfile Input) error { // taking into account whether or not this process is // a child from a graceful restart or not. It blocks // until the servers are listening. -func startServers(groupings Group) error { +func startServers(groupings bindingGroup) error { var startupWg sync.WaitGroup errChan := make(chan error) diff --git a/caddy/config.go b/caddy/config.go index d1620379..dacd5724 100644 --- a/caddy/config.go +++ b/caddy/config.go @@ -213,8 +213,8 @@ func makeStorages() map[string]interface{} { // bind address to list of configs that would become VirtualHosts on that // server. Use the keys of the returned map to create listeners, and use // the associated values to set up the virtualhosts. -func arrangeBindings(allConfigs []server.Config) (Group, error) { - var groupings Group +func arrangeBindings(allConfigs []server.Config) (bindingGroup, error) { + var groupings bindingGroup // Group configs by bind address for _, conf := range allConfigs { @@ -242,7 +242,7 @@ func arrangeBindings(allConfigs []server.Config) (Group, error) { } } if !existing { - groupings = append(groupings, BindingMapping{ + groupings = append(groupings, bindingMapping{ BindAddr: bindAddr, Configs: []server.Config{conf}, }) @@ -362,15 +362,15 @@ var ( Port = DefaultPort ) -// BindingMapping maps a network address to configurations +// bindingMapping maps a network address to configurations // that will bind to it. The order of the configs is important. -type BindingMapping struct { +type bindingMapping struct { BindAddr *net.TCPAddr Configs []server.Config } -// Group maps network addresses to their configurations. +// bindingGroup maps network addresses to their configurations. // Preserving the order of the groupings is important // (related to graceful shutdown and restart) // so this is a slice, not a literal map. -type Group []BindingMapping +type bindingGroup []bindingMapping diff --git a/middleware/markdown/page.go b/middleware/markdown/page.go index 2b417d6e..9266d9c4 100644 --- a/middleware/markdown/page.go +++ b/middleware/markdown/page.go @@ -118,15 +118,17 @@ func (l *linkGen) generateLinks(md Markdown, cfg *Config) bool { } reqPath = "/" + filepath.ToSlash(reqPath) + // Make the summary parser := findParser(body) if parser == nil { // no metadata, ignore. continue } - summary, err := parser.Parse(body) + summaryRaw, err := parser.Parse(body) if err != nil { return err } + summary := blackfriday.Markdown(summaryRaw, SummaryRenderer{}, 0) // truncate summary to maximum length if len(summary) > summaryLen { @@ -145,7 +147,7 @@ func (l *linkGen) generateLinks(md Markdown, cfg *Config) bool { Title: metadata.Title, URL: reqPath, Date: metadata.Date, - Summary: string(blackfriday.Markdown(summary, SummaryRenderer{}, 0)), + Summary: string(summary), }) break // don't try other file extensions