Commit graph

600 commits

Author SHA1 Message Date
Bjørn Erik Pedersen
19f2e72913 Support non-md files as archetype files
It now properly uses the extension of the target file to determine archetype file.

Fixes #3597
Fixes #3618
2017-06-20 13:41:48 +02:00
Bjørn Erik Pedersen
662e12f348 commands, create: Add .Site to the archetype templates
This commit completes the "The Revival of the Archetypes!"

If `.Site` is used in the arcetype template, the site is built and added to the template context.

Note that this may be potentially time consuming for big sites.

A more complete example would then be for the section `newsletter` and the archetype file `archetypes/newsletter.md`:

```
---
title: "{{ replace .TranslationBaseName "-" " " | title }}"
date: {{ .Date }}
tags:
- x
categories:
- x
draft: true
---

<!--more-->

{{ range first 10 ( where .Site.RegularPages "Type" "cool" ) }}
* {{ .Title }}
{{ end }}
```

And then create a new post with:

```bash
hugo new newsletter/the-latest-cool.stuff.md
```

**Hot Tip:** If you set the `newContentEditor` configuration variable to an editor on your `PATH`, the newly created article will be opened.

The above _newsletter type archetype_ illustrates the possibilities: The full Hugo `.Site` and all of Hugo's template funcs can be used in the archetype file.

Fixes #1629
2017-06-19 10:47:00 +02:00
Bjørn Erik Pedersen
deffb4c3d9 releaser: Prepare repository for 0.24-DEV
[ci skip]
2017-06-16 09:52:02 +02:00
Bjørn Erik Pedersen
b502b9d8cc releaser: Bump versions for release of 0.23
[ci skip]
2017-06-16 09:41:39 +02:00
Bjørn Erik Pedersen
873a6f1885 Run gofmt to get imports in line vs gohugoio/hugo 2017-06-13 19:12:10 +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
2aafb24766 Revert "releaser: Bump versions for release of 0.22.1"
This reverts commit dce70fb7c5.
2017-06-13 14:26:56 +02:00
Bjørn Erik Pedersen
4bd5ce7ef3 releaser: Prepare repository for 0.23-DEV 2017-06-13 14:25:19 +02:00
Bjørn Erik Pedersen
0f78dd06a4 releaser: Prepare repository for 0.22.1-DEV
[ci skip]
2017-06-13 14:22:14 +02:00
Bjørn Erik Pedersen
dce70fb7c5 releaser: Bump versions for release of 0.22.1
[ci skip]
2017-06-13 14:17:15 +02:00
Bjørn Erik Pedersen
8ca586a6e5 releaser: Prepare repository for 0.23-DEV
[ci skip]
2017-06-12 09:07:46 +02:00
Bjørn Erik Pedersen
21cf464c1f releaser: Bump versions for release of 0.22
[ci skip]
2017-06-12 09:01:59 +02:00
Bjørn Erik Pedersen
8ddc7a5cde releaser: Prepare repository for 0.22-DEV
[ci skip]
2017-05-22 16:18:26 +03:00
Bjørn Erik Pedersen
1a965e5d2f releaser: Bump versions for release of 0.21
[ci skip]
2017-05-22 16:09:42 +03:00
Albert Nigmatzianov
7d39990497 helpers: Don't clean the path before Join
Join will call Clean anyway.
2017-05-09 14:07:43 +02:00
Albert Nigmatzianov
9b080dc625 helpers: Don't clean path twice
Join calls Clean as it says in docs.

Minor performance improvement:
Before:
Average time per operation: 432ms
Average memory allocated per operation: 127322kB
Average allocations per operation: 2138137

After:
Average time per operation: 428ms
Average memory allocated per operation: 127350kB
Average allocations per operation: 2137892
2017-05-07 17:16:36 +02:00
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
Albert Nigmatzianov
6498d73c08 helpers: Delete RenderingContext.getConfig 2017-04-22 22:40:20 +02:00
Bjørn Erik Pedersen
5e2e62d97f Get versions back to 0.20-DEV
This reverts commit 8ac1fcd0ce.
2017-04-13 16:19:50 +02:00
Bjørn Erik Pedersen
8ac1fcd0ce Prepare release 0.20.1 2017-04-13 16:00:30 +02:00
Bjørn Erik Pedersen
4c6fec56f1 all Bump to 0.21-DEV 2017-04-10 09:33:21 +02:00
Bjørn Erik Pedersen
dac0d4a69d all: Prepare Hugo 0.20 release version 2017-04-10 09:10:53 +02:00
Albert Nigmatzianov
8f09e5f6bc helpers: Add new properties to ContentSpec 2017-04-06 21:02:37 +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
5989c4d464 helpers, output: Fix spelling 2017-03-28 01:19:46 +02:00
Bjørn Erik Pedersen
09c88e84d1 output: Rename HTMLType etc. to HTMLFormat 2017-03-27 15:43:56 +02:00
Bjørn Erik Pedersen
24c1770288 hugolib: Revise paginator alias path handling 2017-03-27 15:43:56 +02:00
Bjørn Erik Pedersen
ee75e2999b Remove the now superflous defaultExtension
And some other unsed fields and methods.
2017-03-27 15:43:56 +02:00
Bjørn Erik Pedersen
15b64d51da all: Propagate baseURL error to the callers 2017-03-27 15:43:56 +02:00
Bjørn Erik Pedersen
d851d6b98f Add custom protocol support in Permalink 2017-03-27 15:43:56 +02:00
Bjørn Erik Pedersen
baa29f6534 output: Rework the base template logic
Extract the logic to a testable function and add support for custom output types.

Fixes #2995
2017-03-27 15:43:56 +02:00
Bjørn Erik Pedersen
6bf010fed4 hugolib: Refactor/-work the permalink/target path logic
This is a pretty fundamental change in Hugo, but absolutely needed if we should have any hope of getting "multiple outputs" done.

This commit's goal is to say:

* Every file target path is created by `createTargetPath`, i.e. one function for all.
* That function takes every page and site parameter into account, to avoid fragile string parsing to uglify etc. later on.
* The path creation logic has full test coverage.
* All permalinks, paginator URLs etc. are then built on top of that same logic.

