mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-23 22:27:38 -05:00
Unexport internal types; improved markdown summaries
This commit is contained in:
parent
e1f23a1eb7
commit
02213402e8
3 changed files with 12 additions and 10 deletions
|
@ -175,7 +175,7 @@ func Start(cdyfile Input) error {
|
||||||
// taking into account whether or not this process is
|
// taking into account whether or not this process is
|
||||||
// a child from a graceful restart or not. It blocks
|
// a child from a graceful restart or not. It blocks
|
||||||
// until the servers are listening.
|
// until the servers are listening.
|
||||||
func startServers(groupings Group) error {
|
func startServers(groupings bindingGroup) error {
|
||||||
var startupWg sync.WaitGroup
|
var startupWg sync.WaitGroup
|
||||||
errChan := make(chan error)
|
errChan := make(chan error)
|
||||||
|
|
||||||
|
|
|
@ -213,8 +213,8 @@ func makeStorages() map[string]interface{} {
|
||||||
// bind address to list of configs that would become VirtualHosts on that
|
// 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
|
// server. Use the keys of the returned map to create listeners, and use
|
||||||
// the associated values to set up the virtualhosts.
|
// the associated values to set up the virtualhosts.
|
||||||
func arrangeBindings(allConfigs []server.Config) (Group, error) {
|
func arrangeBindings(allConfigs []server.Config) (bindingGroup, error) {
|
||||||
var groupings Group
|
var groupings bindingGroup
|
||||||
|
|
||||||
// Group configs by bind address
|
// Group configs by bind address
|
||||||
for _, conf := range allConfigs {
|
for _, conf := range allConfigs {
|
||||||
|
@ -242,7 +242,7 @@ func arrangeBindings(allConfigs []server.Config) (Group, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !existing {
|
if !existing {
|
||||||
groupings = append(groupings, BindingMapping{
|
groupings = append(groupings, bindingMapping{
|
||||||
BindAddr: bindAddr,
|
BindAddr: bindAddr,
|
||||||
Configs: []server.Config{conf},
|
Configs: []server.Config{conf},
|
||||||
})
|
})
|
||||||
|
@ -362,15 +362,15 @@ var (
|
||||||
Port = DefaultPort
|
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.
|
// that will bind to it. The order of the configs is important.
|
||||||
type BindingMapping struct {
|
type bindingMapping struct {
|
||||||
BindAddr *net.TCPAddr
|
BindAddr *net.TCPAddr
|
||||||
Configs []server.Config
|
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
|
// Preserving the order of the groupings is important
|
||||||
// (related to graceful shutdown and restart)
|
// (related to graceful shutdown and restart)
|
||||||
// so this is a slice, not a literal map.
|
// so this is a slice, not a literal map.
|
||||||
type Group []BindingMapping
|
type bindingGroup []bindingMapping
|
||||||
|
|
|
@ -118,15 +118,17 @@ func (l *linkGen) generateLinks(md Markdown, cfg *Config) bool {
|
||||||
}
|
}
|
||||||
reqPath = "/" + filepath.ToSlash(reqPath)
|
reqPath = "/" + filepath.ToSlash(reqPath)
|
||||||
|
|
||||||
|
// Make the summary
|
||||||
parser := findParser(body)
|
parser := findParser(body)
|
||||||
if parser == nil {
|
if parser == nil {
|
||||||
// no metadata, ignore.
|
// no metadata, ignore.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
summary, err := parser.Parse(body)
|
summaryRaw, err := parser.Parse(body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
summary := blackfriday.Markdown(summaryRaw, SummaryRenderer{}, 0)
|
||||||
|
|
||||||
// truncate summary to maximum length
|
// truncate summary to maximum length
|
||||||
if len(summary) > summaryLen {
|
if len(summary) > summaryLen {
|
||||||
|
@ -145,7 +147,7 @@ func (l *linkGen) generateLinks(md Markdown, cfg *Config) bool {
|
||||||
Title: metadata.Title,
|
Title: metadata.Title,
|
||||||
URL: reqPath,
|
URL: reqPath,
|
||||||
Date: metadata.Date,
|
Date: metadata.Date,
|
||||||
Summary: string(blackfriday.Markdown(summary, SummaryRenderer{}, 0)),
|
Summary: string(summary),
|
||||||
})
|
})
|
||||||
|
|
||||||
break // don't try other file extensions
|
break // don't try other file extensions
|
||||||
|
|
Loading…
Reference in a new issue