shithub: hugo

Download patch

ref: ee75e2999b66bd9f258a241c487b6677cf2fa071
parent: 15b64d51da48807c5f896f17b33d8c0d054c9461
author: Bjørn Erik Pedersen <[email protected]>
date: Sat Mar 25 12:09:56 EDT 2017

Remove the now superflous defaultExtension

And some other unsed fields and methods.

--- a/helpers/url.go
+++ b/helpers/url.go
@@ -129,7 +129,6 @@
 //    base:   http://spf13.com/
 //    path:   post/how-i-blog
 //    result: http://spf13.com/post/how-i-blog
-// TODO(bep) output check why this is still in use.
 func MakePermalink(host, plink string) *url.URL {
 
 	base, err := url.Parse(host)
--- a/hugolib/config.go
+++ b/hugolib/config.go
@@ -86,7 +86,6 @@
 	v.SetDefault("taxonomies", map[string]string{"tag": "tags", "category": "categories"})
 	v.SetDefault("permalinks", make(PermalinkOverrides, 0))
 	v.SetDefault("sitemap", Sitemap{Priority: -1, Filename: "sitemap.xml"})
-	v.SetDefault("defaultExtension", "html")
 	v.SetDefault("pygmentsStyle", "monokai")
 	v.SetDefault("pygmentsUseClasses", false)
 	v.SetDefault("pygmentsCodeFences", false)
--- a/hugolib/handler_test.go
+++ b/hugolib/handler_test.go
@@ -28,7 +28,6 @@
 		cfg, fs = newTestCfg()
 	)
 
-	cfg.Set("defaultExtension", "html")
 	cfg.Set("verbose", true)
 	cfg.Set("uglyURLs", true)
 
--- a/hugolib/hugo_sites_build_test.go
+++ b/hugolib/hugo_sites_build_test.go
@@ -811,7 +811,6 @@
 </nav>`
 
 var multiSiteTOMLConfigTemplate = `
-defaultExtension = "html"
 baseURL = "http://example.com/blog"
 disableSitemap = false
 disableRSS = false
@@ -872,7 +871,6 @@
 `
 
 var multiSiteYAMLConfigTemplate = `
-defaultExtension: "html"
 baseURL: "http://example.com/blog"
 disableSitemap: false
 disableRSS: false
@@ -934,7 +932,6 @@
 
 var multiSiteJSONConfigTemplate = `
 {
-  "defaultExtension": "html",
   "baseURL": "http://example.com/blog",
   "disableSitemap": false,
   "disableRSS": false,
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -244,7 +244,6 @@
 	plainInit           sync.Once
 	plainWordsInit      sync.Once
 	renderingConfigInit sync.Once
-	pageURLInit         sync.Once
 }
 
 // IsNode returns whether this is an item of one of the list types in Hugo,
@@ -764,15 +763,9 @@
 }
 
 func (p *Page) Extension() string {
-	if p.extension != "" {
-		// TODO(bep) output remove/deprecate this
-		return p.extension
-	}
-	//
-	// TODO(bep) return MediaType.Suffix
-
-	// TODO(bep) remove this config option =>
-	return p.s.Cfg.GetString("defaultExtension")
+	// Remove in Hugo 0.22.
+	helpers.Deprecated("Page", "Extension", "See OutputFormats with its MediaType", false)
+	return p.extension
 }
 
 // AllTranslations returns all translations, including the current Page.
@@ -1694,17 +1687,6 @@
 		outfile += "/"
 	}
 	return outfile
-}
-
-func (p *Page) addLangFilepathPrefix(outfile string) string {
-	if outfile == "" {
-		outfile = helpers.FilePathSeparator
-	}
-
-	if !p.shouldAddLanguagePrefix() {
-		return outfile
-	}
-	return helpers.FilePathSeparator + filepath.Join(p.Lang(), outfile)
 }
 
 func sectionsFromFilename(filename string) []string {
--- a/hugolib/page_permalink_test.go
+++ b/hugolib/page_permalink_test.go
@@ -64,8 +64,6 @@
 
 		cfg, fs := newTestCfg()
 
-		cfg.Set("defaultExtension", "html")
-
 		cfg.Set("uglyURLs", test.uglyURLs)
 		cfg.Set("canonifyURLs", test.canonifyURLs)
 		cfg.Set("baseURL", test.base)
--- a/hugolib/page_test.go
+++ b/hugolib/page_test.go
@@ -104,28 +104,6 @@
 Some text
 `
 