Fixes #1252
Fixes #2110
Closes #2374
Fixes #1885
Fixes #3102
Fixes #3179
Fixes #1641
Fixes #1989
2017-03-27 15:43:56 +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
Bjørn Erik Pedersen
7acec3c639 helpers: Return partially cleaned URL in case of error in URLPrep anyway
Closes #2987
2017-03-02 00:21:39 +01:00
Bjørn Erik Pedersen
577522bd45 helpers: Remove unused arg 2017-03-01 23:49:24 +01:00
Bjørn Erik Pedersen
3669015f56 Handle Hugo version strings with patch level
Fixes #3025
2017-03-01 15:49:07 +01:00
Bjørn Erik Pedersen
a0e3ff1645 helpers: Fix version string for Hugo 0.20 and similar
Fixes #3112
2017-03-01 14:34:40 +01:00
Bjørn Erik Pedersen
072cd00305 Bump version to 0.20-DEV 2017-02-27 13:58:50 +01:00
Bjørn Erik Pedersen
a1741f192c Update versions to 0.19 release 2017-02-27 10:49:35 +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
bogem
faba90ab96 helpers: Fix misspells 2017-02-04 22:28:36 +01:00
Bjørn Erik Pedersen
c71e1b106e all: Refactor to nonglobal file systems
Updates #2701
Fixes #2951
2017-02-04 11:37:25 +07:00
Bjørn Erik Pedersen
bc06135c96 helpers: Allow tilde in URLs
See #2177
2017-01-07 19:29:20 +01:00
Bjørn Erik Pedersen
001dd01ee2 helpers: Remove unusded WordCount 2017-01-05 00:00:00 +01: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
bogem
2ac9817eae helpers: Add doc to Language.SetParam 2017-01-02 17:01:58 +01:00
bogem
4352156a27 commands, helpers: Fix docs 2017-01-02 17:01:58 +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
3e4fbbaae4 helpers: Add patch version
Fixes #2832
2016-12-26 14:03:50 +01:00
Cameron Moore
8b0c3b9b27 helpers: Remove "no theme set" warning
Fixes #2821
2016-12-23 19:48:50 +01:00
Bjørn Erik Pedersen
1e313ced3f Bump to 0.19-DEV 2016-12-19 23:14:10 +01:00
Bjørn Erik Pedersen
3d6fdb8ed3 Bump to 0.18 release version 2016-12-19 15:35:20 +01:00
Bjørn Erik Pedersen
a3a67163f9 hugolib: Enable override of theme base template only
This commit fixes the base template lookup order to match the behaviour of regular templates.

```
1. <current-path>/<template-name>-baseof.<suffix>, e.g. list-baseof.<suffix>.
2. <current-path>/baseof.<suffix>
3. _default/<template-name>-baseof.<suffix>, e.g. list-baseof.<suffix>.
4. _default/baseof.<suffix>

For each of the steps above, it will first look in the project, then, if theme is set,
in the theme's layouts folder.
```

Fixes #2783
2016-12-15 21:35:38 +01:00
Bjørn Erik Pedersen
c38bfda43b hugolib: Fix regressions with uglyURLs
Fixes #2734
2016-11-27 14:36:17 +01:00
Bjørn Erik Pedersen
65e5959bad helpers: Simplify 2016-11-23 18:54:57 +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
bogem
c06c3234eb helpers: Fix typo in language.Get documentation 2016-11-23 10:51:33 +01:00
bogem
e81c06c3f0 helpers: Rename WalkRootTooShortError to ErrWalkRootTooShort
Fix golint warning: helpers/path.go:473:5: error var
WalkRootTooShortError should have name of the form ErrFoo

See #2014
2016-11-23 09:13:00 +01:00
bogem
647540d0ef helpers: Add documentation to some Language methods
See #2014
2016-11-23 09:13:00 +01:00
bogem
700d531a2c helpers: Use iterate operator by int in Emojify
Fix golint warning: helpers/emoji.go:56:4: should replace start += 1
with start++

See #2014
2016-11-23 09:13:00 +01:00
bogem
120f6b0cf2 all: Use jww instead of fmt for printing
This is an attempt to unify method for printing.
2016-11-22 22:06:48 +01:00
Albert Nigmatzianov
85a2d81e3c commands, tpl: Get rid of repeating viper accesses
* all: Delete some blank lines
* commands, tpl: Get rid of repeating viper accesses
2016-11-07 00:10:32 +01:00
Bjørn Erik Pedersen
d4830fc4fd helpers: Golint fixes 2016-11-05 17:28:14 +01:00
Albert Nigmatzianov
f21e2f25c9 all: Unify case of config variable names
All config variables starts with low-case and uses camelCase.

If there is abbreviation at the beginning of the name, the whole
abbreviation will be written in low-case.
If there is abbreviation at the end of the name, the
whole abbreviation will be written in upper-case.
For example, rssURI.
2016-10-24 20:56:00 +02:00
Bjørn Erik Pedersen
a10b2cd372 Avoid reading from Viper for path and URL funcs
The gain, given the "real sites benchmark" below, is obvious:

```
benchmark           old ns/op       new ns/op       delta
BenchmarkHugo-4     14497594101     13084156335     -9.75%

benchmark           old allocs     new allocs     delta
BenchmarkHugo-4     57404335       48282002       -15.89%

benchmark           old bytes       new bytes      delta
BenchmarkHugo-4     9933505624      9721984424     -2.13%
```

Fixes #2495
2016-10-24 13:45:30 +02:00
choeppler
ddf2a3407a Add page context to error logging in rendering
Add logging of the errors/warnings which rst2html outputs to its stderr
stream when rendering rst documents. Note that rst2html outputs warnings
and errors to stderr but it also adds them to the generated html. ->
hugo logs everything in stderr as error.

Add / complete adding page context (path to file being rendered) to
anything logged by getRstContent and getAsciidocContent.

See #2570
2016-10-19 15:22:40 +02: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
C. Hoeppler
766c82a6bb Add context to asciidoc/-tor error logging
Add DocumentName (path to the file being rendered) to RenderingContext
and use that information to include the path in the error print.

See #2399
Closes #2567
2016-10-13 13:48:43 +02:00
C. Hoeppler
9f9b93af2c Add logging of asciidoc/-tor errors
Add logging of the errors which asciidoc and asciidoctor output to their
stderr stream when converting asciidoc documents. Note that
asciidoctor's exit code may be SUCCESS even if there are ERROR messages
in its stderr output (tested with Asciidoctor 0.1.4 and 1.5.5).
Therefore log the stderr output whenever it is non-empty.

See #2399
2016-10-13 13:48:30 +02:00
Steve Francia
d54d6633ad release: version bump to v0.18-DEV 2016-10-07 11:11:43 -04:00
Steve Francia
5b9f488304 release: version bump to 0.17 2016-10-07 10:08:57 -04:00
Kim Gressens
fbce84450b Whitelist startinline pygments option 2016-10-06 14:59:49 +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
894b69dba5 Remove some unused vars 2016-09-19 22:14:15 +02:00
Bjørn Erik Pedersen
bacc1706cb helpers: Skip TestGetRealPath on Windows when not in CI
`os.Symlink` needs administrator rights on Windows,
and this seems to be the simplest fix while still getting the tests run on Appveyor.

Fixes #2476
2016-09-18 22:04:32 +02:00
Bjørn Erik Pedersen
98c12b7b3d Fail early in TestGetRealPath
See #2476
2016-09-18 19:52:42 +02:00
Bjørn Erik Pedersen
b86a605bfb Make paginate settings configurable per language
Fixes #2449
2016-09-15 09:32:52 +02:00
Bjørn Erik Pedersen
dd45e6d7e5 Lazy calculate WordCount, ReadingTime and FuzzyWordCount
This avoids having to execute these expensive operations for sites not using these values.

