Commit graph

955 commits

Author SHA1 Message Date
Bjørn Erik Pedersen
4a79fa0c33 Revert the "standardize author data"
There were some breaking changes etc. that is too late to fix for 0.17.

Let us think this through and add proper author support for Hugo 0.18.

Fixes #2464

Revert "docs: Add documentation for author profiles"

This reverts commit b6673e5309.

Revert "Add First Class Author Support"

This reverts commit cf978c0649.
2016-09-18 19:16:39 +02:00
Bjørn Erik Pedersen
a7af63037c Make suure SectionPagesMenu setting is always loaded per language 2016-09-17 16:54:35 +02:00
Bjørn Erik Pedersen
51c9bfbc9e Remove Authors.Sort
We may add it again in the future, but let us try to keep the API as small as possible for now.

See #1850
2016-09-17 00:50:11 +02:00
Derek Perkins
cf978c0649 Add First Class Author Support
Closes #1850
2016-09-17 00:49:24 +02:00
digitalcraftsman
e80453a991 tpl: Add EnableMissingTranslationPlaceholders option
Fixes #2451
2016-09-16 17:20:29 +02:00
Bjørn Erik Pedersen
b86a605bfb Make paginate settings configurable per language
Fixes #2449
2016-09-15 09:32:52 +02:00
Bjørn Erik Pedersen
bbb11a4a0f Do not add lang prefix in URL when set in frontmatter
Fixes #2450
2016-09-14 18:51:34 +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
4abaec5c04 Improve TotalWords counter func
It is obviously more efficient when we do not care about the actual words.

```
BenchmarkTotalWords-4            100000         18795 ns/op           0 B/op           0 allocs/op
BenchmarkTotalWordsOld-4          30000         46751 ns/op        6400 B/op           1 allocs/op
```
2016-09-14 10:50:56 +02:00
Bjørn Erik Pedersen
bcd434794a Avoid splitting words for summary
For people using autogenerated summaries, this is one of the hot spots in the memory department.

We don't need to split al the content into words to do proper summary truncation.

This is obviously more effective:

```
BenchmarkTestTruncateWordsToWholeSentence-4            300000          4720 ns/op           0 B/op           0 allocs/op
BenchmarkTestTruncateWordsToWholeSentenceOld-4         100000         17699 ns/op        3072 B/op           3 allocs/op
```
2016-09-14 10:50:55 +02:00
Bjørn Erik Pedersen
69a97823c4 Add Language.LanguageName
Fixes #2435
2016-09-12 20:59:03 +02:00
Bjørn Erik Pedersen
a7dc3c082e Support site menu per language
Fixes #2434
2016-09-12 20:59:03 +02:00
Cameron Moore
46342ad5e8 hugolib: Fix typos in tests 2016-09-12 10:56:16 +02:00
Bjørn Erik Pedersen
ef3c4a56d8 Fix reload dir matching in theme
Fixes #2430
2016-09-11 20:00:38 +02:00
Bjørn Erik Pedersen
364e69ab7f Handle symlink change event
Hugo 0.16 announced support for symbolic links for the root folders, /content, /static etc., but this got broken pretty fast.

The main problem this commit tries to solve is the matching of file change events to "what changed".

An example:

ContentDir: /mysites/site/content where /mysites/site/content is a symlink to /mycontent

/mycontent:

/mypost1.md
/post/mypost2.md

* A change to mypost1.md (on OS X) will trigger a file change event with name "/mycontent/mypost1.md"
* A change to mypost2.md gives event with name "/mysites/site/content/mypost2.md"

The first change will not trigger a correct update of Hugo before this commit. This commit fixes this by doing a two-step check:

1. Check if "/mysites/site/content/mypost2.md" is within /mysites/site/content
2. Check if  "/mysites/site/content/mypost2.md" is within the real path that /mysites/site/content points to

Fixes #2265
Closes #2273
2016-09-11 20:00:38 +02:00
Mathias Biilmann
7d3dfba84b Prevent panic on empty authorlist 2016-09-11 10:46:56 +02:00
Bjørn Erik Pedersen
43bf9ed38e Redirect to root when DefaultContentLanguageInSubdir = false
Fixes #2422
2016-09-09 17:42:02 +02:00
Bjørn Erik Pedersen
4df86a703a Fix paginator counter on x86-32
Atomic operations with 64 bit values must be aligned for 64-bit on x86-32.

According to the spec:

"The first word in a global variable or in an allocated struct or slice can be relied upon to be 64-bit aligned."

