Commit graph

825 commits

Author SHA1 Message Date
Bjørn Erik Pedersen 4fbce78740 Add JSON config to the multilanguage testing
Updates #2309
2016-09-06 18:32:20 +03:00
Bjørn Erik Pedersen d8a256c155 Fix YAML loading of multilingual config
And some other minor fixes from code review.

Updates #2309
2016-09-06 18:32:20 +03:00
Bjørn Erik Pedersen 446e606a09 Add data tests
Updates #2309
2016-09-06 18:32:20 +03:00
Bjørn Erik Pedersen a07293cf97 Create a Node map to get proper node translations
In a multi-language setup, before this commit the Node's Translations() method
would return some "dummy nodes" that would point to the correct page (Permalink),
but would not be the same as the node it points to -- it would not have the translated
title etc.

The node creation is, however, so mingled with rendering, whihc is too early to have any global state,
so the nodes has to be split in a prepare and a render phase. This commits does that with as small
a change as possible. This implementation is a temp solution until we fix #2297.

Updates #2309
2016-09-06 18:32:19 +03:00
Bjørn Erik Pedersen 7610844004 Add IsTranslated to Node and Page
Makes the templates simpler.

See #2309
2016-09-06 18:32:19 +03:00
Bjørn Erik Pedersen 8b55bfc814 Remove unused Multilingual Viper default
See #2312
2016-09-06 18:32:19 +03: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 d953e39e63 Add parent as owner to Site
And pull up common member vars like Tmpl and Multilinguage.

Or: the final multilingual TODO-fixes.

See #2309
2016-09-06 18:32:18 +03:00
Bjørn Erik Pedersen 9798a95670 Make the check command work in multilingual mode
Or: some more multilingual TODO-fixes.

See #2309
2016-09-06 18:32:18 +03:00
Bjørn Erik Pedersen 6b552db75f Make sure drafts etc. are not processed
See #2309
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 0a7d1d0ddc Fix some corner cases in revised summary handling
And clean up the test.

See #2309
2016-09-06 18:32:18 +03:00
Bjørn Erik Pedersen 506e131f28 Fix the shortcode ref tests
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 2079a23dd8 Make it possible to configure Blackfroday per language
See #2309
2016-09-06 18:32:17 +03:00
Bjørn Erik Pedersen 596e0e98e4 Make it possible to add a language in server mode
See #2309
2016-09-06 18:32:17 +03:00
Bjørn Erik Pedersen 8b657a11ee Get the list commands up to multi-site level
This commit also unexports some Site methods, making it clear what the external build API really is.

See #2312
2016-09-06 18:32:17 +03:00
Bjørn Erik Pedersen 90de511017 Make taxonomies configurable per language
See #2312
2016-09-06 18:32:17 +03:00
Bjørn Erik Pedersen 36f2a1f676 Make the config loading testable
This is needed to verify  #2309, but it closes a big hole in Hugo's automated tests.

The loading of the config is now moved to `hugolib` and the same default settings are now used
in production and tests.

As Viper now uses Afero as its filesystem, we now can write fairly complete integration tests with ease.

See #2309
2016-09-06 18:32:17 +03:00
Bjørn Erik Pedersen b6fcb3d0bb Add sitemap index for multilingual sites
See #2309
2016-09-06 18:32:17 +03:00
Bjørn Erik Pedersen d572071784 Redirect to main language from root
See #2312
See #2309
2016-09-06 18:32:17 +03:00
Bjørn Erik Pedersen f0b91852ea Rework the multilingual docs
And in the same go adjusted some minor parts of the language API:

Add LanguagePrefix alias to Node and rename the Multilingual config section to Languages.

See #2309
2016-09-06 18:32:17 +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 f023dfd763 Move the Build* methods to HugoSites
See #2309
2016-09-06 18:32:16 +03:00
Bjørn Erik Pedersen 5b9c2a40f1 Move HugoSites to hugolib
It will get more involved in the build process in a minute.