This commit sums up a set of wordcounting and autosummary related performance improvements.

The effect of these kind of depends on what features your site use, but a benchmark from 4 Hugo sites in the wild shows promise:

```
benchmark           old ns/op       new ns/op       delta
BenchmarkHugo-4     21293005843     20032857342     -5.92%

benchmark           old allocs     new allocs     delta
BenchmarkHugo-4     65290922       65186032       -0.16%

benchmark           old bytes      new bytes      delta
BenchmarkHugo-4     9771213416     9681866464     -0.91%
```

Closes #2378
2016-09-14 10:57:39 +02:00
Bjørn Erik Pedersen
4abaec5c04 Improve TotalWords counter func
It is obviously more efficient when we do not care about the actual words.

```
BenchmarkTotalWords-4            100000         18795 ns/op           0 B/op           0 allocs/op
BenchmarkTotalWordsOld-4          30000         46751 ns/op        6400 B/op           1 allocs/op
```
2016-09-14 10:50:56 +02:00
Bjørn Erik Pedersen
bcd434794a Avoid splitting words for summary
For people using autogenerated summaries, this is one of the hot spots in the memory department.

We don't need to split al the content into words to do proper summary truncation.

This is obviously more effective:

```
BenchmarkTestTruncateWordsToWholeSentence-4            300000          4720 ns/op           0 B/op           0 allocs/op
BenchmarkTestTruncateWordsToWholeSentenceOld-4         100000         17699 ns/op        3072 B/op           3 allocs/op
```
2016-09-14 10:50:55 +02:00
Bjørn Erik Pedersen
74ffb45fbe helpers: Improve the language prefix logic
See #2444
2016-09-13 23:44:16 +02:00
Bjørn Erik Pedersen
f53145b274 helpers: Avoid adding language prefix if already present
Fixes #2444
2016-09-13 21:37:27 +02:00
Bjørn Erik Pedersen
69a97823c4 Add Language.LanguageName
Fixes #2435
2016-09-12 20:59:03 +02:00
Bjørn Erik Pedersen
c700cdc39c Replace some leftover os.Stat with hugofs.Source 2016-09-11 20:00:38 +02:00
Bjørn Erik Pedersen
364e69ab7f Handle symlink change event
Hugo 0.16 announced support for symbolic links for the root folders, /content, /static etc., but this got broken pretty fast.

The main problem this commit tries to solve is the matching of file change events to "what changed".

An example:

ContentDir: /mysites/site/content where /mysites/site/content is a symlink to /mycontent

/mycontent:

/mypost1.md
/post/mypost2.md

* A change to mypost1.md (on OS X) will trigger a file change event with name "/mycontent/mypost1.md"
* A change to mypost2.md gives event with name "/mysites/site/content/mypost2.md"

The first change will not trigger a correct update of Hugo before this commit. This commit fixes this by doing a two-step check:

1. Check if "/mysites/site/content/mypost2.md" is within /mysites/site/content
2. Check if  "/mysites/site/content/mypost2.md" is within the real path that /mysites/site/content points to

Fixes #2265
Closes #2273
2016-09-11 20:00:38 +02:00
Bjørn Erik Pedersen
eaf2f9bce5 Add TODO list support for Blackfriday
* Add CSS class to TODO list and list items
* Add a flag to turn task list support off

Fixes #2269
2016-09-09 13:08:20 +02:00
Bjørn Erik Pedersen
76bf2dcdd2 Fix shortcode vs pygments
This is the nth attempt to fix an issue by changing the placeholder token pattern, but
now we actually have tests for all the historic trouble cases.

Fixes #2223
2016-09-08 21:23:01 +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
a00edff5b1 Make it the DEV version 2016-09-06 23:20:59 +03:00
Bjørn Erik Pedersen
28696b5dca Small adjustment to SiteInfo init
After a visual inspection to make (pretty) sure it is correct re multiple languages.

Updates #2309
2016-09-06 18:32:20 +03:00
Bjørn Erik Pedersen
d8a256c155 Fix YAML loading of multilingual config
And some other minor fixes from code review.

Updates #2309
2016-09-06 18:32:20 +03:00
Bjørn Erik Pedersen
5b331a18d7 Add temp MULTILINGUAL version suffix to this branch
For people having trouble building this.

Now `hugo version` should print something like:

```
Hugo Static Site Generator v0.17-MULTILINGUAL BuildDate: 2016-08-10T08:20:36+02:00
```
2016-09-06 18:32:19 +03:00
Bjørn Erik Pedersen
8da040342e Render main content language in root by default
Fixes #2312
2016-09-06 18:32:18 +03:00
Bjørn Erik Pedersen
e56ecab157 Multilingual TODO-fixes, take 1
See #2309
2016-09-06 18:32:18 +03:00
Bjørn Erik Pedersen
54141f71dd Improve language handling in URLs
The current "rendering language" is needed outside of Site. This commit moves the Language type to the helpers package, and then used to get correct correct language configuration in the markdownify template func.
This commit also adds two new template funcs: relLangURL and absLangURL.

See #2309
2016-09-06 18:32:18 +03:00
Bjørn Erik Pedersen
2079a23dd8 Make it possible to configure Blackfroday per language
See #2309
2016-09-06 18:32:17 +03:00
Bjørn Erik Pedersen
ed0985404d Render the shortcodes as late as possible
This is needed to make shortcode users happy with the new multilanguage support,
but it will also solve many other related posts about "stuff not available in the shortcode".

We will have to revisit this re the handler chain at some point, but that will be easier
now as the integration test story has improved so much.

As part of this commit, the site-building tests in page_test.go is refreshed, they now
tests for all the rendering engines (when available), and all of them now uses the
same code-path as used in production.

Fixes #1229
Fixes #2323
Fixes ##1076
2016-09-06 18:32:16 +03:00
Bjørn Erik Pedersen
708bc78770 Optimize the multilanguage build process
Work In Progress!

This commit makes a rework of the build and rebuild process to better suit a multi-site setup.

This also includes a complete overhaul of the site tests. Previous these were a messy mix that
were testing just small parts of the build chain, some of it testing code-paths not even used in
"real life". Now all tests that depends on a built site follows the same and real production code path.

See #2309
Closes #2211
Closes #477
Closes #1744
2016-09-06 18:32:16 +03:00
Alexandre Bourget
ec33732fbe Add multilingual support in Hugo
Implements:
* support to render:
  * content/post/whatever.en.md to /en/2015/12/22/whatever/index.html
  * content/post/whatever.fr.md to /fr/2015/12/22/whatever/index.html
* gets enabled when `Multilingual:` is specified in config.
* support having language switchers in templates, that know
  where the translated page is (with .Page.Translations)
  (when you're on /en/about/, you can have a "Francais" link pointing to
   /fr/a-propos/)
  * all translations are in the `.Page.Translations` map, including the current one.
