Commit graph

634 commits

Author SHA1 Message Date
Anthony Fok 0d1d33d7f3 Print error when /index.html is zero-length
Also print warning (in verbose mode) for other empty pages.

See #947
2015-12-01 21:03:17 -07:00
Anthony Fok f8302768c7 Run go fmt hugolib/site.go 2015-12-01 21:01:19 -07:00
Steve Francia f045d7a611 Change the license to Apache 2.0 2015-11-23 22:16:36 -05:00
Kato Kazuyoshi 99acbb2eb2 Permalink on Node and Page should be of string
This change fixes #1384.
2015-11-23 17:41:29 +01:00
Marek Janda 5838420aa1 Move blackfriday site-wide config loading to NewBlackFriday() 2015-11-23 17:35:36 +01:00
Cameron Moore fde47c5eb9 Add shortcode IsNamedParams property
It would be helpful to know whether a shortcode was called with positional or
named parameters.  This commit adds a boolean `IsNamedParams` property to the
`ShortcodeWithPage` struct.
2015-11-23 17:17:18 +01:00
Bjørn Erik Pedersen 6fa7f2ac3e Avoid multiple locks for shortcode template
Fixes #1600
2015-11-21 23:29:58 +01:00
Bjørn Erik Pedersen c5f40e8b8b Improve RW-locking of template in shortcode handling
See #1599
2015-11-21 21:57:26 +01:00
Bjørn Erik Pedersen 58c446f562 Fix recently introduced new data race in the shortcode handling
Fixes #1599
2015-11-21 20:03:18 +01:00
Cameron Moore 3abb2675c5 Add RSSLink to SiteInfo 2015-11-20 23:38:15 +01:00
Cameron Moore 05c29ad593 Return error if shortcode template.Tree is nil
If a shortcode template fails to compile, the template will be non-nil, but
template.Tree will be nil which caused a panic.
2015-11-20 23:34:30 +01:00
Bjørn Erik Pedersen b08d9f26ae Make replaceShortcodeTokens rewrite the input slice
Currently a `[]byte` copy is returned. In most cases this is the safe thing to do, but we should just modify/grow the slice as needed.

This is faster and consumes less memory:

```
benchmark                             old ns/op     new ns/op     delta
BenchmarkReplaceShortcodeTokens-4     7350          4419          -39.88%

benchmark                             old allocs     new allocs     delta
BenchmarkReplaceShortcodeTokens-4     5              1              -80.00%

benchmark                             old bytes     new bytes     delta
BenchmarkReplaceShortcodeTokens-4     4816          1152          -76.08%
```

This commit is aso a small spring cleaning of duplicated code in the different `PageConvert` methods.

Fixes #1516
2015-11-17 18:24:17 +01:00
Anthony Fok 18a29964fa Fix trivial typos in code 2015-11-16 07:15:17 -07:00
spf13 5c1204c24b simplify rssuri logic 2015-11-15 11:05:16 -05:00
Bjørn Erik Pedersen 53a5932fa4 Get rid of allocation in the BenchmarkReplaceShortcodeTokens itself
So we can see the real numbers.

See #1516
2015-11-13 22:37:07 +01:00
Tatsushi Demachi 139be09f17 Fix GroupByParam to return original param string
Page.GroupByParam function internally uses Page.GetParam to get a
parameter value for a key of a page group but now Page.GetParam returns
a lowercase character string every time. It has no need to using
lowercase character string as a group key value and it confuse a
function user.

This fixes it to keep and return an original parameter string as a group
key value.

Fix #1564
2015-11-10 14:57:03 +01:00
Bjørn Erik Pedersen 570713a478 Use Identifier as last sort resort for default menu sort
Fixes #1562
2015-11-09 21:02:21 +01:00
digitalcraftsman 9dbb6dc50d Add internal Google Analytics template
This commits also adds the GoogleAnalytics
variable to insert the tracking code.

Fixes #1424.
2015-11-04 17:11:38 -05:00
Bjørn Erik Pedersen 5bda0398e7 Export Page.Layout
And at the same time rename and unexport the badly named `Layout()` func. That method is not very usable outside the package.

