Commit graph

273 commits

Author SHA1 Message Date
Bjørn Erik Pedersen 5109ed520f
Revert "tplimpl: Output xmlns:xhtml only if there are translations available"
This reverts commit 0859d9dfe6.

Fixes #3978
2017-10-17 20:56:50 +02:00
Bjørn Erik Pedersen e2e8bcbec3
tpl: Rework the partial test and benchmarks 2017-10-07 16:53:01 +02:00
Jamie Connolly 0859d9dfe6 tplimpl: Output xmlns:xhtml only if there are translations available 2017-10-03 23:46:18 +02:00
Bjørn Erik Pedersen b5e1dc5892 tpl: Set Metrics at creation time 2017-09-26 20:42:40 +02:00
Cameron Moore b4a14c25fe metrics: Add simple template metrics feature 2017-09-26 20:03:04 +02:00
Bjørn Erik Pedersen 0d29a0f781 Trim newlines in the hightlight shortcode
Fixes #3898
2017-09-23 18:14:07 +02:00
Bjørn Erik Pedersen 2d613dd905 tpl/tplimpl: Fix escaped HTML Go 1.9 multioutput issue (#3880)
Fixes #3876
2017-09-13 12:32:06 +02:00
oneleaftea 88e1bca92c Update template_embedded.go
Changed disqus urls from http to https. This fixes mixed content warnings on browsers when viewing Hugo websites over SSL (https).
2017-08-22 20:26:04 +02:00
Nic Raboy 919bc9210a Add an iFrame title to the YouTube shortcode
To accommodate modern web accessibility as outlined here https://dequeuniversity.com/tips/provide-iframe-titles
2017-08-12 00:36:40 +02:00
Jorin Vogel 81c13171a9 Add some missing doc comments
As pointed out by the linter, some exported functions and types are
missing doc comments.
The linter warnings have been reduced from 194 to 116.
Not all missing comments have been added in this commit though.
2017-08-03 15:57:51 +02:00
Bjørn Erik Pedersen 00b590d7ab Improve the twitter card template
Now fall back to `images` set in site config for twitter card.

Fixes #3711
2017-07-17 23:09:52 +02:00
Bruno Amaral da72805a43 tpl: Only show post's own keywords in schema.org
Fixes #2635
Closes #2646
2017-06-28 21:26:18 +02:00
Yihui Xie eccb064782 tpl: Simplify the Disqus template a little bit (#3655)
In accordance to the official guide: https://disqus.com/admin/universal/
2017-06-27 09:45:48 -06:00
Yihui Xie 2e1e4934b6 tpl: Improve the built-in Disqus template (#3639)
* Improve the built-in Disqus template

  Set `disqus_identifier`, `disqus_title`, and `disqus_url`
  only if the user has explicitly provided them.

  Do not load Disqus when the website is previewed locally,
  otherwise it is very confusing.

* Use disqus_config instead of three global variables

  https://help.disqus.com/customer/portal/articles/472098-javascript-configuration-variables
2017-06-27 05:40:01 -06:00
Bjørn Erik Pedersen 873a6f1885 Run gofmt to get imports in line vs gohugoio/hugo 2017-06-13 19:12:10 +02:00
Bjørn Erik Pedersen c17ad675e8 all: Update textual references in Go source to point to gohugoio/hugo 2017-06-13 18:47:17 +02:00
Bjørn Erik Pedersen d8717cd4c7 all: Update import paths to gohugoio/hugo 2017-06-13 18:42:45 +02:00
Bjørn Erik Pedersen b6ea492b7a tmplimpl: Add support for ellipsed paginator
Fixes #3466
2017-05-17 21:47:05 +03:00
Bjørn Erik Pedersen af72db806f hugolib: Handle shortcode per output format
This commit allows shortcode per output format, a typical use case would be the special AMP media tags.

Note that this will only re-render the "overridden" shortcodes and only  in pages where these are used, so performance in the normal case should not suffer.

Closes #3220
2017-05-13 22:44:15 +03:00
Bjørn Erik Pedersen 690b0f8ff5 tpl: Add docshelper for template funcs
And fix some other minor related issues.

Updates #3418
2017-05-01 21:44:15 +02:00
Bjørn Erik Pedersen 0e2260421e tpl: Fix the remaining template funcs namespace issues
See #3042
2017-05-01 15:13:41 +02:00
Bjørn Erik Pedersen 4714085a10 tpl/urls: Make it a package that stands on its own
See #3042
2017-05-01 15:13:41 +02:00
Bjørn Erik Pedersen 55f90a3a0d tpl/transform: Make it a package that stands on its own
See #3042
2017-05-01 15:13:41 +02:00
Bjørn Erik Pedersen ee5aa84f2a tpl/time: Make it a package that stands on its own
See #3042
2017-05-01 15:13:41 +02:00
Bjørn Erik Pedersen 4a3463463f tpl/safe: Make it a package that stands on its own
See #3042
2017-05-01 15:13:41 +02:00
Bjørn Erik Pedersen b958c0c109 tpl/os: Make it a package that stands on its own
See #3042
2017-05-01 15:13:41 +02:00
Bjørn Erik Pedersen fc77b6303c tpl/inflect: Make it a package that stands on its own
See #3042
2017-05-01 15:13:41 +02:00
Bjørn Erik Pedersen a432c90aee tpl/images: Make it a package that stands on its own
See #3042
2017-05-01 15:13:41 +02:00
Bjørn Erik Pedersen 9aee8ace4e tpl/encoding: Make it a package that stands on its own
See #3042
2017-05-01 15:13:41 +02:00
Bjørn Erik Pedersen 744dccbea4 tpl/crypto: Make it a package that stands on its own
See #3042
2017-05-01 15:13:41 +02:00
Bjørn Erik Pedersen 8a49c0b3b8 tpl/collections: Make it a package that stands on its own
See #3042
2017-05-01 15:13:41 +02:00
Bjørn Erik Pedersen a3bf118eaa tpl/compare: Make it a package that stands on its own
See #3042
2017-05-01 15:13:41 +02:00
Bjørn Erik Pedersen 6561557367 tpl/data: Make it a package that stands on its own
See #3042
2017-05-01 15:13:41 +02:00
Bjørn Erik Pedersen 0ab23eb5a8 tpl/strings: Make it a package that stands on its own
See #3042
2017-05-01 15:13:41 +02:00
Bjørn Erik Pedersen eefa0703cb tpl/math: Make it a package that stands on its own
See #3042
2017-05-01 15:13:41 +02:00
Bjørn Erik Pedersen c5373efcf0 tpl: Add TemplateFuncsNamespaceRegistry
As a first step to remove the hard ties between `tplimpl` and the different namespace packages.

The `lang` package is used as the first example use case.

See #3042
2017-05-01 15:13:41 +02:00
Cameron Moore de7c32a1a8 tpl: Add template function namespaces
This commit moves almost all of the template functions into separate
packages under tpl/ and adds a namespace framework.  All changes should
be backward compatible for end users, as all existing function names in
the template funcMap are left intact.

Seq and DoArithmatic have been moved out of the helpers package and into
template namespaces.

Most of the tests involved have been refactored, and many new tests have
been written.  There's still work to do, but this is a big improvement.

I got a little overzealous and added some new functions along the way:

- strings.Contains
- strings.ContainsAny
- strings.HasSuffix
- strings.TrimPrefix
- strings.TrimSuffix

Documentation is forthcoming.

Fixes #3042
2017-04-30 10:56:38 +02:00
Jack Taylor 90d3fbf1da tplimpl: Add translation links to the default sitemap template
For pages with translations, add links with hreflang attributes to the
default sitemap template. This helps Google to show the correct
language page in its search results. The syntax used is based on
Google's example at [1].

Also update the sitemap template docs to reflect the changes in the
default template.

[1]
https://support.google.com/webmasters/answer/2620865?hl=en&topic=2370587&ctx=topic

Fixes #2569
2017-04-22 22:37:14 +02:00
Bjørn Erik Pedersen 1cf29200b4 tplimpl: Allow text partials in HTML templates
Most obvius benefit of this is to include CSS partials with css file suffix into HTML templates.

A valid workaround would be to rename the file `mystyles.html`, but that doesn't work too good for external editors etc.

The css partial is  a method used in some themes before Hugo 0.20, but then it stopped working.

This commit reintroduces that behaviour.

Note that the regular layout lookups for text templates, i.e. "single.json" will be
prefixed with "_text/" on lookup and will only match in the text collection.

Fixes #3273
2017-04-16 09:17:47 +02:00
Bjørn Erik Pedersen 077005e514 output: Fix base theme vs project base template logic
Fixes #3323
2017-04-13 11:19:54 +02:00
Albert Nigmatzianov 260b55ea56 tpl: Set RenderingContext.Config in markdownify 2017-04-06 21:02:37 +02:00
Bjørn Erik Pedersen 1425587193 hugolib: Add optional outputFormat to Ref/RelRef
Fixes #3224
2017-04-04 23:09:01 +02:00
Bjørn Erik Pedersen bc36d468ab tplimpl: Reintroduce the double template lookup in Partial
So it works as before without the html suffix.

Fixes #3272
2017-04-04 17:21:04 +02:00
Bjørn Erik Pedersen 7da1b65968 all: Use the configured output types to resolve template type
Closes #320
2017-04-04 15:12:30 +02:00
Bjørn Erik Pedersen 8b5b558bb5 tpl: Rework to handle both text and HTML templates
Before this commit, Hugo used `html/template` for all Go templates.

While this is a fine choice for HTML and maybe also RSS feeds, it is painful for plain text formats such as CSV, JSON etc.

This commit fixes that by using the `IsPlainText` attribute on the output format to decide what to use.

A couple of notes:

* The above requires a nonambiguous template name to type mapping. I.e. `/layouts/_default/list.json` will only work if there is only one JSON output format, `/layouts/_default/list.mytype.json` will always work.
* Ambiguous types will fall back to HTML.
* Partials inherits the text vs HTML identificator of the container template. This also means that plain text templates can only include plain text partials.
* Shortcode templates are, by definition, currently HTML templates only.

Fixes #3221
2017-04-02 23:13:10 +02:00
Bjørn Erik Pedersen 7eb71ee064 Revert "tpl: Rework to handle both text and HTML templates"
Will have to take another stab at this ...

This reverts commit 5c5efa03d2.

Closes #3260
2017-04-02 14:20:34 +02:00
Bjørn Erik Pedersen 0aeadfd02d tplimpl: Add test with failing partial
Main motivation to see that the containing template name is included in the error message name.

It is.
2017-04-02 12:06:21 +02:00
Bjørn Erik Pedersen 5c5efa03d2 tpl: Rework to handle both text and HTML templates
Before this commit, Hugo used `html/template` for all Go templates.

While this is a fine choice for HTML and maybe also RSS feeds, it is painful for plain text formats such as CSV, JSON etc.

This commit fixes that by using the `IsPlainText` attribute on the output format to decide what to use.

A couple of notes:

* The above requires a nonambiguous template name to type mapping. I.e. `/layouts/_default/list.json` will only work if there is only one JSON output format, `/layouts/_default/list.mytype.json` will always work.
* Ambiguous types will fall back to HTML.
* Partials inherits the text vs HTML identificator of the container template. This also means that plain text templates can only include plain text partials.
* Shortcode templates are, by definition, currently HTML templates only.

Fixes #3221
2017-04-02 11:37:30 +02:00
Bjørn Erik Pedersen 42a4f6f9cb tplimpl: Fix map data race in URLLock 2017-03-31 10:40:33 +02:00
Bjørn Erik Pedersen 79b34c2f1e tplimpl: Fix deadlock in getJSON
Fixes #3211
2017-03-31 09:17:03 +02:00
Bjørn Erik Pedersen 4923273688 tplimpl: Fix lookup with non-standard layout folder 2017-03-27 15:43:56 +02:00
Bjørn Erik Pedersen 9a0aa5fdbe hugolib: Wrap pageOutput create in sync.Once 2017-03-27 15:43:56 +02:00
Bjørn Erik Pedersen ee75e2999b Remove the now superflous defaultExtension
And some other unsed fields and methods.
2017-03-27 15:43:56 +02:00
Bjørn Erik Pedersen 15b64d51da all: Propagate baseURL error to the callers 2017-03-27 15:43:56 +02:00
Bjørn Erik Pedersen 148fedd227 hugolib, tplimpl: Use OutputFormats to create atom links 2017-03-27 15:43:56 +02:00
Bjørn Erik Pedersen dbb83f925a hugolib: Read default output formats from site config 2017-03-27 15:43:56 +02:00
Bjørn Erik Pedersen baa29f6534 output: Rework the base template logic
Extract the logic to a testable function and add support for custom output types.

Fixes #2995
2017-03-27 15:43:56 +02:00
Bjørn Erik Pedersen 2bea9d0ca1 Revert "tplimpl: return an error on unsupported type in isSet"
This breaks the theme site and lots of themes, so we will have to thinkg a little harder about this one.

This reverts commit 74ea81b885.
2017-03-26 20:09:08 +02:00
Darwin 1b92c8b713 Change RSS description from full .Content to .Summary 2017-03-25 22:58:41 +01:00
digitalcraftsman 5d0748ce51 tpl: Add union template func 2017-03-12 23:04:12 +01:00
Albert Nigmatzianov 48120ccfd2 all: Fix some govet complaints 2017-03-09 14:18:12 +01:00
Cameron Moore 45b9d7223a tplimpl: Add built-in print funcs to FuncMap
Add print, printf, and println to the Hugo FuncMap so that they are
accessible to the apply template func.

Updates #3139
2017-03-09 00:21:55 +01:00
Cameron Moore 74ea81b885 tplimpl: return an error on unsupported type in isSet
Fixes #3092
2017-03-02 00:11:10 +01:00
digitalcraftsman e37e3dcc04 tpl: Add title meta tag to twitter card template
Fixes #3095
2017-02-25 09:53:25 +01:00
Alan Orth eb27c47fc5 tpl: Use og:updated_time OpenGraph tag on nodes
A previous commit greatly improved the OpenGraph tags generated by
Hugo's internal opengraph template, but there was a minor error in
the fix. Nodes are of type "website" and according to the Facebook
docs they should use og:updated_time.

See: https://github.com/spf13/hugo/pull/2979
See: https://developers.facebook.com/docs/reference/opengraph/object-type/website/
2017-02-21 14:41:09 +01:00
Bjørn Erik Pedersen 2cbdd65330 tpl, hugolib: Fix live-reload of non-renderable content pages
Fixes #3062
2017-02-21 13:56:20 +01:00
Alan Orth 4e77c8717b tpl: Remove twitter:domain tag from internal shortcode
It seems this metadata tag is no longer used by Twitter, as it has
been removed from their Cards Markup Tag Reference since at least
2013 according to a post on the W3 mailing list.

See: https://dev.twitter.com/cards/markup
See: https://lists.w3.org/Archives/Public/www-validator/2013Oct/0025.html
2017-02-21 13:24:44 +01:00
Bjørn Erik Pedersen bdc02edfa8 tplimpl: Fix issue with recursive templates
Fixes #2927
2017-02-18 09:08:40 +01:00
Cameron Moore 10c13f5d79 hugolib: Make RSS item limit configurable
Add a new rssLimit site configuration option with default of 15.  Prior
to this fix, you could create your own RSS feed to override the default
limit of 15, but we still had a hardcoded limit of 50 items set in
`hugolib.renderRSS()`.

With this option in place, the `range first 15 .Data.Pages` logic is no
longer hardcoded into the embedded RSS template.

Because the size of the slice passed to the template is now limited to
rssLimit instead of 50, this commit is a breaking change for sites
with a custom RSS template that expects more than 15 items.

Fixes #3035
2017-02-17 19:53:08 +01:00
Cameron Moore d3abb93cc7 tplimpl: Fix instagram shortcode panic on invalid ID
Instagram doesn't return a valid JSON response when the requested ID is
invalid or not found.

Fixes #3048
2017-02-17 17:50:37 +01:00
Bjørn Erik Pedersen 4b3ca38b2e tplimpl: Fix data race in resGetResource
Fixes #3045
2017-02-17 17:15:26 +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