summaryrefslogtreecommitdiffstats
path: root/hugolib
diff options
context:
space:
mode:
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/alias.go29
-rw-r--r--hugolib/alias_test.go4
-rw-r--r--hugolib/author.go45
-rw-r--r--hugolib/collections.go75
-rw-r--r--hugolib/collections_test.go18
-rw-r--r--hugolib/config.go23
-rw-r--r--hugolib/datafiles_test.go6
-rw-r--r--hugolib/disableKinds_test.go40
-rw-r--r--hugolib/embedded_shortcodes_test.go10
-rw-r--r--hugolib/gitinfo.go14
-rw-r--r--hugolib/hugo_sites.go523
-rw-r--r--hugolib/hugo_sites_build.go175
-rw-r--r--hugolib/hugo_sites_build_errors_test.go123
-rw-r--r--hugolib/hugo_sites_build_test.go509
-rw-r--r--hugolib/hugo_sites_multihost_test.go26
-rw-r--r--hugolib/hugo_smoke_test.go303
-rw-r--r--hugolib/language_content_dir_test.go78
-rw-r--r--hugolib/media.go60
-rw-r--r--hugolib/menu.go224
-rw-r--r--hugolib/menu_test.go6
-rw-r--r--hugolib/minify_publisher_test.go20
-rw-r--r--hugolib/multilingual.go16
-rw-r--r--hugolib/orderedMap.go99
-rw-r--r--hugolib/orderedMap_test.go69
-rw-r--r--hugolib/page.go2360
-rw-r--r--hugolib/pageCache.go136
-rw-r--r--hugolib/pageCache_test.go88
-rw-r--r--hugolib/pageGroup.go298
-rw-r--r--hugolib/pageGroup_test.go457
-rw-r--r--hugolib/pageSort.go332
-rw-r--r--hugolib/pageSort_test.go281
-rw-r--r--hugolib/page__common.go112
-rw-r--r--hugolib/page__content.go135
-rw-r--r--hugolib/page__data.go70
-rw-r--r--hugolib/page__menus.go74
-rw-r--r--hugolib/page__meta.go652
-rw-r--r--hugolib/page__new.go291
-rw-r--r--hugolib/page__output.go107
-rw-r--r--hugolib/page__paginator.go83
-rw-r--r--hugolib/page__paths.go148
-rw-r--r--hugolib/page__per_output.go445
-rw-r--r--hugolib/page__position.go76
-rw-r--r--hugolib/page__ref.go (renamed from hugolib/page_ref.go)61
-rw-r--r--hugolib/page__tree.go113
-rw-r--r--hugolib/page_content.go233
-rw-r--r--hugolib/page_errors.go47
-rw-r--r--hugolib/page_kinds.go40
-rw-r--r--hugolib/page_output.go320
-rw-r--r--hugolib/page_paths.go312
-rw-r--r--hugolib/page_paths_test.go194
-rw-r--r--hugolib/page_permalink_test.go44
-rw-r--r--hugolib/page_taxonomy_test.go96
-rw-r--r--hugolib/page_test.go901
-rw-r--r--hugolib/page_time_integration_test.go183
-rw-r--r--hugolib/page_unwrap.go50
-rw-r--r--hugolib/page_unwrap_test.go (renamed from hugolib/page_resource.go)26
-rw-r--r--hugolib/page_without_content.go67
-rw-r--r--hugolib/pagebundler.go42
-rw-r--r--hugolib/pagebundler_capture.go10
-rw-r--r--hugolib/pagebundler_capture_test.go12
-rw-r--r--hugolib/pagebundler_handlers.go141
-rw-r--r--hugolib/pagebundler_test.go308
-rw-r--r--hugolib/pagecollections.go279
-rw-r--r--hugolib/pagecollections_test.go86
-rw-r--r--hugolib/pagemeta/page_frontmatter.go426
-rw-r--r--hugolib/pagemeta/page_frontmatter_test.go261
-rw-r--r--hugolib/pagemeta/pagemeta.go32
-rw-r--r--hugolib/pagesPrevNext.go42
-rw-r--r--hugolib/pagesPrevNext_test.go86
-rw-r--r--hugolib/pages_language_merge.go64
-rw-r--r--hugolib/pages_language_merge_test.go40
-rw-r--r--hugolib/pages_related.go191
-rw-r--r--hugolib/pages_related_test.go75
-rw-r--r--hugolib/pagination.go595
-rw-r--r--hugolib/pagination_test.go579
-rw-r--r--hugolib/path_separators_test.go38
-rw-r--r--hugolib/paths/themes.go4
-rw-r--r--hugolib/permalinker.go5
-rw-r--r--hugolib/permalinks.go213
-rw-r--r--hugolib/permalinks_test.go85
-rw-r--r--hugolib/resource_chain_test.go8
-rw-r--r--hugolib/rss_test.go25
-rw-r--r--hugolib/shortcode.go490
-rw-r--r--hugolib/shortcode_page.go56
-rw-r--r--hugolib/shortcode_test.go400
-rw-r--r--hugolib/site.go1132
-rw-r--r--hugolib/siteJSONEncode_test.go34
-rw-r--r--hugolib/site_output.go15
-rw-r--r--hugolib/site_output_test.go42
-rw-r--r--hugolib/site_render.go444
-rw-r--r--hugolib/site_sections.go273
-rw-r--r--hugolib/site_sections_test.go150
-rw-r--r--hugolib/site_test.go123
-rw-r--r--hugolib/site_url_test.go14
-rw-r--r--hugolib/sitemap.go45
-rw-r--r--hugolib/sitemap_test.go10
-rw-r--r--hugolib/taxonomy.go151
-rw-r--r--hugolib/taxonomy_test.go161
-rw-r--r--hugolib/testhelpers_test.go123
-rw-r--r--hugolib/translations.go56
100 files changed, 6705 insertions, 11988 deletions
diff --git a/hugolib/alias.go b/hugolib/alias.go
index c44f32dbb..599821c0a 100644
--- a/hugolib/alias.go
+++ b/hugolib/alias.go
@@ -1,4 +1,4 @@
-// Copyright 2017 The Hugo Authors. All rights reserved.
+// Copyright 2019 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ import (
"github.com/gohugoio/hugo/output"
"github.com/gohugoio/hugo/publisher"
+ "github.com/gohugoio/hugo/resources/page"
"github.com/gohugoio/hugo/tpl"
"github.com/gohugoio/hugo/helpers"
@@ -55,7 +56,12 @@ func newAliasHandler(t tpl.TemplateFinder, l *loggers.Logger, allowRoot bool) al
return aliasHandler{t, l, allowRoot}
}
-func (a aliasHandler) renderAlias(isXHTML bool, permalink string, page *Page) (io.Reader, error) {
+type aliasPage struct {
+ Permalink string
+ page.Page
+}
+
+func (a aliasHandler) renderAlias(isXHTML bool, permalink string, p page.Page) (io.Reader, error) {
t := "alias"
if isXHTML {
t = "alias-xhtml"
@@ -75,12 +81,9 @@ func (a aliasHandler) renderAlias(isXHTML bool, permalink string, page *Page) (i
}
}
- data := struct {
- Permalink string
- Page *Page
- }{
+ data := aliasPage{
permalink,
- page,
+ p,
}
buffer := new(bytes.Buffer)
@@ -91,11 +94,11 @@ func (a aliasHandler) renderAlias(isXHTML bool, permalink string, page *Page) (i
return buffer, nil
}
-func (s *Site) writeDestAlias(path, permalink string, outputFormat output.Format, p *Page) (err error) {
+func (s *Site) writeDestAlias(path, permalink string, outputFormat output.Format, p page.Page) (err error) {
return s.publishDestAlias(false, path, permalink, outputFormat, p)
}
-func (s *Site) publishDestAlias(allowRoot bool, path, permalink string, outputFormat output.Format, p *Page) (err error) {
+func (s *Site) publishDestAlias(allowRoot bool, path, permalink string, outputFormat output.Format, p page.Page) (err error) {
handler := newAliasHandler(s.Tmpl, s.Log, allowRoot)
isXHTML := strings.HasSuffix(path, ".xhtml")
@@ -126,19 +129,19 @@ func (s *Site) publishDestAlias(allowRoot bool, path, permalink string, outputFo
func (a aliasHandler) targetPathAlias(src string) (string, error) {
originalAlias := src
if len(src) <= 0 {
- return "", fmt.Errorf("Alias \"\" is an empty string")
+ return "", fmt.Errorf("alias \"\" is an empty string")
}
alias := filepath.Clean(src)
components := strings.Split(alias, helpers.FilePathSeparator)
if !a.allowRoot && alias == helpers.FilePathSeparator {
- return "", fmt.Errorf("Alias \"%s\" resolves to website root directory", originalAlias)
+ return "", fmt.Errorf("alias \"%s\" resolves to website root directory", originalAlias)
}
// Validate against directory traversal
if components[0] == ".." {
- return "", fmt.Errorf("Alias \"%s\" traverses outside the website root directory", originalAlias)
+ return "", fmt.Errorf("alias \"%s\" traverses outside the website root directory", originalAlias)
}
// Handle Windows file and directory naming restrictions
@@ -171,7 +174,7 @@ func (a aliasHandler) targetPathAlias(src string) (string, error) {
for _, m := range msgs {
a.log.ERROR.Println(m)
}
- return "", fmt.Errorf("Cannot create \"%s\": Windows filename restriction", originalAlias)
+ return "", fmt.Errorf("cannot create \"%s\": Windows filename restriction", originalAlias)
}
for _, m := range msgs {
a.log.INFO.Println(m)
diff --git a/hugolib/alias_test.go b/hugolib/alias_test.go
index da1b80b70..684e35c9a 100644
--- a/hugolib/alias_test.go
+++ b/hugolib/alias_test.go
@@ -1,4 +1,4 @@
-// Copyright 2018 The Hugo Authors. All rights reserved.
+// Copyright 2019 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -50,7 +50,7 @@ func TestAlias(t *testing.T) {
b.CreateSites().Build(BuildCfg{})
assert.Equal(1, len(b.H.Sites))
- require.Len(t, b.H.Sites[0].RegularPages, 1)
+ require.Len(t, b.H.Sites[0].RegularPages(), 1)
// the real page
b.AssertFileContent("public/page/index.html", "For some moments the old man")
diff --git a/hugolib/author.go b/hugolib/author.go
deleted file mode 100644
index 0f4327097..000000000
--- a/hugolib/author.go
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2015 The Hugo Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package hugolib
-
-// AuthorList is a list of all authors and their metadata.
-type AuthorList map[string]Author
-
-// Author contains details about the author of a page.
-type Author struct {
- GivenName string
- FamilyName string
- DisplayName string
- Thumbnail string
- Image string
- ShortBio string
- LongBio string
- Email string
- Social AuthorSocial
-}