summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/hugo.go14
-rw-r--r--helpers/content.go18
-rw-r--r--helpers/content_test.go10
-rw-r--r--helpers/url.go1
-rw-r--r--hugolib/handler_page.go5
-rw-r--r--hugolib/hugo_sites.go6
-rw-r--r--hugolib/hugo_sites_test.go4
-rw-r--r--hugolib/multilingual.go10
-rw-r--r--hugolib/node.go7
-rw-r--r--hugolib/page.go19
-rw-r--r--hugolib/site.go38
-rw-r--r--hugolib/site_test.go2
-rw-r--r--hugolib/translations.go1
-rw-r--r--source/file.go4
14 files changed, 34 insertions, 105 deletions
diff --git a/commands/hugo.go b/commands/hugo.go
index 3ac35db1c..6c28b78bd 100644
--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -630,11 +630,17 @@ func getDirList() []string {
}
func reCreateAndbuildSites(watching bool) (err error) {
+ if err := initSites(); err != nil {
+ return err
+ }
fmt.Println("Started building sites ...")
return Hugo.Build(hugolib.BuildCfg{CreateSitesFromConfig: true, Watching: watching, PrintStats: true})
}
func resetAndbuildSites(watching bool) (err error) {
+ if err := initSites(); err != nil {
+ return err
+ }
fmt.Println("Started building sites ...")
return Hugo.Build(hugolib.BuildCfg{ResetState: true, Watching: watching, PrintStats: true})
}
@@ -655,13 +661,17 @@ func initSites() error {
}
func buildSites(watching bool) (err error) {
- initSites()
+ if err := initSites(); err != nil {
+ return err
+ }
fmt.Println("Started building sites ...")
return Hugo.Build(hugolib.BuildCfg{Watching: watching, PrintStats: true})
}
func rebuildSites(events []fsnotify.Event) error {
- initSites()
+ if err := initSites(); err != nil {
+ return err
+ }
return Hugo.Rebuild(hugolib.BuildCfg{PrintStats: true, Watching: true}, events...)
}
diff --git a/helpers/content.go b/helpers/content.go
index 427d960a1..49d3469c5 100644
--- a/helpers/content.go
+++ b/helpers/content.go
@@ -396,24 +396,6 @@ func WordCount(s string) map[string]int {
return m
}
-// RemoveSummaryDivider removes summary-divider <!--more--> from content.
-// TODO(bep) ml remove
-func RemoveSummaryDivider(content []byte) []byte {
- b := bytes.Replace(content, summaryDividerAndNewLines, []byte(""), 1)
- if len(b) != len(content) {
- return b
- }
- return bytes.Replace(content, SummaryDivider, []byte(""), 1)
-}
-
-func removeInternalSummaryDivider(content []byte) []byte {
- b := bytes.Replace(content, summaryDividerAndNewLines, []byte(""), 1)
- if len(b) != len(content) {
- return b
- }
- return bytes.Replace(content, SummaryDivider, []byte(""), 1)
-}
-
// TruncateWordsByRune truncates words by runes.
func TruncateWordsByRune(words []string, max int) (string, bool) {
count := 0
diff --git a/helpers/content_test.go b/helpers/content_test.go
index 85e0d7f4f..3a038ea12 100644
--- a/helpers/content_test.go
+++ b/helpers/content_test.go
@@ -409,13 +409,3 @@ func TestWordCount(t *testing.T) {
t.Errorf("Actual Map (%v) does not equal expected (%v)", actualMap, expectedMap)
}
}
-
-func TestRemoveSummaryDivider(t *testing.T) {
- content := []byte("This is before. <!--more-->This is after.")
- actualRemovedContent := RemoveSummaryDivider(content)
- expectedRemovedContent := []byte("This is before. This is after.")
-
- if !bytes.Equal(actualRemovedContent, expectedRemovedContent) {
- t.Errorf("Actual removed content (%s) did not equal expected removed content (%s)", actualRemovedContent, expectedRemovedContent)
- }
-}
diff --git a/helpers/url.go b/helpers/url.go
index f9a41dde3..83273324d 100644
--- a/helpers/url.go
+++ b/helpers/url.go
@@ -186,7 +186,6 @@ func getLanguagePrefix() string {
}
// IsAbsURL determines whether the given path points to an absolute URL.
-// TODO(bep) ml tests
func IsAbsURL(path string) bool {
url, err := url.Parse(path)
if err != nil {
diff --git a/hugolib/handler_page.go b/hugolib/handler_page.go
index 04af20ceb..fcc5b9561 100644
--- a/hugolib/handler_page.go
+++ b/hugolib/handler_page.go
@@ -104,15 +104,10 @@ func commonConvert(p *Page, t tpl.Template) HandledResult {
// TODO(bep) these page handlers need to be re-evaluated, as it is hard to
// process a page in isolation. See the new preRender func.
- // TODO(bep) ml not so raw anymore, but do we need to keep it raw?
if viper.GetBool("EnableEmoji") {
p.rawContent = helpers.Emojify(p.rawContent)
}
- // TODO(bep) ml we let the summary divider survive the rendering. Must check if
- // it actually survives, replace it with something more robus, or maybe
- // rethink this fragile concept.
- //p.rawContent = p.renderContent(helpers.RemoveSummaryDivider(p.rawContent))
// We have to replace the <!--more--> with something that survives all the
// rendering engines.
// TODO(bep) inline replace
diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go
index 561c43a3a..f0012d2af 100644
--- a/hugolib/hugo_sites.go
+++ b/hugolib/hugo_sites.go
@@ -62,8 +62,7 @@ func createSitesFromConfig() ([]*Site, error) {
var sites []*Site
multilingual := viper.GetStringMap("Languages")
if len(multilingual) == 0 {
- // TODO(bep) multilingo langConfigsList = append(langConfigsList, NewLanguage("en"))
- sites = append(sites, newSite(helpers.NewLanguage("en")))
+ sites = append(sites, newSite(helpers.NewDefaultLanguage()))
}
if len(multilingual) > 0 {
@@ -85,10 +84,9 @@ func createSitesFromConfig() ([]*Site, error) {
}
// Reset resets the sites, making it ready for a full rebuild.
-// TODO(bep) multilingo
func (h *HugoSites) reset() {
for i, s := range h.Sites {
- h.Sites[i] = s.Reset()
+ h.Sites[i] = s.reset()
}
}
diff --git a/hugolib/hugo_sites_test.go b/hugolib/hugo_sites_test.go
index 9ccfed054..e2a110d18 100644
--- a/hugolib/hugo_sites_test.go
+++ b/hugolib/hugo_sites_test.go
@@ -73,9 +73,7 @@ func TestMultiSitesBuild(t *testing.T) {
assert.NoError(t, err, "permalink call failed")
assert.Equal(t, "http://example.com/blog/superbob", permalink, "invalid doc3 permalink")
- // TODO(bep) multilingo. Check this case. This has url set in frontmatter, but we must split into lang folders
- // The assertion below was missing the /en prefix.
- assert.Equal(t, "/en/superbob", doc3.URL(), "invalid url, was specified on doc3 TODO(bep)")
+ assert.Equal(t, "/en/superbob", doc3.URL(), "invalid url, was specified on doc3")
assert.Equal(t, doc2.Next, doc3, "doc3 should follow doc2, in .Next")
diff --git a/hugolib/multilingual.go b/hugolib/multilingual.go
index 610587659..a9a2f256c 100644
--- a/hugolib/multilingual.go
+++ b/hugolib/multilingual.go
@@ -75,15 +75,6 @@ func (s *Site) multilingualEnabled() bool {
return s.Multilingual != nil && s.Multilingual.enabled()
}
-// TODO(bep) multilingo remove these
-func (s *Site) currentLanguageString() string {
- return s.currentLanguage().Lang
-}
-
-func (s *Site) currentLanguage() *helpers.Language {
- return s.Language
-}
-
func toSortedLanguages(l map[string]interface{}) (helpers.Languages, error) {
langs := make(helpers.Languages, len(l))
i := 0
@@ -107,7 +98,6 @@ func toSortedLanguages(l map[string]interface{}) (helpers.Languages, error) {
}
// Put all into the Params map
- // TODO(bep) ml reconsile with the type handling etc. from other params handlers.
language.SetParam(loki, v)
}
diff --git a/hugolib/node.go b/hugolib/node.go
index e9a5ab1a9..57bd5021f 100644
--- a/hugolib/node.go
+++ b/hugolib/node.go
@@ -49,7 +49,7 @@ type Node struct {
language *helpers.Language
languageInit sync.Once
- lang string // TODO(bep) multilingo
+ lang string
translations Nodes
translationsInit sync.Once
@@ -168,7 +168,6 @@ func (n *Node) RelRef(ref string) (string, error) {
return n.Site.RelRef(ref, nil)
}
-// TODO(bep) multilingo some of these are now hidden. Consider unexport.
type URLPath struct {
URL string
Permalink string
@@ -192,7 +191,6 @@ func (n *Node) Scratch() *Scratch {
return n.scratch
}
-// TODO(bep) multilingo consolidate. See Page.
func (n *Node) Language() *helpers.Language {
n.initLanguage()
return n.language
@@ -223,8 +221,7 @@ func (n *Node) initLanguage() {
language := ml.Language(pageLang)
if language == nil {
- // TODO(bep) ml
- // This may or may not be serious. It can be a file named stefano.chiodino.md.
+ // It can be a file named stefano.chiodino.md.
jww.WARN.Printf("Page language (if it is that) not found in multilang setup: %s.", pageLang)
language = ml.DefaultLang
}
diff --git a/hugolib/page.go b/hugolib/page.go
index da9fa4f87..a15af60bf 100644
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -327,25 +327,6 @@ func (p *Page) setAutoSummary() error {
return nil
}
-// TODO(bep) ml not used???
-func (p *Page) _renderBytes(content []byte) []byte {
- var fn helpers.LinkResolverFunc
- var fileFn helpers.FileResolverFunc
- if p.getRenderingConfig().SourceRelativeLinksEval {
- fn = func(ref string) (string, error) {
- return p.Node.Site.SourceRelativeLink(ref, p)
- }
- fileFn = func(ref string) (string, error) {
- return p.Node.Site.SourceRelativeLinkFile(ref, p)
- }
- }
- return helpers.RenderBytes(
- &helpers.RenderingContext{
- Content: content, PageFmt: p.determineMarkupType(),
- ConfigProvider: p.Language(),
- DocumentID: p.UniqueID(), Config: p.getRenderingConfig(), LinkResolver: fn, FileResolver: fileFn})
-}
-
func (p *Page) renderContent(content []byte) []byte {
var fn helpers.LinkResolverFunc
var fileFn helpers.FileResolverFunc
diff --git a/hugolib/site.go b/hugolib/site.go
index 8ae3cd16f..1029a38bf 100644
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -99,9 +99,8 @@ type Site struct {
Language *helpers.Language
}
-// Reset returns a new Site prepared for rebuild.
-// TODO(bep) multilingo
-func (s *Site) Reset() *Site {
+// reset returns a new Site prepared for rebuild.
+func (s *Site) reset() *Site {
return &Site{Language: s.Language, Multilingual: s.Multilingual}
}
@@ -144,21 +143,20 @@ type targetList struct {
}
type SiteInfo struct {
- BaseURL template.URL
- Taxonomies TaxonomyList
- Authors AuthorList
- Social SiteSocial
- Sections Taxonomy
- Pages *Pages // Includes only pages in this language
- AllPages *Pages // Includes other translated pages, excluding those in this language.
- rawAllPages *Pages // Includes absolute all pages, including drafts etc.
- Files *[]*source.File
- Menus *Menus
- Hugo *HugoInfo
- Title string
- RSSLink string
- Author map[string]interface{}
- // TODO(bep) multilingo
+ BaseURL template.URL
+ Taxonomies TaxonomyList
+ Authors AuthorList
+ Social SiteSocial
+ Sections Taxonomy
+ Pages *Pages // Includes only pages in this language
+ AllPages *Pages // Includes other translated pages, excluding those in this language.
+ rawAllPages *Pages // Includes absolute all pages, including drafts etc.
+ Files *[]*source.File
+ Menus *Menus
+ Hugo *HugoInfo
+ Title string
+ RSSLink string
+ Author map[string]interface{}
LanguageCode string
DisqusShortname string
GoogleAnalytics string
@@ -701,7 +699,6 @@ func (s *Site) readI18nSources() error {
themeI18nDir, err := helpers.GetThemeI18nDirPath()
if err == nil {
- // TODO(bep) multilingo what is this?
i18nSources = []source.Input{&source.Filesystem{Base: themeI18nDir}, i18nSources[0]}
}
@@ -1622,7 +1619,7 @@ func (s *Site) newTaxonomyNode(t taxRenderInfo) (*Node, string) {
func (s *Site) addMultilingualPrefix(basePath string) string {
hadPrefix := strings.HasPrefix(basePath, "/")
if s.multilingualEnabled() {
- basePath = path.Join(s.currentLanguageString(), basePath)
+ basePath = path.Join(s.Language.Lang, basePath)
if hadPrefix {
basePath = "/" + basePath
}
@@ -1992,7 +1989,6 @@ func (s *Site) Stats() {
func (s *Site) setURLs(n *Node, in string) {
n.URLPath.URL = helpers.URLizeAndPrep(in)
n.URLPath.Permalink = permalink(n.URLPath.URL)
- // TODO(bep) multilingo
n.RSSLink = template.HTML(permalink(in + ".xml"))
}
diff --git a/hugolib/site_test.go b/hugolib/site_test.go
index b93e08aca..3f6e25bad 100644
--- a/hugolib/site_test.go
+++ b/hugolib/site_test.go
@@ -216,9 +216,7 @@ func TestFutureExpirationRender(t *testing.T) {
}
// Issue #957
-// TODO(bep) ml
func TestCrossrefs(t *testing.T) {
- hugofs.InitMemFs()
for _, uglyURLs := range []bool{true, false} {
for _, relative := range []bool{true, false} {
doTestCrossrefs(t, relative, uglyURLs)
diff --git a/hugolib/translations.go b/hugolib/translations.go
index 05dcfb260..e3df3acd1 100644
--- a/hugolib/translations.go
+++ b/hugolib/translations.go
@@ -50,7 +50,6 @@ func assignTranslationsToPages(allTranslations map[string]Translations, pages []
continue
}
- // TODO(bep) multilingo remove lang
for _, translatedPage := range trans {
page.translations = append(page.translations, translatedPage)
}
diff --git a/source/file.go b/source/file.go
index 4bee882a6..500da2548 100644
--- a/source/file.go
+++ b/source/file.go
@@ -129,10 +129,6 @@ func NewFile(relpath string) *File {
f.lang = strings.TrimPrefix(filepath.Ext(f.baseName), ".")
if f.lang == "" {
f.lang = viper.GetString("DefaultContentLanguage")
- if f.lang == "" {
- // TODO(bep) ml
- f.lang = "en"
- }
}
f.translationBaseName = helpers.Filename(f.baseName)