Commit graph

79 commits

Author SHA1 Message Date
Berin Larson
c154c2f7b2 Rewrite relative action URLS
Fixes #5701
2019-02-26 11:31:34 +01:00
Bjørn Erik Pedersen
f7691fe965 transform/urlreplacers: Simplify implementation 2018-12-17 19:17:56 +01:00
Bjørn Erik Pedersen
efe0b4e5c0 transform/urlreplacers: Support unquoted URLs in canonifyURLs replacer
Fixes #5529
2018-12-17 19:17:56 +01:00
Bjørn Erik Pedersen
831d23cb4d Add tpl/site and tpl/hugo
This means that the current `.Site` and ´.Hugo` is available as a globals, so you can do `site.IsServer`, `hugo.Version` etc.

Fixes #5470
Fixes #5467
Fixes #5503
2018-12-06 14:37:25 +01:00
Bjørn Erik Pedersen
789ef8c639
Add support for minification of final output
Hugo Pipes added minification support for resources fetched via ´resources.Get` and similar.

This also adds support for minification of the final output for supported output formats: HTML, XML, SVG, CSS, JavaScript, JSON.

To enable, run Hugo with the `--minify` flag:

```bash
hugo --minify
```

This commit is also a major spring cleaning of the `transform` package to allow the new minification step fit into that processing chain.

Fixes #1251
2018-08-06 19:58:41 +02:00
Bjørn Erik Pedersen
a6b1eb1e91
transform: Reduce allocation in the benchmark itself 2018-08-05 17:27:16 +02:00
Bjørn Erik Pedersen
27110133ff
transform: Simplify the 0 transformer case 2018-08-05 11:24:16 +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
d8717cd4c7 all: Update import paths to gohugoio/hugo 2017-06-13 18:42:45 +02:00
Bjørn Erik Pedersen
7f6430d84d Automate the Hugo release process
This commit adds a work flow aroung GoReleaser to get the Hugo release process automated and more uniform:

* It can be run fully automated or in two steps to allow for manual edits of the relase notes.
* It supports both patch and full releases.
* It fetches author, issue, repo info. etc. for the release notes from GitHub.
* The file names produced are mainly the same as before, but we no use tar.gz as archive for all Unix versions.
* There isn't a fully automated CI setup in place yet, but the release tag is marked in the commit message with "[ci deploy]"

Fixes #3358
2017-04-24 11:08:56 +02:00
Bjørn Erik Pedersen
c4a1165587 all: Handle all errors
As reported by `errcheck`.
2017-04-06 20:35:26 +02: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
3739871f1e transform: Simplify 2016-11-23 18:42:47 +01:00
Bjørn Erik Pedersen
0cd0adda20 transform: Return any read or write error from Apply 2016-11-04 00:44:49 +01:00
Bjørn Erik Pedersen
223073c6fd transform: Add missing GoDoc 2016-07-06 23:23:44 +02:00
Dragos Plesca
7e08d23eeb transform: Explicitly bind LiveReload to server port
If hugo server is run on port 80 or 443, LiveReload does not
correctly bind to the same port, instead using port 35729.
This commit adds functionality to inform LiveReload of the
correct port to bind to.

See https://github.com/livereload/livereload-js/issues/16

Partially contributed by Jeff Minard (@chuyskywalker).

Fixes #2205
2016-06-30 16:47:56 -06:00
Cameron Moore
e3b162ccc6 transform: Don't use helpers.StringToReader 2016-06-25 18:02:07 -05:00
Cameron Moore
e2aea65170 helpers: Remove ToReader funcs
Remove StringToReader and BytesToReader in favor of using the stdlib directly.
2016-06-25 17:57:05 -05:00
Bjørn Erik Pedersen
a7f51703c4 Add Hugo generator tag to home page if not present
Fixes #2182
2016-06-04 21:55:56 -04:00
Bjørn Erik Pedersen
944090722e transform: Group vars and consts in chain_test 2016-03-23 21:55:14 +01:00
Bjørn Erik Pedersen
c7869fd772 transform: Clean up the var naming mess in chain_test 2016-03-23 20:03:13 +01:00
Bjørn Erik Pedersen
626874b94c transform: Golint fixes 2016-03-23 09:35:50 +01:00
Bjørn Erik Pedersen
70739c972e Remove unnecessary type conversions 2016-03-14 20:35:50 +01:00
Bjørn Erik Pedersen
f6c3ca8b2a transform: Remove unused code 2016-03-14 15:46:20 +01:00
Bjørn Erik Pedersen
b21d280c67 transform: Complete test statement coverage
"coverage: 100.0% of statements"
2016-02-06 20:50:26 +01:00
Bjørn Erik Pedersen
08b582e187 Only do one livereload replacement 2016-02-06 19:22:12 +01:00
Bjørn Erik Pedersen
dd1db334ac transform: Add missing test case in livereloadinject
* Test for both </body> and </BODY>
* This also cosmetically changes the behaviour, as the case of the end body tag is kept.
2016-02-06 18:28:26 +01:00
Bjørn Erik Pedersen
96e990456b transform: Add missing test case for NewEmptyTransforms 2016-02-06 18:17:48 +01:00
Anthony Fok
8509727fe8 Add copyright header to that source files that don’t have one.
See #1646
2015-12-10 15:19:38 -07:00
Kato Kazuyoshi
ef4dfcec6c Load livereload.js from "/"
Fix #1406
Instead of loading the file from http://localhost:port/, it can be
loaded from /.
2015-10-15 16:36:13 -04:00
bep
befb54da46 Apply gofmt -s 2015-05-25 12:54:13 +02:00
bep
beaa8b1bca Add support for URLs relative to context root
Setting `RelativeURLs` to `true` will make all relative URLs in the site *really* relative.