The above wasn't enough for the `paginationPageCount` on `SiteInfo`, maybe due to how `SiteInfo` is embedded.

This commit adds a 4 byte padding before the `uint64` that creates the correct alignment.

Fixes #2415
2016-09-09 14:31:49 +02:00
Bjørn Erik Pedersen
76bf2dcdd2 Fix shortcode vs pygments
This is the nth attempt to fix an issue by changing the placeholder token pattern, but
now we actually have tests for all the historic trouble cases.

Fixes #2223
2016-09-08 21:23:01 +02:00
Bjørn Erik Pedersen
ccb3040ad4 Fix pagination page counter on 32 bit
Updates #2415
2016-09-08 17:18:11 +03:00
Bjørn Erik Pedersen
fe0c270577 Reset the i18n func map on reload
Also improve the error message on missing resource bundles.
2016-09-08 17:18:11 +03:00
Bjørn Erik Pedersen
97c57fe37a Add missing read lock in getNodes 2016-09-08 16:51:32 +03:00
Bjørn Erik Pedersen
35d2eac490 Fix go vet 1.7 issues
Updates #2309
2016-09-06 18:32:21 +03:00
Bjørn Erik Pedersen
dc3618abcd Make sure the 404 node has .Data.Pages
Updates #2309
2016-09-06 18:32:21 +03:00
Bjørn Erik Pedersen
30d65fd48d Fix site reset for benchmarks etc.
Updates #2309
2016-09-06 18:32:21 +03:00
Bjørn Erik Pedersen
b3563b40a4 Fix multilingual reload when shortcode changes
This commit also refines the partial rebuild logic, to make sure we do not do more work than needed.

Updates #2309
2016-09-06 18:32:21 +03:00
Bjørn Erik Pedersen
a823b1572b Set lang template globals for each site when render shortcodes
We should get rid of these globals, but that is another month.
2016-09-06 18:32:21 +03:00
Bjørn Erik Pedersen
28696b5dca Small adjustment to SiteInfo init
After a visual inspection to make (pretty) sure it is correct re multiple languages.

Updates #2309
2016-09-06 18:32:20 +03:00
Bjørn Erik Pedersen
1bce8a854b Create a copy of the section node for RSS
So the Permalink gets correct when listing translations.

I have also checked the other relevant places to make sure we do not overwrite node values we need later.

Pointers can be tricky, but lesson learned is: A copy is cheap.

Updates #2309
2016-09-06 18:32:20 +03:00
Bjørn Erik Pedersen
bbfebdea43 Fix Data in multisites
Updates #2309
2016-09-06 18:32:20 +03:00
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
Bjørn Erik Pedersen
fa1a9653e5 hugolib: Taxonomy GoDoc cleanup 2016-03-24 16:01:25 +01:00
Bjørn Erik Pedersen
b5bced1db4 Add a simple benchmark for Scratch 2016-03-24 15:05:40 +01:00
Bjørn Erik Pedersen
7c84e6b3e3 hugolib: Even more Golint fixes 2016-03-24 14:42:03 +01:00
Bjørn Erik Pedersen
3bbfd99176 hugolib: Apply Golint rules to rss_test.go 2016-03-24 14:20:00 +01:00
Bjørn Erik Pedersen
b8bf01cdc6 hugolib: Add missing GoDoc in pagination.go 2016-03-24 14:18:47 +01:00
Bjørn Erik Pedersen
c2c73c2bd2 hugolib: Some more GoLint fixes 2016-03-24 14:11:04 +01:00
Bjørn Erik Pedersen
e467d23374 hugoblib: Clean up the time tests 2016-03-24 13:30:08 +01:00
Bjørn Erik Pedersen
a6de8dfb42 hugolib: Some more Golint fixes 2016-03-23 17:17:54 +01:00
Bjørn Erik Pedersen
dac34f9bfd hugolib: Fix spelling mistake 2016-03-23 17:12:47 +01:00
Bjørn Erik Pedersen
c31fa378c7 hugolib: Add Godoc to pageSort 2016-03-23 17:11:29 +01:00
Bjørn Erik Pedersen
937592cb85 hugolib: Fix some more Golint warnings 2016-03-23 10:10:28 +01:00
Bjørn Erik Pedersen
faf2e50685 Do some minor code cleaning of Site
* Unexport some methods/fields
* Add some godoc

