summaryrefslogtreecommitdiffstats
path: root/common
AgeCommit message (Collapse)Author
2019-05-02releaser: Prepare repository for 0.56.0-DEVhugoreleaser
[ci skip]
2019-05-02releaser: Bump versions for release of 0.55.5hugoreleaser
[ci skip]
2019-04-25releaser: Prepare repository for 0.56.0-DEVhugoreleaser
[ci skip]
2019-04-25releaser: Bump versions for release of 0.55.4hugoreleaser
[ci skip]
2019-04-20releaser: Prepare repository for 0.56.0-DEVhugoreleaser
[ci skip]
2019-04-20releaser: Bump versions for release of 0.55.3hugoreleaser
[ci skip]
2019-04-17releaser: Prepare repository for 0.56.0-DEVhugoreleaser
[ci skip]
2019-04-17releaser: Bump versions for release of 0.55.2hugoreleaser
[ci skip]
2019-04-12releaser: Prepare repository for 0.56.0-DEVhugoreleaser
[ci skip]
2019-04-12releaser: Bump versions for release of 0.55.1hugoreleaser
[ci skip]
2019-04-08releaser: Prepare repository for 0.56.0-DEVhugoreleaser
[ci skip]
2019-04-08releaser: Bump versions for release of 0.55.0hugoreleaser
[ci skip]
2019-03-26herrors/errors: Improve the "feature not available" errorBjørn Erik Pedersen
2019-03-24all: Apply staticcheck recommendationsBjørn Erik Pedersen
2019-03-23Make Page an interfaceBjørn Erik Pedersen
The main motivation of this commit is to add a `page.Page` interface to replace the very file-oriented `hugolib.Page` struct. This is all a preparation step for issue #5074, "pages from other data sources". But this also fixes a set of annoying limitations, especially related to custom output formats, and shortcodes. Most notable changes: * The inner content of shortcodes using the `{{%` as the outer-most delimiter will now be sent to the content renderer, e.g. Blackfriday. This means that any markdown will partake in the global ToC and footnote context etc. * The Custom Output formats are now "fully virtualized". This removes many of the current limitations. * The taxonomy list type now has a reference to the `Page` object. This improves the taxonomy template `.Title` situation and make common template constructs much simpler. See #5074 Fixes #5763 Fixes #5758 Fixes #5090 Fixes #5204 Fixes #4695 Fixes #5607 Fixes #5707 Fixes #5719 Fixes #3113 Fixes #5706 Fixes #5767 Fixes #5723 Fixes #5769 Fixes #5770 Fixes #5771 Fixes #5759 Fixes #5776 Fixes #5777 Fixes #5778
2019-03-06tpl/tplimpl: Fix template truth logicBjørn Erik Pedersen
Before this commit, due to a bug in Go's `text/template` package, this would print different output for typed nil interface values: ``` {{ if .AuthenticatedUser }}User is authenticated!{{ else }}{{ end }} {{ if not .AuthenticatedUser }}{{ else }}}User is authenticated!{{ end }} ``` This commit works around this by wrapping every `if` and `with` with a custom `getif` template func with truth logic that matches `not`, `and` and `or`. Those 3 template funcs from Go's stdlib are now pulled into Hugo's source tree and adjusted to support custom zero values, e.g. types that implement `IsZero`. This means that you can now do: ``` {{ with .Date }}{{ . }}{{ end }} ``` And it would work as expected. Fixes #5738
2019-02-02common/herrors: Fix args order in strings.TrimPrefixIskander (Alex) Sharipov
Old code always returned "." or "" (if filepath.Ext(filename) returned "."). Now it properly trims the prefix. Signed-off-by: Iskander Sharipov <quasilyte@gmail.com>
2019-02-01releaser: Prepare repository for 0.55.0-DEVhugoreleaser
[ci skip]
2019-02-01releaser: Bump versions for release of 0.54.0hugoreleaser
[ci skip]
2019-02-01common/hugo: Use official semver even for main releasesBjørn Erik Pedersen
Closes #5639
2018-12-24releaser: Prepare repository for 0.54-DEVhugoreleaser
[ci skip]
2018-12-24releaser: Bump versions for release of 0.53hugoreleaser
[ci skip]
2018-12-11Add /config dir supportBjørn Erik Pedersen
This commit adds support for a configuration directory (default `config`). The different pieces in this puzzle are: * A new `--environment` (or `-e`) flag. This can also be set with the `HUGO_ENVIRONMENT` OS environment variable. The value for `environment` defaults to `production` when running `hugo` and `development` when running `hugo server`. You can set it to any value you want (e.g. `hugo server -e "Sensible Environment"`), but as it is used to load configuration from the file system, the letter case may be important. You can get this value in your templates with `{{ hugo.Environment }}`. * A new `--configDir` flag (defaults to `config` below your project). This can also be set with `HUGO_CONFIGDIR` OS environment variable. If the `configDir` exists, the configuration files will be read and merged on top of each other from left to right; the right-most value will win on duplicates. Given the example tree below: If `environment` is `production`, the left-most `config.toml` would be the one directly below the project (this can now be omitted if you want), and then `_default/config.toml` and finally `production/config.toml`. And since these will be merged, you can just provide the environment specific configuration setting in you production config, e.g. `enableGitInfo = true`. The order within the directories will be lexical (`config.toml` and then `params.toml`). ```bash config ├── _default │   ├── config.toml │   ├── languages.toml │   ├── menus │   │   ├── menus.en.toml │   │   └── menus.zh.toml │   └── params.toml ├── development │   └── params.toml └── production ├── config.toml └── params.toml ``` Some configuration maps support the language code in the filename (e.g. `menus.en.toml`): `menus` (`menu` also works) and `params`. Also note that the only folders with "a meaning" in the above listing is the top level directories below `config`. The `menus` sub folder is just added for better organization. We use `TOML` in the example above, but Hugo also supports `JSON` and `YAML` as configuration formats. These can be mixed. Fixes #5422
2018-12-06Add tpl/site and tpl/hugoBjørn Erik Pedersen
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-11-29common/collections: Fix defines typoChristian Oliff
2018-11-27Add inline shortcode supportBjørn Erik Pedersen
An inline shortcode's name must end with `.inline`, all lowercase. E.g.: ```bash {{< time.inline >}}{{ now }}{{< /time.inline >}} ``` The above will print the current date and time. Note that an inline shortcode's inner content is parsed and executed as a Go text template with the same context as a regular shortcode template. This means that the current page can be accessed via `.Page.Title` etc. This also means that there are no concept of "nested inline shortcodes". The same inline shortcode can be reused later in the same content file, with different params if needed, using the self-closing syntax: ``` {{< time.inline />}} ``` Fixes #4011
2018-11-13More spelling correctionsBjørn Erik Pedersen
2018-11-13Add a consolidated file cacheBjørn Erik Pedersen
This commits reworks how file caching is performed in Hugo. Now there is only one way, and it can be configured. This is the default configuration: ```toml [caches] [caches.getjson] dir = ":cacheDir" maxAge = -1 [caches.getcsv] dir = ":cacheDir" maxAge = -1 [caches.images] dir = ":resourceDir/_gen" maxAge = -1 [caches.assets] dir = ":resourceDir/_gen" maxAge = -1 ``` You can override any of these cache setting in your own `config.toml`. The placeholders explained: `:cacheDir`: This is the value of the `cacheDir` config option if set (can also be set via OS env variable `HUGO_CACHEDIR`). It will fall back to `/opt/build/cache/hugo_cache/` on Netlify, or a `hugo_cache` directory below the OS temp dir for the others. `:resourceDir`: This is the value of the `resourceDir` config option. `maxAge` is the time in seconds before a cache entry will be evicted, -1 means forever and 0 effectively turns that particular cache off. This means that if you run your builds on Netlify, all caches configured with `:cacheDir` will be saved and restored on the next build. For other CI vendors, please read their documentation. For an CircleCI example, see https://github.com/bep/hugo-sass-test/blob/6c3960a8f4b90e8938228688bc49bdcdd6b2d99e/.circleci/config.yml Fixes #5404
2018-11-02Fix ANSI character output regression on WindowsLorenz Cuno Klopfenstein
Fixes #5377
2018-11-01Add file (line/col) info to ref/relref errorsBjørn Erik Pedersen
See #5371
2018-11-01common/loggers: Improve log color regexpBjørn Erik Pedersen
To avoid coloring WARNING inside log errors.
2018-10-28common/loggers: Make sure the global logger also gets colored labelsBjørn Erik Pedersen
See #4414
2018-10-28common/loggers: Add color to ERROR and WARNBjørn Erik Pedersen
Fixes #4414
2018-10-27common/herrors: Make the file error log format configurableBjørn Erik Pedersen
Will check for an OS environment variable named `HUGO_FILE_LOG_FORMAT`. The tokens available are `:file` (absolute filename), `:line` (line number) and `:col` (column number). The default format is: \":file::line::col\"` How to set OS environment variables is OS specific, but an example on Unix setting an alternative format when running Hugo: ```bash env HUGO_FILE_LOG_FORMAT="\":file::line\"" hugo ``` The above will include filename and line number quoted. Fixes #5352
2018-10-27common/collections: Allow a mix of slice types in append/Scratch.AddBjørn Erik Pedersen
The type handling in these was improved in Hugo 0.49, but this also meant that it was no longer possible to start out with a string slice and later append `Page` etc. to it. This commit makes sure that the old behaviour is now possible again by falling back to a `[]interface{}` as a last resort. Fixes #5361
2018-10-24common/loggers: Remove the ANSI color for the browser error versionBjørn Erik Pedersen
2018-10-24Add some color to the relevant filenames in terminal logBjørn Erik Pedersen
Fixes #5344
2018-10-23herrors: Improve handling of JSON errorsBjørn Erik Pedersen
`*json.UnmarshalTypeError` and `*json.SyntaxError` has a byte `Offset`, so use that. This commit also reworks/simplifies the errror line matching logic. This also makes the file reading unbuffered, but that should be fine in this error case. See #5324
2018-10-22hugolib: Improve errors in /i18n handllingBjørn Erik Pedersen
See #5324
2018-10-22hugolib: Continue the file context/line number errors workBjørn Erik Pedersen
See #5324
2018-10-17Prevent stale content in Fast Render ModeBjørn Erik Pedersen
We do that by re-render visited pages that is not already in the stack. This may potentially do some double work, but that small penalty should be well worth it. Fixes #5281
2018-10-16commands: Show server error info in browserBjørn Erik Pedersen
The main item in this commit is showing of errors with a file context when running `hugo server`. This can be turned off: `hugo server --disableBrowserError` (can also be set in `config.toml`). But to get there, the error handling in Hugo needed a revision. There are some items left TODO for commits soon to follow, most notable errors in content and config files. Fixes #5284 Fixes #5290 See #5325 See #5324
2018-10-11common/collections: Fix type checking in AppendBjørn Erik Pedersen
The fix introduced in Hugo `0.49.1` had an unintended side-effect in the `Append` func used in both `append` and `.Scratch.Add`. This commit fixes that by loosen/fixing the type checking so concrete types can be appended to interface slices. Fixes #5303
2018-10-08common/maps: Improve append in ScratchBjørn Erik Pedersen
This commit consolidates the reflective collections handling in `.Scratch` vs the `tpl` package so they use the same code paths. This commit also adds support for a corner case where a typed slice is appended to a nil or empty `[]interface{}`. Fixes #5275
2018-09-14tpl/collections: Add collections.AppendBjørn Erik Pedersen
Before this commit you would typically use `.Scratch.Add` to manually create slices in a loop. With variable overwrite in Go 1.11, we can do better. This commit adds the `append` template func. A made-up example: ```bash {{ $p1 := index .Site.RegularPages 0 }}{{ $p2 := index .Site.RegularPages 1 }} {{ $pages := slice }} {{ if true }} {{ $pages = $pages | append $p2 $p1 }} {{ end }} ``` Note that with 2 slices as arguments, the two examples below will give the same result: ```bash {{ $s1 := slice "a" "b" | append (slice "c" "d") }} {{ $s2 := slice "a" "b" | append "c" "d" }} ``` Both of the above will give `[]string{a, b, c, d}`. This commit also improves the type handling in the `slice` template function. Now `slice "a" "b"` will give a `[]string` slice. The old behaviour was to return a `[]interface{}`. Fixes #5190
2018-09-10tpl/collections: Improve type handling in collections.SliceBjørn Erik Pedersen
Fixes #5188
2018-09-08tpl/collections: Add group template funcBjørn Erik Pedersen
This extends the page grouping in Hugo with a template function that allows for ad-hoc grouping. A made-up example: ``` {{ $cool := where .Site.RegularPages "Params.cool" true | group "cool" }} {{ $blue := where .Site.RegularPages "Params.blue" true | group "blue" }} {{ $paginator := .Paginate (slice $cool $blue) }} ``` Closes #4865
2018-09-07common: Fix golint errorsCameron Moore
common/errors/errors.go:21:1: comment on exported var FeatureNotAvailableErr should be of the form "FeatureNotAvailableErr ..." common/errors/errors.go:23:5: error var FeatureNotAvailableErr should have name of the form ErrFoo common/maps/scratch.go:76:1: comment on exported method Scratch.Delete should be of the form "Delete ..." common/maps/scratch.go:133:1: exported function NewScratch should have comment or be unexported common/types/types.go:44:1: exported function NewKeyValuesStrings should have comment or be unexported
2018-08-13Fix Resource output in multihost setupsBjørn Erik Pedersen
In Hugo 0.46 we made the output of what you get from resources.Get and similar static, i.e. language agnostic. This makes total sense, as it is wasteful and time-consuming to do SASS/SCSS/PostCSS processing for lots of languages when the output is lots of duplicates with different filenames. But since we now output the result once only, this had a negative side effect for multihost setups: We publish the resource once only to the root folder (i.e. not to the language "domain folder"). This commit removes the language code from the processed image keys. This creates less duplication in the file cache, but it means that you should do a `hugo --gc` to clean up stale files. Fixes #5058
2018-07-06Add a newScratch template funcBjørn Erik Pedersen
Fixes #4685