* easily tweak themes to support Multilingual mode
* renders in a single swift, no need for two config files.

Adds a couple of variables useful for multilingual sites

Adds documentation (content/multilingual.md)

Added language prefixing for all URL generation/permalinking see in the
code base.

Implements i18n. Leverages the great github.com/nicksnyder/go-i18n lib.. thanks Nick.
* Adds "i18n" and "T" template functions..
2016-09-06 18:32:15 +03:00
Cameron Moore
b6635e1baf helpers: Fix bug in emoji renderer
Fixes #2391
2016-08-30 00:34:48 +02:00
Mark D. Blackwell
be429d2268 docs: Correct all erroneous swaps of "it's" and "its" 2016-08-18 20:42:40 +02: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
Bjørn Erik Pedersen
b426c20e14 Return specific error on walk path too short 2016-07-30 22:32:03 +02:00
Bjørn Erik Pedersen
15b6693541 Adjust the sanity check to path length 4 2016-07-30 20:07:35 +02:00
Bjørn Erik Pedersen
94d998989d Add sanity check to the file walker
As more tests now hit the virtual filesystem, add this check
to prevent any walking of the entire file system.
2016-07-30 19:54:07 +02:00
Bjørn Erik Pedersen
5f5fccbc36 Do not return empty theme dirs
This prevents reading data etc. from the root.

Fixes #2320
2016-07-30 16:21:57 +02:00
Bjørn Erik Pedersen
9489272681 Handle errors during filesystem walk
Fixes #2318
2016-07-30 14:03:38 +02:00
Bjørn Erik Pedersen
91b61b976d Simplify the configuration of HugoHTMLRenderer 2016-07-22 11:00:52 +02:00
Mathias Biilmann
330639d2ae Fix panic when using URLize
Using URLize on a string like '100%-true' would cause a panic
2016-07-11 10:06:40 +02:00
Bjørn Erik Pedersen
d44bb4ec05 Revert "Use bufferpool in Asciidoc handler"
This reverts commit 068a77151e.

This was hasty. We would need to create a copy to use the pool in this case.
2016-07-10 19:42:14 +02:00
Bjørn Erik Pedersen
7c125ebb7d Revert "Use bufferpool in Rst handler"
This reverts commit d9bc233f1f.

This was hasty. We would need to make a copy to use the pool in this case.
2016-07-10 19:41:16 +02:00
Bjørn Erik Pedersen
d9bc233f1f Use bufferpool in Rst handler 2016-07-10 12:54:15 +02:00
Bjørn Erik Pedersen
00d70e5569 Remove []byte to string to []byte conversion in Rst 2016-07-10 12:52:20 +02:00
Bjørn Erik Pedersen
068a77151e Use bufferpool in Asciidoc handler 2016-07-10 12:31:31 +02:00
Bjørn Erik Pedersen
ed5ad12af3 Remove []byte to string to []byte conversion in Asciidoc 2016-07-10 12:28:34 +02:00
Bjørn Erik Pedersen
1d7f4413f5 Consolidate the Render funcs 2016-07-10 11:36:25 +02:00
Bjørn Erik Pedersen
e6d97c4fca Add Rst shortcode test
Fixes #2253
2016-07-04 10:49:20 +02:00
Bjørn Erik Pedersen
5388211c11 Add Asciidoc shortcode test
Fixes #2249
2016-07-04 00:33:08 +02:00
Bjørn Erik Pedersen
6c0f705217 Fix Emoji benchmark
The Emoji implementations gives slightly different output. One of them pads with a space.
2016-07-01 17:59:39 +02:00
Bjørn Erik Pedersen
aa66478c20 Add Emoji test case
See #2246
2016-07-01 17:06:13 +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
34f40044d7 Fix shortcode in markdown headers
This issue was introduced as a fix to shortcode not working in RST.

One could argue that Blackfriday and friends should handle `#` in titles, but that will be a discussion
for another day.

The new placeholder pattern should be RST safe and work with titles.

And now with a test so this doesn't break again.

Fixes #2192
Fixes #2209
Closes #2210
2016-06-15 09:12:07 +02:00
Bjørn Erik Pedersen
2564f46a68 Fix Emojfy for certain text patterns
Fixes #2198
2016-06-11 20:40:56 +02:00
Steve Francia
f9cadee8de Bump version to 0.17-DEV 2016-06-06 09:10:55 -04:00
Steve Francia
26c18005a2 Remove HugoVersionSuffix "-DEV" prior to 0.16 release 2016-06-03 11:51:45 -04:00
Bjørn Erik Pedersen
26906d8569 Don't add any space around Emojis 2016-05-09 22:59:49 +02:00
Cameron Moore
e4ee1b89ad helpers: Use net/url for URL parsing in AbsURL
Fixes #2112
2016-04-27 10:29:46 -05:00
Bjørn Erik Pedersen
06772eefcd Default to plainIDAnchors
Fixes #2057
2016-04-12 18:34:46 +02:00
Bjørn Erik Pedersen
39c9ae3108 Revert "Use Node.ID for anchor ID"
This reverts commit cd558958a0.
2016-04-12 18:11:24 +02:00
Bjørn Erik Pedersen
cd558958a0 Use Node.ID for anchor ID
Fixes #2057
2016-04-11 13:17:25 +02:00
Robert Basic
37fb2d43e5 helpers: Ignore cache for Pygments when flag set
When the --ignoreCache flag is set to true, do not write and read
the Pygments results to/from the cache directory.

Fixes #2066
Closes #2068
2016-04-10 20:55:57 +02:00
Sven Dowideit
1648e327c0 Document and clean SourceRelativeLinksEval code 2016-04-07 20:10:38 +02:00
Philipp Oppermann
43b5dfabb5 Disable syntax guessing for PygmentsCodeFences by default
This disables highlighting for fenced code blocks without explicitly specified language. It also introduces a new `PygmentsCodeFencesGuessSyntax` config option (defaulting to false).

To enable syntax guessing again, add the following to your config file: `PygmentsCodeFencesGuessSyntax = true`

This is a breaking change.
2016-04-04 22:19:36 +02:00
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
dbfc7ea024 Fix error handling in SymbolicWalk 2016-03-25 18:18:39 +01:00
Bjørn Erik Pedersen
bfe8009415 helpers: Fix SymbolicWalk for the root folder
handle the root folders themselves.

This commit fixes that.

