Commit graph

1275 commits

Author SHA1 Message Date
Bjørn Erik Pedersen 417c5e2b67 Make Page.Content a method that returns interface{}
To prepare for a `Resource.Content` method.

See #4622
2018-04-15 18:08:06 +02:00
Bjørn Erik Pedersen f3775877c6
hugolib: Fix livereload of bundled pages
Fixes #4607
2018-04-12 12:19:46 +02:00
Bjørn Erik Pedersen 14c35c8a56
Allow "*/" inside commented out shortcodes
Fixes #4608
2018-04-11 22:41:48 +02:00
Bjørn Erik Pedersen 080302eb87
Fix handling of --contentDir etc. flag
We need to revisit the commands package re globals and tests, but this should fix the init order of flags and languages.

Fixes #4589
2018-04-07 16:40:45 +02:00
Anthony Fok e84b7ade65
Revert "Disable failing test on Travis"
This reverts commit 2170943ae6
and commit 623c9afa84.
2018-04-07 06:53:47 -06:00
Bjørn Erik Pedersen 623c9afa84
And now really disable failing test on Travis
See #4584
2018-04-06 18:14:11 +02:00
Bjørn Erik Pedersen 2170943ae6
Disable failing test on Travis
See #4584
2018-04-06 17:31:13 +02:00
Bjørn Erik Pedersen 6792d86ad0
hugolib: Set .Parent in bundled pages to its owner
Fixes #4582
2018-04-06 10:41:28 +02:00
Bjørn Erik Pedersen f87239e4ca
Fix livereload for the home page bundle
Fixes #4576
2018-04-05 18:03:33 +02:00
Bjørn Erik Pedersen a4deaeff0c
Fix some livereload content regressions
Introduced in Hugo 0.38.

Fixes #4566
2018-04-05 14:28:45 +02:00
Brian Fitzgerald 26f34fd59d Fix two tests that are broken on Windows
Put guards around TestPageBundlerCaptureSymlinks and
TestPageBundlerSiteWitSymbolicLinksInContent so that they aren't
run on Windows (they both use symbolic links and the Go library
implementation requires administrator mode on Windows).
2018-04-05 08:35:06 +02:00
Bjørn Erik Pedersen eb42774e58
Add support for a content dir set per language
A sample config:

```toml
defaultContentLanguage = "en"
defaultContentLanguageInSubdir = true

[Languages]
[Languages.en]
weight = 10
title = "In English"
languageName = "English"
contentDir = "content/english"

[Languages.nn]
weight = 20
title = "På Norsk"
languageName = "Norsk"
contentDir = "content/norwegian"
```

The value of `contentDir` can be any valid path, even absolute path references. The only restriction is that the content dirs cannot overlap.

The content files will be assigned a language by

1. The placement: `content/norwegian/post/my-post.md` will be read as Norwegian content.
2. The filename: `content/english/post/my-post.nn.md` will be read as Norwegian even if it lives in the English content folder.

The content directories will be merged into a big virtual filesystem with one simple rule: The most specific language file will win.
This means that if both `content/norwegian/post/my-post.md` and `content/english/post/my-post.nn.md` exists, they will be considered duplicates and the version inside `content/norwegian` will win.

Note that translations will be automatically assigned by Hugo by the content file's relative placement, so `content/norwegian/post/my-post.md` will be a translation of `content/english/post/my-post.md`.

If this does not work for you, you can connect the translations together by setting a `translationKey` in the content files' front matter.

