Commit graph

217 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
Derek Perkins cf978c0649 Add First Class Author Support
Closes #1850
2016-09-17 00:49:24 +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
Mathias Biilmann 7d3dfba84b Prevent panic on empty authorlist 2016-09-11 10:46:56 +02: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 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 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 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 2079a23dd8 Make it possible to configure Blackfroday per language
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 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 c4e7c37055 Add Translations and AllTranslations methods to Page
Will revisit Node later.
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 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
Vincent Batoufflet eda3678742 Add automatic page date fallback
Closes #2239
2016-06-28 23:50:50 +02:00
Bjørn Erik Pedersen 8588103316 Unexport ShouldBuild and AssertShouldBuild 2016-06-14 15:53:49 +02:00
Hanchen Wang fb0c1350d4 hugolib: Handle unpecified date for IsFuture and IsExpired 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 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 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
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
Sven Dowideit 1648e327c0 Document and clean SourceRelativeLinksEval code 2016-04-07 20:10:38 +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 d770130530 hugolib: Remove unused Tmpl on Page 2016-03-24 18:34:41 +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 de8fc8761a Re-render shortcode on template or data file change
Fixes  #1971
2016-03-21 21:09:25 -04: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 924028a9be Fix for page in multiple menus
Fixes #1934
2016-03-10 10:31:12 +01:00
Steve Francia d08e4c87a7 Rewrite commentary on static event handling 2016-01-26 14:56:42 -05:00
Steve Francia 7e196a8294 Handle remove & rename source operations incrementally 2016-01-26 14:30:28 -05:00
Steve Francia 9f3796a31d Read/reread individual source content files
next is incremental conversion
2016-01-26 14:26:23 -05: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
Bjørn Erik Pedersen 8cea428802 Fix data race in non-renderable pages
Fixes #1601
2015-12-18 11:24:35 +01:00
Bjørn Erik Pedersen 9569d116cb Duplicate p.Description in Params map
Fixes #1484
2015-12-12 22:20:26 +01:00
Bjørn Erik Pedersen e445c35d6a Fix copyright headers in source files
Still need to add some missing headers and an AUTHORS file.

See #1646
2015-12-07 19:57:01 +01:00
Steve Francia f045d7a611 Change the license to Apache 2.0 2015-11-23 22:16:36 -05:00
Marek Janda 5838420aa1 Move blackfriday site-wide config loading to NewBlackFriday() 2015-11-23 17:35:36 +01:00
Bjørn Erik Pedersen b08d9f26ae Make replaceShortcodeTokens rewrite the input slice
Currently a `[]byte` copy is returned. In most cases this is the safe thing to do, but we should just modify/grow the slice as needed.

This is faster and consumes less memory:

```
benchmark                             old ns/op     new ns/op     delta
BenchmarkReplaceShortcodeTokens-4     7350          4419          -39.88%

benchmark                             old allocs     new allocs     delta
BenchmarkReplaceShortcodeTokens-4     5              1              -80.00%

benchmark                             old bytes     new bytes     delta
BenchmarkReplaceShortcodeTokens-4     4816          1152          -76.08%
```

This commit is aso a small spring cleaning of duplicated code in the different `PageConvert` methods.

Fixes #1516
2015-11-17 18:24:17 +01:00
Bjørn Erik Pedersen 5bda0398e7 Export Page.Layout
And at the same time rename and unexport the badly named `Layout()` func. That method is not very usable outside the package.

Fixes #1539
2015-11-02 17:24:50 +01:00
Bjørn Erik Pedersen 078fad49e2 Add Param(key) to Node and Page
This  is a convenience method to do lookups in Page's (Page only)  and Site's Params map (Page and Node), in that order.

Fixes #1462
2015-10-12 06:11:01 +02:00