Fixes #2018
2016-03-25 12:49:23 +01:00
digitalcraftsman
5d3705df16 helpers: Apply GoLint rules 2016-03-24 23:16:18 +01:00
Bjørn Erik Pedersen
3e77886aad helpers: Fix GoDoc in Hugo version constants 2016-03-24 14:27:36 +01:00
Bjørn Erik Pedersen
8a60571fd2 helpers: Fix and add Godoc in path* 2016-03-23 10:03:29 +01:00
Bjørn Erik Pedersen
6ff2e1dbe7 helpers: Remove the else in MakePathSanitized 2016-03-23 09:45:18 +01:00
Bjørn Erik Pedersen
4f00f1c94f heloers: Add a linefeed to make Golint happy 2016-03-23 00:07:44 +01:00
Bjørn Erik Pedersen
b0e21f967b helpers: Silence some Golint warnings 2016-03-22 23:53:19 +01:00
Bjørn Erik Pedersen
b9127ecca6 helpers: Apply gofmt 2016-03-22 19:43:03 +01:00
Bjørn Erik Pedersen
e5aa477491 Add support for symbolic links for content, layout, static, theme
Note: This is for the content roots only, but that should satisfy most needs.

Fixes #1855
2016-03-21 19:13:29 -04:00
Aditya Bhargava
c42982f76b Add '+' as one of the valid characters in urls specified in the front matter
Fixes #1290
2016-03-21 18:48:50 -04:00
Anthony Fok
d45b55bdd4 helpers: Rename getMmarkHtmlRenderer to getMmarkHTMLRenderer
To be consistent with the changes made in commit 67df33f, see #959.
2016-03-21 15:17:37 +08:00
Anthony Fok
2c5e4f7640 helpers: Support EXTENSION_BACKSLASH_LINE_BREAK for Blackfriday
Exposed as "backslashLineBreak" and enabled by default
as upstream have done.

Fixes #1935
2016-03-20 04:21:16 +08:00
Anthony Fok
4c4ce55217 helpers: Fix minor typo in content_test.go 2016-03-20 04:12:53 +08:00
Bjørn Erik Pedersen
0a768ec95f Simplify GetDottedRelativePath 2016-03-19 17:17:17 +01:00
Bjørn Erik Pedersen
8d86f1ec6e Return early from parseOptions 2016-03-19 17:12:10 +01:00
Bjørn Erik Pedersen
70739c972e Remove unnecessary type conversions 2016-03-14 20:35:50 +01:00
Bjørn Erik Pedersen
5d915e7e96 helpers: Unexport some internals 2016-03-14 17:27:15 +01:00
Bjørn Erik Pedersen
91ffc76b24 helpers: Remove unused code 2016-03-14 15:20:36 +01:00
Bjørn Erik Pedersen
542e220cc4 Make tests green on both Pygments 2.0.2 and 2.1.3
See #1969
2016-03-13 22:06:51 +01:00
Bjørn Erik Pedersen
cafb784799 Add emoji support
This uses the Emoji map from https://github.com/kyokomi/emoji -- but with a custom replacement implementation.

The built-in are fine for most use cases, but in Hugo we do care about pure speed.

The benchmarks below are skewed in Hugo's direction as the source and result is a byte slice,
Kyokomi's implementation works best with strings.

Curious: The easy-to-use `strings.Replacer` is also plenty fast.

```
BenchmarkEmojiKyokomiFprint-4  	   20000	     86038 ns/op	   33960 B/op	     117 allocs/op
BenchmarkEmojiKyokomiSprint-4  	   20000	     83252 ns/op	   38232 B/op	     122 allocs/op
BenchmarkEmojiStringsReplacer-4	  100000	     21092 ns/op	   17248 B/op	      25 allocs/op
BenchmarkHugoEmoji-4           	  500000	      5728 ns/op	     624 B/op	      13 allocs/op
```

Fixes #1891
2016-03-11 15:51:37 -06:00
Marek Janda
0962470850 Make absURL properly handle baseURL with path component 2016-03-10 11:08:50 +01:00
Bjørn Erik Pedersen
a2abad9677 Add support for Go 1.6 block keyword in templates
NOTE: Needs Go 1.6 to use the new feature.

Fixes #1832
2016-03-10 10:53:54 +01:00
Bjørn Erik Pedersen
5b065a27a2 Some missing shortcode replacements
See #1904
2016-03-01 13:51:46 +01:00
Bjørn Erik Pedersen
7f682d7802 Fix shortcode handling in RST
Fixes #1904
2016-03-01 11:04:25 +01:00
Gergely Brautigam
e95f3af933 helpers: Test coverage increase
Started to increase coverage in helpers package, now at 74.9% of statements.

In the process, also a few minor changes have been applied to content.go.

* Content.go has undergone a formatting refactor regarding comments
* Unused function TruncateWords has been removed
* RenderingContext's "mmark" has been changed to use MmarkRender
* Content_test.go added to cover content.go's functionality
2016-02-06 14:27:11 +01:00
Bjørn Erik Pedersen
318a984526 Apply gofmt -s 2016-02-06 13:09:52 +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
Ben Thomas
26d23f7f4b added remaining relevant options 2016-01-04 11:52:40 -05:00
Ben Thomas
e904ccffb6 added more pygments opts 2016-01-04 11:52:40 -05:00
John McFarlane
b1f2b433bc Fix /.xml RSSLink when uglyurls are enabled
Prior to this commit the root url with uglyurls enabled is "/.xml".
This commit relates to #175.
2016-01-04 11:25:37 -05:00
Sven Dowideit
0f6b334b67 Source file based relative linking
ala GitHub repository markdown for both md files and non-md files

Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
2016-01-01 15:23:11 -05:00
digitalcraftsman
47587321d9 Add themesDir option to configuration
themesDir can be used to change the default
path of the themes folder.

Fixes 1556
2016-01-01 14:46:40 -05:00
Daniel TISCHER
40fccf2251 Fixes #1292 2016-01-01 14:35:58 -05:00
Anthony Fok
de82404d35 Fix hugo server "Watching for changes" path display
especially when the given `--source` path is a relative directory.

Also, when `--source` is specified, make WorkingDir an absolute path
from the very beginning, to be consistent with the case when `--source`
is not given.  Otherwise, the function name helpers.AbsPathify(), which
prepends WorkingDir to a relative path, does not really make sense.

Fixes #1721
2015-12-19 05:19:31 -07: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
Steve Francia
6042fc2b83 move some of the path helper utilities to afero
and provide wrappers in Hugo.
2015-12-08 16:46:43 -05: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
d356720f74 Version bump to 0.16-DEV 2015-11-25 09:49:03 -05:00
Steve Francia
6faf1d01e0 version bump to v0.15 2015-11-25 09:33:53 -05:00
Steve Francia
f045d7a611 Change the license to Apache 2.0 2015-11-23 22:16:36 -05:00
Bjørn Erik Pedersen
b00771ca14 Simplify ExtractRootPaths 2015-11-23 22:35:54 +01:00
Andrew Brampton
c3931ef748 Add PygmentsOptions option
This allows default pygments settings to be used, if none are explictly set per shortcode.

