Commit Graph

177 Commits

Author SHA1 Message Date
Bjørn Erik Pedersen 254cd89c8e hugolob: A first incorporation of output types in rendering 2017-03-27 15:43:56 +02:00
Bjørn Erik Pedersen c4989c39f1 Add MediaType and a crude implementation
See #2828
2017-03-27 15:43:56 +02:00
Bjørn Erik Pedersen 2f2ea42c09 hugolib: Fix reloading corner cases for shortcodes
This commit fixes two different, but related issues:

1) Live-reload when a new shortcode was defined in the content file before the shortcode itself was created.
2) Live-reload when a newly defined shortcode changed its "inner content" status.

This commit also improves the shortcode related error messages to include the full path to the content file in question.

Fixes #3156
2017-03-11 20:21:06 +01:00
Albert Nigmatzianov 48120ccfd2 all: Fix some govet complaints 2017-03-09 14:18:12 +01:00
Albert Nigmatzianov 4bfa189031 hugolib: Remove unnecessary params
Found by github.com/mvdan/unparam
2017-03-08 12:28:56 +01:00
Anton Staaf 22c89dcb6c hugolib: Fix HugoSites.createMissingPages
Previously it would only check for existing KindTaxonomyTerm pages
if the taxonomy had any terms defined.  So for a taxonomy with no terms
but a taxonomy terms page it would generate a second empty terms page.
2017-03-04 21:37:52 +01:00
Bjørn Erik Pedersen 9671162a22 hugolib: Make sure that empty terms lists are still created
Fixes #2977
2017-03-01 17:07:38 +01:00
Bjørn Erik Pedersen c1425a166d hugolib: Fix preserveTaxonomyNames regression
Fixes #3070
2017-02-23 10:09:42 +01:00
Bjørn Erik Pedersen 13972d6c83 hugolib: Cleanup the Goroutine count calculation 2017-02-21 18:56:56 +01:00
bogem 7e0fa13faa Get rid of some viper.Get* calls
Enforce usage of PathSpec

Fixes #3060
Updates #2728
2017-02-20 08:10:13 +01:00
Bjørn Erik Pedersen 6d2281c8ea hugolib: Add disableKinds option
Fixes #2534
2017-02-18 22:53:23 +01:00
Bjørn Erik Pedersen 4493e8ed9f hugolib: Fix issue with taxonomies when only some have content page
Fixes #2992
2017-02-18 08:37:11 +01:00
Bjørn Erik Pedersen 77cbe4d60b tplimpl: Refactor imageConfig into a struct
Updates #2701
2017-02-17 17:15:26 +01:00
Bjørn Erik Pedersen c507e2717d tpl: Refactor package
Now:

* The template API lives in /tpl
* The rest lives in /tpl/tplimpl

This is bound te be more improved in the future.

Updates #2701
2017-02-17 17:15:26 +01:00
Bjørn Erik Pedersen 93ca7c9e95 all: Refactor to nonglobal Viper, i18n etc.
This is a final rewrite that removes all the global state in Hugo, which also enables
the use if `t.Parallel` in tests.

Updates #2701
Fixes #3016
2017-02-17 17:15:26 +01:00
Bjørn Erik Pedersen c71e1b106e all: Refactor to nonglobal file systems
Updates #2701
Fixes #2951
2017-02-04 11:37:25 +07:00
Bjørn Erik Pedersen d6000a208c all: Refactor to nonglobal template handling
Updates #2701
2017-01-10 01:36:59 +01:00
Bjørn Erik Pedersen 45e3ed517a all: Refactor to non-global logger
Note that this looks like overkill for just the logger, and that is correct,
but this will make sense once we start with the template handling etc.

Updates #2701
2017-01-07 17:06:35 +01:00
magikstm 01ee525f47 hugolib: Correct usage of "shortcode" in error messages 2017-01-05 15:40:28 +01:00
Bjørn Erik Pedersen bcb3ef7413 hugolib: Fix preserveTaxonomyNames regressions
Fixes #2809
2016-12-28 13:44:55 +01:00
Bjørn Erik Pedersen 88b5bbd532 hugolib: Fix IsTranslated for "old" node types
The new logic for creating Page objects from old node types
didn't include itself in the translation logic, so
`IsTranslated` returned falsely false for sites with only two languages.

The `AllTranslations` method also returned too few pages in that case.

This commit fixes that.

Fixes #2812
2016-12-27 12:01:54 +01:00
Bjørn Erik Pedersen 15622c80ee hugolib: Remove superfluous assignment 2016-12-02 16:09:18 +01:00
Bjørn Erik Pedersen 2f026ab3f3 hugolib: Make RawContent raw again
This was a regression introduced in Hugo 0.17.