-	simplePageNoLayout = `---
-title: simple_no_layout
----
-No Layout called out`
-
-	simplePageLayoutFoobar = `---
-title: simple layout foobar
-layout: foobar
----
-Layout foobar`
-
-	simplePageTypeFoobar = `---
-type: foobar
----
-type foobar`
-
-	simplePageTypeLayout = `---
-type: barfoo
-layout: buzfoo
----
-type and layout set`
-
 	simplePageWithSummaryDelimiter = `---
 title: Simple
 ---
@@ -1089,10 +1067,6 @@
 	}
 }
 
-func L(s ...string) []string {
-	return s
-}
-
 func TestSliceToLower(t *testing.T) {
 	t.Parallel()
 	tests := []struct {
@@ -1140,8 +1114,6 @@
 	for _, test := range tests {
 		cfg, fs := newTestCfg()
 
-		cfg.Set("defaultExtension", "html")
-
 		if test.hasPermalink {
 			cfg.Set("permalinks", siteParmalinksSetting)
 		}
@@ -1385,20 +1357,6 @@
 	p := s.RegularPages[0]
 
 	checkPageTitle(t, p, "Simple")
-}
-
-func listEqual(left, right []string) bool {
-	if len(left) != len(right) {
-		return false
-	}
-
-	for i := range left {
-		if left[i] != right[i] {
-			return false
-		}
-	}
-
-	return true
 }
 
 // TODO(bep) this may be useful for other tests.
--- a/hugolib/shortcode_test.go
+++ b/hugolib/shortcode_test.go
@@ -532,7 +532,6 @@
 
 	cfg, fs := newTestCfg()
 
-	cfg.Set("defaultExtension", "html")
 	cfg.Set("defaultContentLanguage", "en")
 	cfg.Set("baseURL", baseURL)
 	cfg.Set("uglyURLs", false)
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -1958,13 +1958,6 @@
 	return helpers.WriteToDisk(path, r, s.Fs.Destination)
 }
 
-func (s *Site) langDir() string {
-	if s.Language.Lang != s.Info.multilingual.DefaultLang.Lang || s.Info.defaultContentLanguageInSubdir {
-		return s.Language.Lang
-	}
-	return ""
-}
-
 func (s *Site) draftStats() string {
 	var msg string
 
--- a/hugolib/site_render.go
+++ b/hugolib/site_render.go
@@ -124,6 +124,7 @@
 
 		// write alias for page 1
 		// TODO(bep) ml all of these n.addLang ... fix.
+		//TODO(bep) output fix
 
 		aliasPath := p.addLangPathPrefix(s.PathSpec.PaginateAliasPath(path.Join(p.sections...), 1))
 		link := p.Permalink()
--- a/hugolib/site_test.go
+++ b/hugolib/site_test.go
@@ -273,7 +273,6 @@
 
 	cfg, fs := newTestCfg()
 
-	cfg.Set("defaultExtension", "html")
 	cfg.Set("baseURL", baseURL)
 	cfg.Set("uglyURLs", uglyURLs)
 	cfg.Set("verbose", true)
@@ -325,7 +324,6 @@
 
 	cfg, fs := newTestCfg()
 
-	cfg.Set("defaultExtension", "html")
 	cfg.Set("verbose", true)
 	cfg.Set("baseURL", "http://auth/bub")
 	cfg.Set("disableSitemap", false)
@@ -427,7 +425,6 @@
 	cfg, fs := newTestCfg()
 
 	cfg.Set("baseURL", "http://auth/sub/")
-	cfg.Set("defaultExtension", "html")
 	cfg.Set("uglyURLs", uglify)
 	cfg.Set("pluralizeListTitles", pluralize)
 	cfg.Set("canonifyURLs", canonify)
@@ -481,7 +478,6 @@
 
 	cfg, fs := newTestCfg()
 
-	cfg.Set("defaultExtension", "html")
 	cfg.Set("verbose", true)
 	cfg.Set("canonifyURLs", true)
 	cfg.Set("uglyURLs", true)
@@ -539,7 +535,6 @@
 
 			cfg, fs := newTestCfg()
 
-			cfg.Set("defaultExtension", "html")
 			cfg.Set("uglyURLs", true)
 			cfg.Set("canonifyURLs", canonify)
 			cfg.Set("baseURL", baseURL)
@@ -934,7 +929,6 @@
 	cfg, fs := newTestCfg()
 
 	cfg.Set("baseURL", "http://auth/")
-	cfg.Set("defaultExtension", "html")
 	cfg.Set("uglyURLs", false)
 	cfg.Set("pluralizeListTitles", false)
 	cfg.Set("canonifyURLs", false)
--- a/tpl/tplimpl/template.go
+++ b/tpl/tplimpl/template.go
@@ -439,9 +439,6 @@
 
 const baseFileBase = "baseof"
 
-var aceTemplateInnerMarkers = [][]byte{[]byte("= content")}
-var goTemplateInnerMarkers = [][]byte{[]byte("{{define"), []byte("{{ define")}
-
 func isBaseTemplate(path string) bool {
 	return strings.Contains(path, baseFileBase)
 }