Commit graph

521 commits

Author SHA1 Message Date
Bjørn Erik Pedersen 91ab455d84
tpl: Remove some "debug info"
See #4881
2018-06-26 11:33:12 +02:00
Bjørn Erik Pedersen ca1e46efb9
tpl: Update internal pagination template to support Bootstrap 4
Fixes #4881
2018-06-26 11:31:46 +02:00
Anthony Fok 3d5928889a
Revert "tpl: Support text/template/parse API change in go1.11"
Go developers have undone the breaking API changes
in the following commit:

commit bedfa4e1c37bd08063865da628f242d27ca06ec4
Author: Daniel Theophanes <kardianos@gmail.com>
Date:   Thu Jun 21 10:41:26 2018 -0700

    text/template/parse: undo breaking API changes

    golang.org/cl/84480 altered the API for the parse package for
    clarity and consistency. However, the changes also broke the
    API for consumers of the package. This CL reverts the API
    to the previous spelling, adding only a single new exported
    symbol.

    Fixes #25968

    Change-Id: Ieb81054b61eeac7df3bc3864ef446df43c26b80f
    Reviewed-on: https://go-review.googlesource.com/120355
    Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
    Reviewed-by: Rob Pike <r@golang.org>
    Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
    TryBot-Result: Gobot Gobot <gobot@golang.org>

See https://github.com/golang/go/issues/25968

This reverts commit 9f27091e10.

Closes #4784
Fixes #4873
2018-06-23 15:07:52 -06:00
Anthony Fok 9f27091e10 tpl: Support text/template/parse API change in go1.11
Thanks to @rjoleary for the investigation.

Fixes #4784
2018-06-14 08:58:42 +02:00
Bjørn Erik Pedersen 80230f26a3
Add support for theme composition and inheritance
This commit adds support for theme composition and inheritance in Hugo.

With this, it helps thinking about a theme as a set of ordered components:

```toml
theme = ["my-shortcodes", "base-theme", "hyde"]
```

The theme definition example above in `config.toml` creates a theme with the 3 components with presedence from left to right.

So, Hugo will, for any given file, data entry etc., look first in the project, and then in `my-shortcode`, `base-theme` and lastly `hyde`.

Hugo uses two different algorithms to merge the filesystems, depending on the file type:

* For `i18n` and `data` files, Hugo merges deeply using the translation id and data key inside the files.
* For `static`, `layouts` (templates) and `archetypes` files, these are merged on file level. So the left-most file will be chosen.

The name used in the `theme` definition above must match a folder in `/your-site/themes`, e.g. `/your-site/themes/my-shortcodes`. There are  plans to improve on this and get a URL scheme so this can be resolved automatically.

Also note that a component that is part of a theme can have its own configuration file, e.g. `config.toml`. There are currently some restrictions to what a theme component can configure:

* `params` (global and per language)
* `menu` (global and per language)
* `outputformats` and `mediatypes`

The same rules apply here: The left-most param/menu etc. with the same ID will win. There are some hidden and experimental namespace support in the above, which we will work to improve in the future, but theme authors are encouraged to create their own namespaces to avoid naming conflicts.

A final note: Themes/components can also have a `theme` definition in their `config.toml` and similar, which is the "inheritance" part of this commit's title. This is currently not supported by the Hugo theme site. We will have to wait for some "auto dependency" feature to be implemented for that to happen, but this can be a powerful feature if you want to create your own theme-variant based on others.

Fixes #4460
Fixes #4450
2018-06-10 23:55:20 +02:00
Christian Oliff 2e6712e281 tpl: Always load GA script over HTTPS 2018-06-09 23:47:44 +02:00
Alexandros 65deb72dc4 tplimpl: Remove speakerdeck shortcode
Fixes #4830
2018-06-09 11:13:36 +02:00
David E. Wheeler 019bd5576b tpl/strings: strings.RuneCount 2018-06-04 20:47:03 +03:00
Anthony Fok c3115292a7 tpl: Prevent isBaseTemplate() from matching "baseof" in dir
Fixes #4809
2018-06-04 10:09:55 +03:00
Bjørn Erik Pedersen 0c6c98e401
tpl/strings: Remove overflow check in strings.Repeat
The test fails on 32 bit systems. Let it panic instead.
2018-06-03 23:23:48 +03:00
Bjørn Erik Pedersen 90c7749085
tpl/strings: Adjust the overflow validation in strings.Repeat
This now matches the validation in the stdlib, but we return an error instead.
2018-06-03 10:35:45 +03:00
David E. Wheeler 13435a6f60 tpl: Add strings.Repeat 2018-06-03 09:55:37 +03:00
Alex 07b96d16e8 Fixes #4798 2018-05-31 18:05:38 +02:00
Alex ceaff7cafc tpl: Remove frameborder attr YT iframe + CSS fixes 2018-05-30 14:06:32 +02:00
Alex b84389c5e0 Fix vimeo_simple thumb scaling 2018-05-30 11:30:28 +02:00
Alexandros 8de5324479 Add vimeo_simple
Fixes #4749
2018-05-30 00:48:36 +02:00
Alex d68367cbe7 fix typo instagram_simple 2018-05-27 11:06:40 +02:00
Bjørn Erik Pedersen 4ed1228d55
Fix GA anonymizeIp order 2018-05-25 16:05:45 +02:00
Bjørn Erik Pedersen a51945ea4b Add no-cookie variants of the Google Analytics templates
The current full set of options for GA is now:

```toml
[privacy]
[privacy.googleAnalytics]
disable = false
respectDoNotTrack = true
anonymizeIP = true
useSessionStorage = true
```

Fixes #4775
2018-05-25 15:56:10 +02:00
Bjørn Erik Pedersen 0bf0e1972d
tpl: Remove the shortcode assets for now
Not in use.
2018-05-25 14:34:40 +02:00
Bjørn Erik Pedersen 1f244b802e
tpl: Adjust instagram_simple margins 2018-05-25 12:38:25 +02:00
Bjørn Erik Pedersen 448081b840
Remove youtube_simple for now
We need to revisit and complete that.

See #4751
2018-05-25 11:16:23 +02:00
Bjørn Erik Pedersen 1f1d955b56
Add anonymizeIP to GA privacy config
See #4751
2018-05-25 10:53:39 +02:00
Bjørn Erik Pedersen ffcf26e68c
Fix broken test 2018-05-24 13:03:23 +02:00
Bjørn Erik Pedersen 9753cb59f1
Support DNT in Twitter shortcode for GDPR
Fixes #4765
2018-05-24 12:25:52 +02:00
Bjørn Erik Pedersen 3bfe8f4be6
tpl: Alias tweet shortode to twitter
See #4765
2018-05-24 11:40:47 +02:00
Bjørn Erik Pedersen 6aa2c38507
Regenerate embedded templates
See #4761
2018-05-23 21:25:04 +02:00
Alexandros 6d69dac9da Fix youtube_simple thumb scaling
Fixes #4761
2018-05-23 21:22:25 +02:00
Bjørn Erik Pedersen 9ad46a2035 Add instagram_simple shortcode
Fixes #4748
2018-05-23 16:52:08 +02:00
Bjørn Erik Pedersen bed7a0faff
Remove the id from youtube_simple
For now, anyway.

See #4751
2018-05-23 10:24:01 +02:00
Bjørn Erik Pedersen 35ccf06dae
Fix some recently broken embedded templates
And add tests for them.

Fixes #4757
2018-05-23 10:03:11 +02:00
Bjørn Erik Pedersen 353148c2bc Move the privacy config into a parent
See #4751
2018-05-22 18:11:03 +02:00
Bjørn Erik Pedersen 14705ecead
tpl: Add another class and an id to youtube_simple
To provide some more styling options.

See #4616
2018-05-22 09:11:34 +02:00
Bjørn Erik Pedersen 69ee6b41e3
Make the simple mode YouTube links schemaless
See #4616
2018-05-21 22:25:04 +02:00
Bjørn Erik Pedersen 88e3568680 Add YouTube shortcode simple mode
Adapted from the work of @onedrawingperday.

See #4616
2018-05-21 21:56:42 +02:00
Bjørn Erik Pedersen 5f24a2c047 Add PrivacyEnhanced mode for YouTube to the GDPR Policy
See #4616
2018-05-21 16:49:00 +02:00
Bjørn Erik Pedersen 710142016b Add RespectDoNotTrack to GDPR privacy policy for Google Analytics
See #4616
2018-05-21 13:16:43 +02:00
Bjørn Erik Pedersen f45b522ebf
tpl/tplimpl: Adjust GA templates
See #4616
2018-05-21 10:21:36 +02:00
Bjørn Erik Pedersen 6789207347 tpl/tplimpl/embedded: Wrap the relevant templates with the privacy policy disable check
See #4616
2018-05-21 00:41:42 +02:00
Bjørn Erik Pedersen c2bb62d63e
tpl/tplimpl: Move README one level up 2018-05-05 11:00:39 +02:00
Bjørn Erik Pedersen 34ad9a4f17
tpl/tplimpl: Extract internal templates
Having them in separate files should make maintainance easier.

When adding new or making changes to the templates:

```bash
mage generate
```

This will get the Go code in sync.

Fixes #4457
2018-05-04 23:12:10 +02:00
Bjørn Erik Pedersen 47e7788b3c tpl/path: Add path.Ext, path.Dir and path.Base 2018-04-22 10:57:37 +02:00
Bjørn Erik Pedersen 51af1d2ead
tpl/os: Make fileExist use the same filesystem as readFile
Fixes #4633
2018-04-21 23:46:34 +02:00
Lucas Liberacki 5cc944ffd7 Updated GetCSV error message (#4636) 2018-04-17 07:20:14 +02:00
Bjørn Erik Pedersen 4dba6ce15a
tpl/urls: Add anchorize template func 2018-04-15 23:17:50 +02:00
Bjørn Erik Pedersen 880ca19f20 tpl/path: Add path.Join 2018-04-15 22:19:12 +02:00
Bjørn Erik Pedersen 01b72eb592 tpl: Add path.Split template func 2018-04-15 22:19:12 +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
Bjørn Erik Pedersen 61f6e9f63b
tpl/transform: Add a comments test for Remarshal
See #4521
2018-03-20 18:23:32 +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