Commit graph

14 commits

Author SHA1 Message Date
Bjørn Erik Pedersen 4f66f790b1 Add readFile template func
This also includes a refactor of the hugofs package and its usage.

The motivation for that is:

The Afero filesystems are brilliant. Hugo's way of adding a dozen of global variables for the different filesystems was a mistake. In readFile (and also in some other places in Hugo today) we need a way to restrict the access inside the working dir. We could use ioutil.ReadFile and implement the path checking, checking the base path and the dots ("..") etc. But it is obviously better to use an Afero BasePathFs combined witha ReadOnlyFs. We could create a use-once-filesystem and handle the initialization ourselves, but since this is also useful to others and the initialization depends on some other global state (which would mean to create a new file system on every invocation), we might as well do it properly and encapsulate the predefined set of filesystems. This change also leads the way, if needed, to encapsulate the file systems in a struct, making it possible to have several file system sets in action at once (parallel multilanguage site building? With Moore's law and all...)

Fixes #1551
2016-03-31 21:24:18 +02:00
Bjørn Erik Pedersen 3c100cc32c tpl: Unexport the rest of the internal template funcs 2016-03-04 01:00:41 +01:00
Bjørn Erik Pedersen 318a984526 Apply gofmt -s 2016-02-06 13:09:52 +01:00
Bjørn Erik Pedersen fe7ca7d78c Fix build 2015-12-18 23:23:37 +01:00
Bjørn Erik Pedersen 13d14ab94d Remove "Host:" prefix from Host header
That thould work with Go 1.4.3 according to sources inside Google.
2015-12-18 23:09:50 +01:00
Bjørn Erik Pedersen dd2ab2820e Correct the strings.Contains syntax in failing test 2015-12-18 16:19:00 +01:00
Bjørn Erik Pedersen 31035f8ad1 Fix remote test on Go 1.4 2015-12-18 16:05:24 +01:00
Bjørn Erik Pedersen 89f8fa586c Set the request Host on http test server
Needed for the remote tests to pass on Go 1.6.

See #1470
2015-12-18 15:52:17 +01:00
Bjørn Erik Pedersen e445c35d6a Fix copyright headers in source files
Still need to add some missing headers and an AUTHORS file.

See #1646
2015-12-07 19:57:01 +01:00
Steve Francia f045d7a611 Change the license to Apache 2.0 2015-11-23 22:16:36 -05:00
Cyrill Schumacher cc5d63c37a GetJSON/GetCSV: Add retry on invalid content
The retry gets triggered when the parsing of the content fails.

Fixes #1166
2015-06-01 12:05:16 +02: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
Cyrill Schumacher 10c2b41b85 Add --ignoreCache CLI flag with description "Ignores the
cache directory for reading but still writes to it" as @spf13
suggested.
2015-02-17 12:14:39 -05:00
Cyrill Schumacher 5e2d3d2e10 Merge to stay up to date with current dev
Feature: GetJson and GetJson in short codes or other layout files.
For more details please see: http://cyrillschumacher.com/2014/12/21/dynamic-pages-with-gohugo.io/
2015-02-17 12:14:39 -05:00