Fixes #1260
2015-11-23 17:50:54 +01:00
Marek Janda
5838420aa1 Move blackfriday site-wide config loading to NewBlackFriday() 2015-11-23 17:35:36 +01:00
Bjørn Erik Pedersen
831e936846 Improve "watching for ..." logging 2015-11-23 16:32:06 +01:00
Anthony Fok
8727475596 Fix missing word in code comment (my own fault) 2015-11-22 09:40:22 -07:00
Bjørn Erik Pedersen
8d8fa7222f Remove some superficial tests 2015-11-19 20:27:02 +01:00
Anthony Fok
e95db67b20 Add smartDashes flag for Blackfriday
To allow the end users to disable any form of smart dashes
(LaTeX-style or not) while keeping the rest of Blackfriday
SmartyPants features.

Depends on https://github.com/russross/blackfriday/pull/190
"Add HTML_SMARTYPANTS_DASHES for toggling smart dashes"
to be accepted by Blackfriday developers.
2015-10-30 13:30:25 -06:00
Bjørn Erik Pedersen
36adb5fb88 Preserve Unicode marks in MakePath
Fixes #1488
2015-10-18 10:36:27 +02:00
Nathan Youngman
ec9c691216 Insert code tag for server-side syntax highlighting
Inserts a code tag into Pygments output with the language-info that is present when using client-side highlighting (useful for CSS hooks)

```html
<code class="language-go" data-lang="go">
```

closes #1490
2015-10-15 17:59:28 +02:00
Bjørn Erik Pedersen
6a3aced15a Rename prettiyPath to prettifyPath 2015-10-15 10:15:26 +02:00
Bjørn Erik Pedersen
5619fe52d3 Unexport internal path helper 2015-10-14 21:34:34 +02:00
Bjørn Erik Pedersen
72f14a8202 Apply project wide go fmt 2015-10-12 20:47:06 +02:00
Alexander Morozov
7b4e4769d0 Fix comment for NormalizeHugoFlags 2015-10-07 21:28:29 +02:00
coderzh
823334875d WordCount and Summary support CJK Language
* add global `hasCJKLanguage` flag, if true, turn on auto-detecting CJKLanguage
 * add `isCJKLanguage` frontmatter to force specify whether is CJKLanguage or not
 * For .Summary: If isCJKLanguage is true, use the runes as basis for truncation, else keep as today.
 * For WordCount: If isCJKLanguage is true, use the runes as basis for calculation, else keep as today.
 * Unexport RuneCount

Fixes #1377
2015-10-07 15:14:57 +02:00
Andrew Brampton
c2c694f136 Add GitHub style code fence support to mmark
Fixes #1258.
2015-10-05 17:45:37 -04:00
Bjørn Erik Pedersen
218554e363 Rename NormalizeHugoFlagsFunc to NormalizeHugoFlags
It IS a func.
2015-10-02 06:48:02 +02:00
Bjørn Erik Pedersen
f5308da320 Move isThemeVsHugoVersionMismatch to /commands
To prevent potential package cycles in /helpers.
2015-09-14 17:31:39 +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
coderzh
0e1fd78fb2 WordCount Summary support UTF-8 string 2015-09-12 15:41:17 +02:00
chrongzhang
52d94fa675 Add config option "disablePathToLower"
Enabling this prevents lowercasing of the path/url.

Fixes #557
2015-09-01 15:26:02 +02:00
Bjørn Erik Pedersen
5b90b388cb Unexport FileAndExt
If needed outside helpers, create an exported file path (FilePathAndExt?)  and/or a url version.
2015-08-26 21:29:32 +02:00
Bjørn Erik Pedersen
b05a292c21 Revert "Fix some Go code doc issues"
This reverts commit de7dd70bbc.

Broke the code fence feat.
2015-08-07 20:09:40 +02:00
Bjørn Erik Pedersen
de7dd70bbc Fix some Go code doc issues 2015-08-06 22:58:10 +02:00
Anthony Fok
4a2eda49cd Add option to disable Blackfriday Smartypants
Can be used in site config or per page front matter:

```
[blackfriday]
smartypants = false
```
2015-08-04 21:42:32 +02:00
Baptiste Mathus
b23b546a30 Asciidoc[tor]: use --no-header-footer option
This simplifies the retrieval of the HTML (no more need to extract the
part within body) and also removes the unwanted "Last Updated" part in
the article.
2015-07-29 17:36:19 +02:00
Bjørn Erik Pedersen
77c60a3440 Add RuneCount to Page
Fixes #1266
2015-07-12 11:05:37 +02:00
Andrew Brampton
c139c6e1ef Add support for GitHub-flavoured markdown code fences for highlighting
This commit adds a new PygmentsCodeFences config option (default false), which if true will allow GitHub style backtick code fences around code, which will then be rendered by Pygments.

For example:

``` language
your code
```

can be used instead of {{< highlight language >}}your code {{< /highlight >}}.

Fixes #362
2015-07-08 08:12:52 +02:00
Andrew Brampton
fdab118010 If no language is provided to Pygments, then try and guess it
Previously if no language was specified, then illegal args would be passed to pygments, for example `pygments -l -fhtml`, which would result in pygments printing an error.
2015-07-08 08:12:06 +02:00
Bjørn Erik Pedersen
483fc8fa3d Add config option for Blackfriday HTML_HREF_TARGET_BLANK
Fixes #1220
2015-06-28 15:18:15 +02:00
Bjørn Erik Pedersen
05c07c561a Add option to disable Blackfriday LaTeX style dashes
Can be used in site config of per page front matter:

```
[blackfriday]
latexDashes = false
```

Fixes #1231
2015-06-28 15:08:52 +02:00
Jonathan Anderson
1058cb17d1 Refactor theme path helper functions.
Reduce duplication (`x + FilePathSeparator + y` a few lines away from `filepath.Join(x, y)`) and add a `GetThemeDir()` function to get the current theme's directory.

Also add a comment complaining about the `GetThemesDirPath()` function, which doesn't seem to do what its name would suggest. This might be a candidate for deprecation?
2015-06-25 18:05:43 +02:00
Bjørn Erik Pedersen
50269f2512 Remove superfluous return 2015-06-16 22:31:51 +02:00
Bjørn Erik Pedersen
4b7c1342fd Make removal of accents in taxonomy and section paths optional
And default off.

Fixes #1180
2015-06-16 19:25:48 +02:00
Vincent Batoufflet
82cc1ac0f8 Add Blackfriday definition lists extension support 2015-06-15 21:15:05 +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
3ea4df35f2 Remove accents in URLs
So the taxonomy `Gérard Depardieu` gives paths on the form `gerard-depardieu`.

Unfortunately this introduces two imports from the `golang.org/`, but Unicode-normalization isn't something we'd want to write from scratch.

See https://blog.golang.org/normalization

