Commit graph

997 commits

Author SHA1 Message Date
Bjørn Erik Pedersen
9f978d387f
Pull in the latest code from Go's template packages (#11771)
Fixes #10707
Fixes #11507
2023-12-04 12:07:54 +01:00
Razon Yang
14d85ec136
tpl: Allow using page resources on the images page parameter for opengraph, schema and twitter_cards templates
The page images selection order as follows:

1. Page's images parameter, image resources are supported.
2. Page's image resources that naming in *feature*, *cover* or *thumbnail* pattern.
3. If no page images specified, then the first one of site's images will be used as the fallback, supports site resources.
2023-12-04 12:05:41 +01:00
Joe Mooring
d24da1712f tpl/fmt: Print suppression help with erroridf
Closes #11506
2023-12-04 11:39:27 +01:00
Joe Mooring
4583b41305 tpl/transform: Display Chroma highlighting errors
Closes #9642
2023-12-04 11:38:23 +01:00
Joe Mooring
b4c5df42ff tpl/transform: Add transform.XMLEscape template function
Fixes #3268
2023-11-27 10:52:33 +01:00
Joe Mooring
8d32ca223d tpl/tplimpl: Remove superfluous type attr on script elements
Closes #6379
2023-11-27 10:45:53 +01:00
Joe Mooring
0bde6931ac helpers: Fix TrimShortHTML used by markdownify and RenderString
Closes #11698
2023-11-16 18:21:01 +01:00
Joe Mooring
cb98e9061b tpl/tplimpl: Fix deprecation logic in embedded templates
Closes #11658
2023-11-01 17:42:45 +01:00
Bjørn Erik Pedersen
ab21433689 Fix deprecation printing on info level
Fixes #11638
2023-10-31 10:42:23 +01:00
Joe Mooring
23fcfb7f74
tpl/tplimpl: Fix deprecation logic in RSS template
Closes #11639
2023-10-31 08:34:30 +01:00
Joe Mooring
a349aafb7f tpl/urls: Return strings from URL functions
Closes #11511
2023-10-29 18:12:24 +01:00
Bjørn Erik Pedersen
e54139c85b tpl/collections: Make delimit return a string
Closes #10876
Closes #11502
2023-10-28 11:54:23 +02:00
Bjørn Erik Pedersen
71fd79a3f4 Revise the deprecation logging
This introduces a more automatic way of increasing the log levels for deprecation log statements based on the version it was deprecated.

The thresholds are a little arbitrary, but

* We log INFO for 6 releases
* We log WARN for another 6 releases
* THen ERROR (failing the build)

This should give theme authors plenty of time to catch up without having the log filled with warnings.
2023-10-26 20:41:19 +02:00
Bjørn Erik Pedersen
46bdc03885
tpl/debug: Add average and median to timer output 2023-10-21 15:41:21 +02:00
Bjørn Erik Pedersen
5160c7efa5 tpl/debug: Add debug.Timer
Closes #11580
2023-10-20 09:46:45 +02:00
Joe Mooring
2eca1b3cc1 hugolib: Deprecate .Site.DisqusShortname
Use .Site.Config.Services.Disqus.Shortname instead.
2023-10-18 17:35:54 +02:00
Lars Lehtonen
625162674d
tpl/tplimpl: Fix dropped error 2023-10-18 17:33:00 +02:00
Joe Mooring
a692278bc6 hugolib: Deprecate .Site.GoogleAnalytics
Use .Site.Config.Services.GoogleAnalytics.ID instead.
2023-10-17 20:06:42 +02:00
Joe Mooring
d4016dd5cd tpl/tplimpl: Deprecate .Site.Author usage in RSS template 2023-10-17 20:04:49 +02:00
Joe Mooring
4910312ee7 tpl/tplimpl: Deprecate .Site.Social usage with internal templates 2023-10-17 20:04:24 +02:00
Oleksandr Redko
274852bcf2 all: Format files with gofmt 2023-10-05 14:45:55 +02:00
Joe Mooring
46da0b7aaa tpl/lang: Formally deprecate lang.NumFmt
Use lang.FormatNumberCustom instead.
2023-09-27 17:34:45 +02:00
Joe Mooring
75f56b4ce6 tpl/collections: Fix and deprecate echoParams
Fixes #11498
2023-09-27 17:34:13 +02:00
Carl Johnson
c32094ace1 google_analytics_async.html: Add deprecation warning 2023-09-23 18:57:19 +02:00
Bjørn Erik Pedersen
1e9b87f760 Upgrade to Go 1.21.1
See https://github.com/golang/go/issues?q=milestone%3AGo1.21.1+label%3ACherryPickApproved

Fixes #11474
Fixes #11414
2023-09-21 21:38:41 +02:00
Bjørn Erik Pedersen
24b1be45c1 Go 1.21 Upgrade
Fixes #11351
2023-08-23 21:49:27 +02:00
Bjørn Erik Pedersen
ade7ec8187 Add Page.RenderShortcodes
A layouts/shortcodes/include.html shortcode may look like this:

```html
{{ $p := site.GetPage (.Get 0) }}
{{ $p.RenderShortcodes }}
```

Fixes #7297
2023-08-03 20:00:57 +02:00
Bjørn Erik Pedersen
ef6e813ca8
tpl/collections: Add BenchmarkWhereOps
```
BenchmarkWhereOps/eq-10 	    8702	    120410 ns/op	   52280 B/op	    2515 allocs/op
BenchmarkWhereOps/ne-10 	    9829	    120759 ns/op	   52280 B/op	    2515 allocs/op
BenchmarkWhereOps/like-10           6754	    176377 ns/op	   52917 B/op	    2515 allocs/op
```
2023-07-28 10:08:13 +02:00
Joe Mooring
f4598a0986 tpl/collections: Add like operator to where function
Closes #11279
2023-07-28 09:53:00 +02:00
Joe Mooring
dc2a544fac tpl/collections: Fix description of apply function
The collections.Apply template function cannot be used with maps.
2023-07-28 09:51:01 +02:00
Bjørn Erik Pedersen
4d7af757c9
Add a common regexp cache
```
BenchmarkGetOrCompileRegexp-10    	73959368	        13.71 ns/op	       0 B/op	       0 allocs/op
BenchmarkCompileRegexp-10         	 3143529	       380.1 ns/op	     872 B/op	      10 allocs/op
```
2023-07-27 19:23:12 +02:00
Bjørn Erik Pedersen
5bec50838c tpl/collections: Fix WordCount (etc.) regression in Where, Sort, Delimit
Fixes #11234
2023-07-11 12:11:39 +02:00
Bjørn Erik Pedersen
a78b17d7f1 Make imageConfig work with modules
Fixes #11205
2023-07-08 17:20:18 +02:00
Bjørn Erik Pedersen
79639c981c Fix output formats and media type per language config regression
Fixes #11159
2023-06-28 12:33:33 +02:00
khayyam
b74b8d6478
common/collections: Fix append regression to allow appending nil
Closes #11180
2023-06-28 09:41:36 +02:00
Oleksandr Redko
e3308a0bbc tpl/tplimpl: Fix typo in global variable name 2023-06-26 15:12:21 +02:00
Bjørn Erik Pedersen
7c9fada778 Replace the old log setup, with structured logging etc.
Fixes #11124
2023-06-18 13:03:04 +02:00
Bjørn Erik Pedersen
ee359df172 Fix upstream Go templates bug with reversed key/value assignment
The template packages are based on go1.20.5 with the patch in befec5ddbbfbd81ec84e74e15a38044d67f8785b  added.

This also includes a security fix that now disallows Go template actions in JS literals (inside backticks).

This will throw an error saying "... appears in a JS template literal".

If you're really sure this isn't a security risk in your case, you can revert to the old behaviour:

```toml
[security]
[security.gotemplates]
allowActionJSTmpl = true
```

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

Fixes #11112
2023-06-15 23:04:33 +02:00
Bjørn Erik Pedersen
d178fe94fe tpl/collections: Fix append when appending a slice to a slice of slices
Fixes #11093
2023-06-14 20:18:54 +02:00
Bjørn Erik Pedersen
2ba2271e4a
tpl/math: Allow variadic math functions to take slice args, add math.Product, math.Sum
* Update math.Min and math.Max to allow 1 or more args, either scalar or slice, or combination of the two
* Add math.Sum (allow 1 or more args, either scalar or slice, or combination of the two)
* Add math.Product (allow 1 or more args, either scalar or slice, or combination of the two)

Fixes #11030
2023-06-13 20:00:00 +02:00
Oleksandr Redko
382c726e63 markup: Fix typo in function and struct names 2023-06-01 17:59:44 +02:00
Oleksandr Redko
4c46f9400b all: Replace deprecated ioutil with io and os 2023-06-01 17:52:21 +02:00
Joe Mooring
ff77a927f9 tpl/tplimpl: Use .Language.LanguageCode in built-in templates 2023-05-30 20:10:16 +02:00
Bjørn Erik Pedersen
32585696be Fix potential deadlock in ByParam
Fixes #11039
2023-05-29 14:01:07 +02:00
Bjørn Erik Pedersen
b6e6438f7f docs: Regen docshelper 2023-05-22 18:54:34 +02:00
InLaw
2db7ec622f
tpl/tplimpl: Add img loading attribute to figure shortcode (#10927) 2023-05-21 12:28:45 -07:00
Bjørn Erik Pedersen
7c7baa6183 Add hugo.WorkingDir
Fixes #10969
2023-05-20 17:45:56 +02:00
Joe Mooring
150d190ff0 tpl/urls: Return empty string when JoinPath has zero args 2023-05-20 11:14:18 +02:00
Bjørn Erik Pedersen
e4e0313c80
tpl/urls: Fix build broken by a merge 2023-05-19 10:57:03 +02:00
Joe Mooring
5b3e165bad tpl/urls: Add JoinPath template function
See https://pkg.go.dev/net/url#JoinPath

Closes #9694
2023-05-19 10:31:17 +02:00