Commit graph

110 commits

Author SHA1 Message Date
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
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
04d80e6e87 commands, helpers: Add correct verbose log level to the global loggers
We still use those in some cases.
2017-04-04 15:12:30 +02:00
Bjørn Erik Pedersen
87b3cd4655 hugolib, helpers: Reduce log level to WARN on .Render for non-regular pages
We will eventually support all types in the Render method.
2017-03-29 08:08:45 +02:00
Bjørn Erik Pedersen
6eddb3e587 Revert "helpers: Add a Debug method to DistinctLogger"
Not needed.

This reverts commit 4382a8a6a0.
2017-03-19 10:24:12 +01:00
Bjørn Erik Pedersen
4382a8a6a0 helpers: Add a Debug method to DistinctLogger 2017-03-18 17:34:49 +01:00
Chase Adams
86e8dd62f0 all: Add org-mode support
Fixes #1483 
See #936
2017-02-21 08:46:03 +01: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
234273a5b5 Deprecate sourceRelativeLinks
Fixes #3028
Closes #3026
Closes #2891
Closes #2691
2017-02-11 16:51:22 +07:00
Anthony Fok
e3e5600b81 helpers: Fix minor typo in error message for Seq() 2017-01-04 00:57:28 -07:00
Bjørn Erik Pedersen
c344b1901f commands, helpers, vendor: Update to the latest jww logger
Updates #2701
2017-01-03 16:57:43 +01:00
David Kassa
09a0af94f5 Fix Appveyor Windows build and GitInfo path issue on Windows 2017-01-01 23:16:58 +01:00
Bjørn Erik Pedersen
f1ed89fec4 Revise the deprecation strategy
Git users and theme authors two Hugo releases to fix:

1. With a visible warning
2. Then with an ERROR that exits with -1

Fixes #2726
2016-11-23 17:26:13 +01:00
Bjørn Erik Pedersen
df943595a7 helpers: Slight improvement of ToLowerMap
See #2581
2016-10-16 22:49:56 +02:00
Bjørn Erik Pedersen
40b1b8f703 Fix case issue Viper vs Blackfriday config
There are still work to be done in the case department, but that will have to be another day.

Fixes #2581
See https://github.com/spf13/viper/issues/261
2016-10-16 19:28:21 +02:00
Bjørn Erik Pedersen
614dd2aa16 Deprecate PageMeta.WordCount etc.
Fix #2503
2016-09-28 11:05:21 +02:00
Bjørn Erik Pedersen
fe0c270577 Reset the i18n func map on reload
Also improve the error message on missing resource bundles.
2016-09-08 17:18:11 +03:00
Bjørn Erik Pedersen
93f3a85bf8 Fix the time template func test
By making it not depend on the locale setup.
2016-08-04 10:36:44 +02: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
b0e21f967b helpers: Silence some Golint warnings 2016-03-22 23:53:19 +01:00
Bjørn Erik Pedersen
70739c972e Remove unnecessary type conversions 2016-03-14 20:35:50 +01:00
Bjørn Erik Pedersen
5def6d9aee Make the watch logger less chatty 2016-01-28 15:33:41 +01:00
Bjørn Erik Pedersen
3054a46185 Make the DistinctErrorLogger more generic 2016-01-28 15:33:41 +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
Bjørn Erik Pedersen
831e936846 Improve "watching for ..." logging 2015-11-23 16:32:06 +01:00
Alexander Morozov
7b4e4769d0 Fix comment for NormalizeHugoFlags 2015-10-07 21:28:29 +02:00
Bjørn Erik Pedersen
218554e363 Rename NormalizeHugoFlagsFunc to NormalizeHugoFlags
It IS a func.
2015-10-02 06:48:02 +02:00
Anthony Fok
d05b297e61 Add helpers.NormalizeHugoFlagsFunc() to handle flag name changes
It currently handles --baseUrl to --baseURL, and --uglyUrls to --uglyURLs.