Still plenty to do here.
2016-03-23 09:43:04 +01:00
Bjørn Erik Pedersen
dc7d8a9eac Spring cleaning of the menu code 2016-03-23 00:29:39 +01:00
Bjørn Erik Pedersen
df92fc31ca hugolib: Fix Java-styled all-caps consts 2016-03-22 23:59:07 +01:00
Bjørn Erik Pedersen
35b798247e Check returned error in Scratch-test 2016-03-22 23:40:39 +01:00
Cameron Moore
b1b7ac7e75 hugolib: Use field keys in composite literals
Small fix in shortcode tests to use field keys in a composite literal.
2016-03-22 19:43:28 +01:00
Bjørn Erik Pedersen
048e07422d Add Scratch to shortcode
Fixes #2000
2016-03-21 21:11:20 -04:00
Bjørn Erik Pedersen
de8fc8761a Re-render shortcode on template or data file change
Fixes  #1971
2016-03-21 21:09:25 -04:00
Bjørn Erik Pedersen
02effd9dc4 Protect against concurrent Scratch read and write
Fixes #2005
2016-03-21 20:42:27 +01:00
Bjørn Erik Pedersen
3529152efe Return early from appendThemeTemplates 2016-03-17 23:36:11 +01:00
Bjørn Erik Pedersen
70739c972e Remove unnecessary type conversions 2016-03-14 20:35:50 +01:00
Bjørn Erik Pedersen
dea185aa9b hugolib: Remove unused code 2016-03-14 15:41:03 +01:00
Bjørn Erik Pedersen
0fb31e4a82 Create an alias from shortcode.Page.Site to shortcode.Site
Fixes #1976
2016-03-14 14:10:15 +01:00
Bjørn Erik Pedersen
542e220cc4 Make tests green on both Pygments 2.0.2 and 2.1.3
See #1969
2016-03-13 22:06:51 +01:00
Bjørn Erik Pedersen
cafb784799 Add emoji support
This uses the Emoji map from https://github.com/kyokomi/emoji -- but with a custom replacement implementation.

The built-in are fine for most use cases, but in Hugo we do care about pure speed.

The benchmarks below are skewed in Hugo's direction as the source and result is a byte slice,
Kyokomi's implementation works best with strings.

Curious: The easy-to-use `strings.Replacer` is also plenty fast.

```
BenchmarkEmojiKyokomiFprint-4  	   20000	     86038 ns/op	   33960 B/op	     117 allocs/op
BenchmarkEmojiKyokomiSprint-4  	   20000	     83252 ns/op	   38232 B/op	     122 allocs/op
BenchmarkEmojiStringsReplacer-4	  100000	     21092 ns/op	   17248 B/op	      25 allocs/op
BenchmarkHugoEmoji-4           	  500000	      5728 ns/op	     624 B/op	      13 allocs/op
```

Fixes #1891
2016-03-11 15:51:37 -06:00
Ján Koščo
be3519fac0 Use default sitemap configuration for homepage
Fixes #1304
2016-03-10 11:02:00 +01:00
Bjørn Erik Pedersen
924028a9be Fix for page in multiple menus
Fixes #1934
2016-03-10 10:31:12 +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
9896cd0030 Add reference to parent shortcode
Fixes #1936
2016-03-09 11:06:40 +01:00
Bjørn Erik Pedersen
c7acc318b5 Add some missing resets on rebuild
Fixes #1928
Fixes #1929
2016-03-06 16:33:32 +01:00
Bjørn Erik Pedersen
eaba04e82b Add list support in Scratch 2016-03-06 15:44:17 +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
Bjørn Erik Pedersen
8aa90f2b7e Try both prepped and unprepped taxonomy keys
Fixes #1869
2016-03-03 22:01:09 +01:00
Bjørn Erik Pedersen
ccd2f4c32b Prevent capitalized taxonomy labels
Fixes #1880
2016-03-03 21:54:23 +01:00
Bjørn Erik Pedersen
7f682d7802 Fix shortcode handling in RST
Fixes #1904
2016-03-01 11:04:25 +01:00
Bjørn Erik Pedersen
6b922750f3 Revert "Create template clone for late template execution"
This reverts commit 93b04e67f6.
2016-02-28 12:15:33 +01:00
Bjørn Erik Pedersen
93b04e67f6 Create template clone for late template execution
Fixing some breaking blogs on Go 1.6

Fixes #1879
2016-02-28 11:51:51 +01:00
Bjørn Erik Pedersen
804603155f Check for the presence of pages before setting dates
See #1903
2016-02-27 23:25:41 +01:00
Bjørn Erik Pedersen
75cf324322 Set Date and Lastmod for main home page
Fixes #1903
2016-02-27 23:21:07 +01:00
Bjørn Erik Pedersen
455df10752 Optimize replaceShortcodeTokens
We can of course skip reading the entire byte slice again and again.