And will do so with speed.

So:

In `/post/myblogpost.html`:

`/mycss.css` becomes `../mycss.css`

The same in `/index.html` will become:

`./mycss.css` etc.

Note that absolute URLs will not be touched (either external resources, or URLs constructed with `BaseURL`).

The speediness is about the same as before:

```
benchmark                    old ns/op     new ns/op     delta
BenchmarkAbsURL              17462         18164         +4.02%
BenchmarkAbsURLSrcset        18842         19632         +4.19%
BenchmarkXMLAbsURLSrcset     18643         19313         +3.59%
BenchmarkXMLAbsURL           9283          9656          +4.02%

benchmark                    old allocs     new allocs     delta
BenchmarkAbsURL              24             28             +16.67%
BenchmarkAbsURLSrcset        29             32             +10.34%
BenchmarkXMLAbsURLSrcset     27             30             +11.11%
BenchmarkXMLAbsURL           12             14             +16.67%

benchmark                    old bytes     new bytes     delta
BenchmarkAbsURL              3154          3404          +7.93%
BenchmarkAbsURLSrcset        2376          2573          +8.29%
BenchmarkXMLAbsURLSrcset     2569          2763          +7.55%
BenchmarkXMLAbsURL           1888          1998          +5.83%

```

Fixes #1104
Fixes #622
Fixes #937
Fixes #157
2015-05-16 00:11:44 +02:00
bep
be1287fba0 Add data-no-instant to livereload script tag
To support instantclick.

Fixes #1135
2015-05-12 19:49:46 +02:00
bep
bef3df7481 Polish absurlreplacer 2015-05-04 12:51:52 +02:00
bep
be918d7145 Rename field i to the more descriptive idx 2015-05-04 00:06:00 +02:00
bep
be57b1fe10 absurlreplacer: remove superfluous code, take 2
```
benchmark                    old ns/op     new ns/op     delta
BenchmarkAbsURL              17946         17454         -2.74%
BenchmarkAbsURLSrcset        19236         18979         -1.34%
BenchmarkXMLAbsURLSrcset     19046         18688         -1.88%
BenchmarkXMLAbsURL           9561          9432          -1.35%

benchmark                    old allocs     new allocs     delta
BenchmarkAbsURL              24             24             +0.00%
BenchmarkAbsURLSrcset        29             29             +0.00%
BenchmarkXMLAbsURLSrcset     27             27             +0.00%
BenchmarkXMLAbsURL           12             12             +0.00%

benchmark                    old bytes     new bytes     delta
BenchmarkAbsURL              3139          3139          +0.00%
BenchmarkAbsURLSrcset        2374          2369          -0.21%
BenchmarkXMLAbsURLSrcset     2574          2572          -0.08%
BenchmarkXMLAbsURL           1871          1871          +0.00%

```

See #1059
2015-05-03 23:04:37 +02:00
bep
be4ca21746 absurlreplacer: remove superfluous code
```
benchmark                    old ns/op     new ns/op     delta
BenchmarkAbsURL              18381         17946         -2.37%
BenchmarkAbsURLSrcset        19531         19236         -1.51%
BenchmarkXMLAbsURLSrcset     19316         19046         -1.40%
BenchmarkXMLAbsURL           9818          9561          -2.62%

benchmark                    old allocs     new allocs     delta
BenchmarkAbsURL              24             24             +0.00%
BenchmarkAbsURLSrcset        29             29             +0.00%
BenchmarkXMLAbsURLSrcset     27             27             +0.00%
BenchmarkXMLAbsURL           12             12             +0.00%

benchmark                    old bytes     new bytes     delta
BenchmarkAbsURL              3139          3139          +0.00%
BenchmarkAbsURLSrcset        2354          2374          +0.85%
BenchmarkXMLAbsURLSrcset     2584          2574          -0.39%
BenchmarkXMLAbsURL           1864          1871          +0.38%
```