Fixes #4523
Fixes #4552
Fixes #4553
2018-04-02 08:06:21 +02:00
Ricardo N Feliciano 1823c053c8 Add .Site.IsServer
Fixes #4478
2018-03-30 20:15:22 +02:00
Bjørn Erik Pedersen 93e24a03ce
hugolib: Fix freeze in invalid front matter error case
Fixes #4526
2018-03-24 10:06:58 +01:00
Bjørn Erik Pedersen e9c7b6205f
Allow themes to define output formats, media types and params
This allows a `config.toml` (or `yaml`, ´yml`, or `json`)  in the theme to set:

1) `params` (but cannot override params in project. Will also get its own "namespace", i.e. `{{ .Site.Params.mytheme.my_param }}` will be the same as `{{ .Site.Params.my_param }}` providing that the main project does not define a param with that key.
2) `menu` -- but cannot redefine/add menus in the project. Must create its own menus with its own identifiers.
3) `languages` -- only `params` and `menu`. Same rules as above.
4) **new** `outputFormats`
5) **new** `mediaTypes`

This should help with the "theme portability" issue and people having to copy and paste lots of setting into their projects.

Fixes #4490
2018-03-21 09:22:19 +01:00
Bjørn Erik Pedersen 3d1a6e109c
hugolib: Add ConfigSourceDescriptor
To prepare for config in themes

See #4490
2018-03-20 21:30:43 +01:00
Bjørn Erik Pedersen da88015776
Spring test cleaning, take 2 2018-03-18 09:54:32 +01:00
Bjørn Erik Pedersen debd3663dd hugolib: Test cleaning #1 2018-03-17 18:59:07 +01:00
Bjørn Erik Pedersen af67ad8af1 hugolib: Trim some now superflous tests
These were written as a development aid in some kind of structural change at some point.

They served their purpose then, but these are tests covered elsewhere and is deleted to reduce maintainance.

The reported test covrage is not reduced because of this.
2018-03-17 18:59:07 +01:00
cmal e46ab29bd2 hugolib: Add Reset method to delete key from Scratch 2018-03-17 00:13:23 +01:00
Bjørn Erik Pedersen ffaec4ca8c
Add a way to merge pages by language
As an example:

```html
{{ $pages := .Site.RegularPages | lang.Merge $frSite.RegularPages | lang.Merge $enSite.RegularPages }}
```

Will "fill in the gaps" in the current site with, from left to right, content from the French site, and lastly the English.

Fixes #4463
2018-03-16 10:10:01 +01:00
Bjørn Erik Pedersen e427ba4268
hugolib: Remove superflous debug file 2018-03-12 23:36:20 +01:00
Bjørn Erik Pedersen 79dd7cb31a
hugolib: Simplify Prev/Next 2018-03-12 22:13:25 +01:00
Bjørn Erik Pedersen f12ad7d56a
hugolib: Adjust GitInfo author date test
Now that we have a commit to assert against.

See #4495
2018-03-11 21:32:15 +01:00
Bjørn Erik Pedersen ce6e4310fe
Refactor the GitInfo into the date handlers
Fixes #4495
2018-03-11 21:32:05 +01:00
Bjørn Erik Pedersen 68bf1511f2
hugolib: Extract date and slug from filename
This commit makes it possible to extract the date from the content filename. Also, the filenames in these cases will make for very poor permalinks, so we will also use the remaining part as the page `slug` if that value is not set in front matter.

This should make it easier to move content from Jekyll to Hugo.

To enable, put this in your `config.toml`:

```toml
[frontmatter]
date  = [":filename", ":default"]
```

This commit is also a spring cleaning of how the different dates are configured in Hugo. Hugo will check for dates following the configuration from left to right, starting with `:filename` etc.

So, if you want to use the `file modification time`, this can be a good configuration:

 ```toml
[frontmatter]
date = [ "date",":fileModTime", ":default"]
lastmod = ["lastmod" ,":fileModTime", ":default"]
```

The current `:default` values for the different dates are

```toml
[frontmatter]
date = ["date","publishDate", "lastmod"]
lastmod = ["lastmod", "date","publishDate"]
publishDate = ["publishDate", "date"]
expiryDate = ["expiryDate"]
```

The above will now be the same as:

```toml
[frontmatter]
date = [":default"]
lastmod = [":default"]
publishDate = [":default"]
expiryDate = [":default"]
```

Note:

* We have some built-in aliases to the above: lastmod => modified, publishDate => pubdate, published and expiryDate => unpublishdate.
* If you want a new configuration for, say, `date`, you can provide only that line, and the rest will be preserved.
* All the keywords to the right that does not start with a ":" maps to front matter parameters, and can be any date param (e.g. `myCustomDateParam`).
* The keywords to the left are the **4 predefined dates in Hugo**, i.e. they are constant values.
* The current "special date handlers" are `:fileModTime` and `:filename`. We will soon add `:git` to that list.

Fixes #285
Closes #3310
Closes #3762
Closes #4340
2018-03-11 18:26:18 +01:00
Bjørn Erik Pedersen f8dc47eeff Allow partial redefinition of the ouputs config
Fixes #4487
2018-03-10 16:57:25 +01:00
Bjørn Erik Pedersen e7fda289b1
Remove defaultLayout config
Not in use.
2018-03-01 17:19:49 +01:00
Bjørn Erik Pedersen 9f740b37cf
hugolib: Fix paginator URL for sections with URL in front matter
Fixes #4415
2018-02-26 17:45:51 +01:00
Bjørn Erik Pedersen e39797fa72
hugolib: Avoid scanning entire site to find the home
See #4447
2018-02-25 10:50:44 +01:00
Vas Sudanagunta 00868081f6 Fix bug in Site.assembleSections method
Site.assembleSections logic assumes that the the home page would always be the first in the Site's list of pages. This is not in fact guaranteed to be true. When it is not, the method can fail to set the parent for some or all root-level pages. 

Fixes #4447
2018-02-25 10:34:24 +01:00
Bjørn Erik Pedersen e9750d831f
hugolib: Continue GitInfo lookup on error
The current logic stops looking after the first failure to connect a page with a Git commit. This implies a fatal error, but that may not be the case.
2018-02-22 17:21:09 +01:00
Bjørn Erik Pedersen 0602135fd4
Make ge, le etc. work with the Hugo Version number
This means that you can do something ala:

```html
{{ if ge .Hugo.Version "0.36" }}Reasonable new Hugo version!{{ end }}
```

The intented use is feature toggling, but please note that it will take some time and Hugo versions until this can be trusted. It does not work in older Hugo versions.

Fixes #4443
2018-02-22 09:15:12 +01:00
Bjørn Erik Pedersen 772128485a Run gofmt -s with Go 1.10
See #4434
2018-02-21 09:59:33 +01:00
Bjørn Erik Pedersen c2c4cb1f9f
hugolib: Fix broken footnote test
See #4433
2018-02-21 09:25:32 +01:00
Bjørn Erik Pedersen 4edb4bcc65
hugolib: Improve error message in .Render 2018-02-13 09:01:47 +01:00
Vas Sudanagunta 1fa2417777 Add support for YAML array data files
* Unmarshaled YAML arrays indistinguishable from JSON arrays.
* Fixes #3890
2018-02-12 17:14:40 +01:00
Vas Sudanagunta bb549a0d57 Account for array type data in data dir merge/override logic
* Fixes #4366

* Error message to console for unsupported data types
2018-02-12 17:14:40 +01:00
Vas Sudanagunta 82eefded13 hugolib: Refactor tests for JSON, YAML and TOML equivalency, add coverage
The same code now cycles through equivalent JSON, YAML and TOML data sets,
verifying output both proper and identical. Coverage increased by applying
previous tests for one format to the others.

More DRY. Added tests for numeric and bool value types.
2018-02-12 17:14:40 +01:00
Vas Sudanagunta e172834993 hugolib: Re-enable YAML data tests disabled in f554503f
Also gave basic tests for JSON, YAML and TOML identical inputs and expected outputs, a step toward JSON, YAML and TOML equivalency (see https://github.com/gohugoio/hugo/issues/4393#issuecomment-364437785).
2018-02-12 17:14:40 +01:00
Kaushal Modi 2e95ec6844 Add "target" and "rel" parameters to figure shortcode
Also:

- Remove unnecessary space from `figure` tag if no class is specified.
  - Update related tests.
- Add test cases for the changes made to the figure shortcode.
- Document the newly added target and rel parameters
- Add more detail to the documentation of all figure shortcode parameters.
2018-02-09 22:27:58 +01:00
Bjørn Erik Pedersen f554503fef
hugolib: Temp. disable some YAML data tests
They fail.

We will have to think about this.

See #4393
2018-02-09 12:32:45 +01:00
Cameron Moore fc06d5c18b hugolib: Add additional test to TestTemplateLookupOrder
Add an additional test to "Variant 4, theme, use site base" to also test
for the index.html base (from by testing of #3505).  Also add a "name"
field to the test cases to make it easier to know which test is failing
versus just getting a slice index.
2018-02-05 08:38:04 +01:00
Cameron Moore 9a367d9d06 hugolib: Fix broken TestTemplateLookupOrder
It looks like we left some debugging code in place that caused all but
one test case to run.
2018-02-05 08:38:04 +01:00
Vas Sudanagunta 4402c07775 Fix JSON array-based data file handling regression
This bug was introduced in Hugo 0.35.

Fixes #4361
2018-02-02 09:14:37 +01:00
Vas Sudanagunta 4743de0d3c Increase data directory test coverage
*  Adds retro-coverage for #4361
*  Verifies open issues #4138, #3890, #4366, 4083
*  Removes test reliance on the very code it is testing (hugo/parser package).
   Expected results are now all built manually / are more precise.
   Tests can run against different versions (no linkage errs)
2018-02-02 09:14:37 +01:00
Bjørn Erik Pedersen ae742cb1bd Fix language params handling
This fixes some issues with language params handling by separating params from configuration values per language.

This means that you can now do this:

```toml
[languages]
[languages.en]
languageName = "English"
weight = 1
title = "My Cool Site"
[languages.en.params]
myParam = "Hi!"
```

This is not a breaking change, but the above is a less suprising way of configuring custom params.

It also fixes some hard-to-debug corner-cases in multilingual sites.

Fixes #4356
Fixes #4352
2018-01-30 18:53:07 +01:00
Bjørn Erik Pedersen 94e736c5e1
hugolib: Extract the Fast Render Mode logic into a method
This also improves on the previous commit as it takes pages without content files into account.

Closes #4339
2018-01-30 10:49:24 +01:00
Alexey Grachov 1707dae8d3
hugolib: Handle newly created files in Fast Render Mode
Updates #4339
2018-01-30 10:49:24 +01:00
Bjørn Erik Pedersen adfd4370b6
hugolib: Deprecate useModTimeAsFallback
Fixes #4351
2018-01-29 13:52:04 +01:00