2019-01-02 06:33:26 -05:00
|
|
|
// Copyright 2019 The Hugo Authors. All rights reserved.
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
//
|
|
|
|
// 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
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2019-01-02 06:33:26 -05:00
|
|
|
"path"
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
"runtime"
|
2019-01-02 06:33:26 -05:00
|
|
|
"strings"
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
"testing"
|
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
"github.com/gohugoio/hugo/common/loggers"
|
|
|
|
"github.com/gohugoio/hugo/resources/page"
|
|
|
|
|
2018-03-21 12:21:46 -04:00
|
|
|
"github.com/gohugoio/hugo/helpers"
|
|
|
|
|
2018-01-01 05:07:23 -05:00
|
|
|
"io"
|
|
|
|
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
"github.com/spf13/afero"
|
|
|
|
|
|
|
|
"github.com/gohugoio/hugo/media"
|
|
|
|
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/gohugoio/hugo/deps"
|
|
|
|
"github.com/gohugoio/hugo/hugofs"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
2018-03-21 12:21:46 -04:00
|
|
|
func TestPageBundlerSiteRegular(t *testing.T) {
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
t.Parallel()
|
|
|
|
|
2018-11-15 01:21:14 -05:00
|
|
|
baseBaseURL := "https://example.com"
|
|
|
|
|
|
|
|
for _, baseURLPath := range []string{"", "/hugo"} {
|
2018-11-15 07:35:28 -05:00
|
|
|
for _, canonify := range []bool{false, true} {
|
|
|
|
for _, ugly := range []bool{false, true} {
|
2019-01-02 06:33:26 -05:00
|
|
|
baseURLPathId := baseURLPath
|
|
|
|
if baseURLPathId == "" {
|
|
|
|
baseURLPathId = "NONE"
|
|
|
|
}
|
|
|
|
t.Run(fmt.Sprintf("ugly=%t,canonify=%t,path=%s", ugly, canonify, baseURLPathId),
|
2018-11-15 07:35:28 -05:00
|
|
|
func(t *testing.T) {
|
|
|
|
baseURL := baseBaseURL + baseURLPath
|
|
|
|
relURLBase := baseURLPath
|
|
|
|
if canonify {
|
|
|
|
relURLBase = ""
|
|
|
|
}
|
|
|
|
assert := require.New(t)
|
|
|
|
fs, cfg := newTestBundleSources(t)
|
|
|
|
cfg.Set("baseURL", baseURL)
|
|
|
|
cfg.Set("canonifyURLs", canonify)
|
|
|
|
assert.NoError(loadDefaultSettingsFor(cfg))
|
|
|
|
assert.NoError(loadLanguageSettings(cfg, nil))
|
|
|
|
|
|
|
|
cfg.Set("permalinks", map[string]string{
|
|
|
|
"a": ":sections/:filename",
|
|
|
|
"b": ":year/:slug/",
|
|
|
|
"c": ":sections/:slug",
|
|
|
|
"": ":filename/",
|
|
|
|
})
|
|
|
|
|
|
|
|
cfg.Set("outputFormats", map[string]interface{}{
|
|
|
|
"CUSTOMO": map[string]interface{}{
|
2019-01-02 06:33:26 -05:00
|
|
|
"mediaType": media.HTMLType,
|
|
|
|
"baseName": "cindex",
|
|
|
|
"path": "cpath",
|
|
|
|
"permalinkable": true,
|
2018-11-15 07:35:28 -05:00
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
cfg.Set("outputs", map[string]interface{}{
|
|
|
|
"home": []string{"HTML", "CUSTOMO"},
|
|
|
|
"page": []string{"HTML", "CUSTOMO"},
|
|
|
|
"section": []string{"HTML", "CUSTOMO"},
|
|
|
|
})
|
|
|
|
|
|
|
|
cfg.Set("uglyURLs", ugly)
|
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
s := buildSingleSite(t, deps.DepsCfg{Logger: loggers.NewErrorLogger(), Fs: fs, Cfg: cfg}, BuildCfg{})
|
2018-11-15 07:35:28 -05:00
|
|
|
|
|
|
|
th := testHelper{s.Cfg, s.Fs, t}
|
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
assert.Len(s.RegularPages(), 8)
|
2018-11-15 07:35:28 -05:00
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
singlePage := s.getPage(page.KindPage, "a/1.md")
|
2018-11-15 07:35:28 -05:00
|
|
|
assert.Equal("", singlePage.BundleType())
|
|
|
|
|
|
|
|
assert.NotNil(singlePage)
|
|
|
|
assert.Equal(singlePage, s.getPage("page", "a/1"))
|
|
|
|
assert.Equal(singlePage, s.getPage("page", "1"))
|
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
assert.Contains(content(singlePage), "TheContent")
|
2018-11-15 07:35:28 -05:00
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
relFilename := func(basePath, outBase string) (string, string) {
|
|
|
|
rel := basePath
|
|
|
|
if ugly {
|
|
|
|
rel = strings.TrimSuffix(basePath, "/") + ".html"
|
|
|
|
}
|
2018-11-15 07:35:28 -05:00
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
var filename string
|
|
|
|
if !ugly {
|
|
|
|
filename = path.Join(basePath, outBase)
|
|
|
|
} else {
|
|
|
|
filename = rel
|
|
|
|
}
|
|
|
|
|
|
|
|
rel = fmt.Sprintf("%s%s", relURLBase, rel)
|
|
|
|
|
|
|
|
return rel, filename
|
2018-11-15 07:35:28 -05:00
|
|
|
}
|
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
// Check both output formats
|
|
|
|
rel, filename := relFilename("/a/1/", "index.html")
|
|
|
|
th.assertFileContent(filepath.Join("/work/public", filename),
|
|
|
|
"TheContent",
|
|
|
|
"Single RelPermalink: "+rel,
|
|
|
|
)
|
|
|
|
|
|
|
|
rel, filename = relFilename("/cpath/a/1/", "cindex.html")
|
|
|
|
|
|
|
|
th.assertFileContent(filepath.Join("/work/public", filename),
|
|
|
|
"TheContent",
|
|
|
|
"Single RelPermalink: "+rel,
|
|
|
|
)
|
|
|
|
|
2018-11-15 07:35:28 -05:00
|
|
|
th.assertFileContent(filepath.FromSlash("/work/public/images/hugo-logo.png"), "content")
|
|
|
|
|
|
|
|
// This should be just copied to destination.
|
|
|
|
th.assertFileContent(filepath.FromSlash("/work/public/assets/pic1.png"), "content")
|
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
leafBundle1 := s.getPage(page.KindPage, "b/my-bundle/index.md")
|
2018-11-15 07:35:28 -05:00
|
|
|
assert.NotNil(leafBundle1)
|
|
|
|
assert.Equal("leaf", leafBundle1.BundleType())
|
|
|
|
assert.Equal("b", leafBundle1.Section())
|
2019-01-02 06:33:26 -05:00
|
|
|
sectionB := s.getPage(page.KindSection, "b")
|
2018-11-15 07:35:28 -05:00
|
|
|
assert.NotNil(sectionB)
|
|
|
|
home, _ := s.Info.Home()
|
|
|
|
assert.Equal("branch", home.BundleType())
|
|
|
|
|
|
|
|
// This is a root bundle and should live in the "home section"
|
|
|
|
// See https://github.com/gohugoio/hugo/issues/4332
|
2019-01-02 06:33:26 -05:00
|
|
|
rootBundle := s.getPage(page.KindPage, "root")
|
2018-11-15 07:35:28 -05:00
|
|
|
assert.NotNil(rootBundle)
|
|
|
|
assert.True(rootBundle.Parent().IsHome())
|
2019-01-02 06:33:26 -05:00
|
|
|
if !ugly {
|
|
|
|
th.assertFileContent(filepath.FromSlash("/work/public/root/index.html"), "Single RelPermalink: "+relURLBase+"/root/")
|
|
|
|
th.assertFileContent(filepath.FromSlash("/work/public/cpath/root/cindex.html"), "Single RelPermalink: "+relURLBase+"/cpath/root/")
|
2018-11-15 07:35:28 -05:00
|
|
|
}
|
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
leafBundle2 := s.getPage(page.KindPage, "a/b/index.md")
|
2018-11-15 07:35:28 -05:00
|
|
|
assert.NotNil(leafBundle2)
|
2019-01-02 06:33:26 -05:00
|
|
|
unicodeBundle := s.getPage(page.KindPage, "c/bundle/index.md")
|
2018-11-15 07:35:28 -05:00
|
|
|
assert.NotNil(unicodeBundle)
|
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
pageResources := leafBundle1.Resources().ByType(pageResourceType)
|
2018-11-15 07:35:28 -05:00
|
|
|
assert.Len(pageResources, 2)
|
2019-01-02 06:33:26 -05:00
|
|
|
firstPage := pageResources[0].(page.Page)
|
|
|
|
secondPage := pageResources[1].(page.Page)
|
|
|
|
assert.Equal(filepath.FromSlash("/work/base/b/my-bundle/1.md"), firstPage.File().Filename(), secondPage.File().Filename())
|
|
|
|
assert.Contains(content(firstPage), "TheContent")
|
|
|
|
assert.Equal(6, len(leafBundle1.Resources()))
|
2018-11-15 07:35:28 -05:00
|
|
|
|
|
|
|
// Verify shortcode in bundled page
|
2019-01-02 06:33:26 -05:00
|
|
|
assert.Contains(content(secondPage), filepath.FromSlash("MyShort in b/my-bundle/2.md"))
|
2018-11-15 07:35:28 -05:00
|
|
|
|
|
|
|
// https://github.com/gohugoio/hugo/issues/4582
|
|
|
|
assert.Equal(leafBundle1, firstPage.Parent())
|
|
|
|
assert.Equal(leafBundle1, secondPage.Parent())
|
|
|
|
|
|
|
|
assert.Equal(firstPage, pageResources.GetMatch("1*"))
|
|
|
|
assert.Equal(secondPage, pageResources.GetMatch("2*"))
|
|
|
|
assert.Nil(pageResources.GetMatch("doesnotexist*"))
|
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
imageResources := leafBundle1.Resources().ByType("image")
|
2018-11-15 07:35:28 -05:00
|
|
|
assert.Equal(3, len(imageResources))
|
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
assert.NotNil(leafBundle1.OutputFormats().Get("CUSTOMO"))
|
2018-11-15 07:35:28 -05:00
|
|
|
|
|
|
|
relPermalinker := func(s string) string {
|
|
|
|
return fmt.Sprintf(s, relURLBase)
|
|
|
|
}
|
|
|
|
|
|
|
|
permalinker := func(s string) string {
|
|
|
|
return fmt.Sprintf(s, baseURL)
|
|
|
|
}
|
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
if ugly {
|
|
|
|
th.assertFileContent("/work/public/2017/pageslug.html",
|
|
|
|
relPermalinker("Single RelPermalink: %s/2017/pageslug.html"),
|
|
|
|
permalinker("Single Permalink: %s/2017/pageslug.html"),
|
|
|
|
relPermalinker("Sunset RelPermalink: %s/2017/pageslug/sunset1.jpg"),
|
|
|
|
permalinker("Sunset Permalink: %s/2017/pageslug/sunset1.jpg"))
|
|
|
|
} else {
|
|
|
|
th.assertFileContent("/work/public/2017/pageslug/index.html",
|
|
|
|
relPermalinker("Sunset RelPermalink: %s/2017/pageslug/sunset1.jpg"),
|
|
|
|
permalinker("Sunset Permalink: %s/2017/pageslug/sunset1.jpg"))
|
|
|
|
|
|
|
|
th.assertFileContent("/work/public/cpath/2017/pageslug/cindex.html",
|
|
|
|
relPermalinker("Single RelPermalink: %s/cpath/2017/pageslug/"),
|
|
|
|
relPermalinker("Short Sunset RelPermalink: %s/cpath/2017/pageslug/sunset2.jpg"),
|
|
|
|
relPermalinker("Sunset RelPermalink: %s/cpath/2017/pageslug/sunset1.jpg"),
|
|
|
|
permalinker("Sunset Permalink: %s/cpath/2017/pageslug/sunset1.jpg"),
|
|
|
|
)
|
2018-11-15 07:35:28 -05:00
|
|
|
}
|
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
th.assertFileContent(filepath.FromSlash("/work/public/2017/pageslug/c/logo.png"), "content")
|
|
|
|
th.assertFileContent(filepath.FromSlash("/work/public/cpath/2017/pageslug/c/logo.png"), "content")
|
|
|
|
th.assertFileNotExist("/work/public/cpath/cpath/2017/pageslug/c/logo.png")
|
|
|
|
|
|
|
|
// Custom media type defined in site config.
|
|
|
|
assert.Len(leafBundle1.Resources().ByType("bepsays"), 1)
|
|
|
|
|
2018-11-15 07:35:28 -05:00
|
|
|
if ugly {
|
|
|
|
th.assertFileContent(filepath.FromSlash("/work/public/2017/pageslug.html"),
|
|
|
|
"TheContent",
|
|
|
|
relPermalinker("Sunset RelPermalink: %s/2017/pageslug/sunset1.jpg"),
|
|
|
|
permalinker("Sunset Permalink: %s/2017/pageslug/sunset1.jpg"),
|
|
|
|
"Thumb Width: 123",
|
|
|
|
"Thumb Name: my-sunset-1",
|
|
|
|
relPermalinker("Short Sunset RelPermalink: %s/2017/pageslug/sunset2.jpg"),
|
|
|
|
"Short Thumb Width: 56",
|
|
|
|
"1: Image Title: Sunset Galore 1",
|
|
|
|
"1: Image Params: map[myparam:My Sunny Param]",
|
2019-04-22 03:13:47 -04:00
|
|
|
relPermalinker("1: Image RelPermalink: %s/2017/pageslug/sunset1.jpg"),
|
2018-11-15 07:35:28 -05:00
|
|
|
"2: Image Title: Sunset Galore 2",
|
|
|
|
"2: Image Params: map[myparam:My Sunny Param]",
|
|
|
|
"1: Image myParam: Lower: My Sunny Param Caps: My Sunny Param",
|
2019-04-22 03:13:47 -04:00
|
|
|
"0: Page Title: Bundle Galore",
|
2018-11-15 07:35:28 -05:00
|
|
|
)
|
2019-04-22 03:13:47 -04:00
|
|
|
|
|
|
|
// https://github.com/gohugoio/hugo/issues/5882
|
|
|
|
th.assertFileContent(
|
|
|
|
filepath.FromSlash("/work/public/2017/pageslug.html"), "0: Page RelPermalink: |")
|
|
|
|
|
2018-11-15 07:35:28 -05:00
|
|
|
th.assertFileContent(filepath.FromSlash("/work/public/cpath/2017/pageslug.html"), "TheContent")
|
|
|
|
|
|
|
|
// 은행
|
|
|
|
th.assertFileContent(filepath.FromSlash("/work/public/c/은행/logo-은행.png"), "은행 PNG")
|
|
|
|
|
|
|
|
} else {
|
|
|
|
th.assertFileContent(filepath.FromSlash("/work/public/2017/pageslug/index.html"), "TheContent")
|
|
|
|
th.assertFileContent(filepath.FromSlash("/work/public/cpath/2017/pageslug/cindex.html"), "TheContent")
|
|
|
|
th.assertFileContent(filepath.FromSlash("/work/public/2017/pageslug/index.html"), "Single Title")
|
|
|
|
th.assertFileContent(filepath.FromSlash("/work/public/root/index.html"), "Single Title")
|
|
|
|
|
|
|
|
}
|
2018-11-15 01:21:14 -05:00
|
|
|
|
|
|
|
})
|
2018-11-15 07:35:28 -05:00
|
|
|
}
|
2018-11-15 01:21:14 -05:00
|
|
|
}
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-01-20 11:11:03 -05:00
|
|
|
func TestPageBundlerSiteMultilingual(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
for _, ugly := range []bool{false, true} {
|
|
|
|
t.Run(fmt.Sprintf("ugly=%t", ugly),
|
|
|
|
func(t *testing.T) {
|
|
|
|
|
|
|
|
assert := require.New(t)
|
2018-03-21 12:21:46 -04:00
|
|
|
fs, cfg := newTestBundleSourcesMultilingual(t)
|
2018-01-20 11:11:03 -05:00
|
|
|
cfg.Set("uglyURLs", ugly)
|
|
|
|
|
|
|
|
assert.NoError(loadDefaultSettingsFor(cfg))
|
2018-03-18 06:07:24 -04:00
|
|
|
assert.NoError(loadLanguageSettings(cfg, nil))
|
2018-01-20 11:11:03 -05:00
|
|
|
sites, err := NewHugoSites(deps.DepsCfg{Fs: fs, Cfg: cfg})
|
|
|
|
assert.NoError(err)
|
|
|
|
assert.Equal(2, len(sites.Sites))
|
|
|
|
|
|
|
|
assert.NoError(sites.Build(BuildCfg{}))
|
|
|
|
|
|
|
|
s := sites.Sites[0]
|
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
assert.Equal(8, len(s.RegularPages()))
|
|
|
|
assert.Equal(16, len(s.Pages()))
|
|
|
|
assert.Equal(31, len(s.AllPages()))
|
2018-01-25 11:03:29 -05:00
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
bundleWithSubPath := s.getPage(page.KindPage, "lb/index")
|
2018-01-20 11:11:03 -05:00
|
|
|
assert.NotNil(bundleWithSubPath)
|
|
|
|
|
2018-01-24 03:47:30 -05:00
|
|
|
// See https://github.com/gohugoio/hugo/issues/4312
|
|
|
|
// Before that issue:
|
|
|
|
// A bundle in a/b/index.en.md
|
|
|
|
// a/b/index.en.md => OK
|
|
|
|
// a/b/index => OK
|
|
|
|
// index.en.md => ambigous, but OK.
|
|
|
|
// With bundles, the file name has little meaning, the folder it lives in does. So this should also work:
|
|
|
|
// a/b
|
|
|
|
// and probably also just b (aka "my-bundle")
|
|
|
|
// These may also be translated, so we also need to test that.
|
|
|
|
// "bf", "my-bf-bundle", "index.md + nn
|
2019-01-02 06:33:26 -05:00
|
|
|
bfBundle := s.getPage(page.KindPage, "bf/my-bf-bundle/index")
|
2018-01-24 03:47:30 -05:00
|
|
|
assert.NotNil(bfBundle)
|
2019-01-02 06:33:26 -05:00
|
|
|
assert.Equal("en", bfBundle.Language().Lang)
|
|
|
|
assert.Equal(bfBundle, s.getPage(page.KindPage, "bf/my-bf-bundle/index.md"))
|
|
|
|
assert.Equal(bfBundle, s.getPage(page.KindPage, "bf/my-bf-bundle"))
|
|
|
|
assert.Equal(bfBundle, s.getPage(page.KindPage, "my-bf-bundle"))
|
2018-01-24 03:47:30 -05:00
|
|
|
|
|
|
|
nnSite := sites.Sites[1]
|
2019-01-02 06:33:26 -05:00
|
|
|
assert.Equal(7, len(nnSite.RegularPages()))
|
2018-01-25 11:03:29 -05:00
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
bfBundleNN := nnSite.getPage(page.KindPage, "bf/my-bf-bundle/index")
|
2018-01-24 03:47:30 -05:00
|
|
|
assert.NotNil(bfBundleNN)
|
2019-01-02 06:33:26 -05:00
|
|
|
assert.Equal("nn", bfBundleNN.Language().Lang)
|
|
|
|
assert.Equal(bfBundleNN, nnSite.getPage(page.KindPage, "bf/my-bf-bundle/index.nn.md"))
|
|
|
|
assert.Equal(bfBundleNN, nnSite.getPage(page.KindPage, "bf/my-bf-bundle"))
|
|
|
|
assert.Equal(bfBundleNN, nnSite.getPage(page.KindPage, "my-bf-bundle"))
|
2018-01-24 03:47:30 -05:00
|
|
|
|
2018-01-20 11:11:03 -05:00
|
|
|
// See https://github.com/gohugoio/hugo/issues/4295
|
|
|
|
// Every resource should have its Name prefixed with its base folder.
|
2019-01-02 06:33:26 -05:00
|
|
|
cBundleResources := bundleWithSubPath.Resources().Match("c/**")
|
2018-01-20 11:11:03 -05:00
|
|
|
assert.Equal(4, len(cBundleResources))
|
2019-01-02 06:33:26 -05:00
|
|
|
bundlePage := bundleWithSubPath.Resources().GetMatch("c/page*")
|
2018-01-20 11:11:03 -05:00
|
|
|
assert.NotNil(bundlePage)
|
2019-01-02 06:33:26 -05:00
|
|
|
assert.IsType(&pageState{}, bundlePage)
|
2018-01-20 11:11:03 -05:00
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-25 11:03:29 -05:00
|
|
|
func TestMultilingualDisableDefaultLanguage(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
assert := require.New(t)
|
2018-03-21 12:21:46 -04:00
|
|
|
_, cfg := newTestBundleSourcesMultilingual(t)
|
2018-01-25 11:03:29 -05:00
|
|
|
|
|
|
|
cfg.Set("disableLanguages", []string{"en"})
|
|
|
|
|
|
|
|
err := loadDefaultSettingsFor(cfg)
|
2018-03-18 06:07:24 -04:00
|
|
|
assert.NoError(err)
|
|
|
|
err = loadLanguageSettings(cfg, nil)
|
2018-01-25 11:03:29 -05:00
|
|
|
assert.Error(err)
|
|
|
|
assert.Contains(err.Error(), "cannot disable default language")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMultilingualDisableLanguage(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
assert := require.New(t)
|
2018-03-21 12:21:46 -04:00
|
|
|
fs, cfg := newTestBundleSourcesMultilingual(t)
|
2018-01-25 11:03:29 -05:00
|
|
|
cfg.Set("disableLanguages", []string{"nn"})
|
|
|
|
|
|
|
|
assert.NoError(loadDefaultSettingsFor(cfg))
|
2018-03-21 12:21:46 -04:00
|
|
|
assert.NoError(loadLanguageSettings(cfg, nil))
|
|
|
|
|
2018-01-25 11:03:29 -05:00
|
|
|
sites, err := NewHugoSites(deps.DepsCfg{Fs: fs, Cfg: cfg})
|
|
|
|
assert.NoError(err)
|
|
|
|
assert.Equal(1, len(sites.Sites))
|
|
|
|
|
|
|
|
assert.NoError(sites.Build(BuildCfg{}))
|
|
|
|
|
|
|
|
s := sites.Sites[0]
|
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
assert.Equal(8, len(s.RegularPages()))
|
|
|
|
assert.Equal(16, len(s.Pages()))
|
2018-01-25 11:03:29 -05:00
|
|
|
// No nn pages
|
2019-01-02 06:33:26 -05:00
|
|
|
assert.Equal(16, len(s.AllPages()))
|
2018-01-25 11:03:29 -05:00
|
|
|
for _, p := range s.rawAllPages {
|
2019-01-02 06:33:26 -05:00
|
|
|
assert.True(p.Language().Lang != "nn")
|
2018-01-25 11:03:29 -05:00
|
|
|
}
|
2019-01-02 06:33:26 -05:00
|
|
|
for _, p := range s.AllPages() {
|
|
|
|
assert.True(p.Language().Lang != "nn")
|
2018-01-25 11:03:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
func TestPageBundlerSiteWitSymbolicLinksInContent(t *testing.T) {
|
2018-03-23 01:11:35 -04:00
|
|
|
if runtime.GOOS == "windows" && os.Getenv("CI") == "" {
|
|
|
|
t.Skip("Skip TestPageBundlerSiteWitSymbolicLinksInContent as os.Symlink needs administrator rights on Windows")
|
|
|
|
}
|
|
|
|
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
assert := require.New(t)
|
2018-07-20 09:02:35 -04:00
|
|
|
ps, clean, workDir := newTestBundleSymbolicSources(t)
|
|
|
|
defer clean()
|
|
|
|
|
2018-03-21 12:21:46 -04:00
|
|
|
cfg := ps.Cfg
|
|
|
|
fs := ps.Fs
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
|
Add support for theme composition and inheritance
This commit adds support for theme composition and inheritance in Hugo.
With this, it helps thinking about a theme as a set of ordered components:
```toml
theme = ["my-shortcodes", "base-theme", "hyde"]
```
The theme definition example above in `config.toml` creates a theme with the 3 components with presedence from left to right.
So, Hugo will, for any given file, data entry etc., look first in the project, and then in `my-shortcode`, `base-theme` and lastly `hyde`.
Hugo uses two different algorithms to merge the filesystems, depending on the file type:
* For `i18n` and `data` files, Hugo merges deeply using the translation id and data key inside the files.
* For `static`, `layouts` (templates) and `archetypes` files, these are merged on file level. So the left-most file will be chosen.
The name used in the `theme` definition above must match a folder in `/your-site/themes`, e.g. `/your-site/themes/my-shortcodes`. There are plans to improve on this and get a URL scheme so this can be resolved automatically.
Also note that a component that is part of a theme can have its own configuration file, e.g. `config.toml`. There are currently some restrictions to what a theme component can configure:
* `params` (global and per language)
* `menu` (global and per language)
* `outputformats` and `mediatypes`
The same rules apply here: The left-most param/menu etc. with the same ID will win. There are some hidden and experimental namespace support in the above, which we will work to improve in the future, but theme authors are encouraged to create their own namespaces to avoid naming conflicts.
A final note: Themes/components can also have a `theme` definition in their `config.toml` and similar, which is the "inheritance" part of this commit's title. This is currently not supported by the Hugo theme site. We will have to wait for some "auto dependency" feature to be implemented for that to happen, but this can be a powerful feature if you want to create your own theme-variant based on others.
Fixes #4460
Fixes #4450
2018-03-01 09:01:25 -05:00
|
|
|
s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg, Logger: loggers.NewErrorLogger()}, BuildCfg{})
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
|
|
|
|
th := testHelper{s.Cfg, s.Fs, t}
|
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
assert.Equal(7, len(s.RegularPages()))
|
|
|
|
a1Bundle := s.getPage(page.KindPage, "symbolic2/a1/index.md")
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
assert.NotNil(a1Bundle)
|
2019-01-02 06:33:26 -05:00
|
|
|
assert.Equal(2, len(a1Bundle.Resources()))
|
|
|
|
assert.Equal(1, len(a1Bundle.Resources().ByType(pageResourceType)))
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
|
|
|
|
th.assertFileContent(filepath.FromSlash(workDir+"/public/a/page/index.html"), "TheContent")
|
|
|
|
th.assertFileContent(filepath.FromSlash(workDir+"/public/symbolic1/s1/index.html"), "TheContent")
|
|
|
|
th.assertFileContent(filepath.FromSlash(workDir+"/public/symbolic2/a1/index.html"), "TheContent")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-01-23 08:02:54 -05:00
|
|
|
func TestPageBundlerHeadless(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
cfg, fs := newTestCfg()
|
|
|
|
assert := require.New(t)
|
|
|
|
|
|
|
|
workDir := "/work"
|
|
|
|
cfg.Set("workingDir", workDir)
|
|
|
|
cfg.Set("contentDir", "base")
|
|
|
|
cfg.Set("baseURL", "https://example.com")
|
|
|
|
|
|
|
|
pageContent := `---
|
|
|
|
title: "Bundle Galore"
|
|
|
|
slug: s1
|
|
|
|
date: 2017-01-23
|
|
|
|
---
|
|
|
|
|
|
|
|
TheContent.
|
|
|
|
|
|
|
|
{{< myShort >}}
|
|
|
|
`
|
|
|
|
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "layouts", "_default", "single.html"), "single {{ .Content }}")
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "layouts", "_default", "list.html"), "list")
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "layouts", "shortcodes", "myShort.html"), "SHORTCODE")
|
|
|
|
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "a", "index.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "a", "l1.png"), "PNG image")
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "a", "l2.png"), "PNG image")
|
|
|
|
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "b", "index.md"), `---
|
|
|
|
title: "Headless Bundle in Topless Bar"
|
|
|
|
slug: s2
|
|
|
|
headless: true
|
|
|
|
date: 2017-01-23
|
|
|
|
---
|
|
|
|
|
|
|
|
TheContent.
|
|
|
|
HEADLESS {{< myShort >}}
|
|
|
|
`)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "b", "l1.png"), "PNG image")
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "b", "l2.png"), "PNG image")
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "b", "p1.md"), pageContent)
|
|
|
|
|
|
|
|
s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{})
|
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
assert.Equal(1, len(s.RegularPages()))
|
2018-01-23 08:02:54 -05:00
|
|
|
assert.Equal(1, len(s.headlessPages))
|
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
regular := s.getPage(page.KindPage, "a/index")
|
2018-01-23 08:02:54 -05:00
|
|
|
assert.Equal("/a/s1/", regular.RelPermalink())
|
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
headless := s.getPage(page.KindPage, "b/index")
|
2018-01-23 08:02:54 -05:00
|
|
|
assert.NotNil(headless)
|
|
|
|
assert.Equal("Headless Bundle in Topless Bar", headless.Title())
|
|
|
|
assert.Equal("", headless.RelPermalink())
|
|
|
|
assert.Equal("", headless.Permalink())
|
2019-01-02 06:33:26 -05:00
|
|
|
assert.Contains(content(headless), "HEADLESS SHORTCODE")
|
2018-01-23 08:02:54 -05:00
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
headlessResources := headless.Resources()
|
2018-01-23 08:02:54 -05:00
|
|
|
assert.Equal(3, len(headlessResources))
|
|
|
|
assert.Equal(2, len(headlessResources.Match("l*")))
|
|
|
|
pageResource := headlessResources.GetMatch("p*")
|
|
|
|
assert.NotNil(pageResource)
|
2019-01-02 06:33:26 -05:00
|
|
|
assert.IsType(&pageState{}, pageResource)
|
|
|
|
p := pageResource.(page.Page)
|
|
|
|
assert.Contains(content(p), "SHORTCODE")
|
2018-01-23 08:02:54 -05:00
|
|
|
assert.Equal("p1.md", p.Name())
|
|
|
|
|
|
|
|
th := testHelper{s.Cfg, s.Fs, t}
|
|
|
|
|
|
|
|
th.assertFileContent(filepath.FromSlash(workDir+"/public/a/s1/index.html"), "TheContent")
|
|
|
|
th.assertFileContent(filepath.FromSlash(workDir+"/public/a/s1/l1.png"), "PNG")
|
|
|
|
|
|
|
|
th.assertFileNotExist(workDir + "/public/b/s2/index.html")
|
|
|
|
// But the bundled resources needs to be published
|
|
|
|
th.assertFileContent(filepath.FromSlash(workDir+"/public/b/s2/l1.png"), "PNG")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-01-02 06:33:26 -05:00
|
|
|
func TestMultiSiteBundles(t *testing.T) {
|
|
|
|
assert := require.New(t)
|
|
|
|
b := newTestSitesBuilder(t)
|
|
|
|
b.WithConfigFile("toml", `
|
|
|
|
|
|
|
|
baseURL = "http://example.com/"
|
|
|
|
|
|
|
|
defaultContentLanguage = "en"
|
|
|
|
|
|
|
|
[languages]
|
|
|
|
[languages.en]
|
|
|
|
weight = 10
|
|
|
|
contentDir = "content/en"
|
|
|
|
[languages.nn]
|
|
|
|
weight = 20
|
|
|
|
contentDir = "content/nn"
|
|
|
|
|
|
|
|
|
|
|
|
`)
|
|
|
|
|
|
|
|
b.WithContent("en/mybundle/index.md", `
|
|
|
|
---
|
|
|
|
headless: true
|
|
|
|
---
|
|
|
|
|
|
|
|
`)
|
|
|
|
|
|
|
|
b.WithContent("nn/mybundle/index.md", `
|
|
|
|
---
|
|
|
|
headless: true
|
|
|
|
---
|
|
|
|
|
|
|
|
`)
|
|
|
|
|
|
|
|
b.WithContent("en/mybundle/data.yaml", `data en`)
|
|
|
|
b.WithContent("en/mybundle/forms.yaml", `forms en`)
|
|
|
|
b.WithContent("nn/mybundle/data.yaml", `data nn`)
|
|
|
|
|
|
|
|
b.WithContent("en/_index.md", `
|
|
|
|
---
|
|
|
|
Title: Home
|
|
|
|
---
|
|
|
|
|
|
|
|
Home content.
|
|
|
|
|
|
|
|
`)
|
|
|
|
|
|
|
|
b.WithContent("en/section-not-bundle/_index.md", `
|
|
|
|
---
|
|
|
|
Title: Section Page
|
|
|
|
---
|
|
|
|
|
|
|
|
Section content.
|
|
|
|
|
|
|
|
`)
|
|
|
|
|
|
|
|
b.WithContent("en/section-not-bundle/single.md", `
|
|
|
|
---
|
|
|
|
Title: Section Single
|
|
|
|
Date: 2018-02-01
|
|
|
|
---
|
|
|
|
|
|
|
|
Single content.
|
|
|
|
|
|
|
|
`)
|
|
|
|
|
|
|
|
b.Build(BuildCfg{})
|
|
|
|
|
|
|
|
b.AssertFileContent("public/nn/mybundle/data.yaml", "data nn")
|
|
|
|
b.AssertFileContent("public/nn/mybundle/forms.yaml", "forms en")
|
|
|
|
b.AssertFileContent("public/mybundle/data.yaml", "data en")
|
|
|
|
b.AssertFileContent("public/mybundle/forms.yaml", "forms en")
|
|
|
|
|
|
|
|
assert.False(b.CheckExists("public/nn/nn/mybundle/data.yaml"))
|
|
|
|
assert.False(b.CheckExists("public/en/mybundle/data.yaml"))
|
|
|
|
|
|
|
|
homeEn := b.H.Sites[0].home
|
|
|
|
assert.NotNil(homeEn)
|
|
|
|
assert.Equal(2018, homeEn.Date().Year())
|
|
|
|
|
|
|
|
b.AssertFileContent("public/section-not-bundle/index.html", "Section Page", "Content: <p>Section content.</p>")
|
|
|
|
b.AssertFileContent("public/section-not-bundle/single/index.html", "Section Single", "|<p>Single content.</p>")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-03-21 12:21:46 -04:00
|
|
|
func newTestBundleSources(t *testing.T) (*hugofs.Fs, *viper.Viper) {
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
cfg, fs := newTestCfg()
|
2018-01-01 05:07:23 -05:00
|
|
|
assert := require.New(t)
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
|
|
|
|
workDir := "/work"
|
|
|
|
cfg.Set("workingDir", workDir)
|
|
|
|
cfg.Set("contentDir", "base")
|
|
|
|
cfg.Set("baseURL", "https://example.com")
|
|
|
|
cfg.Set("mediaTypes", map[string]interface{}{
|
|
|
|
"text/bepsays": map[string]interface{}{
|
2018-08-28 08:18:12 -04:00
|
|
|
"suffixes": []string{"bep"},
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
pageContent := `---
|
|
|
|
title: "Bundle Galore"
|
|
|
|
slug: pageslug
|
|
|
|
date: 2017-10-09
|
|
|
|
---
|
|
|
|
|
|
|
|
TheContent.
|
2018-04-19 12:06:40 -04:00
|
|
|
`
|
|
|
|
|
|
|
|
pageContentShortcode := `---
|
|
|
|
title: "Bundle Galore"
|
|
|
|
slug: pageslug
|
|
|
|
date: 2017-10-09
|
|
|
|
---
|
|
|
|
|
|
|
|
TheContent.
|
|
|
|
|
|
|
|
{{< myShort >}}
|
2018-01-01 05:07:23 -05:00
|
|
|
`
|
|
|
|
|
2018-01-15 14:40:39 -05:00
|
|
|
pageWithImageShortcodeAndResourceMetadataContent := `---
|
2018-01-01 05:07:23 -05:00
|
|
|
title: "Bundle Galore"
|
|
|
|
slug: pageslug
|
|
|
|
date: 2017-10-09
|
2018-01-15 14:40:39 -05:00
|
|
|
resources:
|
|
|
|
- src: "*.jpg"
|
|
|
|
name: "my-sunset-:counter"
|
|
|
|
title: "Sunset Galore :counter"
|
|
|
|
params:
|
|
|
|
myParam: "My Sunny Param"
|
2018-01-01 05:07:23 -05:00
|
|
|
---
|
|
|
|
|
|
|
|
TheContent.
|
|
|
|
|
|
|
|
{{< myShort >}}
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
`
|
|
|
|
|
|
|
|
pageContentNoSlug := `---
|
|
|
|
title: "Bundle Galore #2"
|
|
|
|
date: 2017-10-09
|
|
|
|
---
|
|
|
|
|
|
|
|
TheContent.
|
|
|
|
`
|
|
|
|
|
2018-01-01 05:07:23 -05:00
|
|
|
singleLayout := `
|
2018-01-27 12:03:06 -05:00
|
|
|
Single Title: {{ .Title }}
|
2019-01-02 06:33:26 -05:00
|
|
|
Single RelPermalink: {{ .RelPermalink }}
|
|
|
|
Single Permalink: {{ .Permalink }}
|
2018-01-01 05:07:23 -05:00
|
|
|
Content: {{ .Content }}
|
2018-06-12 23:27:47 -04:00
|
|
|
{{ $sunset := .Resources.GetMatch "my-sunset-1*" }}
|
2018-01-01 05:07:23 -05:00
|
|
|
{{ with $sunset }}
|
|
|
|
Sunset RelPermalink: {{ .RelPermalink }}
|
2018-11-15 01:21:14 -05:00
|
|
|
Sunset Permalink: {{ .Permalink }}
|
2018-01-01 05:07:23 -05:00
|
|
|
{{ $thumb := .Fill "123x123" }}
|
|
|
|
Thumb Width: {{ $thumb.Width }}
|
2018-01-15 14:40:39 -05:00
|
|
|
Thumb Name: {{ $thumb.Name }}
|
|
|
|
Thumb Title: {{ $thumb.Title }}
|
|
|
|
Thumb RelPermalink: {{ $thumb.RelPermalink }}
|
|
|
|
{{ end }}
|
2019-04-22 03:13:47 -04:00
|
|
|
{{ $types := slice "image" "page" }}
|
|
|
|
{{ range $types }}
|
|
|
|
{{ $typeTitle := . | title }}
|
|
|
|
{{ range $i, $e := $.Resources.ByType . }}
|
|
|
|
{{ $i }}: {{ $typeTitle }} Title: {{ .Title }}
|
|
|
|
{{ $i }}: {{ $typeTitle }} Name: {{ .Name }}
|
|
|
|
{{ $i }}: {{ $typeTitle }} RelPermalink: {{ .RelPermalink }}|
|
|
|
|
{{ $i }}: {{ $typeTitle }} Params: {{ printf "%v" .Params }}
|
|
|
|
{{ $i }}: {{ $typeTitle }} myParam: Lower: {{ .Params.myparam }} Caps: {{ .Params.MYPARAM }}
|
|
|
|
{{ end }}
|
2018-01-01 05:07:23 -05:00
|
|
|
{{ end }}
|
|
|
|
`
|
|
|
|
|
|
|
|
myShort := `
|
2019-01-02 06:33:26 -05:00
|
|
|
MyShort in {{ .Page.File.Path }}:
|
2018-06-12 23:27:47 -04:00
|
|
|
{{ $sunset := .Page.Resources.GetMatch "my-sunset-2*" }}
|
2018-01-01 05:07:23 -05:00
|
|
|
{{ with $sunset }}
|
|
|
|
Short Sunset RelPermalink: {{ .RelPermalink }}
|
|
|
|
{{ $thumb := .Fill "56x56" }}
|
|
|
|
Short Thumb Width: {{ $thumb.Width }}
|
|
|
|
{{ end }}
|
|
|
|
`
|
|
|
|
|
|
|
|
listLayout := `{{ .Title }}|{{ .Content }}`
|
|
|
|
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "layouts", "_default", "single.html"), singleLayout)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "layouts", "_default", "list.html"), listLayout)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "layouts", "shortcodes", "myShort.html"), myShort)
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "_index.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "_1.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "_1.png"), pageContent)
|
|
|
|
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "images", "hugo-logo.png"), "content")
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "a", "2.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "a", "1.md"), pageContent)
|
|
|
|
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "a", "b", "index.md"), pageContentNoSlug)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "a", "b", "ab1.md"), pageContentNoSlug)
|
|
|
|
|
|
|
|
// Mostly plain static assets in a folder with a page in a sub folder thrown in.
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "assets", "pic1.png"), "content")
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "assets", "pic2.png"), "content")
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "assets", "pages", "mypage.md"), pageContent)
|
|
|
|
|
|
|
|
// Bundle
|
2018-01-27 12:03:06 -05:00
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "b", "my-bundle", "index.md"), pageWithImageShortcodeAndResourceMetadataContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "b", "my-bundle", "1.md"), pageContent)
|
2018-04-19 12:06:40 -04:00
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "b", "my-bundle", "2.md"), pageContentShortcode)
|
2018-01-27 12:03:06 -05:00
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "b", "my-bundle", "custom-mime.bep"), "bepsays")
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "b", "my-bundle", "c", "logo.png"), "content")
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
|
2018-01-10 04:20:08 -05:00
|
|
|
// Bundle with 은행 slug
|
|
|
|
// See https://github.com/gohugoio/hugo/issues/4241
|
2018-01-27 12:03:06 -05:00
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "c", "bundle", "index.md"), `---
|
2018-01-10 04:20:08 -05:00
|
|
|
title: "은행 은행"
|
|
|
|
slug: 은행
|
|
|
|
date: 2017-10-09
|
|
|
|
---
|
|
|
|
|
|
|
|
Content for 은행.
|
|
|
|
`)
|
2018-01-27 12:03:06 -05:00
|
|
|
|
|
|
|
// Bundle in root
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "root", "index.md"), pageWithImageShortcodeAndResourceMetadataContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "root", "1.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "root", "c", "logo.png"), "content")
|
|
|
|
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "c", "bundle", "logo-은행.png"), "은행 PNG")
|
2018-01-10 04:20:08 -05:00
|
|
|
|
2018-01-01 05:07:23 -05:00
|
|
|
// Write a real image into one of the bundle above.
|
|
|
|
src, err := os.Open("testdata/sunset.jpg")
|
|
|
|
assert.NoError(err)
|
|
|
|
|
|
|
|
// We need 2 to test https://github.com/gohugoio/hugo/issues/4202
|
2018-01-27 12:03:06 -05:00
|
|
|
out, err := fs.Source.Create(filepath.Join(workDir, "base", "b", "my-bundle", "sunset1.jpg"))
|
2018-01-01 05:07:23 -05:00
|
|
|
assert.NoError(err)
|
2018-01-27 12:03:06 -05:00
|
|
|
out2, err := fs.Source.Create(filepath.Join(workDir, "base", "b", "my-bundle", "sunset2.jpg"))
|
2018-01-01 05:07:23 -05:00
|
|
|
assert.NoError(err)
|
|
|
|
|
|
|
|
_, err = io.Copy(out, src)
|
2019-01-02 06:33:26 -05:00
|
|
|
assert.NoError(err)
|
2018-01-01 05:07:23 -05:00
|
|
|
out.Close()
|
|
|
|
src.Seek(0, 0)
|
|
|
|
_, err = io.Copy(out2, src)
|
|
|
|
out2.Close()
|
|
|
|
src.Close()
|
|
|
|
assert.NoError(err)
|
|
|
|
|
2018-03-21 12:21:46 -04:00
|
|
|
return fs, cfg
|
|
|
|
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
}
|
|
|
|
|
2018-03-21 12:21:46 -04:00
|
|
|
func newTestBundleSourcesMultilingual(t *testing.T) (*hugofs.Fs, *viper.Viper) {
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
cfg, fs := newTestCfg()
|
|
|
|
|
|
|
|
workDir := "/work"
|
|
|
|
cfg.Set("workingDir", workDir)
|
|
|
|
cfg.Set("contentDir", "base")
|
|
|
|
cfg.Set("baseURL", "https://example.com")
|
|
|
|
cfg.Set("defaultContentLanguage", "en")
|
|
|
|
|
|
|
|
langConfig := map[string]interface{}{
|
|
|
|
"en": map[string]interface{}{
|
|
|
|
"weight": 1,
|
|
|
|
"languageName": "English",
|
|
|
|
},
|
|
|
|
"nn": map[string]interface{}{
|
|
|
|
"weight": 2,
|
|
|
|
"languageName": "Nynorsk",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
cfg.Set("languages", langConfig)
|
|
|
|
|
|
|
|
pageContent := `---
|
|
|
|
slug: pageslug
|
|
|
|
date: 2017-10-09
|
|
|
|
---
|
|
|
|
|
|
|
|
TheContent.
|
|
|
|
`
|
|
|
|
|
|
|
|
layout := `{{ .Title }}|{{ .Content }}|Lang: {{ .Site.Language.Lang }}`
|
|
|
|
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "layouts", "_default", "single.html"), layout)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "layouts", "_default", "list.html"), layout)
|
|
|
|
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "1s", "mypage.md"), pageContent)
|
2018-01-25 11:03:29 -05:00
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "1s", "mypage.nn.md"), pageContent)
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "1s", "mylogo.png"), "content")
|
|
|
|
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "bb", "_index.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "bb", "_index.nn.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "bb", "en.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "bb", "_1.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "bb", "_1.nn.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "bb", "a.png"), "content")
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "bb", "b.png"), "content")
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "bb", "b.nn.png"), "content")
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "bb", "c.nn.png"), "content")
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "bb", "b", "d.nn.png"), "content")
|
|
|
|
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "bc", "_index.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "bc", "page.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "bc", "logo-bc.png"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "bc", "page.nn.md"), pageContent)
|
|
|
|
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "bd", "index.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "bd", "page.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "bd", "page.nn.md"), pageContent)
|
|
|
|
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "be", "_index.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "be", "page.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "be", "page.nn.md"), pageContent)
|
|
|
|
|
|
|
|
// Bundle leaf, multilingual
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "lb", "index.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "lb", "index.nn.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "lb", "1.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "lb", "2.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "lb", "2.nn.md"), pageContent)
|
2018-01-20 11:11:03 -05:00
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "lb", "c", "page.md"), pageContent)
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "lb", "c", "logo.png"), "content")
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "lb", "c", "logo.nn.png"), "content")
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "lb", "c", "one.png"), "content")
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "lb", "c", "d", "deep.png"), "content")
|
|
|
|
|
2018-01-24 03:47:30 -05:00
|
|
|
//Translated bundle in some sensible sub path.
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "bf", "my-bf-bundle", "index.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "bf", "my-bf-bundle", "index.nn.md"), pageContent)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "base", "bf", "my-bf-bundle", "page.md"), pageContent)
|
|
|
|
|
2018-03-21 12:21:46 -04:00
|
|
|
return fs, cfg
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
}
|
|
|
|
|
2018-07-20 09:02:35 -04:00
|
|
|
func newTestBundleSymbolicSources(t *testing.T) (*helpers.PathSpec, func(), string) {
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
assert := require.New(t)
|
|
|
|
// We need to use the OS fs for this.
|
|
|
|
cfg := viper.New()
|
|
|
|
fs := hugofs.NewFrom(hugofs.Os, cfg)
|
|
|
|
fs.Destination = &afero.MemMapFs{}
|
|
|
|
loadDefaultSettingsFor(cfg)
|
|
|
|
|
2018-07-20 09:02:35 -04:00
|
|
|
workDir, clean, err := createTempDir("hugosym")
|
|
|
|
assert.NoError(err)
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
|
|
|
|
contentDir := "base"
|
|
|
|
cfg.Set("workingDir", workDir)
|
|
|
|
cfg.Set("contentDir", contentDir)
|
|
|
|
cfg.Set("baseURL", "https://example.com")
|
|
|
|
|
2018-03-21 12:21:46 -04:00
|
|
|
if err := loadLanguageSettings(cfg, nil); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
layout := `{{ .Title }}|{{ .Content }}`
|
|
|
|
pageContent := `---
|
|
|
|
slug: %s
|
|
|
|
date: 2017-10-09
|
|
|
|
---
|
|
|
|
|
|
|
|
TheContent.
|
|
|
|
`
|
|
|
|
|
|
|
|
fs.Source.MkdirAll(filepath.Join(workDir, "layouts", "_default"), 0777)
|
|
|
|
fs.Source.MkdirAll(filepath.Join(workDir, contentDir), 0777)
|
|
|
|
fs.Source.MkdirAll(filepath.Join(workDir, contentDir, "a"), 0777)
|
|
|
|
for i := 1; i <= 3; i++ {
|
|
|
|
fs.Source.MkdirAll(filepath.Join(workDir, fmt.Sprintf("symcontent%d", i)), 0777)
|
|
|
|
|
|
|
|
}
|
|
|
|
fs.Source.MkdirAll(filepath.Join(workDir, "symcontent2", "a1"), 0777)
|
|
|
|
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "layouts", "_default", "single.html"), layout)
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "layouts", "_default", "list.html"), layout)
|
|
|
|
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, contentDir, "a", "regular.md"), fmt.Sprintf(pageContent, "a1"))
|
|
|
|
|
|
|
|
// Regular files inside symlinked folder.
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "symcontent1", "s1.md"), fmt.Sprintf(pageContent, "s1"))
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "symcontent1", "s2.md"), fmt.Sprintf(pageContent, "s2"))
|
|
|
|
|
|
|
|
// A bundle
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "symcontent2", "a1", "index.md"), fmt.Sprintf(pageContent, ""))
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "symcontent2", "a1", "page.md"), fmt.Sprintf(pageContent, "page"))
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "symcontent2", "a1", "logo.png"), "image")
|
|
|
|
|
|
|
|
// Assets
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "symcontent3", "s1.png"), "image")
|
|
|
|
writeSource(t, fs, filepath.Join(workDir, "symcontent3", "s2.png"), "image")
|
|
|
|
|
2018-01-01 05:07:23 -05:00
|
|
|
wd, _ := os.Getwd()
|
|
|
|
defer func() {
|
|
|
|
os.Chdir(wd)
|
|
|
|
}()
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
// Symlinked sections inside content.
|
|
|
|
os.Chdir(filepath.Join(workDir, contentDir))
|
|
|
|
for i := 1; i <= 3; i++ {
|
|
|
|
assert.NoError(os.Symlink(filepath.FromSlash(fmt.Sprintf(("../symcontent%d"), i)), fmt.Sprintf("symbolic%d", i)))
|
|
|
|
}
|
|
|
|
|
|
|
|
os.Chdir(filepath.Join(workDir, contentDir, "a"))
|
|
|
|
|
|
|
|
// Create a symlink to one single content file
|
|
|
|
assert.NoError(os.Symlink(filepath.FromSlash("../../symcontent2/a1/page.md"), "page_s.md"))
|
|
|
|
|
|
|
|
os.Chdir(filepath.FromSlash("../../symcontent3"))
|
|
|
|
|
|
|
|
// Create a circular symlink. Will print some warnings.
|
|
|
|
assert.NoError(os.Symlink(filepath.Join("..", contentDir), filepath.FromSlash("circus")))
|
|
|
|
|
|
|
|
os.Chdir(workDir)
|
|
|
|
assert.NoError(err)
|
|
|
|
|
2018-03-21 12:21:46 -04:00
|
|
|
ps, _ := helpers.NewPathSpec(fs, cfg)
|
|
|
|
|
2018-07-20 09:02:35 -04:00
|
|
|
return ps, clean, workDir
|
:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark old ns/op new ns/op delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86%
benchmark old allocs new allocs delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30%
benchmark old bytes new bytes delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
2017-07-24 03:00:23 -04:00
|
|
|
}
|
2019-04-15 06:06:12 -04:00
|
|
|
|
|
|
|
// https://github.com/gohugoio/hugo/issues/5858
|
|
|
|
func TestBundledResourcesWhenMultipleOutputFormats(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
b := newTestSitesBuilder(t).Running().WithConfigFile("toml", `
|
|
|
|
baseURL = "https://example.org"
|
|
|
|
[outputs]
|
|
|
|
# This looks odd, but it triggers the behaviour in #5858
|
|
|
|
# The total output formats list gets sorted, so CSS before HTML.
|
|
|
|
home = [ "CSS" ]
|
|
|
|
|
|
|
|
`)
|
|
|
|
b.WithContent("mybundle/index.md", `
|
|
|
|
---
|
|
|
|
title: Page
|
|
|
|
date: 2017-01-15
|
|
|
|
---
|
|
|
|
`,
|
|
|
|
"mybundle/data.json", "MyData",
|
|
|
|
)
|
|
|
|
|
|
|
|
b.CreateSites().Build(BuildCfg{})
|
|
|
|
|
|
|
|
b.AssertFileContent("public/mybundle/data.json", "MyData")
|
|
|
|
|
|
|
|
// Change the bundled JSON file and make sure it gets republished.
|
|
|
|
b.EditFiles("content/mybundle/data.json", "My changed data")
|
|
|
|
|
|
|
|
b.Build(BuildCfg{})
|
|
|
|
|
|
|
|
b.AssertFileContent("public/mybundle/data.json", "My changed data")
|
|
|
|
|
|
|
|
}
|