See #1180
2015-05-31 20:30:45 +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
be964e95a1 Never remove trailing slash in RelPermalink
Fixed #1174
2015-05-27 20:41:43 +02:00
bep
beaa008c2f Make deprecated warning for this release more alert 2015-05-26 23:08:25 +02:00
bep
be381683ff Hyphenate DEV version 2015-05-26 22:44:39 +02:00
spf13
d4de261508 bumping master version to v0.15-DEV 2015-05-25 21:46:29 -04:00
spf13
6af9d6789e Bump version to Hugo v0.14.0 2015-05-25 11:59:47 -04:00
bep
beee679dfb Unexport filepath/path bridge types
They are of no use outside the helpers package.

See #1160
2015-05-25 13:10:40 +02:00
bep
be79c35bda Pass RenderingContext by reference in Mmark 2015-05-25 12:57:58 +02:00
spf13
a584ff207b Stop Viper from leaking across many of the tests (now tests pass regardless of order tested) 2015-05-20 02:21:21 -04: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
bec839e652 Add relURL template func
Fixes #1126
2015-05-11 13:59:02 +02:00
bep
be0cbeee7f Add absURL template func
Fixes #1106
2015-05-11 12:28:35 +02:00
bep
bec90e0850 Make page 1 alias ugly
When `uglyurls = true`

Fixes #1121
2015-05-10 18:28:44 +02:00
bep
a52e508d46 Update test logs for uniformity and consistency
Many minor fixes to make test logs more consistent and correct a
mispelling.

Standardize on "[%i] got X but expected Y" for log messages. Using
a consistent layout makes it easier to read the test results. This
was mostly changing "Got" to "got". Swapped the order of values on
several calls to bring them in line with the convention.

A few log messages had a sequence number added to identify the
exact scenario that failed. Otherwise, there would be no way to
ascertain which failed When there are many scenarios.

Correct spelling of "expected."

Fixes #1028
Merged be2097e1ad