Special thanks to Eric Paris (@eparis) for writing the
"normalized name" support in Cobra, and for showing us
how it is used in Kubernetes.

See Issue #959
2015-09-13 05:20:14 -06:00
Bjørn Erik Pedersen
77c60a3440 Add RuneCount to Page
Fixes #1266
2015-07-12 11:05:37 +02:00
bep
beeae6ab69 Add some tests for IgnoreFiles
And log error on invalid regexp.

See #1189
2015-06-03 18:54:15 +02:00
bep
be7404e337 Support Fish and Chips section
Section names are also used as the title of the list pages, but naming section folders as `Fish and Chips` and similar didn't work very well.

This commit fixes that.

This commit also changes the title casing of the section titles. Some may argue that this is a breaking change, but the old behaviour was also pretty broken,
even for languages that use title capitalizations, as it didn't follow any particular style guide, `fish and chips` became `Fish And Chips` etc.

Now it just turns the first letter into upper case, so `Fish and Chips` will be left as `Fish and Chips`.

People wanting the good old behaviour can use the `title` template func.

Fixes #1176
2015-05-28 23:05:17 +02:00
bep
beaa008c2f Make deprecated warning for this release more alert 2015-05-26 23:08:25 +02:00
Anthony Fok
563a6302a0 Very experimental support for mmark
Either name the content files as `*.mmark`,
or add `markup = "mmark"` in the front matter
of your `*.md` content files.
2015-05-08 22:05:41 -04:00
bep
be7b830f33 tpl: add sanity check to prevent panic in seq on big nums
Fixes #1092
2015-04-30 13:25:46 +02:00
bep
beb66c19a4 helpers: add some missing documentation 2015-04-03 22:30:08 +02:00
bep
bea5feb34d Return early from DistinctErrorLogger's Printf 2015-04-03 21:16:32 +02:00
bep
bec4bdae99 Return error on wrong use of the Paginator
`Paginate`now returns error when

1) `.Paginate` is called after `.Paginator`
2) `.Paginate` is repeatedly called with different arguments

This should help remove some confusion.

This commit also introduces DistinctErrorLogger, to prevent spamming the log for duplicate rendering errors from the pagers.

Fixes #993
2015-03-31 22:33:17 +02:00
bep
be21e2cbed Add some more corner tests for ReaderContains 2015-03-30 01:22:09 +02:00
bep
be6696c34b Handle views in combo with Ace base templates
As views looks like a regular template, but doesn't need a base template, we have to look inside it.

Altough really not needed by this commit, reading the full file content into memory just to do a substring search is a waste.
So this commit implements a `ReaderContains` func that in most cases should be much faster than doing an `ioutil.ReadAll` and `bytes.Contains`:

```
benchmark                   old ns/op     new ns/op     delta
BenchmarkReaderContains     78452         20260         -74.18%

benchmark                   old allocs     new allocs     delta
BenchmarkReaderContains     46             20             -56.52%

benchmark                   old bytes     new bytes     delta
BenchmarkReaderContains     46496         1258          -97.29%
```

Fixes #999
2015-03-29 21:12:13 +02:00
bep
f4244be036 Calculate the next Hugo version in Deprecated
Deprecation will be an ongoing activity for many future versions.
2015-03-18 12:27:56 +01:00
bep
e39a258ec4 Improve type handling in Seq 2015-03-18 11:30:37 +01:00
bep
0be2aade99 Add Seq template func
Very similar to GNU's seq.

Fixes #552

Conflicts:
	tpl/template.go
2015-03-12 22:08:36 -04:00
Anthony Fok
358dcce7a6 Experimental AsciiDoc support with external helpers
See #470

 * Based on existing support for reStructuredText files

 * Handles content files with extensions `.asciidoc` and `.ad`

 * Pipes content through `asciidoctor --safe -`.
   If `asciidoctor` is not installed, then `asciidoc --safe -`.

 * To make sure `asciidoctor` or `asciidoc` is found, after adding
   a piece of AsciiDoc content, run `hugo` with the `-v` flag
   and look for this message:

        INFO: 2015/01/23 Rendering with /usr/bin/asciidoctor ...

