Commit graph

119 commits

Author SHA1 Message Date
Bjørn Erik Pedersen e371ac0b6f node to page: Basic outline
Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen 6a3d1037b3 Fix RSS Title regression
And add tests to make sure it doesn't happen again.

Fixes #2645
2016-10-28 14:46:33 +02:00
Bjørn Erik Pedersen 0406be3d54 Add missing template error logging 2016-10-25 22:56:44 +02:00
Bjørn Erik Pedersen 333bb05512 Remove now superfluous lowercasing
See #2615
See #1129
2016-10-24 21:33:11 +02:00
Albert Nigmatzianov f21e2f25c9 all: Unify case of config variable names
All config variables starts with low-case and uses camelCase.

If there is abbreviation at the beginning of the name, the whole
abbreviation will be written in low-case.
If there is abbreviation at the end of the name, the
whole abbreviation will be written in upper-case.
For example, rssURI.
2016-10-24 20:56:00 +02:00
Bjørn Erik Pedersen 40b1b8f703 Fix case issue Viper vs Blackfriday config
There are still work to be done in the case department, but that will have to be another day.

Fixes #2581
See https://github.com/spf13/viper/issues/261
2016-10-16 19:28:21 +02:00
Bjørn Erik Pedersen dd45e6d7e5 Lazy calculate WordCount, ReadingTime and FuzzyWordCount
This avoids having to execute these expensive operations for sites not using these values.

This commit sums up a set of wordcounting and autosummary related performance improvements.

The effect of these kind of depends on what features your site use, but a benchmark from 4 Hugo sites in the wild shows promise:

```
benchmark           old ns/op       new ns/op       delta
BenchmarkHugo-4     21293005843     20032857342     -5.92%

benchmark           old allocs     new allocs     delta
BenchmarkHugo-4     65290922       65186032       -0.16%

benchmark           old bytes      new bytes      delta
BenchmarkHugo-4     9771213416     9681866464     -0.91%
```

Closes #2378
2016-09-14 10:57:39 +02:00
Bjørn Erik Pedersen 8da040342e Render main content language in root by default
Fixes #2312
2016-09-06 18:32:18 +03:00
Bjørn Erik Pedersen e56ecab157 Multilingual TODO-fixes, take 1
See #2309
2016-09-06 18:32:18 +03:00
Bjørn Erik Pedersen 54141f71dd Improve language handling in URLs
The current "rendering language" is needed outside of Site. This commit moves the Language type to the helpers package, and then used to get correct correct language configuration in the markdownify template func.
This commit also adds two new template funcs: relLangURL and absLangURL.

See #2309
2016-09-06 18:32:18 +03:00
Bjørn Erik Pedersen ed0985404d Render the shortcodes as late as possible
This is needed to make shortcode users happy with the new multilanguage support,
but it will also solve many other related posts about "stuff not available in the shortcode".

We will have to revisit this re the handler chain at some point, but that will be easier
now as the integration test story has improved so much.

As part of this commit, the site-building tests in page_test.go is refreshed, they now
tests for all the rendering engines (when available), and all of them now uses the
same code-path as used in production.

Fixes #1229
Fixes #2323
Fixes ##1076
2016-09-06 18:32:16 +03:00
Bjørn Erik Pedersen 708bc78770 Optimize the multilanguage build process
Work In Progress!

This commit makes a rework of the build and rebuild process to better suit a multi-site setup.

This also includes a complete overhaul of the site tests. Previous these were a messy mix that
were testing just small parts of the build chain, some of it testing code-paths not even used in
"real life". Now all tests that depends on a built site follows the same and real production code path.

See #2309
Closes #2211
Closes #477
Closes #1744
2016-09-06 18:32:16 +03:00
Bjørn Erik Pedersen 3a02807970 Add Translations and AllTranslations to Node
This commit also consolidates URLs on Node vs Page, so now .Permalink should be interoperable.

Note that this implementations should be fairly short-livded, waiting for #2297, but the API should be stable.
2016-09-06 18:32:16 +03:00
Bjørn Erik Pedersen 75dd596e6c Introduce HugoSites type
And a Hugo global variable which contains the site under build.

This is really needed to get some level of control of the "multiple languages" in play.