See #2309
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 52bf8f9095 Rework the i18n template func handling
Setting the language to use when loading the language bundles just doesn't work.
The template system is unfortanetely a global, and the last languate processed won ...
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 618948e4a8 Reset translation slice on rebuild
Also add all translations, including the current, to the slice. We filter later.
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
Bjørn Erik Pedersen 20c4311df4 Switch to a more up to date TOML library
Fixes #2089
2016-08-20 20:33:06 +01:00
Cameron Moore 715d4425ad hugolib: Use named keys in composite literals
Make `go vet` great again
2016-08-19 12:22:19 +01:00
Bjørn Erik Pedersen f6d4801ba4 Skipt Twitter test in short mode 2016-08-13 18:50:06 +02:00
Bjørn Erik Pedersen 93f3a85bf8 Fix the time template func test
By making it not depend on the locale setup.
2016-08-04 10:36:44 +02:00
Bjørn Erik Pedersen a0859dc672 Make LazyFileReader use the Afero source fs
Fixes #2317
2016-07-30 15:21:02 +02:00
Bjørn Erik Pedersen 4d4da001a0 Fix broken shortcode test
See #2249
2016-07-21 22:30:10 +02:00
Bjørn Erik Pedersen 39a452a4c7 Add "missing slice" to the Params test
See #2249
2016-07-21 21:03:44 +02:00
Bjørn Erik Pedersen 593a546fc6 Check for nil Params in shortcode's Get
Fixes #2294
2016-07-21 17:22:31 +02:00
Bjørn Erik Pedersen 0bdc0d62d4 Add shortcode null param variant
See #2294
2016-07-21 15:30:43 +02:00
Bjørn Erik Pedersen e9924e964b Add shortcode test for mmark 2016-07-20 00:40:40 +02:00
Bjørn Erik Pedersen ef9b915680 Revert "Throw a noisy error when a post has no layout"
We have to figure out another way. There are perfectly valid reasons not having a layout for a page (I have have some broken sites as result of this).

See #1313

This reverts commit b15934008f.
2016-07-14 11:29:21 +02:00
Aditya Bhargava b15934008f Throw a noisy error when a post has no layout
Fixes #1313
2016-07-13 23:57:18 +02:00
Bjørn Erik Pedersen 1d7f4413f5 Consolidate the Render funcs 2016-07-10 11:36:25 +02:00
Vincent Batoufflet b8af06f26a Make auto-date disabled by default
Fixes #2244
Closes #2260
2016-07-08 14:43:10 +02:00
Bjørn Erik Pedersen e6d97c4fca Add Rst shortcode test
Fixes #2253
2016-07-04 10:49:20 +02:00
Bjørn Erik Pedersen 5388211c11 Add Asciidoc shortcode test
Fixes #2249
2016-07-04 00:33:08 +02:00
Vincent Batoufflet eda3678742 Add automatic page date fallback
Closes #2239
2016-06-28 23:50:50 +02:00
Bjørn Erik Pedersen cdd6a124c2 Add test for shortcode in fenced code block
Which I expected to fail, but it doesn't ...

See #2223
2016-06-26 19:46:29 +02:00
Cameron Moore e2aea65170 helpers: Remove ToReader funcs
Remove StringToReader and BytesToReader in favor of using the stdlib directly.
2016-06-25 17:57:05 -05:00
Bjørn Erik Pedersen 714d4a9a97 Fix failing Windows test
Closes #2225
2016-06-18 13:58:54 +02:00
Kishin Yagami 44edd9382a Add tests for embedded shortcodes
Fixes #1956
Closes #2204
2016-06-18 11:49:55 +02:00
Bjørn Erik Pedersen 34f40044d7 Fix shortcode in markdown headers
This issue was introduced as a fix to shortcode not working in RST.

One could argue that Blackfriday and friends should handle `#` in titles, but that will be a discussion
for another day.

The new placeholder pattern should be RST safe and work with titles.

And now with a test so this doesn't break again.

Fixes #2192
Fixes #2209
Closes #2210
2016-06-15 09:12:07 +02:00
Bjørn Erik Pedersen 8588103316 Unexport ShouldBuild and AssertShouldBuild 2016-06-14 15:53:49 +02:00
Hanchen Wang eeaafb4b26 hugolib: futureStats plural 2016-06-14 15:45:27 +02:00
Hanchen Wang fb0c1350d4 hugolib: Handle unpecified date for IsFuture and IsExpired 2016-06-14 15:45:26 +02:00
Hanchen Wang 673e41bf6a hugolib: Add expiredStats to build feedback 2016-06-14 15:45:26 +02:00
Hanchen Wang 32c0e3fd1f hugolib: Bug fix futureStats 2016-06-14 15:45:26 +02:00
Hanchen Wang 4724a5794e hugolib: Refactor page.ShouldBuild and table driven test 2016-06-14 15:45:26 +02:00
Hanchen Wang c1c8ecc9d6 hugolib: Add GroupByExpireDate function 2016-06-14 15:45:26 +02:00
Hanchen Wang 091915c75d hugolib: Add sort ByExpiryDate function 2016-06-14 15:45:25 +02:00
Hanchen Wang 6472f158a4 hugelib: Add expiredCount as a Site variable 2016-06-14 15:45:25 +02:00
Hanchen Wang d4156e6127 hugolib: Support an expiration date 2016-06-14 15:45:25 +02:00
Sam Broughton 75deb923d9 Remove unneeded casts in page.getParam
Closes #2186
2016-06-09 15:40:06 +02:00
Bjørn Erik Pedersen a7f51703c4 Add Hugo generator tag to home page if not present
Fixes #2182
2016-06-04 21:55:56 -04:00
Steve Francia f94cd2813d Handle errors during rereading properly
Without this fix, any error during rereading would cause Hugo to hang.
Fixes #2168
Closes #2179
2016-06-02 23:47:30 +02:00
Bjørn Erik Pedersen 608cfe62cf Remove kr/pretty dependency
Fixes #2124
See https://github.com/kr/text/issues/6
2016-05-08 13:16:16 +02:00
Bjørn Erik Pedersen 10af906371 Add ByLastmod page sort 2016-04-22 20:43:18 +02:00
Sven Dowideit 22683a3b66 Make alias redirect output URL's relative
Closes #2093
2016-04-22 08:14:19 +02:00
Anthony Fok 9ddf52021b Update import path of fsnotify
Rename "gopkg.in/fsnotify.v1" to "github.com/fsnotify/fsnotify"
per upstream recommendation.