See #1059
2015-05-03 22:43:04 +02:00
bep
be96aacb11 Add benchmark tests for srcset handling
See #1059
2015-05-03 20:57:39 +02:00
bep
beb601c7ff Fix testdata: srcset items should be comma separated, according to spec
See #1059
2015-05-03 20:09:42 +02:00
bep
bee6a69846 canonifyurls in srcset
Speed is about the same as before, uses slightly less memory:

```
benchmark              old ns/op     new ns/op     delta
BenchmarkAbsURL        17302         17713         +2.38%
BenchmarkXMLAbsURL     9463          9470          +0.07%

benchmark              old allocs     new allocs     delta
BenchmarkAbsURL        28             24             -14.29%
BenchmarkXMLAbsURL     14             12             -14.29%

benchmark              old bytes     new bytes     delta
BenchmarkAbsURL        3422          3144          -8.12%
BenchmarkXMLAbsURL     1985          1864          -6.10%
```

Fixes #1059
2015-05-03 19:54:23 +02:00
bep
be049ff96a absurl: export a base url var for testing 2015-05-01 12:29:03 +02:00
bep
bec9b92d0c Make contentTransformer names consistent 2015-04-01 00:54:40 +02:00
bep
1e8e5d4e7a Format docs 2015-03-19 02:09:42 +01:00
bep
66cf3bdc77 Rename interface contentRewriter to contentTransformer
Is is a much better name.
2015-03-19 02:07:57 +01:00
bep
b15d0a168f transform: remove some superfluous int conversions 2015-03-18 20:18:18 +01:00
bep
658cfb287e Remove URL param from exported AbsURL methods
This is to make it clear that there is only one URL in play,
the BaseURL.
2015-03-18 20:03:34 +01:00
bep
e7099cfa26 Un-export ContentReWriter 2015-03-18 17:33:12 +01:00
bep
98ee69bce2 Write to rotating ContentReWriter in transformer chain
This commit adds the interface ContentReWriter in the tranformer chain.

This is backed by two pooled byte buffers, alternating between being the reader or the writer.

This keeps the performance characteristic of the old implementation, but in a thread safe way.

Fixes #911

Benchmark old vs new:

benchmark              old ns/op     new ns/op     delta
BenchmarkAbsURL        17614         17384         -1.31%
BenchmarkXMLAbsURL     9431          9248          -1.94%

benchmark              old allocs     new allocs     delta
BenchmarkAbsURL        24             28             +16.67%
BenchmarkXMLAbsURL     12             14             +16.67%

benchmark              old bytes     new bytes     delta
BenchmarkAbsURL        3295          3424          +3.92%
BenchmarkXMLAbsURL     1954          1987          +1.69%
2015-03-18 17:05:54 +01:00
Anthony Fok
8b8fb417ae More initialism corrections (golint)
Thanks to @bep's new, brilliant helpers.Deprecated() function,
the following functions or variables are transitioned to their
new names, preserving backward compatibility for v0.14
and warning the user of upcoming obsolescence in v0.15:

 * .Url → .URL (for node, menu and paginator)
 * .Site.BaseUrl → .Site.BaseURL
 * .Site.Indexes → .Site.Taxonomies
 * .Site.Recent → .Site.Pages
 * getJson → getJSON
 * getCsv → getCSV
 * safeHtml → safeHTML
 * safeCss → safeCSS
 * safeUrl → safeURL

Also fix related initialisms in strings and comments.

Continued effort in fixing #959.
2015-03-18 11:30:37 +01:00
Anthony Fok
67df33f500 Correct initialisms as suggested by golint
First step to use initialisms that golint suggests,
for example:

    Line 116: func GetHtmlRenderer should be GetHTMLRenderer

as see on http://goreportcard.com/report/spf13/hugo

Thanks to @bep for the idea!

Note that command-line flags (cobra and pflag)
as well as struct fields like .BaseUrl and .Url
that are used in Go HTML templates need more work
to maintain backward-compatibility, and thus
are NOT yet dealt with in this commit.

First step in fixing #959.
2015-03-11 21:55:00 +01:00