Fixes #1539
2015-11-02 17:24:50 +01:00
Kato Kazuyoshi 698019a552 Disable LiveReload when Hugo is not running as a server
This change fixes #1410.
2015-10-15 16:36:14 -04:00
Nathan Youngman bea7b2e202 Fix typo in shortcode tests 2015-10-15 18:00:10 +02:00
Bjørn Erik Pedersen 078fad49e2 Add Param(key) to Node and Page
This  is a convenience method to do lookups in Page's (Page only)  and Site's Params map (Page and Node), in that order.

Fixes #1462
2015-10-12 06:11:01 +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
Bjørn Erik Pedersen dcd9c69aa8 Use filepath as the last default sort key for pages 2015-09-30 05:43:11 +02:00
Sven Dowideit a1e32439fb Allow for any (short) line begining or ending with html comment
Fixes #1428
2015-09-25 18:32:32 +02:00
Anthony Fok e71bef79e5 Validate aliases to prevent directory traversal etc.
Add validation before creating aliases:

 * Prevent creating aliases outside webroot (public/ dir)
 * Skip empty "" alias
 * Skip "/" → "/index.html", which gets overwritten anyway
 * Refuse to create Windows-invalid filenames on Windows;
   warn on other platforms
 * In case of invalid aliases, after skipping them,
   return `err = nil` to prevent the error passing up
   all the way to `hugolib.Render()` and causing Hugo to abort.
 * Update alias tests.

Fixes #701: Add support for alias with whitespace
Fixes #1418: Add validation for alias
2015-09-13 18:08:42 +02:00
Anthony Fok 29aa9baecd Complete the Url-to-URL transition in tests
See #959
2015-09-13 05:21:24 -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
Jeff Hodges 49fe04c0bd Correct check of published boolean 2015-08-31 05:26:46 +02:00
Jeff Hodges 311593bff0 Add undocumented published setting to front matter
A new "published" setting that is the opposite of "draft" is added and
left intentionally undocumented.

This setting comes from jekyll and eases the transition to hugo
greatly. We leave it undocumented so that folks don't rely on it, but
also don't shoot themselves in the foot during a jekyll migration.

The foot-shooting occurs if they have only a few documents that were
drafts ("published: false") in the jekyll version of their site and
don't notice that they were published in the migration to hugo.
2015-08-30 20:40:56 +02:00
Bjørn Erik Pedersen 04b4c996ac Reset Scratch for 404
The 404 pages etc. need a better solution, but fix this issue for now.

Fixes #1336
2015-08-07 20:30:01 +02:00
Bjørn Erik Pedersen 0f1fb8c7d8 Avoid panic in shortcode param handling
Fixes #1337
2015-08-07 20:08:23 +02:00
Bjørn Erik Pedersen 35bb72c83e Do not panic on index out of range in shortcode.Get
Fixes #1335
2015-08-07 19:21:26 +02:00
Anthony Fok b0416e9bef Strip trailing whitespace in code 2015-08-04 11:59:32 -06:00
Marek Janda 4bed69629e Add map support to scratch 2015-08-02 17:23:36 +02:00
Anthony Fok 252ea96d1d Remove deprecated fields and methods for v0.15
Special thanks to @bep for his guidance and
for making sure all of the Hugo themes get updated.

Fixes #1172
2015-07-30 13:33:38 +02:00
Bjørn Erik Pedersen 43891e3994 Always use the template provided in page.Render
Fixes #1306
2015-07-29 01:19:29 +02:00
Bjørn Erik Pedersen 3037d200cb Fix inconsistent front matter handling
Fixes #768
2015-07-26 15:28:56 +02:00
Ryan Clarke 18d69d7f8c Fix periods in taxonomies create bad paths
Fixes #1188
2015-07-25 21:43:20 +02:00
Bjørn Erik Pedersen c1a2b7a102 Replace strings.Compare
Which is a Go 1.5 func.