[close #1040]
2015-05-08 22:27:00 -04: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
Yosuke INOUE
3596b1b810 Add blackfriday/ExtensionsMask option. 2015-05-07 21:12:28 +02:00
Andrew Gallant
ee5a1bbf44 Allow 'classprefix' pygments options. 2015-05-07 03:45:51 +02:00
bep
bea9280fb3 Do not add trailing slash to baseURL
Fixes #1105
2015-05-05 16:02:44 +02: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
be29c0bfbd Print ERROR on theme vs Hugo version mismatch
Fixes #1070
2015-04-28 20:39:25 +02:00
bep
be0d977009 Only write highlight to cache when CacheDir is set
To avoid writing cache files when testing.
2015-04-16 02:27:23 +02:00
bep
be24457acf Add more options to highlight
Fixes #1021
2015-04-15 20:31:06 +02:00
bep
be540f5b8f Fix potential Windows path issue with Pygments cache 2015-04-14 19:58:33 +02:00
bep
beb66c19a4 helpers: add some missing documentation 2015-04-03 22:30:08 +02:00
bep
bea42218b6 helpers: fix some go vet errors 2015-04-03 21:20:25 +02:00
bep
bea5feb34d Return early from DistinctErrorLogger's Printf 2015-04-03 21:16:32 +02:00
Dylan MacKenzie
99a18b21fc List directories being watched when server is run
Fixes part of issue 1030. Previously hugo only listed the content
directory as being watched. Now we list all files being watched
according to `commands.getDirList()`. We also introduce a RemoveSubpaths
function and test in the helpers module to reduce noise in the command
line output by not showing subdirectories of ones already being watched.

For example, instead of:
`Watching for changes in $HOME/blog/content`
We get:
`Watching for changes in
$HOME/blog/{data,content,layouts,static,themes/my-theme}`
2015-04-02 12:52:08 +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
Ruben Vermeersch
e8ca8602c0 Hash all pygments parameters.
Ensures that Hugo rehighlights source code whenever one of the
highlighting options changes.
2015-03-29 13:01:44 +02:00
Ruben Vermeersch
15463d3d45 Cache pygments rendering between runs
Fixes #1000
2015-03-27 19:50:48 +01:00
bep
9688ed2585 Comment out shaky Seq test 2015-03-18 12:42:00 +01: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
3273fce044 Refactor Hugo version
Put version handling into the helpers package so it can be used by many,
and split version and suffix to make it possible to calculate the next Hugo version.
2015-03-18 12:23:13 +01:00
bep
e39a258ec4 Improve type handling in Seq 2015-03-18 11:30:37 +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
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
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
bep
bd2b679eaf helpers: apply some Golint rules 2015-03-07 00:02:06 +01:00
bep
e685dfc0c6 Apply some more Golint suggestions 2015-03-06 18:07:50 +01:00
bep
103ea842f8 Fix errors reported by Go Vet 2015-03-06 15:25:19 +01:00
bep
9d80ecb4d8 Keep trailing slash when baseUrl contains a sub path
Before this commit, .Site.BaseUrl ended up as:

http://mysite.com/ => http://mysite.com/
http://mysite.com/sub/ => http://mysite.com/sub

Now it becomes:

http://mysite.com/ => http://mysite.com/
http://mysite.com/sub/ => http://mysite.com/sub/

Fixed #931
2015-02-28 18:45:02 +01:00
Cyrill Schumacher
a3892685bc Add trailing file separator to temp dir
Make sure that the file separator is added to the temp dir in all cases.

This prevents cache temp files being written to the root temp folder.

Fixes #910
2015-02-19 14:16:04 +01:00
Anthony Fok
c4393257e8 Adapt to relative path bug fix in purell
Temporary workaround for the bug fix and resulting
behavioral change in purell.NormalizeURLString():
a leading '/' was inadvertently to relative links,
but no longer, see #878.

I think the real solution is to allow Hugo to
make relative URL with relative path,
e.g. "../../post/hello-again/", as wished by users
in issues #157, #622, etc., without forcing
relative URLs to begin with '/'.
Once the fixes are in, let's remove this kludge
and restore SanitizeUrl() to the way it was.

Fixes #878
2015-02-17 12:31:39 -05:00
Cyrill Schumacher
41a5168198 Fix bug on windows where the backslash got removed in func MakePath() 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
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
fa71f6c11e Make # survice Url cleaning
To enable anchors in Urls.

Fixes #888
2015-02-10 19:14:19 +01:00
bep
08219161dd Use buffer pool in StripHTML
Allocates less memory:

benchmark              old ns/op     new ns/op     delta
BenchmarkStripHTML     6572          6695          +1.87%

benchmark              old allocs     new allocs     delta
BenchmarkStripHTML     5              4              -20.00%

benchmark              old bytes     new bytes     delta
BenchmarkStripHTML     848           737           -13.09%

Compared to 0.12:

benchmark              old ns/op     new ns/op     delta
BenchmarkStripHTML     10210         6695          -34.43%

benchmark              old allocs     new allocs     delta
BenchmarkStripHTML     6              4              -33.33%

benchmark              old bytes     new bytes     delta
BenchmarkStripHTML     1456          737           -49.38%
2015-02-06 15:35:45 +01:00
bep
43e48a8989 Add benchmark test for StripHTML
go test -test.run=NONE -bench=".*" -test.benchmem=true ./helpers

Old vs new impl (string.Replace vs string.Replacer):

benchmark              old ns/op     new ns/op     delta
BenchmarkStripHTML     10210         6572          -35.63%

benchmark              old allocs     new allocs     delta
BenchmarkStripHTML     6              5              -16.67%

benchmark              old bytes     new bytes     delta
BenchmarkStripHTML     1456          848           -41.76%
2015-02-06 10:00:42 +01:00
bep
48b6777ea2 Fix Truncate
TruncateWordsToWholeSentence knows if the summary is truncated, so let "him" decide.

Fixes #880
2015-02-05 14:04:48 -07:00
bep
2bee4a1570 Replace 4 strings.Replace with 1 strings.Replacer
Consumes less memory, slightly faster.
2015-02-05 18:31:11 +01:00
bep
f8704c1bf2 Avoid calling strings.Fields multiple times with same content
This should be a relief for big sites.
2015-02-05 00:38:50 +01:00
Naoya Inada
d1364ffb68 Fix defaults for Blackfriday 2015-01-31 22:06:50 +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
e1e6aaed2f Merge branch 'master' of github.com:spf13/hugo 2015-01-31 01:04:28 -05:00
spf13
66ed5c5e02 Adding BufferPool. Implementing BP in ReaderTo{Bytes,String}(). 2015-01-30 11:12:07 -08:00
Dan Hersam
523f38a9a8 Fix for issue 839 and 490 on Windows
The paths were seen as changed but not static because of the backslashes in
ev.Name. Once the backslashes were added, I discovered that the JSON
sent to livereload was invalid and failed to work because it had backslashes.

Hence the code to replace the backslashes from the path to make them work
in JSON and for the URL.

With this fix, changes to a stylesheet are shown on the page, and if it's a
single file that changed, it's reflected in the browser without reloading the whole
page.
2015-01-30 14:18:17 +01:00
fundon
ee1045ad42 ignore root path, no need strip traling slash 2015-01-28 09:43:43 +01:00
bep
e52a76f559 Use runtime.GOOS to identify Windows specific path tests 2015-01-27 23:01:32 +01:00
bep
251f5e9d40 Do not panic on permission denied
Replace panic with FATAL logging and graceful shutdown.

Fixes #837
2015-01-27 16:51:24 +01:00
bep
8ad4fd05d8 Split Windows and Unix specific path tests 2015-01-27 15:09:01 +01:00
bep
b155e8b4cb Temporarily comment out breaking Windows test case 2015-01-27 12:12:35 +01:00
bep
bedc2d8488 Introduce FilepathPathBridge
This commit introduces the new interface FilepathPathBridge to remove some code that differs only in their use of either the path or filepath package.
2015-01-27 11:44:41 +01:00
bep
5f9596e68c Add more tests to helper 2015-01-27 10:15:57 +01:00
bep
37445bc6aa Add pagination support for home page, sections and taxonomies
Two new configuration properties, `Paginate` (default `0`) and `PaginatePath` (default `page`) are added.

Setting `paginate` to a positive value will split the list pages for the home page, sections and taxonomies into chunks of size of the `paginate` property.

A `.Paginator` is provided to help building a pager menu.

There are two ways to configure a `.Paginator`:

1. The simplest way is just to call `.Paginator.Pages` from a template. It will contain the pages for "that page" (`.Data.Pages` will (like today) contain all the pages).
2. Select a sub-set of the pages with the available template functions and pass the slice to `.Paginate` : `{{ range (.Paginate (where .Data.Pages "Type" "post")).Pages }}`

**NOTE:** For a given Node, it's one of the options above. It's perfectly legitimate to iterate over the same pager more than once, but it's static and cannot change.

The `.Paginator` contains enough information to build a full-blown paginator interface.

The pages are built on the form (note: BLANK means no value, i.e. home page):

```
[SECTION/TAXONOMY/BLANK]/index.html
[SECTION/TAXONOMY/BLANK]/page/1/index.html => redirect to  [SECTION/TAXONOMY/BLANK]/index.html
[SECTION/TAXONOMY/BLANK]/page/2/index.html
....
```

Fixes #96
2015-01-26 12:59:37 +01:00
Naoya Inada
407e80a9ab Add site-wide/per-page [blackfriday] extensions option 2015-01-26 09:55:37 +01:00
Anthony Fok
f6c0b472e9 Make Blackfriday smart fractions to really default to true
Fix my own bug in Pull Request #829,
commit eb686352b1
2015-01-24 22:06:15 +01:00
Anthony Fok
eb686352b1 Add site-wide/per-page [blackfriday] fractions option
Make Blackfriday's `HTML_SMARTYPANTS_FRACTIONS` option
user-configurable.  Defaults to `true` as before.  See
discussions at:

http://discuss.gohugo.io/t/any-way-to-disable-smart-fractions/328

Thanks to @bjornerik and @spf13 for laying the groundwork
making it easy to expose Blackfriday's underlying configurable
options.
2015-01-24 20:57:40 +01:00
bep
1b42dc572a Fix RelPermalink() and Urls in menus vs canonifyUrls
canonifyUrls=true, RelPermalink and baseUrl with sub-path did not work.

This fixes that by adding a check for canonifyUrl=trues=true in RelPermalink().

So given

- baseUrl "http://somehost.com/sub/"
- the path "some-path/file.html"

For canonifyUrls=false RelPermalink() returns "/sub/some-path/file.html"
For canonifyUrls=true RelPermalink() returns "/some-path/file.html"

In the last case, the Url will be made absolute and clickable in a later step.

This commit also makes the menu urls defined in site config releative. To make them work with canonifying of urls, the context root is prepended if canonifying is turned off.

Fixes #519
Fixes #711
2015-01-23 14:13:00 +01:00
Anthony Fok
19c52ab0b5 Register rstHandler to restore experimental reST support
(Experimental) reStructuredText support was working in v0.12,
but was no longer handled after some refactoring in v0.13-DEV.
That experimental support is now restored.

Furthermore, check for both rst2html and rst2html.py in the PATH,
and execute whichever is found.

See #472 for more information.
2015-01-21 06:41:19 -07:00
bep
2ec046afb1 Minor polish in path/url 2015-01-20 20:45:03 +01:00
bep
9e688507a7 Add more tests to general helper 2015-01-20 18:13:47 +01:00
Marek Stanley
49f5eb5c84 Moved a test regarding a content.go function to a new test file content_test.go.
Added some tests for general helpers, especially as a way to document the expected behavior,
and as a warm-up welcome contribution.
2015-01-09 12:42:13 +01:00
Jacob Gillespie
c0f54aefe3 Rename to plainIdAnchors 2015-01-05 21:00:22 +01:00
Jacob Gillespie
4adf58cce7 Group both options under Blackfriday: documentIDAnchor 2015-01-05 21:00:22 +01:00