mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-25 17:56:34 +08:00
Unexport internal types; improved markdown summaries
This commit is contained in:
parent
e1f23a1eb7
commit
02213402e8
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user