Caveats:

 * The final "Last updated" timestamp is currently not stripped.

 * When `hugo` is run with `-v`, you may see a lot of these messages

        INFO: 2015/01/23 Rendering with /usr/bin/asciidoctor ...

   if you have lots of `*.ad`, `*.adoc` or `*.asciidoc` files.

 * Some versions of `asciidoc` may have trouble with its safe mode.
   To test if you are affected, try this:

        $ echo "Hello" | asciidoc --safe -
        asciidoc: ERROR: unsafe: ifeval invalid
        asciidoc: FAILED: ifeval invalid safe document

   If so, I recommend that you install `asciidoctor` instead.

Feedback and patches welcome!

Ideally, we should be using https://github.com/VonC/asciidocgo,
@VonC's wonderful Go implementation of Asciidoctor.  However,
there is still a bit of work needed for asciidocgo to expose
its API so that Hugo can actually use it.

Until then, hope this "experimental AsciiDoc support through external
helpers" can serve as a stopgap solution for our community. :-)

2015-01-30: Updated for the replaceShortcodeTokens() syntax change
2015-02-21: Add `.adoc` extension as suggested by @Fale

Conflicts:
	helpers/content.go
2015-03-12 22:01:49 -04:00
bep
b190ad0ff9 source: add some test cases for File 2015-03-12 20:50:44 +01:00
bep
f8a840a14c Add double checking in Deprecated
To prevent possible duplicate log statements.
2015-03-12 18:51:31 +01:00
bep
6e30c10d09 Add deprecated logger 2015-03-12 16:10:34 +01:00
bep
bd2b679eaf helpers: apply some Golint rules 2015-03-07 00:02:06 +01:00
bep
ebcc1e6699 Add data files support in themes
If duplicate keys, the main data dir wins.

Fixes #892
2015-02-11 20:24:56 +01:00
bep
420c9e4d3d Add writable context to Node
The variable scope in the Go templates makes it hard, if possible at all, to write templates with counter variables or similar state.

This commit fixes that by adding a writable context to Node, backed by a map: Scratch.

This context has three methods, Get, Set and Add. The Add is tailored for counter variables, but can be used for any built-in numeric values or strings.
2015-01-31 22:01:30 +01:00
spf13
66ed5c5e02 Adding BufferPool. Implementing BP in ReaderTo{Bytes,String}(). 2015-01-30 11:12:07 -08:00
Anthony Fok
f5a3fb149f Wrap comments helpers package to fit 80-column width
Add an initial space after `//` where appropriate.
Minor copyediting.
2014-12-26 08:07:03 -07:00
Ahsanul Haque
14bce119b6 Commented helpers package 2014-12-18 22:18:36 -05:00
Ahsanul Haque
2c8e9a7931 Commenting helpers package 2014-12-12 02:57:25 +06:00
bep
9f77f93071 Fix various Windows-issues
File handling was broken on Windows. This commit contains a revision of the path handling with separation of file paths and urls where needed.

There may be remaining issues and there may be better ways to do this, but it is easier to start that refactoring job with a set of passing tests.

Fixes #687
Fixes #660
2014-12-09 09:43:15 -05:00
spf13
dcea0fa5ce Adding ReaderTo and ToReader helper functions 2014-11-04 00:26:56 -05:00
spf13
dfb8482569 Handlers WIP - Convert now working 2014-10-20 20:15:33 -04:00
spf13
5dfc1dedb8 Big refactor of how source files are used. Also added default destination extension option. 2014-10-16 20:20:09 -04:00
spf13
296d218e67 Better handling of when the specified port is already in use 2014-05-15 17:41:03 -04:00
spf13
14227351fa Reorganization of helpers. Centralized Url/Path logic. Fixed #175. 2014-02-27 20:33:18 -05:00