See #1299
2015-07-25 17:38:13 +02:00
Bjørn Erik Pedersen 40efc8677a Fix sort test and title sort
See #1299
2015-07-25 17:22:46 +02:00
Bjørn Erik Pedersen 36e0d005ed Fall back to link title for default page sort
Fixes #1299
2015-07-25 16:34:35 +02:00
Bjørn Erik Pedersen 28020f866b Move apply before cache put
It just looks better.

See #1293
2015-07-24 00:28:21 +02:00
Bjørn Erik Pedersen a9c5133a77 Fix data races in sorting and Reverse
The custom sort functions used from the templates had some subtle data race- and related issues,
especially when used in the single page template.

This commit fixes this by making copies and protect the read and writes with a RWMutex.

The results are cached (it will typically be invoked *number of pages* times with exactly the same data).

This is, not surprisingly, also faster:

```
benchmark                           old ns/op     new ns/op     delta
BenchmarkSortByWeightAndReverse     14228         491           -96.55%

benchmark                           old allocs     new allocs     delta
BenchmarkSortByWeightAndReverse     1              0              -100.00%

benchmark                           old bytes     new bytes     delta
BenchmarkSortByWeightAndReverse     32            0             -100.00%
```

Fixes #1293
2015-07-23 12:43:57 +02:00
Bjørn Erik Pedersen ea6ae769dc Fix broken test 2015-07-21 21:12:03 +02:00
Bjørn Erik Pedersen 5cf0aa2fc0 Add benchmark for sort and reverse 2015-07-21 21:08:20 +02:00
Edward Vielmetti c8477c4f6e Fix typo: "taxononomy" -> "taxonomy" 2015-07-19 19:36:23 +02:00
Bjørn Erik Pedersen 1a94148d06 Add paginator support for page groups
Fixed #1274
2015-07-18 14:53:52 +02:00
Valere JEANTET 2c22a8b79a fix TestHomeNodeMenu test
Signed-off-by: Valere JEANTET <valere.jeantet@gmail.com>
2015-07-14 21:31:47 +02:00
Valere JEANTET 247574976c Allow page.HasMenuCurrent() and node.HasMenuCurrent() to proceed with multi-level nested menus
Currently HasMenuCurrent only process the first 2 levels.
2015-07-14 21:31:47 +02:00
Bjørn Erik Pedersen a2fa3895ee Fix log message in test 2015-07-12 19:27:29 +02:00
Bjørn Erik Pedersen 3663828f5e Optimize RuneCount
Do not create it unless used.

See #1266
2015-07-12 11:28:19 +02:00
Bjørn Erik Pedersen 77c60a3440 Add RuneCount to Page
Fixes #1266
2015-07-12 11:05:37 +02:00
delputnam 9b3d0cf5bf Added missing "Social" section to SiteInfo
I could be wrong here, but it looks to me like .Site.Social.facebook is used in tpl/template_embedded.go, but the variable is never set. I've added a line to initializeSiteInfo to map the info from config into this variable.
2015-07-02 19:26:01 +02:00
Marc-Antoine Ruel c9fc0e786f Add Page.RawContent() to access raw Markdown as a string.
In particular, RawContent() excludes the metadata header.

This is necessary in the use case of embedding remarkjs.com slides, as it needs
the unprocessed Markdown content to generate the slides.
2015-07-02 19:24:30 +02:00
Bjørn Erik Pedersen 664a97819f 404 is homeless
Fixes #1235
2015-06-28 10:43:43 +02:00
Piotr Kowalczuk 29e786aac5 Proper parsing structured array from yaml based FrontMatter 2015-06-25 17:56:22 +02:00
Bjørn Erik Pedersen e764a6e638 Use pooled buffer in replaceShortcodes
Even as a copy at the end is needed, this consumes way less memory on Go 1.4.2:

```benchmark                           old ns/op     new ns/op     delta
BenchmarkParsePage                  145979        139964        -4.12%
BenchmarkReplaceShortcodeTokens     633574        631946        -0.26%
BenchmarkShortcodeLexer             195842        187938        -4.04%

benchmark                           old allocs     new allocs     delta
BenchmarkParsePage                  87             87             +0.00%
BenchmarkReplaceShortcodeTokens     9424           9415           -0.10%
BenchmarkShortcodeLexer             274            274            +0.00%

benchmark                           old bytes     new bytes     delta
BenchmarkParsePage                  141830        141830        +0.00%
BenchmarkReplaceShortcodeTokens     35219         25385         -27.92%
BenchmarkShortcodeLexer             30178         30177         -0.00%
```
See #1148
2015-06-22 20:30:20 +02:00
Bjørn Erik Pedersen d4b6f9aca3 Fix map-order dependent menu tests
Fixes #1222
2015-06-21 23:36:58 +02:00
Bjørn Erik Pedersen c507229191 Print URL when failing menu test
See #1222
2015-06-21 23:09:39 +02:00
Bjørn Erik Pedersen dbd93f5112 Remove unused var 2015-06-21 22:57:42 +02:00
Bjørn Erik Pedersen 004fcddc80 Remove superfluous p-tags around shortcodes
This commit replaces the regexp driven `replaceShortcodeTokens` with a handwritten one.

It wasnt't possible to handle the p-tags case without breaking performance.

This fix actually improves in that area:

```
benchmark                           old ns/op     new ns/op     delta
BenchmarkParsePage                  142738        142667        -0.05%
BenchmarkReplaceShortcodeTokens     665590        575645        -13.51%
BenchmarkShortcodeLexer             176038        181074        +2.86%

benchmark                           old allocs     new allocs     delta
BenchmarkParsePage                  87             87             +0.00%
BenchmarkReplaceShortcodeTokens     9631           9424           -2.15%
BenchmarkShortcodeLexer             274            274            +0.00%

benchmark                           old bytes     new bytes     delta
BenchmarkParsePage                  141830        141830        +0.00%
BenchmarkReplaceShortcodeTokens     52275         35219         -32.63%
BenchmarkShortcodeLexer             30177         30178         +0.00%
```

Fixes #1148
2015-06-21 22:51:12 +02:00
Bjørn Erik Pedersen ae4f72b091 Comment out mystery test
Fails on Travis in Go 1.3 + 1.5.

Will have to look into that one.
2015-06-21 22:28:50 +02:00
Bjørn Erik Pedersen 6bcb7e83e7 Revert "add preliminary support for content/index.md file to be homepage content"
This reverts commit 5f84bc02cd.
2015-06-21 15:01:09 +02:00
Bjørn Erik Pedersen 3eb301b57a Revert "refactor and clean up site tests"
This reverts commit 99e250917d.
2015-06-21 15:01:06 +02:00
Bjørn Erik Pedersen f25ce7fefa Revert "Move matchRender to test helpers file"
This reverts commit 32d91d616e.
2015-06-21 15:01:02 +02:00
Bjørn Erik Pedersen d770fa59a5 Revert "Add tests for homepage content support"
This reverts commit 24351c58be.
2015-06-21 15:01:01 +02:00
Bjørn Erik Pedersen 59c6ba4e45 Revert "Make .IsHome work when homepage as page"
This reverts commit 7e765cc1bd.
2015-06-21 15:00:53 +02:00
spf13 7e765cc1bd Make .IsHome work when homepage as page 2015-06-19 10:07:47 -04:00
spf13 24351c58be Add tests for homepage content support 2015-06-17 12:35:44 -04:00
spf13 32d91d616e Move matchRender to test helpers file 2015-06-17 10:47:49 -04:00
spf13 99e250917d refactor and clean up site tests 2015-06-17 10:47:49 -04:00
spf13 5f84bc02cd add preliminary support for content/index.md file to be homepage content 2015-06-17 10:47:49 -04:00
bep be6cf6a9c6 Revert "Add some debug to failing menu test"
This reverts commit becc627e1e.
2015-06-12 22:49:49 +02:00
bep becc627e1e Add some debug to failing menu test 2015-06-11 22:49:07 +02:00
bep bed8197de5 Move Viper reset to correct level in menu tests 2015-06-11 22:41:17 +02:00
bep beda46d289 Reset Viper for every duplicate menu test iteration 2015-06-11 21:22:29 +02:00
bep be44345272 Silence chatty JSON test 2015-06-06 20:57:13 +02:00
bep be38acdce7 Add PreserveTaxonomyNames flag
Before this commit, taxonomy names were hyphenated, lower-cased and normalized -- then fixed and titleized on the archive page.