See https://github.com/fsnotify/fsnotify/issues/108 for rationale.
2016-04-20 22:28:26 +08:00
Bjørn Erik Pedersen 77159b4b9b Add some schemaless BaseURL tests
See #2085
2016-04-17 20:01:21 +02:00
Mattias Wadman 5d50c46482 Chomp Unicode BOM if present
Useful if using or sharing files with users that use editors that
append a unicode byte order marker header (like Windows notepad).

This will still assume files are UTF-8 encoded.

Closes #2075
2016-04-14 10:46:27 +02:00
Bjørn Erik Pedersen 206440eef2 Fix broken tests 2016-04-12 19:18:02 +02:00
Bjørn Erik Pedersen c3d28d2897 Revert "Add Node.ID"
This reverts commit 5ef52294f9.
2016-04-12 18:11:52 +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 5ef52294f9 Add Node.ID
Fixes #2071
2016-04-11 11:49:02 +02:00
Bjørn Erik Pedersen c0cf1a7e37 Fix section menus for lazy blogger
IsMenuCurrent was always returning false for the top level entries.

Fixes #2065
2016-04-10 13:49:32 +02:00
digitalcraftsman b7efbdc12f hugolib: Add option to disable rendering of 404 page
Fixes #1889
Closes #2037
2016-04-09 20:25:59 +02:00
nitoyon 72bda5ad26 Move section initialization to Site.assembleSections
Closes #1527
2016-04-09 20:13:35 +02:00
Bjørn Erik Pedersen 8fe48a6576 Fix potential data race in test 2016-04-09 14:30:22 +02:00
ypnos 9f6b5ad3b4 Save auto-detected markup type in Page.Markup
If Page.Markup was not set by the user, it will now be set after
guessing from the file extension. This means, Page.Markup will be set in
any case. It can be used by a theme to differentiate between markup
types.

Fixes #1950
2016-04-09 00:48:53 +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 819271cb78 Re-export the methods used in page group tests 2016-04-07 18:44:58 +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 05b888877d huglib: Add even more missing GoDoc
See #2014
2016-04-07 16:05:23 +02:00
Bjørn Erik Pedersen ddd02b2f6a hugolib: Camel-case ALL_CAPS const in test 2016-04-07 15:22:41 +02:00
Bjørn Erik Pedersen 98ee8c3f7b hugolib: Add GoDoc to pageGroup.go
See #2014
2016-04-07 15:21:41 +02:00
Bjørn Erik Pedersen 54750b0780 Do not create robots.txt by default
Meny people, including me, have a custom robots.txt in static.

Also remove that option from the command line; it doesn't feel
important enough.

Fixes ##2049
2016-04-05 22:20:39 +02:00
Robert Basic 7d5c9fbf44 Make ByCount sort consistently
When two or more taxonomies have the same number of pages,
sort them by name to have consistent ByCount sorting of
taxonomies.

Fixes #1930
2016-04-02 22:59:10 +02:00
Bjørn Erik Pedersen b678e90db7 Use to most specific interface in WriteDestPage 2016-04-02 00:04:08 +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 8aec5ee2dd hugolib: Some more unexports 2016-03-25 03:12:31 +01:00
Bjørn Erik Pedersen 6dbae7b671 Be explicit about the type in Scratch test
A puzzle, but it sometimes produces a int64 as it is now.
2016-03-24 19:57:26 +01:00
Bjørn Erik Pedersen d770130530 hugolib: Remove unused Tmpl on Page 2016-03-24 18:34:41 +01:00
Bjørn Erik Pedersen c846b051f3 Do not use defer for unlocking in Scratch
It is a fairly costly operation:

```
benchmark                 old ns/op     new ns/op     delta
BenchmarkScratchGet-4     109           31.6          -71.01%

benchmark                 old allocs     new allocs     delta
BenchmarkScratchGet-4     0              0              +0.00%

benchmark                 old bytes     new bytes     delta
BenchmarkScratchGet-4     0             0             +0.00%
´´´
2016-03-24 16:03:31 +01:00