Commit graph

680 commits

Author SHA1 Message Date
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
bep bec90e0850 Make page 1 alias ugly
When `uglyurls = true`

Fixes #1121
2015-05-10 18:28:44 +02:00
bep 0e00ca6a6e Fix paginator with uglyurls
Fixes #1120
2015-05-10 15:23:36 +02:00
bep bef496b97e Fix .Truncated in manual summaries
Fixes #1119
2015-05-10 13:34:02 +02:00
bep be325a3088 Fix IsMenuCurrent for SectionPagesMenu
Pretty sure it has worked at some point, but that PR probably has been rebased to pieces.

This refactors the fix by @dannys42 into a method, as this URL fix is applied several places.

Fixes #1114
2015-05-09 20:53:58 +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
Danny Sung 2b91b480d0 IsMenuCurrent now resolving correctly when baseUrl is not at the root path 2015-05-08 22:22:50 -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
bep d4acacd4f5 Section menu for the lazy blogger
The current menu system works great, but is too much work if all you want is a simple menu with the sections as menu items, and having these menu items connected to the pages in a way that enables setting the correct menu item as active for both the section lists and the pages itself.

This commit adds a new option `SectionPagesMenu' which, if set, will create a new menu with that name with all the sections as menu items. The pages in the sections will behave as "shadow members" of these section items as `blogpage.HasMenuCurrent "sectionmenu" $sectionmenuitem` will return true.

If a menu item with the same `identifier` is defined in site config, *that* item will take precedence.
2015-05-08 21:28:19 -04:00
bep beb4ab162d Make RSS output test more realistic
By setting a non-default RSS uri config value.
2015-05-08 20:33:37 +02:00
Dana H. P'Simer fd08e16ec8 Add RSSUri to specify the name of the RSS file 2015-05-07 22:20:00 +02:00
bep bec2c1e37a Add shortcode support for HTML files
Fixes #674
2015-05-06 19:11:42 +02:00
bep bea9280fb3 Do not add trailing slash to baseURL
Fixes #1105
2015-05-05 16:02:44 +02:00
bep be9df84772 shortcodeparser: fix panic on slash following opening shortcode comment
Fixes #1093
2015-04-30 15:59:07 +02:00
bep be15b07733 Fix typo in test 2015-04-29 19:22:11 +02:00
bep bee1358e48 Return error from HandleShortcodes
To be able to test for it.
2015-04-29 19:08:27 +02:00
bep be2c67ad45 Fix broken Travis tests
No idea why these suddenly starts to fail.
2015-04-22 18:59:42 +02:00
bep beb32af7a2 Do not fail on unknown files in /data
Fixes #1068
2015-04-22 18:35:56 +02:00
bep be366bfe1e pagination: export pager to make Golint happy 2015-04-21 21:25:34 +02:00
bep be8e6d4f1f Use fmt.Errorf to make Golint happy 2015-04-21 21:13:30 +02:00
bep be01f8430e Add shortcut to Scratch from shortcode 2015-04-19 14:50:27 +02:00
bep be46a4b9b0 Polish func naming in shortcode handling 2015-04-18 00:40:59 +02:00
bep bed053071e Remove unused types Shortcode and ShortcodeFunc 2015-04-18 00:31:56 +02:00
bep bee52f85ae Fix broken Highlight test 2015-04-16 02:20:10 +02:00
bep be6a92c8b6 Temporarily disable Highlight test 2015-04-16 00:58:21 +02:00
bep be01d04870 hugolib: make Page implement the ReaderFrom interface 2015-04-03 21:41:24 +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 bec22f8981 Add pager size argument to paginator methods
Fixes #1013
2015-03-31 19:12:56 +02:00
bep be1429fa88 Fix shortcode handling in ToC
Fixes #1010
2015-03-29 22:27:21 +02:00
Anthony Fok 0921761e47 Add missing ".adoc" extension in handler_page.go
Commit 358dcce supposedly added ".adoc" extension recognition
for AsciiDoc, but one place was missed.

Thanks to @sjfloat for reporting the bug!
See discussions at #470.
2015-03-24 20:27:06 -06:00
bep 9cc3d67c57 Pull Data Files tests into its own file 2015-03-19 17:23:14 +01:00
bep efb564775a Change safeHTtml to safeHTML in sitemap template 2015-03-18 21:27:29 +01:00
bep 658cfb287e Remove URL param from exported AbsURL methods
This is to make it clear that there is only one URL in play,
the BaseURL.
2015-03-18 20:03:34 +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 49f20bbc9b Add UrlPath to the deprecated list 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 bcdad02c06 Use ReaderToString in site tests
Since a string is what's really needed.
2015-03-17 18:14:29 +01:00
bep e1340c060b Fix crossrefs on Windows
Have to convert path slashes to file path slashes before the URL path is compared to a file path.

Fixes #957
2015-03-17 16:29:10 +01: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
Anthony Fok 232398f1b9 Remove trailing space from site build statistics 2015-03-12 08:46:42 -06: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 91d16fbba0 Fix UglyUrls on Windows
Fixes #958
2015-03-07 18:03:17 +01:00
bep 602ceec06d Handle 404 thread safely
Replaces hack that temporarily changes a global flag.

Fixes #955
Fixes #939
2015-03-07 15:18:00 +01:00
bep 851badcb7e There is only one s.PageTarget() - so we cannot change it, even tempoararily. We have to find another solution to this.
...

Prevent 404.html from prettifying into 404/index.html

Restore @realchaseadams's commit 348e123
"Force `UglyUrls` option to force `404.html` file name"
which got lost after some refactoring (commit 8db3c0b).

Remove the equivalent "force `UglyUrls`" code for `sitemap.xml`
because the refactored code now calls `renderAndWriteXML()`
which uses `WriteDestFile()` which does not prettify a filename.

Fixes #939 (reverted from commit c4c19ad303)
2015-03-07 13:22:02 +01:00
bep e007c9b25d hugolib: apply some more Golint rules 2015-03-07 12:53:20 +01:00
bep 5759007874 menu: make receiver name on Page methods consistent
Apply some Golint rules on Menu, esp. making the method receiver names consistent.
2015-03-07 12:52:29 +01:00
bep e24a775962 page: make receiver name on Page methods consistent
Apply some Golint rules on Page, esp. making the method receiver names consistent:

(page *Page) ==> (p *Page)
2015-03-07 12:25:38 +01:00
bep 8539f78143 hugolib: apply some Hugolint rules 2015-03-07 00:13:06 +01:00
bep b9f8c0c120 author: fix doc 2015-03-07 00:10:00 +01:00
bep 103ea842f8 Fix errors reported by Go Vet 2015-03-06 15:25:19 +01:00
Anthony Fok c4c19ad303 Prevent 404.html from prettifying into 404/index.html
Restore @realchaseadams's commit 348e123
"Force `UglyUrls` option to force `404.html` file name"
which got lost after some refactoring (commit 8db3c0b).

Remove the equivalent "force `UglyUrls`" code for `sitemap.xml`
because the refactored code now calls `renderAndWriteXML()`
which uses `WriteDestFile()` which does not prettify a filename.

Fixes #939
2015-03-06 13:12:01 +01:00
bep 3343cacc0e Avoid panic when pagination on 0 pages
Fixes #948
2015-03-06 00:48:33 +01:00
bep 6e1b0e0c00 Apply gofmt -s 2015-03-05 23:57:38 +01:00
bep 8557e2cbb8 Add benchmark for the shortcode lexer 2015-03-05 21:11:15 +01:00
bep ab5862cd00 Allow the same shortcode to be used with or without inline content
Fixes #934
2015-03-02 21:49:33 +01:00