There are still work related to this scattered around, but that will come.

With this commit, the multilingual feature is starting to work.
2016-09-06 18:32:16 +03:00
Bjørn Erik Pedersen c4e7c37055 Add Translations and AllTranslations methods to Page
Will revisit Node later.
2016-09-06 18:32:15 +03:00
Bjørn Erik Pedersen 06d12ab895 Add proper Language and Languages types 2016-09-06 18:32:15 +03:00
Alexandre Bourget ec33732fbe Add multilingual support in Hugo
Implements:
* support to render:
  * content/post/whatever.en.md to /en/2015/12/22/whatever/index.html
  * content/post/whatever.fr.md to /fr/2015/12/22/whatever/index.html
* gets enabled when `Multilingual:` is specified in config.
* support having language switchers in templates, that know
  where the translated page is (with .Page.Translations)
  (when you're on /en/about/, you can have a "Francais" link pointing to
   /fr/a-propos/)
  * all translations are in the `.Page.Translations` map, including the current one.
* easily tweak themes to support Multilingual mode
* renders in a single swift, no need for two config files.

Adds a couple of variables useful for multilingual sites

Adds documentation (content/multilingual.md)

Added language prefixing for all URL generation/permalinking see in the
code base.

Implements i18n. Leverages the great github.com/nicksnyder/go-i18n lib.. thanks Nick.
* Adds "i18n" and "T" template functions..
2016-09-06 18:32:15 +03:00
Cameron Moore 715d4425ad hugolib: Use named keys in composite literals
Make `go vet` great again
2016-08-19 12:22:19 +01:00
Hanchen Wang d4156e6127 hugolib: Support an expiration date 2016-06-14 15:45:25 +02:00
Bjørn Erik Pedersen 77159b4b9b Add some schemaless BaseURL tests
See #2085
2016-04-17 20:01:21 +02:00
Bjørn Erik Pedersen 206440eef2 Fix broken tests 2016-04-12 19:18:02 +02:00
Bjørn Erik Pedersen 39c9ae3108 Revert "Use Node.ID for anchor ID"
This reverts commit cd558958a0.
2016-04-12 18:11:24 +02:00
Bjørn Erik Pedersen cd558958a0 Use Node.ID for anchor ID
Fixes #2057
2016-04-11 13:17:25 +02:00
Bjørn Erik Pedersen f2ff77f3ac Make Hugo build without Mercurial
By creating a fork of the Bitbucket inflect repo. It hasn't changed since 2013,
so it must be considered pretty stable.

Fixes #2062
2016-04-08 21:11:44 +02:00
Bjørn Erik Pedersen 1c3c148b38 hugolib: Un-export internal Site-methods
These are obviously internal and for the most part undocumented, creating lots of GoLint warnings.

See #1160
See #2014
2016-04-08 17:55:23 +02:00
Sven Dowideit 1648e327c0 Document and clean SourceRelativeLinksEval code 2016-04-07 20:10:38 +02:00
Bjørn Erik Pedersen 3950b1375c hugolib: Camelcase ALL_CAPS vars and const in tests
See #2014
2016-04-07 16:10:41 +02:00
Bjørn Erik Pedersen 4f66f790b1 Add readFile template func
This also includes a refactor of the hugofs package and its usage.

The motivation for that is:

The Afero filesystems are brilliant. Hugo's way of adding a dozen of global variables for the different filesystems was a mistake. In readFile (and also in some other places in Hugo today) we need a way to restrict the access inside the working dir. We could use ioutil.ReadFile and implement the path checking, checking the base path and the dots ("..") etc. But it is obviously better to use an Afero BasePathFs combined witha ReadOnlyFs. We could create a use-once-filesystem and handle the initialization ourselves, but since this is also useful to others and the initialization depends on some other global state (which would mean to create a new file system on every invocation), we might as well do it properly and encapsulate the predefined set of filesystems. This change also leads the way, if needed, to encapsulate the file systems in a struct, making it possible to have several file system sets in action at once (parallel multilanguage site building? With Moore's law and all...)