Fixes #2601
2016-12-01 17:29:49 +01:00
Bjørn Erik Pedersen 4360452001 hugolib: Simplify 2016-11-23 18:32:17 +01:00
Bjørn Erik Pedersen 0a0db9cd25 hubolib: Simplify map range 2016-11-23 16:46:16 +01:00
Bjørn Erik Pedersen ff2498ee89 Remove ShowPlan
It is out of sync with reality, has some disabled tests, and the cost
of getting it up-to-date is too high to be worth it.
2016-11-23 16:35:49 +01:00
Bjørn Erik Pedersen 0eb5f54d30 node to page: Fix site pages sort
Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen 976f8f84bf node to page: Fixe index page translation issues
Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen a843d5d3bb node to page: Final TODO-fixes
Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen 99d11386a7 node to page: Fix the Page copy()
By embeding the init sync.Once var in a pointer so we can reset it when we copy the page.

Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen 62e9e7e6ba node to page: Misc. TODO-fixes
Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen c8d3124dde node to page: Remove Node
And misc. TODO-fixes

Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen 9347084d61 node to page: Make Kind a string
Having a custom string type isn't worth it when it doesn't work
with `where`, `eq` etc.

Fixes #2689
Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen 9fba2a30a9 node to page: Rename PageType to Kind
And embed that on Page.

Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen 487b210fb8 node to page: Handle Date and Lastmod
Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen c80308e6b3 node to page: Add Pages to Page
As an alias to .Data.Pages for home page etc.

Also renamte NodeType to PageType and make it a string so it can be used in `where`.

Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen 063b78d2ec node to page: Make Nodes into Pages
* `.Site.Pages` now contains all page types, including sections etc.
* `.Data.Pages` will also contain "node type" pages where relevant.

Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen 88972b0d5b node to page: Refactor the build process
To make it easier to follow and understand.

Both building and rebuilding now follow a four step flow:

1. Init
2. Process
3. Assemble
4. Render

And now there are only one Build method, used for both builds and rebuilds.

Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen d3d3863c05 node to page: Add all nodes to sitemap
Updates #2297
Fixes #1303
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen 7cc637e97a node to page: Do not create section node for root
Because that will overwrite the home page, which is bad.

Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen 503fb29953 node to page: Get Rebuild up to speed
Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen 94ea12ebcf node to page: Remove unused code
Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen bde1bfd34a node to page: Handle aliases, 404, robots.txt, sitemap
Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen ec2d502b4f node to page: Handle translations
Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen 698b994f71 node to page: Fix the page collections
Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen 3ff25b37a3 node to page: Handle RSS
Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen 75c38071d8 node to page: Create pages for nodes without content
Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen 3737c9bcb3 node to page: Handle taxonomy lists
Updates #2297
2016-11-22 09:57:03 +01:00
Bjørn Erik Pedersen e371ac0b6f node to page: Basic outline
Updates #2297
2016-11-22 09:57:03 +01:00
Tristan Rice a49f838cd0 tpl: Add imageConfig function
Add imageConfig function which calls image.DecodeConfig and returns the height, width and color mode of the image. (#2677)

This allows for more advanced image shortcodes and templates such as those required by AMP.

layouts/shortcodes/amp-img.html
```
{{ $src := .Get "src" }}
{{ $config := imageConfig (printf "/static/%s" $src) }}

<amp-img src="{{$src}}"
           height="{{$config.Height}}"
           width="{{$config.Width}}"
           layout="responsive">
</amp-img>
```
2016-11-16 13:00:45 +01:00
Bjørn Erik Pedersen e8380e612f Add GitInfo
This commit adds a `GitInfo` object to `Page` if `EnableGitInfo` is set.

It then also sets `Lastmod` for the given `Page` to the author date provided by Git.

The Git integrations should be fairly performant, but it adds "some time" to the build, somewhat depending on the Git history size.

If you want, you can run without during development and turn it on when deploying to the live server: `hugo --enableGitInfo`.

Fixes #2102
2016-11-01 23:04:12 +01:00
Joonatan Saarhelo 89e3125664 Get rid of the rawContentCopy field of the Page struct
It is not needed, because it is only used to store temporary data during `preparePagesForRender`.
2016-10-25 20:40:32 +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
Luca Corbatto d9f54a13c1 Handle ToC before handling shortcodes
Fixes #2433
2016-10-24 14:40:57 +02:00
Bjørn Erik Pedersen 67df33d83f Fix a more summary corner case
Also refactor the rendering pages test to accept more than one page source per test run, which wasn't really needed for this issue, but may be in the future.

Closes #2586
Fixes #2538
2016-10-18 08:43:44 +02:00
Bjørn Erik Pedersen 63a6da06d8 Make multilingual respect DisableSitemap
Fixes #2485
2016-09-23 10:30:55 +02: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 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 bbfebdea43 Fix Data in multisites
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 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 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 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 b6fcb3d0bb Add sitemap index for multilingual sites
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