This was a slip in the original implementation; functionally the same,
but is slightly faster, esp. for larger data sets with many shortcodes:

```
benchmark                             old ns/op     new ns/op     delta
BenchmarkReplaceShortcodeTokens-4     15505         14753         -4.85%

benchmark                             old allocs     new allocs     delta
BenchmarkReplaceShortcodeTokens-4     1              1              +0.00%

benchmark                             old bytes     new bytes     delta
BenchmarkReplaceShortcodeTokens-4     3072          3072          +0.00%
```
2016-02-25 23:50:43 +01:00
Bjørn Erik Pedersen
8375995378 Enlarge data in BenchmarkReplaceShortcodeTokens 2016-02-25 21:45:13 +01:00
Tatsushi Demachi
e9853642e5 Listen channel before sending values to it
The 'results' channel is not listend before sending error values in a
loop checking IsRenderable or not. This fixes it.
2016-02-20 14:03:06 +09:00
Bjørn Erik Pedersen
50182cd06b Remove superfluous Errorf 2016-02-16 02:05:59 +01:00
Derek Perkins
bac1ba4655 Fix spelling and go vet errors 2016-02-13 19:08:48 +08: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
05c8bccf84 hugolib: Add test for parseSitemap 2016-02-07 15:56:56 +01:00
Bjørn Erik Pedersen
0f6c8439b9 Add missing menu tests 2016-02-07 13:43:42 +01:00
Bjørn Erik Pedersen
c462440dcd Add Page tests for simple methods 2016-02-07 13:32:08 +01:00
Bjørn Erik Pedersen
66570d2fb3 Add Node tests for simple methods 2016-02-07 13:18:16 +01:00
Bjørn Erik Pedersen
75044c199f Add menu sort tests 2016-02-07 12:34:43 +01:00
Bjørn Erik Pedersen
7c3dceeaed Fix buggy Menu.Limit() 2016-02-06 22:53:59 +01:00
Bjørn Erik Pedersen
a95426d40c Remove Printf in test 2016-02-06 22:19:58 +01:00
Bjørn Erik Pedersen
88a320fb2d Fix buggy Pages.Limit
Also add missing page sort related tests.
2016-02-06 22:10:36 +01:00
Bjørn Erik Pedersen
318a984526 Apply gofmt -s 2016-02-06 13:09:52 +01:00
Tatsushi Demachi
68e2e63d92 Fix Hugo hang up with empty content directory
Site.ReadPagesFromSource returns nil chan error value when a site
content directory is empty but its receiver expects to be passed
something error values via the channel.

This fixes it by returning a channel which will be immediately closed.

Fix #1797
2016-02-03 08:19:02 +09:00
Anthony Fok
57eebbf243 Use FEEDBACK instead of ERROR for empty home page warning
jww.ERROR.Println() seems to have become too verbose,
making the warning message intended for new users
a lot less readable.
2016-01-30 17:39:17 +08:00
Bjørn Erik Pedersen
5def6d9aee Make the watch logger less chatty 2016-01-28 15:33:41 +01:00
Steve Francia
d08e4c87a7 Rewrite commentary on static event handling 2016-01-26 14:56:42 -05:00
Steve Francia
9413cf8499 Handle self rename operations gracefully 2016-01-26 14:33:08 -05:00
Steve Francia
7e196a8294 Handle remove & rename source operations incrementally 2016-01-26 14:30:28 -05:00
Steve Francia
e01c340915 A single file can be replaced in site.Files 2016-01-26 14:29:37 -05:00
Steve Francia
45e5091428 Process only the source content that has changed 2016-01-26 14:28:53 -05:00
Steve Francia
9f3796a31d Read/reread individual source content files
next is incremental conversion
2016-01-26 14:26:23 -05:00
Steve Francia
ca6ca4f4fc Separate handling content, data and template changes
Data & Templates reading independently
Need to work on page source reading and other source files
2016-01-26 14:25:39 -05:00
Steve Francia
bcc42c0549 Separate reading source and processing source operations 2016-01-25 14:41:47 -05:00
Bjørn Erik Pedersen
3526afc773 Fix some Go vet errors 2016-01-16 00:28:48 +01:00
Bjørn Erik Pedersen
78f9bf2444 Add one more menu test
See #1774
2016-01-14 17:30:05 +01:00
Bjørn Erik Pedersen
ab70e6f52f Add menu test for external URL
See #1774
2016-01-14 15:14:21 +01:00