Fixes #1551
2016-03-31 21:24:18 +02:00
Bjørn Erik Pedersen 7c84e6b3e3 hugolib: Even more Golint fixes 2016-03-24 14:42:03 +01:00
Bjørn Erik Pedersen dea185aa9b hugolib: Remove unused code 2016-03-14 15:41:03 +01:00
Bjørn Erik Pedersen 973393c99e Create template clone for late template execution
Fixing some breaking blogs on Go 1.6

Fixes #1879
2016-03-09 14:37:58 +01:00
Bjørn Erik Pedersen 4e32dc80a2 Simplify the IsHome test cases 2016-03-06 00:41:11 +01:00
Bjørn Erik Pedersen 023992abad Unexport the target handlers
These are of no interest outside the package.
2016-03-05 20:56:38 +01:00
Bjørn Erik Pedersen 27f8d8f963 Allow URL with extension in frontmatter
Fixes #1923
2016-03-05 20:50:53 +01:00
Tatsushi Demachi 2b3b90a6df Add test for Hugo hanging up with empty content
This adds a test for the issue #1797 and its fix in 68e2e63.
2016-02-08 20:55:19 +09:00
Bjørn Erik Pedersen 9ff36c5a8f Add some trailing newline shortcode tests
See #1753
2016-01-04 23:48:05 +01:00
Sven Dowideit 0f6b334b67 Source file based relative linking
ala GitHub repository markdown for both md files and non-md files

Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
2016-01-01 15:23:11 -05:00
Sven Dowideit b78f13b041 Write a simplistic test for site.refLink
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
2016-01-01 14:50:37 -05:00
Bjørn Erik Pedersen 9edc58a03a Fix failing template related tests in Go 1.6
Fixes #1470
2015-12-18 15:28:43 +01:00
Bjørn Erik Pedersen 8cea428802 Fix data race in non-renderable pages
Fixes #1601
2015-12-18 11:24:35 +01:00
Anthony Fok 8509727fe8 Add copyright header to that source files that don’t have one.
See #1646
2015-12-10 15:19:38 -07:00
Anthony Fok 29aa9baecd Complete the Url-to-URL transition in tests
See #959
2015-09-13 05:21:24 -06:00
Anthony Fok b0416e9bef Strip trailing whitespace in code 2015-08-04 11:59:32 -06:00
Bjørn Erik Pedersen 664a97819f 404 is homeless
Fixes #1235
2015-06-28 10:43:43 +02:00
Bjørn Erik Pedersen 004fcddc80 Remove superfluous p-tags around shortcodes
This commit replaces the regexp driven `replaceShortcodeTokens` with a handwritten one.

It wasnt't possible to handle the p-tags case without breaking performance.

This fix actually improves in that area:

```
benchmark                           old ns/op     new ns/op     delta
BenchmarkParsePage                  142738        142667        -0.05%
BenchmarkReplaceShortcodeTokens     665590        575645        -13.51%
BenchmarkShortcodeLexer             176038        181074        +2.86%

benchmark                           old allocs     new allocs     delta
BenchmarkParsePage                  87             87             +0.00%
BenchmarkReplaceShortcodeTokens     9631           9424           -2.15%
BenchmarkShortcodeLexer             274            274            +0.00%

benchmark                           old bytes     new bytes     delta
BenchmarkParsePage                  141830        141830        +0.00%
BenchmarkReplaceShortcodeTokens     52275         35219         -32.63%
BenchmarkShortcodeLexer             30177         30178         +0.00%
```

Fixes #1148
2015-06-21 22:51:12 +02:00
Bjørn Erik Pedersen 3eb301b57a Revert "refactor and clean up site tests"
This reverts commit 99e250917d.
2015-06-21 15:01:06 +02:00
Bjørn Erik Pedersen f25ce7fefa Revert "Move matchRender to test helpers file"
This reverts commit 32d91d616e.
2015-06-21 15:01:02 +02:00
Bjørn Erik Pedersen d770fa59a5 Revert "Add tests for homepage content support"
This reverts commit 24351c58be.
2015-06-21 15:01:01 +02:00
spf13 24351c58be Add tests for homepage content support 2015-06-17 12:35:44 -04:00
spf13 32d91d616e Move matchRender to test helpers file 2015-06-17 10:47:49 -04:00