diff --git a/hugolib/page.go b/hugolib/page.go index 0c66c2154..206652334 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -28,7 +28,6 @@ import ( "github.com/spf13/cast" "github.com/spf13/hugo/helpers" "github.com/spf13/hugo/parser" - "github.com/spf13/hugo/template/bundle" jww "github.com/spf13/jwalterweatherman" "github.com/spf13/viper" "github.com/theplant/blackfriday" @@ -49,7 +48,7 @@ type Page struct { contentType string Draft bool Aliases []string - Tmpl bundle.Template + Tmpl Template Markup string renderable bool layout string @@ -519,7 +518,7 @@ func (page *Page) parse(reader io.Reader) error { return nil } -func (p *Page) ProcessShortcodes(t bundle.Template) { +func (p *Page) ProcessShortcodes(t Template) { p.rawContent = []byte(ShortcodesHandle(string(p.rawContent), p, t)) p.Summary = template.HTML(ShortcodesHandle(string(p.Summary), p, t)) } diff --git a/template/bundle/path_seperators_windows_test.go b/hugolib/path_seperators_windows_test.go similarity index 96% rename from template/bundle/path_seperators_windows_test.go rename to hugolib/path_seperators_windows_test.go index e5f168b4f..5cdd7c5f6 100644 --- a/template/bundle/path_seperators_windows_test.go +++ b/hugolib/path_seperators_windows_test.go @@ -1,4 +1,4 @@ -package bundle +package hugolib import ( "testing" diff --git a/hugolib/shortcode.go b/hugolib/shortcode.go index 92e81195e..67204b740 100644 --- a/hugolib/shortcode.go +++ b/hugolib/shortcode.go @@ -20,7 +20,6 @@ import ( "strings" "unicode" - "github.com/spf13/hugo/template/bundle" jww "github.com/spf13/jwalterweatherman" ) @@ -78,7 +77,7 @@ func (scp *ShortcodeWithPage) Get(key interface{}) interface{} { type Shortcodes map[string]ShortcodeFunc -func ShortcodesHandle(stringToParse string, p *Page, t bundle.Template) string { +func ShortcodesHandle(stringToParse string, p *Page, t Template) string { leadStart := strings.Index(stringToParse, `{{%`) if leadStart >= 0 { leadEnd := strings.Index(stringToParse[leadStart:], `%}}`) + leadStart @@ -147,7 +146,7 @@ func FindEnd(str string, name string) (int, int) { return startPos, endPos } -func GetTemplate(name string, t bundle.Template) *template.Template { +func GetTemplate(name string, t Template) *template.Template { if x := t.Lookup("shortcodes/" + name + ".html"); x != nil { return x } diff --git a/hugolib/site.go b/hugolib/site.go index 050eaafbf..20d03cb01 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -27,7 +27,6 @@ import ( "github.com/spf13/hugo/helpers" "github.com/spf13/hugo/source" "github.com/spf13/hugo/target" - "github.com/spf13/hugo/template/bundle" "github.com/spf13/hugo/transform" jww "github.com/spf13/jwalterweatherman" "github.com/spf13/nitro" @@ -57,7 +56,7 @@ var DefaultTimer *nitro.B // 5. The entire collection of files is written to disk. type Site struct { Pages Pages - Tmpl bundle.Template + Tmpl Template Taxonomies TaxonomyList Source source.Input Sections Taxonomy @@ -72,19 +71,20 @@ type Site struct { } type SiteInfo struct { - BaseUrl template.URL - Taxonomies TaxonomyList - Indexes *TaxonomyList // legacy, should be identical to Taxonomies - Recent *Pages - Title string - Author string - AuthorEmail string - LanguageCode string - Copyright string - LastChange time.Time - ConfigGet func(key string) interface{} - Permalinks PermalinkOverrides - Params map[string]interface{} + BaseUrl template.URL + Taxonomies TaxonomyList + Indexes *TaxonomyList // legacy, should be identical to Taxonomies + Recent *Pages + Title string + Author map[string]string + LanguageCode string + DisqusShortname string + Copyright string + LastChange time.Time + ConfigGet func(key string) interface{} + Permalinks PermalinkOverrides + Params map[string]interface{} +} } type runmode struct { @@ -130,7 +130,7 @@ func (s *Site) Analyze() { } func (s *Site) prepTemplates() { - s.Tmpl = bundle.NewTemplate() + s.Tmpl = NewTemplate() s.Tmpl.LoadTemplates(s.absLayoutDir()) if s.hasTheme() { s.Tmpl.LoadTemplatesWithPrefix(s.absThemeDir()+"/layouts", "theme") @@ -234,16 +234,16 @@ func (s *Site) initializeSiteInfo() { permalinks = make(PermalinkOverrides) } - s.Info = SiteInfo{ - BaseUrl: template.URL(helpers.SanitizeUrl(viper.GetString("BaseUrl"))), - Title: viper.GetString("Title"), - Author: viper.GetString("author"), - AuthorEmail: viper.GetString("authoremail"), - LanguageCode: viper.GetString("languagecode"), - Copyright: viper.GetString("copyright"), - Recent: &s.Pages, - Params: params, - Permalinks: permalinks, + s.Info = &SiteInfo{ + BaseUrl: template.URL(helpers.SanitizeUrl(viper.GetString("BaseUrl"))), + Title: viper.GetString("Title"), + Author: viper.GetStringMapString("author"), + LanguageCode: viper.GetString("languagecode"), + Copyright: viper.GetString("copyright"), + DisqusShortname: viper.GetString("DisqusShortname"), + Recent: &s.Pages, + Params: params, + Permalinks: permalinks, } } diff --git a/template/bundle/template.go b/hugolib/template.go similarity index 97% rename from template/bundle/template.go rename to hugolib/template.go index 30d24144b..f7bd52815 100644 --- a/template/bundle/template.go +++ b/hugolib/template.go @@ -1,4 +1,4 @@ -package bundle +package hugolib import ( "errors" @@ -192,7 +192,11 @@ func (t *GoHtmlTemplate) LoadEmbedded() { } func (t *GoHtmlTemplate) AddInternalTemplate(prefix, name, tpl string) error { - return t.AddTemplate("_internal/"+prefix+"/"+name, tpl) + if prefix != "" { + return t.AddTemplate("_internal/"+prefix+"/"+name, tpl) + } else { + return t.AddTemplate("_internal/"+name, tpl) + } } func (t *GoHtmlTemplate) AddInternalShortcode(name, content string) error { diff --git a/template/bundle/embedded.go b/hugolib/template_embedded.go similarity index 67% rename from template/bundle/embedded.go rename to hugolib/template_embedded.go index 45e182b7a..2555f9a21 100644 --- a/template/bundle/embedded.go +++ b/hugolib/template_embedded.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bundle +package hugolib type Tmpl struct { Name string @@ -49,7 +49,7 @@ func (t *GoHtmlTemplate) EmbedTemplates() { Hugo {{ .Permalink }} {{ with .Site.LanguageCode }}{{.}}{{end}} - {{ with .Site.Author }}{{.}}{{end}} + {{ with .Site.Author.name }}{{.}}{{end}} {{ with .Site.Copyright }}{{.}}{{end}} {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 MST" }} {{ range first 15 .Data.Pages }} @@ -57,7 +57,7 @@ func (t *GoHtmlTemplate) EmbedTemplates() { {{ .Title }} {{ .Permalink }} {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 MST" }} - {{with .Site.Author}}{{.}}{{end}} + {{with .Site.Author.name}}{{.}}{{end}} {{ .Permalink }} {{ .Content | html }} @@ -65,4 +65,20 @@ func (t *GoHtmlTemplate) EmbedTemplates() { `) + t.AddInternalTemplate("", "disqus.html", `{{ if .Site.DisqusShortname }}
+ + +comments powered by Disqus{{end}}`) + } diff --git a/template/bundle/template_test.go b/hugolib/template_test.go similarity index 98% rename from template/bundle/template_test.go rename to hugolib/template_test.go index 019816f6e..ffc417b4c 100644 --- a/template/bundle/template_test.go +++ b/hugolib/template_test.go @@ -1,4 +1,4 @@ -package bundle +package hugolib import ( "reflect"