So what you entered in the front matter isn't necessarily what you got in the final site.

To preserve backwards compability, `PreserveTaxonomyNames` is default `false`.

Setting it to `true` will preserve what you type (the first characters is made toupper for titles), but normalized in URLs.

This also means that, if you manually construct URLs to the archive pages, you will have to pass the Taxonomy names through the `urlize` func.

Fixes #1180
2015-05-31 20:30:53 +02:00
bep be0903c71a Fix FullFilePath
Fixes #732
2015-05-31 18:54:20 +02:00
Artem Vorotnikov 3cee9b7786 Allow custom RSS Uri for section and taxonomy feeds
Fixes #1147
2015-05-31 15:59:51 +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 be535832f7 Add IsHome
To determine if a page is the "Home Page" has inspired lots of creativity in the template department.

This commit makes it simpler: IsHome will tell the truth.
2015-05-28 03:20:08 +02:00
bep be6dfcc495 Add some missing page permalink test cases 2015-05-28 02:30:01 +02:00
bep be964e95a1 Never remove trailing slash in RelPermalink
Fixed #1174
2015-05-27 20:41:43 +02:00
bep bec697b0d5 Remove unused Completed chan on Site
See #1160
2015-05-23 22:13:07 +02:00
bep be7c3bbb09 Prevent cyclic ref crash in JSON encode
Note that this commit makes no promise about great JSON output from the encoder, but the cyclic refs should be broken.

Fixes #1123
2015-05-23 12:28:08 +02:00
bep be0784bbe9 Grammar fix in error message 2015-05-21 23:04:46 +02:00
bep be7f5a4268 Do not consider single.html for the home page
Fixes #1152
2015-05-21 20:12:18 +02:00
spf13 fc946ded29 Adding default handler & tests Fixes #147 2015-05-20 18:55:24 -04:00
spf13 bdb187e482 Merge branch 'master' of GitHub.com:spf13/hugo 2015-05-20 18:48:33 -04: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 be0262786e Add benchmark test for replaceShortcodeTokens 2015-05-19 22:00:48 +02:00
Takuya Wakisaka 2890b6db36 Fix UTF8 permalink
Generate unencoded directory in public dir.

Fixes #988
2015-05-17 14:54:59 +02:00
Takuya Wakisaka 8a96234b1f Add Page tests with UTF8 paths
See #988
2015-05-17 14:54:27 +02:00
bep beaa8b1bca Add support for URLs relative to context root
Setting `RelativeURLs` to `true` will make all relative URLs in the site *really* relative.

And will do so with speed.

So:

In `/post/myblogpost.html`:

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

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

`./mycss.css` etc.

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

The speediness is about the same as before:

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

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

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

```

Fixes #1104
Fixes #622
Fixes #937
Fixes #157
2015-05-16 00:11:44 +02:00
Juan B. Rodriguez d0a4645a34 Set s.Info.LastChange to Lastmod
Set sitemap.xml <lastmod> field to Lastmod.

See #733
2015-05-15 13:10:11 +02:00
Juan B. Rodriguez 3882e7ceaf Add Lastmod field
Create new field in Node
Update Page to look for lastmod field in the front matter. If not present, then assign Date to Lastmod
Update Site, to assign a value to Lastmod (based on the same logic used for Date)

Fixes #733
2015-05-15 13:09:30 +02:00
David Calavera d5c77bdf68 Allow to reverse taxonomy entries. 2015-05-12 18:26:40 +02:00