Commit graph

924 commits

Author SHA1 Message Date
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
bep
241f9f9e46 Improve error message on missing shortcode inner content
Fixes #933
2015-02-28 19:24:30 +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
bep
176ce5deab Allow hyphens in shortcode name
Fixes #929
2015-02-27 11:57:23 +01:00
spf13
729a6739f2 Bumping to version "v0.14-DEV" 2015-02-21 23:11:36 -05:00
bep
dc7b7ef865 Avoid race condition in target list init
As reported by Go's race detector.

See #917
2015-02-20 18:38:35 +01:00
bep
c33a8528f8 Avoid race condition in isInnerShortcode
As reported by Go's race detector.

See #917
2015-02-20 17:41:37 +01:00
bep
8ed67169ed Fix broken data dir test 2015-02-11 21:55:11 +01:00
bep
8df59c8123 Temporarily disable broken test 2015-02-11 20:33:19 +01:00
bep
ebcc1e6699 Add data files support in themes
If duplicate keys, the main data dir wins.

Fixes #892
2015-02-11 20:24:56 +01:00
bep
fa71f6c11e Make # survice Url cleaning
To enable anchors in Urls.

Fixes #888
2015-02-10 19:14:19 +01:00
bep
22d85c2a18 Avoid converting summary to []byte and back to string 2015-02-10 14:37:29 +01:00
bep
6afe70d5da Better error message for data-file parsing errors 2015-02-09 16:07:30 +01:00
bep
1c50f775b5 DataDir: Minor polish and add missing tests
Also, now logs an ERROR on duplicate keys, instead of returning an error and make sure sub-folders take presedence in data dir.
2015-02-09 13:19:19 +01:00
Erlend Klakegg Bergheim
773812de6f Reads data files inside data/ and makes data available in .Site.Data
Fixes #476.

Conflicts:
	hugolib/site.go
2015-02-09 13:17:13 +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
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
bep
11a19e0760 Build PageMenus only once 2015-02-04 21:27:27 +01:00
bep
8b95cab94c Avoid panic on unknown markup
Fixes #863
2015-02-01 22:30:57 +01:00
bep
b984ec96bc Optimize for the common case in Blackfriday config 2015-01-31 23:45:38 +01:00
Anthony Fok
c50780930e Print template parsing errors to aid troubleshooting
Added a new Template.PrintErrors() function call,
used in hugolib/site.go#Process() so it does not clutter
up `go test -v ./...` results.

Special thanks to @tatsushid for mapping out the call trace
which makes it a lot easier to find the appropriate places
to place the Template.PrintErrors() call.

Fixes #316
2015-01-31 23:27: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
bep
47c8f32967 Prevent site config being overwritten
Fixed #867
2015-01-31 19:14:13 +01:00
spf13
f4737689bd Updating shortcode imports & site test to work with new buffer pool functions 2015-01-31 01:24:52 -05:00
spf13
e1e6aaed2f Merge branch 'master' of github.com:spf13/hugo 2015-01-31 01:04:28 -05:00
spf13
8db3c0b0a6 page rendering and writing using BBP 2015-01-30 12:05:05 -08:00
Jeffrey Tolar
35684e8f6f Use strings instead of byte arrays for replaceShortcodeTokens tests 2015-01-30 20:58:25 +01:00
Jeffrey Tolar
366c557251 Use a regular expression in replaceShortcodeTokens
This fixes a bug where a shortcode needs to be expanded multiple times,
which can arise in practice when using reference links.
2015-01-30 20:58:25 +01:00
spf13
b4c507287a site's XML generation using BBP 2015-01-30 11:51:06 -08:00
spf13
77074127e0 page source creation using BBP 2015-01-30 11:42:02 -08:00
spf13
2f2297bdb3 shortcodes using BBP 2015-01-30 11:19:46 -08:00
Anthony Fok
ba44e860a3 [Docs] Copyediting
* Add meta author, description and generator tags
 * Add Hugo version beside the logo and in the footer
 * Suggest the user to run `go get -u -v` to update dependencies
 * Requires Go 1.3+ rather than Go 1.1+
 * Improve rendering/formatting in some places
 * Add trailing slash to URLs where appropriate
 * GitHub redirects all http requests to https, update accordingly
2015-01-28 18:02:40 -07:00
bep
7c74a77db6 Replace assert.Equal(true/false) with assert.True/False 2015-01-27 19:47:22 +01:00
bep
de76d4a84e Improve pagination testing
* Add missing pagination test cases
* Remove some unreachable code paths
* Fix some corner cases
2015-01-27 01:27:07 +01:00
bep
fb594fc6e0 Set detault for Paginate to 10
10 is a better default than 0, since no paginator pages will be created unles referenced by a `.Paginator`.

See #750
2015-01-26 15:26:19 +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
Jonathan Anderson
e72ce89aaf Move s.prepUrl() before prepending BaseUrl.
When we have an absolute menu url specified in the config file
(e.g., `menu: { main: { name: "News", url: "/news" } }`),
its menu entry is generated by prefixing it with the BaseUrl.
The result is then run through prepUrl(), which uses helpers.Urlize to
convert urls such as 'My First Link' to 'my-first-link'.

The behaviour is backwards: we do not want to run helpers.Urlize on the
BaseUrl, only on the absolute component. Currently, a BaseUrl such as
'http://my.edu/ENG101' will be converted to 'http://my.edu/eng101',
resulting in broken links in all of my menus.

This commit switches the URL prep and BaseUrl prepending actions around. I
would argue that these URLs shouldn't be run through prepUrl anyway
because the site developer has specified them explicitly in a config file
and might be surprised for, e.g., URLs to change case, but that's another
commit for another time.
2015-01-26 01:03:18 +01:00
Anthony Fok
803865f870 Fix for page.GetParam() for JSON and TOML maps
Setting per-page Blackfriday angledQuotes did not work
with TOML or JSON front matter, but it does work with YAML.

It turns out that page.Params("blackfriday") returns
type map[interface{}]interface{} for YAML, but
type map[string]interface{} for JSON and TOML.

This patch updates page.GetParam() to catch the latter,
with an error message if page.GetParam() does not recognize
a type.  A test is also added.
2015-01-24 15:25:44 +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
bep
01ec44a6b4 Add menu tests for pages with both Yaml and Toml front matter
See #817
2015-01-22 17:23:01 +01:00
bep
878754c21f Protect the innerShortCodeCache by a RW lock 2015-01-21 19:13:11 +01:00
bep
c8f8f48e96 Cache the page's rendering context flags
This map can potentially be used many times for a given page, and altough the cost of re-creating the map should be minimal, caching it is simple -- and could save some GC and CPU cycles.
2015-01-21 15:30:03 +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
1cc6386937 Make ref and relref respect plainIdAnchors
Fixes #813
2015-01-21 14:35:33 +01:00
Anthony Fok
02da49597d Fix string comparison for .Truncated page variable
Instead of `strings.TrimSpace()`, use `strings.Join(strings.Fields(s), " ")`
to collapse all whitespaces into single spaces, in order to match the
behaviour of helpers.TruncateWordsToWholeSentence(),
in order to detect non-truncated content correctly.
2015-01-20 15:50:32 -07:00
bep
9712d06b36 Fix the Hugo.Generator tag so it can be used 2015-01-19 08:26:06 +01:00
bep
c23dfd99dd Use an init() method to create the HugoInfo instance
See #570
2015-01-19 03:06:07 +01:00
bep
724357a242 Make sure there are only one HugoInfo instance
See #570
2015-01-19 02:53:07 +01:00
bep
73d923e95d Fix HugoInfo init
See #570
2015-01-19 02:40:34 +01:00
Derek Perkins
ac6b86aff8 Added top level .Hugo variable with version, commit and generator information + docs
Added Version, CommitHash and BuildDate to hugolib/hugo.go and used it in build
Removed commitHash and buildDate from commands/version.go and used hugolib vars
Removed getDateFormat function from commands/version.go

Conflicts:
	README.md
	docs/content/templates/variables.md
2015-01-19 01:22:23 +01:00
bep
714abd5ce0 Fix issue with nested shortcodes
Fixes #797
2015-01-15 12:21:15 +01:00
bep
f0b3979a9f Disable shortcode processing for html files
May be enabled later, but then it will have to do the complete "shortcode dance".

See ##674
2015-01-14 20:49:43 +01:00
Anthony Fok
6ee35f654f Correct typo in hugolib/path_separators_windows_test.go 2015-01-12 13:15:04 -07:00
Anthony Fok
a4eef4eb16 Correct spelling of two test files: seperators → separators 2015-01-11 02:21:51 -07:00
Tatsushi Demachi
78e9229c52 Fix "hugo new" EOF error with an archetype file without the final EOL
This rewrites `extractFrontMatterDelims` function to make it work with
an archetype file without the final EOL and adds more detailed error
messages and comments.

It also removes `matches` and `matches_quick` functions which aren't
called anywhere.
2015-01-10 19:48:35 +01:00
Dave Johnston
a5f5106154 Add in-section Next/Prev content pointers
Conflicts:
	docs/content/meta/release-notes.md
	docs/content/templates/variables.md
2015-01-05 18:26:09 +01:00
bep
837922d32b Add ERROR logging on invalid date and publishdate
Having correct dates is important in Hugo. Previously date parsing errors were swallowed, leading to confusing results.

This commit adds ERROR logging when date or publishdate in front matter cannot be parsed into a time.Time.
2015-01-05 12:44:41 +01:00
bep
076a475d16 Revert "Temporarily disable failing menu test"
This reverts commit e4a22255cc.
2015-01-01 23:40:14 +01:00
Austin Ziegler
5e0a16ea21 Fix a crash for ref page#anchor.
- Remove an improperly shadowed variable.
- Fixes #741.
2014-12-26 18:06:21 +01:00
Ryan Martinsen
7dacc999f8 Add ability to canonify URLs in rendered XML output. 2014-12-26 16:24:28 +01:00
bep
fbf8bcacc4 Add configurable support for angled quotes
The flag `HTML_SMARTYPANTS_ANGLED_QUOTES` was added to Blackfriday on Black Friday. This configures rendering of double quotes as angled left and right quotes (&laquo;
&raquo;).

Typical use cases would be either or, or combined, but never in the same
document. As an example would be a person from Norway; he has a blog in both
English and Norwegian (his native tongue); he would then configure Blackfriday
to use angled quotes for the Norwegian section, but keep them as reqular
double quotes for the English.

This commit adds configuration support for this new flag, configuration that can be set in the site configuration, but overridden in page front matter.

Fixes #605
2014-12-26 14:31:55 +01:00
bep
bb37698226 Fix unicode menu URLs
Menu urls like /categories/новости-проекта would turn into /categories/d0bdd0bed0b2d0bed181d182d0b8-d0bfd180d0bed0b5d0bad182d0b0, which is illegal, while the directory under the categories/ is created with the original name. It results in 404 not found error.

This commit fixes that by make sure that SanitizeUrl() is called last.

Fixes #719
2014-12-26 13:30:46 +01:00
bep
e4a22255cc Temporarily disable failing menu test 2014-12-26 13:14:06 +01:00
bep
331043b98e Remove noisy Println in test 2014-12-19 14:21:05 +01:00
Derek Perkins
8f6f871f53 Added AuthorList, Author, AuthorSocial, SiteSocial, Image and Video structs
Added Page.Author(s) functions
Added schema, opengraph, twitter_cards, google_news metadata templates
Added "" template
2014-12-18 22:26:10 -05:00
Austin Ziegler
112c3c5c04 Provide (relative) reference funcs & shortcodes.
-   `.Ref` and `.RelRef` take a reference (the logical filename for a
    page, including extension and/or a document fragment ID) and return
    a permalink (or relative permalink) to the referenced document.

    -   If the reference is a page name (such as `about.md`), the page
        will be discovered and the permalink will be returned: `/about/`
    -   If the reference is a page name with a fragment (such as
        `about.md#who`), the page will be discovered and used to add the
        `page.UniqueID()` to the resulting fragment and permalink:
        `/about/#who:deadbeef`.
    -   If the reference is a fragment and `.*Ref` has been called from
        a `Node` or `SiteInfo`, it will be returned as is: `#who`.
    -   If the reference is a fragment and `.*Ref` has been called from
        a `Page`, it will be returned with the page’s unique ID:
        `#who:deadbeef`.

-   `.*Ref` can be called from either `Node`, `SiteInfo` (e.g.,
    `Node.Site`), `Page` objects, or `ShortcodeWithPage` objects in
    templates.

-   `.*Ref` cannot be used in content, so two shortcodes have been
    created to provide the functionality to content: `ref` and `relref`.
    These are intended to be used within markup, like `[Who]({{% ref
    about.md#who %}})` or `<a href="{{% ref about.md#who %}}">Who</a>`.

-   There are also `ref` and `relref` template functions (used to create
    the shortcodes) that expect a `Page` or `Node` object and the
    reference string (e.g., `{{ relref . "about.md" }}` or `{{
    "about.md" | ref . }}`). It actually looks for `.*Ref` as defined on
    `Node` or `Page` objects.

-   Shortcode handling had to use a *differently unique* wrapper in
    `createShortcodePlaceholder` because of the way that the `ref` and
    `relref` are intended to be used in content.
2014-12-18 22:18:36 -05:00
bep
9b04c27998 Revert "Make Urls in menus respect CanonifyUrls"
This reverts commit 3ccb397902.
2014-12-11 05:33:40 +01:00
bep
3ccb397902 Make Urls in menus respect CanonifyUrls
Fixes #519
2014-12-10 20:32:39 +01:00
bep
9f77f93071 Fix various Windows-issues
File handling was broken on Windows. This commit contains a revision of the path handling with separation of file paths and urls where needed.

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

Fixes #687
Fixes #660
2014-12-09 09:43:15 -05:00
bep
11cdb81501 Remove Println that panics in test 2014-12-08 22:06:37 +01:00
spf13
b719ba7e2b Adding Prev/Next functionality to all lists of pages (sections, taxonomies, etc) 2014-11-27 23:15:25 -05:00
Austin Ziegler
8f9cea7f58 Enable descriptive header IDs.
Enable blackfriday.EXTENSION_AUTO_HEADER_IDS to generate the name of the
header ID from the text in the header. Works for prefix and underline
headers.

- TOC extraction had to be modified to look for `<li><a href="#`>
  instead of `#toc_` because of this change.
- Fixed a number of tests that depended on the presence of `toc_` with
  as an `id` or as a `href` value.
- Renames the earlier parameter `footnoteref` to `documentId` as it more
  accurately represents the nature of the parameter. The `documentId` is
  appended to all generated headers through the new HTML renderer
  parameter `HeaderIDSuffix`.
2014-11-24 18:01:57 -05:00
spf13
0282c922b4 fixing race condition in CreatePages 2014-11-24 17:51:47 -05:00
spf13
cdbc741cb8 fixed #656. Templates work properly when watching. 2014-11-24 17:10:38 -05:00
spf13
4a2f16f91e refactor handlers to use types instead of structs. 2014-11-20 12:43:34 -05:00
spf13
73f203ad86 Move template library into it's own package (tpl). No longer dependent on hugolib. Can be used externally. 2014-11-20 12:36:57 -05:00
bep
a6a9df3955 Fix failing shortcode tests on Travis
Some newly added shortcode tests compared maps in assertions.

This failed on Travis, as iteration order isn't guaranteed for maps since Go 1.

This commit fixes that by do a sort of the keys in the shortcode String() function.
2014-11-18 10:14:12 -05:00
Kartik Singhal
596d679386 Various fixes in RSS feed generation
- Prevent `.xml` generation for root section
- Remove redundant check for DisableRSS
- Fix permalinks for rel="alternate"
- Rename generated xml file to <type>/index.xml
- Add required description element in default template
- Make default RSS template validate on w3c (timezone format is still an issue)

Conflicts:
	hugolib/site.go
2014-11-17 18:55:40 -05:00
Chase Adams
b716dbec1d Fix template checking order in site.go
- Change order of HasPrefix to match correct order
- Remove theme concatenation to _internal in last loop of
  appendthemetemplates so it looks in the right place for internal
templates

Conflicts:
	hugolib/site.go
2014-11-17 18:42:36 -05:00
bep
55fcd2f30f Shortcode rewrite, take 2
This commit contains a restructuring and partial rewrite of the shortcode handling.

Prior to this commit rendering of the page content was mingled with handling of the shortcodes. This led to several oddities.

The new flow is:

1. Shortcodes are extracted from page and replaced with placeholders.
2. Shortcodes are processed and rendered
3. Page is processed
4. The placeholders are replaced with the rendered shortcodes

The handling of summaries is also made simpler by this.

This commit also introduces some other chenges:

1. distinction between shortcodes that need further processing and those who do not:

* `{{< >}}`: Typically raw HTML. Will not be processed.
* `{{% %}}`: Will be processed by the page's markup engine (Markdown or (infuture) Asciidoctor)

The above also involves a new shortcode-parser, with lexical scanning inspired by Rob Pike's talk called "Lexical Scanning in Go",
which should be easier to understand, give better error messages and perform better.

2. If you want to exclude a shortcode from being processed (for documentation etc.), the inner part of the shorcode must be commented out, i.e. `{{%/* movie 47238zzb */%}}`. See the updated shortcode section in the documentation for further examples.

The new parser supports nested shortcodes. This isn't new, but has two related design choices worth mentioning:

* The shortcodes will be rendered individually, so If both `{{< >}}` and `{{% %}}` are used in the nested hierarchy, one will be passed through the page's markdown processor, the other not.
* To avoid potential costly overhead of always looking far ahead for a possible closing tag, this implementation looks at the template itself, and is branded as a container with inner content if it contains a reference to `.Inner`

Fixes #565
Fixes #480
Fixes #461

And probably some others.
2014-11-17 18:32:06 -05:00
Tatsushi Demachi
7e692544f0 Fix GroupBy function issues
Following issues are fixed

1. Can't access fields and methods specified in GroupBy call
2. PagesGroup doesn't contain Pages. It's always empty.
3. When GroupBy is called with Section key, it doesn't work as expected
2014-11-13 22:48:58 -05:00
Joel Scoble
2c51bba0c3 converted path 2 filepath 2014-11-13 22:38:21 -05:00
bep
8ad9c0a7dd Make Where template-method accept methodname as key
This is necessary to make constructs like `{{ range first 1 (where .Data.Pages "Type" "post") }}` -- as Type and Section is methods not fields.
2014-11-13 12:42:26 -05:00
Austin Ziegler
d467ec0aab Fix a bug with taxonomy rendering.
- In `layouts/_default/taxonomy.html`, the `.Data` result does not
  provide the same information that `layouts/_default/terms.html` does
  for being able to identify the plural value of the term.
- This change adds `.Data.Singular` and `.Data.Plural` to provide
  similar capabilities.
- This *may* be incompatible with templates that check for `{{ if ne
  $taxonomy "Pages" }}` if the `page.Params` has either the singular or
  plural values as keys.
2014-11-13 12:32:10 -05:00
Austin Ziegler
d7e6e490c2 Allow partial without .html
`partial "header" .` means the same thing as `partial "header.html" .`.
2014-11-13 12:30:45 -05:00
bep
266511b6d3 Fix missing space before 'width'
The newly introduced width-param on figure did not work in combo with alt or caption due to space-issues.

This fixes that.
2014-11-13 12:29:06 -05:00
spf13
8a5dd06ad0 Use page.Markup to determine which PageHandler to use if it's set. 2014-11-04 00:44:30 -05:00
spf13
ade2ca6072 Adding an html file handler 2014-11-04 00:43:09 -05:00
spf13
7fba250023 Adding a proper css file handler (with automatic minification) 2014-11-04 00:42:36 -05:00
spf13
4dcf734acd Updating tests to use new Targets & Writers and switch to using Afero.MemMapFs for more accurate tests. 2014-11-04 00:41:47 -05:00
spf13
7b960ac121 New targets & new renderers and write methods [WIP] 2014-11-04 00:39:37 -05:00
spf13
e02dc6742a Cleanup file conversion handling 2014-11-04 00:36:05 -05:00
spf13
3616d16701 Better error messages for show_plan_test 2014-11-04 00:32:55 -05:00
spf13
07f2ef9c5e Page Group functions now work even when an uppercase field / method is provided. 2014-11-04 00:31:57 -05:00
spf13
2cb89a523a Update menu test to work with revised source struct 2014-11-03 10:14:10 -05:00
Austin Ziegler
8cc7684a91 Change the type of .Site.Author from…
…`map[string]string` to `map[string]interface{}`.

This allows values other than `string` values to be saved to Author,
such as:

    ```toml
    # config.toml
    …
    [Author]
      name = "Austin Ziegler"
      social-site = [ "Facebook", "Twitter", "GitHub" ]
    ```

My specific use-case is that I’m trying to make something work similar
whether it’s specified in `.Params.Author` or in `.Site.Author` without
introducing `.Site.Params.Author`.
2014-11-02 00:45:33 -04:00
Austin Ziegler
c1942e915a Change permalink validation and substitution. 2014-11-02 00:43:01 -04:00
Tatsushi Demachi
af47e5a2cf Extend template's mod and modBool functions to accept any int types
Fixes #575
2014-11-01 23:00:46 -04:00
Tatsushi Demachi
5e28606b84 Add sort and grouping functions for publish date and param of Page
`GroupBy` is modified to allow it to receive a method name argument for
example `Type` as its first argument. It is only allowed to call with
a method which takes no arguments and returns a result or a pair of
a result and an error.

The functions discussed at #443 are also added

- `ByPublishDate`: Order contents by `PublishDate` front matter variable
- `GroupByPublishDate(format, order)`: Group contents by `PublishDate`
  front matter variable formatted in string like `GroupByDate`
- `GroupByParam(key, order)`: Group contents by `Param` front matter
  variable specified by `key` argument
- `GroupByParamDate(key, format, order)`: Group contents by `Param`
  front matter variable specified by `key` argument and formatted in
  string like `GroupByDate`. It's effective against `time.Time` type
  front matter variable
2014-11-01 22:41:04 -04:00
bep
d013edb7f8 Implement HasMenuCurrent and IsMenuCurrent for Nodes
Prior to this commit, `HasMenuCurrent` and `IsMenuCurrent` on `Node` always returned false.

This made it hard (if possible at all) to mark the currently selected menu item/group for non-Page content (home page, category pages etc.), i.e. for menus defined in the site configuration.

This commit provides an implementation of these two methods.

Notable design choices:

* These menu items have a loose coupling to the the resources they navigate to; the `Url` is the best common identificator. To facilitate a consistent matching, and to get it in line with the menu items connected to `Page`, relative Urls (Urls starting with '/') for menu items in the site configuration are converted to permaLinks using the same rules used for others’.
* `IsMenuCurrent` only looks at the children of the current node; this is in line with the implementation on `Page`.
* Due to this loose coupling, `IsMenuCurrent` have to search downards in the tree to make sure that the node is inside the current menu. This could have been made simpler if it could answer `yes` to any match of any menu item matching the current resource.

This commit also adds a set of unit tests for the menu system.

Fixes #367
2014-11-01 22:34:49 -04:00
spf13
c5f1031e45 Handler WIP 2014-11-01 12:05:37 -04:00
spf13
141f3e19e0 Migrating Hugo to Afero for filesystem calls. 2014-11-01 11:57:29 -04:00
spf13
dfb8482569 Handlers WIP - Convert now working 2014-10-20 20:15:33 -04:00
spf13
30d4a26ba0 Handlers WIP (builds) 2014-10-20 17:51:53 -04:00
spf13
93f3d604c6 Handlers WIP 2014-10-20 17:42:16 -04:00
spf13
8bd0ffba43 Initial Handler Architecture WIP 2014-10-17 16:57:48 -04:00
spf13
5dfc1dedb8 Big refactor of how source files are used. Also added default destination extension option. 2014-10-16 20:20:09 -04:00
bep
da5d98e958 Make First accept any int
TOML and YAML handles integers differently, creating issues when using integer values from configuration or front matter in the First template function.

This currently works in YAML (parses into int), but not in TOML (parses into int64).

This commit modifies First so it accepts any int.

Fixes #551
2014-10-15 12:39:09 -04:00
bep
16330cea91 Add nil-check to Intersect
The Intersect template-method would fail if one or both of the lists were nil (post vs page; post has tags, page has not).

This commit adds a nil-check and returns an empty result if any of the inputs are nil.

See #537
2014-10-15 12:31:22 -04:00
Raphael Estrada
3da97656ea add 'width' parameter to 'figure' shortcode 2014-10-15 12:09:26 -04:00
Joel Scoble
4b9e4c90d9 #462 fix, remove leading and trailing dashes from urlized slug. includes test changes 2014-10-07 17:05:11 -04:00
Joel Scoble
f52e662890 Feed the titleized taxonomy key through string replace to replace '-' with ' ' for proper display of the taxonmy title 2014-10-07 17:01:39 -04:00
Will Stevens
938733f48f added In and Intersect template functions 2014-10-07 16:52:12 -04:00
Austin Ziegler
9cdd2e54c2 Use md5 against the file path for uniqueness. 2014-10-07 16:45:23 -04:00
Austin Ziegler
603b24a163 Make each generated page’s footnotes unique.
If content pages are fully rendered in a list page, footnotes that use
the same reference (`[^fn]`) will have duplicated anchors. This change
builds on #526 to put the page filename (`Page.File.Name`) as part of
the anchor for a footnote.

This would fix discussion [116](http://discuss.gohugo.io/t/footnote-references-are-duplicated-on-list-pages/116).
2014-10-07 16:44:28 -04:00
Austin Ziegler
e68e7ef96f Configure footnote rendering.
- The config file can provide FootnoteAnchorPrefix, which will be used
  by blackfriday when rendering to HTML. A value of `q:` has the effect
  of making the anchor for a footnote `[^footie]` be `fn:q:footie`. The
  default is `""`.

- The config file can provide FootnoteReturnLinkContents, which will be
  used by blackfriday when rendering to HTML. A value of `^` has the
  effect of making the return link be `^` instead of `[return]`.
2014-10-07 16:43:33 -04:00
Kartik Singhal
879e90dca7 Switch to new hompage 2014-10-02 13:39:59 -04:00
spf13
e3d4d40d32 better error messages for template errors 2014-10-02 13:37:38 -04:00
Nate Finch
3f59abe885 add some information to rendering errors so it's easier to tell what's failing. 2014-09-29 09:19:39 -04:00
Tatsushi Demachi
5d565c34e5 Extend template's basic math functions to accept float, uint and string values 2014-09-22 09:01:40 -04:00
Nate Finch
b590de6917 limit the number of goroutines used in taxonomy rendering to gomaxprocs*4 2014-09-14 07:23:03 -04:00
Nate Finch
49045b1cbc limit the number of goroutines we use for page rendering to gomaxprocs*4 2014-09-14 07:01:40 -04:00
Nate Finch
cf3e748bd9 remove unused field 2014-09-12 07:25:45 -04:00
Nate Finch
a72ca38c07 make the value of the BuildDrafts flag available to templates.This can be useful for if you only want to show some specific information on your local machine and/or when showing drafts. 2014-09-11 17:24:10 -04:00
Nate Finch
7142374332 Sort by title if dates are the same 2014-09-11 17:23:01 -04:00
Joel Scoble
becd4fe337 refactor handling of amber to AddTemplateFile as the TODO note stated. Used switch statement to make it easier to add other template support 2014-09-11 17:09:16 -04:00
Joel Scoble
4e9b04086a fix tags not being in lowercase, #491 2014-09-11 17:03:31 -04:00
Nate Finch
0099b5a3cb Change all uses of sort.Sort to sort.Stable.Using sort.Stable ensures that even if the sort keys are the same, the order of the sort will not randomly change. Using the old sort.Sort, if you had pages with no date, the lists of those pages would randomly reorder every time you regenerate the list, causing spurious changes to the output. Now they'll always get ordered in the same way. 2014-09-09 09:22:16 -04:00
Nate Finch
acf9561a31 fix zero date 2014-09-08 11:55:54 -04:00
Nate Finch
2ca615c551 Add Node.Site.Pages to all nodes and ensure all pages from the site exist in the list before processing shortcodes.
Node.Site.Recent is not really just recent pages, but all pages, so I figured it was better to add a new parameter with a more informative name.

I also changed the code slightly so that all pages are added to the list of pages before we start rendering shortcodes... this way you can use a shortcode to refer to another page.  Previosuly, this had been broken, because the list ofg pages would not be fully populated while the shortcodes were being processed.  The code that does this is not reading from disk or doing any rendering, so it shouldn't take any more time to do.
2014-09-08 11:50:09 -04:00
Nate Finch
b97c6c7082 add Name to File, which is the filename minus the extension 2014-09-08 11:44:50 -04:00
spf13
4bb5e326db Taxonomies can now be provided as a single string value if there is only one in frontmatter (tag = "val" vs tag = ["val"]) 2014-09-05 09:29:01 -04:00
spf13
1b7f18e391 Making partials context optional for compatibility with template.
If not provided, context is nil.
2014-09-03 11:30:08 -04:00
Dave Johnston
13a317b975 Enable header id blackfriday extension 2014-08-30 14:12:53 -04:00
spf13
242d6b4e6b Adjusting the number of go routines to build the pages in to 4*GOMAXPROCS (from 2) for faster rendering. 2014-08-30 01:15:20 -04:00
Nate Finch
47c91a4ca2 Fix CreatePages
This fixes #450.  There are two problems:

1.) We're creating a new goroutine for every page.
2.) We're calling s.Pages = append(s.Pages, page) inside each goroutine.

1 is a problem if in that if you have a ton of pages, that's a ton of goroutines.  It's not really useful to have more than a few goroutines at a time, and lots can actually make your code much slower, and, evidently, crash.

2 is a problem in that append is not thread safe. Sometimes it returns a new slice with a larger capacity, when the original slice isn't large enough.  This can cause problems if two goroutines do this at the same time.

The solution for 1 is to use a limited number of workers (I chose 2*GOMAXPROCS as a nice guess).
The solution for 2 is to serialize access to s.Pages, which I did by doing it in a single goroutine.
2014-08-30 01:02:35 -04:00
spf13
7e19fa40e7 Making direction optional (and setting defaults) for GroupBy Pages functionality. 2014-08-29 23:51:29 -04:00
spf13
b15eb889e8 Adding .Reverse() to PagesGroup 2014-08-29 23:50:25 -04:00
spf13
41b28462e8 Switch .Data to .Pages in the PageGroup functionality for increased consistency. 2014-08-29 23:48:24 -04:00
spf13
70dc370c08 Making the term "Term" more consistent with Taxonomy usage. 2014-08-29 23:44:39 -04:00
spf13
01caaeba7a Making the Pages Sorting methods available within a taxonomy term. 2014-08-29 23:43:38 -04:00
spf13
53b7d5b8a1 Inner Shortcodes now treated as markdown. fixed #185 2014-08-28 12:48:31 -04:00
spf13
1b5f59b071 go fmt site.go 2014-08-25 13:13:11 -04:00
spf13
30af267b32 Fix #302. Links now have trailing slashes. 2014-08-25 12:45:47 -04:00
Nate Finch
a31edb3388 Support subdir in baseurl.
Mainly this was a change to helpers.MakePermalink, but to get the local server to run correctly,
we needed to redirect the path of the request from /foo to /.  In addition, I added tests for the
server's code for fixing up the base url with different config file & CLI options.
2014-08-25 11:51:51 -04:00
Joel Scoble
4c735a7878 preserve alias case while lowercasing taxonomy 2014-08-25 10:16:59 -04:00
Chase Adams
348e123c9f Update 404 to be compiled to .html instead of directory 2014-08-25 09:38:08 -04:00
Tatsushi Demachi
50a8c50726 Add page grouping functions 2014-08-25 09:18:52 -04:00
Joel Scoble
c750a95e22 support for futre/draft summary info output 2014-08-20 14:21:15 -04:00
spf13
aae1ff3c92 Adding IsNode & IsPage functions to Page & Node 2014-08-19 21:27:13 -04:00
Tatsushi Demachi
002a5b6756 Add 'where' template function 2014-08-18 11:31:17 -04:00
Billie H. Cleek
aa42f4309c allow site to be built with empty content
Build the site even if there isn't anything in the content directory.
2014-06-30 15:28:18 -04:00
Nicholas Whittier
78962a14f8 Allows 404 templates from themes/THEME directories. 2014-06-30 15:22:52 -04:00
Nicholas Whittier
ac99ceccac Add shortcode template loading from themes directory. 2014-06-30 15:22:18 -04:00
Kristoffer Grönlund
35d04671d3 Add PluralizeListTitles option (default true) to allow disabling use of the inflect package 2014-06-30 15:21:09 -04:00
Andrew Jones
5969315c8f switch back to master blackfriday; enable footnotes 2014-06-30 15:14:42 -04:00
spf13
4483a6655a Centralizing the template execution logic in one place 2014-06-06 17:27:31 -04:00
spf13
c297d7451f Adding 'partial' template function to add theme / local awareness to the partials directory. 2014-06-06 16:15:19 -04:00
spf13
4e99d6b54c Adding proper error message when view is not found.. fixing #303 2014-06-04 12:33:27 -04:00
spf13
640ab3c72e fixed #303. Adding theme support to views 2014-06-03 17:53:00 -04:00
Jake Mitchell
e0ea6b9955 Support embedding <script> tags in markdown pages 2014-06-03 15:14:38 -04:00
spf13
c502f078bc Add handling for publishDates (which will be ignored if in the future). Fixed #260 2014-05-29 00:48:40 -04:00
Rinat Abdullin
4ebaec8906 Include Section Taxonomy into SiteInfo
This allows to build more complex pages, like :
http://martinfowler.com/tags/
2014-05-28 19:31:50 -04:00
spf13
35a605976e SiteInfo is now a pointer on the Node 2014-05-28 19:11:54 -04:00
spf13
4076d77029 Simplifying the siteInfo handling 2014-05-28 18:37:59 -04:00
Phil Pennock
280df4e380 Fix Viperized .Site.Params
git bisect identified 62dd1d4 as the breaking commit; when
github.com/spf13/viper was introduced, the Params field was always
empty.

Given a map in YAML in Viper, the return type is
`map[interface{}]interface{}`, _not_ `map[string]interface{}`, even if
`.SetDefault()` has been called with an item of
`map[string]interface{}{}` so the cast assertion on the `.Get("Params")`
always failed.
2014-05-28 18:15:23 -04:00
Lorenzo Bolla
e98f0014f2 Allow to use filename in permalinks 2014-05-28 17:59:49 -04:00
spf13
57ad3abe7b Pre and Post in Menu are type HTML 2014-05-27 18:34:29 -04:00
spf13
be1ee22032 Proper integration of live reload with automatic injection 2014-05-16 17:49:27 -04:00
spf13
a4a1e39a51 Fixing issue when two menu items have the same name. 2014-05-14 18:08:11 -04:00
spf13
4f75ec985d Homepage renders with _default/list.html or then _default/single.html when index.html is not present. 2014-05-13 17:07:50 -04:00
Dato Simó
025a37df2f Fix permalink functionality, which was broken in 62dd1d4.
Viper stores Permalinks as a map[string]interface{}, so the type assertion
to PermalinkOverrides (map[string]PathPattern) will always fail.

We can, however, get Permalinks as a map[string]string, and convert each
value to a PathPattern.
2014-05-12 15:47:52 -04:00
Dato Simó
05b76dcb6f Add a blank line after the front matter when writing back a page.
Could also be done in parser.InterfaceToFrontMatter(), but logically the
extra blank line belongs to the page, not the front matter itself.
2014-05-12 15:46:58 -04:00
Vincent Batoufflet
73cbefdbc8 Make template comparison functions handle floats 2014-05-10 15:38:18 -04:00
Vincent Batoufflet
667a047cea Fix date issue with home page in Sitemap 2014-05-10 15:33:18 -04:00
Vincent Batoufflet
35926dcf37 Add Sitemap testing 2014-05-09 23:11:42 -04:00
Vincent Batoufflet
2a902bbca6 Add Sitemaps config values handling 2014-05-09 23:11:33 -04:00
Vincent Batoufflet
f8e675d064 Add base Sitemap support 2014-05-09 23:11:27 -04:00
Vincent Batoufflet
179225449c Add template comparison functions (Go 1.1 compat) 2014-05-09 22:42:28 -04:00
spf13
08c30b6e44 Using new helpers in page.go 2014-05-02 01:04:48 -04:00
spf13
fb7d45e613 permitting empty files again. Fixing some tests to now pass. 2014-05-01 14:11:56 -04:00
spf13
859a78e1bd Providing the ability to save (write) a content's source file. 2014-05-01 13:21:37 -04:00
spf13
1302ef9f63 Making site page initialization a bit more granular and accessible 2014-05-01 13:20:58 -04:00
spf13
cbd9506c29 moving front matter parsing (and creation) to parse package 2014-05-01 13:20:09 -04:00
tummychow
2e954d8551 Fix permalinks to subdomains
If you don't have access to the root domain of your site (eg a GitHub project
page) and you try to generate custom permalinks, they must begin with a slash.
Go's URL resolution library sees the leading slash and thinks "this URL starts
at the root", just like a filesystem - so it discards your subdomain and maps
all custom permalinks from the root of your site. Fine if you control the root
domain, not so useful if you don't.

Removing the check for a leading slash fixes this problem. You can now specify
custom permalinks that do not start with a slash, and they will map safely
regardless of what subdomain you upload the generated site under.

Tests have been updated for this commit so that they continue to function.
2014-04-26 23:01:28 -06:00
spf13
bdf7cd9f9d Creating site menu configuration and have the docs site use it 2014-04-24 16:11:08 -06:00
spf13
4f813c09ea Fixing some bugs introduced in prior few commits. Tests now pass. 2014-04-24 10:18:47 -06:00
spf13
9ecf58e29b new menus system including active link & nesting 2014-04-23 02:59:19 -04:00
spf13
69c1944f1f Add handling of deeply nested front matter 2014-04-23 02:55:43 -04:00
spf13
4a8de8ea46 Add Disqus support out of the box. Move template/bundle into hugolib. 2014-04-23 02:53:12 -04:00
spf13
8afff8c7c4 Preliminary Theme Support 2014-04-10 08:10:12 -04:00
spf13
c0a046cbfb Added internal rss.xml template and config option to turn off rss creation 2014-04-09 17:45:34 -04:00
spf13
bb9bcdcf30 Add more information to the siteInfo (and configuration options) for better RSS generation. 2014-04-09 17:15:52 -04:00
spf13
93bcddebb3 Renamed Indexes to Taxonomies. Old template and config parameters still work. 2014-04-09 17:15:04 -04:00
spf13
aae6fa0b6b Fix test to not fail when order is different, but slice contents are the same. 2014-04-08 21:57:25 -04:00
spf13
bd022534bc Adding Params to node for easy template access of page.params without throwing errors. 2014-04-08 21:40:38 -04:00
spf13
c8269d6dbc Making node.Keywords the correct length 2014-04-08 21:40:03 -04:00
spf13
af1acfbce7 writing indexes under more configuration conditions 2014-04-07 23:29:35 -04:00
spf13
ad34be9d77 strip trailing baseurl slash. Added a new template function "sanitizeurl" which ensures no double slashes. Fixed #221 2014-04-07 22:02:08 -04:00
spf13
9a83f7a01b Fixing all tests to pass with new Viper Config 2014-04-07 11:44:51 -04:00
spf13
62dd1d45c1 Hugo config abstracted into a general purpose config library called "Viper".
Hugo casting now in own library called "cast"
2014-04-05 01:40:33 -04:00
spf13
e50b9d8ac1 Adding support for logging & verbose logging. Consolidation of error handling. Integration of jWalterWeatherman library. Fixed #137 2014-03-31 13:23:34 -04:00
Nate Finch
c02a02070f change golang to go 2014-03-24 14:34:41 -04:00
spf13
6205a16b6e Fixes #227 by properly scoping the variables within the go routine. 2014-03-13 20:34:47 +01:00
Ruben
eec0e512f9 Add sort pages by Title and by LinkTitle
Sorting can now be done on Title and on LinkTitle
2014-03-13 11:39:13 +01:00
spf13
3dfb475136 Parallelizing the largest build processes (templates, pages, indexes). Seeing 300%+ improvement of total build time. 2014-03-05 23:48:42 -05:00
Mike Keesey
2540d884d8 Fixing issues go vet reports. 2014-03-01 09:56:17 -05:00
Ask Bjørn Hansen
0becad727a Make error message when encountering unrecognized file extensions more helpful 2014-02-28 22:11:41 -05:00
Ask Bjørn Hansen
ea8d0981d5 Make per-page url overrides take precedence over section permalink settings
This seems more reasonable to me.

I didn't understand why the pUrl comparision was on len > 2; I changed it to 0.

Closes #212.
2014-02-28 11:55:37 -05:00
spf13
14227351fa Reorganization of helpers. Centralized Url/Path logic. Fixed #175. 2014-02-27 20:33:18 -05:00
spf13
64572d2d60 Shortcode cleanup. Added a ton of tests. Much more flexible with input. Doesn't crash with bad input. Fixed #193
Also added the .Get function to short codes and documentation for that function.
2014-02-25 23:57:31 -05:00
Ask Bjørn Hansen
82fdfa2c72 Warn about bad shortcode parameters (and don't crash)
closes #193
2014-02-20 06:54:56 -05:00
Ask Bjørn Hansen
ed0fe9ddf7 Make 'read a string' code understand float64 (json) and int (yaml) as well as actual strings 2014-02-18 18:44:56 -05:00
Ask Bjørn Hansen
b41622bc49 Allow 1/0 for true/false in Yaml front-matter 2014-02-18 18:44:47 -05:00
Ask Bjørn Hansen
e4af4f652e Support ISO8601 date/time format without timezones 2014-02-18 18:44:40 -05:00
Ask Bjørn Hansen
0bfe9276c2 Make the invalid date/time format error message more helpful 2014-02-18 18:44:32 -05:00
Anton Ageev
11ca84f8cb Add unicode support for aliases, indexes, urlize template filter.
Now aliases and indexes are not restricted ASCII letters and can include
any unicode letters.
2014-02-05 11:49:57 -05:00
Anton Ageev
72ba6d633d Fix permalink bug in uglyurls mode (refs #187). 2014-02-02 00:56:01 -05:00
Niels Widger
c1b9380dfd Add back blackfriday extensions during Markdown conversion
Modified markdownRender and markdownRenderWithTOC in hugolib/page.go to
use the same flags and extensions as were previously used when we simply
called blackfriday.MarkdownCommon to convert Markdown to HTML.  These
flags/extensions were dropped during the refactor that added the
`.TableOfContents` page variable, and caused features like Markdown
tables to no longer work.

Modified the expected output for TestTableOfContents in page_test.go,
apparently changing the flags/extensions caused an `&mdash;` to become
`&ndash;`.
2014-01-30 23:04:37 -05:00
Tibor Vass
6dd2e9a49a gofmt all go code 2014-01-29 18:03:35 -05:00
spf13
1882ffabc6 Adding support for boolean params 2014-01-28 23:24:59 -05:00
spf13
1da3fd039a Continue with TOC integration and page refactor. Updated a few tests to match new generated output. 2014-01-28 23:11:05 -05:00
spf13
f45c6bc38a Moved TOC test into page_test. Some general page_test cleanup. 2014-01-28 23:09:24 -05:00
spf13
9666f33e2f Don’t render short codes on summary twice 2014-01-27 17:32:36 -05:00
spf13
d0825a211a Big refactor of pages code. Changed TOC code to only parse when actually used 2014-01-27 17:20:20 -05:00
Niels Widger
f62e3e9940 Add new TableOfContents Page variable (Markdown only)
Added TableOfContents field to hugolib.Page struct.  New function
getTableOfContents is used in convertMarkdown to set the TableOfContents
field.

Added new test file hugolib/page_toc_test.go with a simple test of the
new functionality.

Conflicts:
	hugolib/page.go
2014-01-23 17:27:08 -05:00
spf13
3851117c25 renaming MinRead to ReadingTime and adding to documentation. 2014-01-21 20:08:24 -05:00
spf13
f0634ec059 fixed #171. RSSlink is now RSSLink (and matches existing docs).
Added backwards compatibility accessor for existing templates.
2014-01-18 22:16:19 -05:00
spf13
ae15ff0968 Fixing test which erroneously checked values and order, rather than just values. 2014-01-18 21:26:34 -05:00
spf13
44186c6af1 Extending rss item limit to 50… can reduce further in template with ‘first N’ functionality. 2014-01-18 21:18:54 -05:00
spf13
cb04053385 RSS improvements, now limit to 15 items and provide accurate date. fixed #172 2014-01-18 11:05:50 -05:00
Phil Pennock
438c219892 Add canonifyurls config option.
Be able to inhibit AbsURL canonicalization of content, on a site
configuration basis. Advantages of being able to inhibit this include
making it easier to rendering on other hostnames, and being able to
include resources on http or https depending on how this page was
retrieved, avoiding mixed-mode client complaints without adding latency
for plain http.
2014-01-13 10:06:12 -05:00
spf13
3fd6c1a24e Adding some embedded short codes (including code highlighting) 2014-01-10 21:27:32 -05:00
spf13
8055838c70 Allowing empty files (ignored) so you can touch a new file while watching 2013-12-28 13:47:34 -05:00
Egon Elbre
e46148f948 Fix static file change detection on Windows.
Fixed windows uses different filepath separator. The filepath.ToSlash
shouldn't be used, because it can cause errors in filepath suffix and prefix
testing since "c:\a" isn't a prefix of "c:/a/b/c".
2013-12-28 13:45:38 -05:00
spf13
065928fcf0 Adding page sorting by weight function (the default) 2013-12-28 12:56:12 -05:00
spf13
70745e8cb5 Complete refactor of indexes, move (and rewrite) page sorting to page.go, add tests 2013-12-20 09:10:05 -05:00
Henry
6aa3e51228 Added PageSorter and PagesByDate 2013-12-16 17:55:37 -05:00
Caleb Spare
6da23f7449 Gofmt
Command: `gofmt -l -s -w .`
2013-12-16 17:40:10 -05:00
spf13
0e04b9a029 Moving processing short codes to the page 2013-12-06 23:57:24 -05:00
spf13
d0ef3d43bd better handling of detecting markup format 2013-12-06 23:56:51 -05:00
spf13
f432b187a0 render shortcodes prior to converting to html 2013-12-06 23:32:00 -05:00
spf13
a45de56db1 adding support for shortcodes with opening and closing tags 2013-12-06 23:14:54 -05:00
spf13
44d57fdc0c Reorganize helpers 2013-12-05 09:29:41 -05:00
Tim Esselens
860f982cc4 fixed trailing dir slash when using slug
See testcase, dir + slug contained double slash when dir had a trailing
slash.

Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-11-20 15:32:22 -08:00
Phil Pennock
07978e4a49 configurable permalinks support
A sample config.yaml for a site might contain:

```yaml
permalinks:
  post: /:year/:month/:title/
```

Then, any article in the `post` section, will have the canonical URL
formed via the permalink specification given.

Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-11-18 13:32:56 -08:00
spf13
ad2c0b5616 Homepage now has all content available, use sorting and first to control rendering 2013-11-14 09:37:58 -05:00
Phil Pennock
40d05f12a7 Truncated; .Site.Params; First function
* Add `.Truncated` bool to each page; will be set true if the
  `.Summary` is truncated and it's worth showing a "more" link of some
  kind.
* Add `Params` to the site config, defining `.Site.Params` accessible
  to each page; this lets the site maintainer associate arbitrary data
  with names, on a site-wide basis.
* Provide a `First` function to templates:
  * Use-case: `{{range First 5 .Site.Recent}}` or anything else which
    is a simple iterable provided by hugolib
* Tests by me for `.Truncated` and `First`

Also @noahcampbell contributed towards this:

* Add UnitTest for `.Site.Params`:
> Digging into this test case a bit more, I'm realizing that we need
> to create a param test case to ensure that for each type we render
> (page, index, homepage, rss, etc.) that the proper fields are
> represented.  This will help us refactor without fear in the
> future.

Sample config.yaml:

```yaml
title: "Test site"
params:
  Subtitle: "More tests always good"
  AuthorName: "John Doe"
  SidebarRecentLimit: 5
```

Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-11-12 22:49:54 +00:00
Noah Campbell
86233c00a0 Remove the hugo-nav function
Remove the hugo-nav since it relied on a slow library.  The current
build reimplements the absurl functionality based on string replace.
Discovered that my prior implementation missed the requirement for
making absolute paths (/path) absolute with the host, whereas a relative
path is left untouched.  Updated the test cases to support this if this
is reimplemented.
2013-11-05 22:28:06 +00:00
Noah Campbell
1cebce12ad Adding RSS test case.
Checks to make sure the xml document starts with <?xml.  Previously, the
html translate package would write additional details into the document
that caused it to fail.
2013-11-05 07:03:02 +00:00
Noah Campbell
b22364570b Fix Test Name 2013-11-05 06:39:50 +00:00
spf13
1fbcaf9279 Buffers instead of pipes 2013-11-05 00:28:08 -05:00
Noah Campbell
9af47f07d3 Improve rendering time
50% speedup.  Fix #91

to run the benchmark:

		go test -test.run=NONE -bench=".*" -test.benchmem=true ./transform/ > new.txt

to compare the results:

		/usr/local/go/misc/benchcmp baseline.txt new.txt

Speedup and memory improvements

		benchmark             old ns/op    new ns/op    delta
		BenchmarkChain           101219        50453  -50.15%
		BenchmarkTransform        51625        45531  -11.80%

		benchmark            old allocs   new allocs    delta
		BenchmarkChain              222          103  -53.60%
		BenchmarkTransform          135          106  -21.48%

		benchmark             old bytes    new bytes    delta
		BenchmarkChain            23919        10998  -54.02%
		BenchmarkTransform        11858        10665  -10.06%
2013-11-01 09:59:57 -07:00
Noah Campbell
789aa6ad76 Removing check for directory: static, layouts
Removed these checks so a single file in content can generate a site.

For example, given a site with a content directory and an index.html,
running hugo -s dir will generate a project without any more input.
2013-10-31 16:06:24 -07:00
spf13
a7dae30a8f More work on indexes 2013-10-31 09:49:29 -04:00
spf13
df0523ff7f Flipping around weight order. higher weight at the bottom. use negative to pin to top. 2013-10-26 00:20:48 -04:00
spf13
d20b41a2cf Big index overhaul. Now supporting ordering tokens by count or alphabetically. Also made full indexes available to the Site variable. 2013-10-25 18:40:55 -04:00
spf13
9388f23606 Adding support for linkTitles 2013-10-25 18:37:53 -04:00
spf13
b580a25d1f Better error handling when rendering error found when in watch mode
In watch mode it should continue to watch for changes, in any other mode it should exit with a -1 error code so can check for success when scripting
2013-10-25 18:03:14 -04:00
spf13
a5606b06ca Adding support for ordering content in indexes by other than date (weighted indexes) 2013-10-24 15:24:47 -07:00
spf13
471fb1ff69 Adding support for date field in front matter as date (as TOML provides) 2013-10-24 15:18:57 -07:00
spf13
f3c816eabd Adding support for more front matter types (int, float & date) 2013-10-24 14:31:04 -07:00
spf13
3558e3d6f0 Add support for weighted pages
Now pages can be sorted by other than date
2013-10-18 11:01:31 -04:00
spf13
90090175f8 Adding preliminary support for weighted indexes (for ordering by other than date) 2013-10-17 23:57:25 -04:00
spf13
4263094d75 Adding support for MinRead. Closed #106 2013-10-15 09:32:21 -04:00
spf13
be5ace1588 Wordcount restored. fixed #92 2013-10-15 09:15:52 -04:00
spf13
e58d8fe791 fixed #95, fixed #93 2013-10-09 23:38:51 -04:00
spf13
f5fda80486 simplified buildSite & better error handling around it 2013-10-09 19:14:26 -04:00
Noah Campbell
4993152dda Permalink to include multiple directories levels 2013-10-08 18:44:15 +02:00
Noah Campbell
6e1268f45b Test case for permalink functionality 2013-10-08 18:44:15 +02:00
Noah Campbell
9500ec1b6b Refactor layout selection code
The render code path would use a fallback if there was an exception.
This change instead relies on explicit declaration of the layout to use
and includes a check to see if the layout indeed exists before
attempting to render it.
2013-10-08 18:44:15 +02:00
Noah Campbell
197aacb647 Add support for Relative Permalinks 2013-10-08 18:42:03 +02:00
Noah Campbell
06da609138 Refactor Permalink to private function
This will allow for reuse of this particular function.
2013-10-08 18:42:03 +02:00
Noah Campbell
6fa6f69a4a Change transformer order 2013-10-08 18:42:03 +02:00
Noah Campbell
d712d6f331 Moving transformation on a per-page level 2013-10-08 18:42:03 +02:00
Noah Campbell
9032a228b0 Better handle missing layouts
Panic is too extreme.  Instead the library will write out a message in
verbose mode.
2013-10-08 18:42:02 +02:00
Noah Campbell
54a2790fce Use io.Pipe for chaning render tasks.
Also clean up logic for finding layouts.
2013-10-08 18:42:02 +02:00
Noah Campbell
19cb6c7819 Move writing next to rendering
All render(Thing) calls have a WritePublic call directly after it.  This
refactor creates one function that makes the specific call sequence.
2013-10-08 18:40:40 +02:00
Noah Campbell
2176d2c197 Reducing scope of RenderThing* 2013-10-08 18:37:50 +02:00
Noah Campbell
ff8b52758d Move in memory target into target module. 2013-10-08 18:37:50 +02:00
Noah Campbell
80009b427f Change the order of Apply to be more Unixy
Typically the destination is on the left and the src is on the right.
2013-10-08 18:37:50 +02:00
Noah Campbell
f0211b84a1 Rename Transform to AbsURL 2013-10-08 18:37:49 +02:00
spf13
5e14af957a Proper handling of 404 page return value 2013-10-07 09:24:13 -04:00
spf13
7468292c4e Fixing bug where RSS for site was rendered in wrong location 2013-10-07 09:23:42 -04:00
spf13
d829e05036 Fixing bug where only the first index list was created. 2013-10-07 09:07:14 -04:00
spf13
2aaf92b515 Summary can now contain short codes when using <!--more--> to define end of summary. 2013-10-04 16:07:24 -04:00
spf13
266f583a8c Restoring former snippet behavior & adding test to ensure future behavior 2013-10-04 12:28:28 -04:00
spf13
dcfcbac589 Enabling Nitro ('--stepAnalysis') again. Fix #58 2013-10-03 09:44:45 -04:00
spf13
18f2b82658 Switching to the rjson library which is more friendly to human generated json. 2013-10-01 22:45:24 -04:00
spf13
92cff05582 go fmt so code 2013-09-29 02:10:29 -04:00
spf13
ff2b98c9dd Better error message when no source content is found. 2013-09-29 02:10:29 -04:00
Noah Campbell
db50154e75 Support index.html indexes in content directory
If a file named index.html exists in a directory, or root, it will be
rendered as if ugly urls are turned on.  This allows for top level
content to not need a supporting layout file and content in content.
This change should not affect anyone who is using the perscribed way.

I also cleaned up a bunch of one off functions in site.go.
2013-09-24 21:27:25 -07:00
Noah Campbell
4250bf8e30 Fixes #80 - Homepage now renders correctly
I mistakenly make RenderHomePage a NOP.  Bad programmer.
2013-09-24 14:41:21 -07:00
Noah Campbell
bffe4baf42 Create a TargetPath() method that provides OutFile
Moved the generation of the target path to the page breaking all
dependecies on Site.
2013-09-20 17:24:25 -07:00
Noah Campbell
52e8c7a0ac Section is determined by the source, not the url
This change allows for top level html content to exists.
2013-09-20 17:03:43 -07:00
Noah Campbell
784077da4d Fix fragments being AbsUrlified in final html
Found that fragments were getting the BaseURL applied creating a proper
anchor url and redirecting off the page.
2013-09-18 15:48:36 -07:00
Noah Campbell
311e102223 Allow non-markdown content in content directory
Allow content that is not markdown and does not need to be rendered to
exists in the content directory.  Currently any valid html or xml
document can exist.  Templates are applied to these documents as well.
If you need to have content that doesn't have templates or AbsUrlify
like operations, then continue to put this content in static and it will
be copied over.
2013-09-18 14:21:27 -07:00
Noah Campbell
5374242ff7 More expressive --check output 2013-09-18 11:52:30 -07:00
Noah Campbell
c510140c0c Add renderer information to --check
Now reports if the page will be rendered or not and by which render
engine.
2013-09-18 10:27:56 -07:00
Noah Campbell
67b2abaf09 Add IsRenderable to Page
As pages are read from the target, they will be assessed if they should
be rendered or not.  The logic for IsRenderable is in the parser/page.go
and looks for anything exception '<'.
2013-09-18 10:17:43 -07:00
Noah Campbell
d8e1834910 Fix parsing edge case of frontmatter
When the frontmatter contains a - (or other delimiter) close to the
closing frontmatter delimiter, frontmatter detection would fail.
2013-09-18 09:15:46 -07:00
Noah Campbell
a82efe5bb1 Merge remote-tracking branch 'origin/parser' into mrg_praser
Also brought in parse for github.com/noahcampbell/akebia

Conflicts:
	hugolib/page.go
	hugolib/page_test.go
2013-09-17 15:52:40 -07:00
Noah Campbell
6b0752e8c0 Move AbUrlify to post content transformation
Currently the a@href and script@src elements will have BaseUrl applied
to their elements prior to being written to disk.
2013-09-17 14:16:06 -07:00
Noah Campbell
172ff5ea7a Initialize HTMLRedirectAlias before ShowPlan()
Without it, no alias information is generated when running --check
2013-09-13 15:06:37 -07:00
Noah Campbell
d45fb72f67 Add /index.html to unadorned alias paths
Bring code to be better in line with documentation.
2013-09-13 14:51:28 -07:00
Noah Campbell
803a0fce1e Remove RenderedContent from page.
The output is written directly to disk after being written.  Not
entirely sure why it was split into two steps.
2013-09-13 10:30:27 -07:00
Noah Campbell
2ebfb33fe0 Move alias logic to target module
I want to move all logic to writing aliases to target so I can pave the
way for writing aliases specific to other runtimes (like .htaccess for
apache or a script for updating AWS or symlinking on a filesystem).
2013-09-12 21:20:00 -07:00
Noah Campbell
2f10da1570 Move alias rendering to target 2013-09-12 16:18:30 -07:00
Noah Campbell
74b55fc7c8 Normalize paths within hugo
filepath was used inconsistently throughout the hugolib.  With the
introduction of source and target modules, all path are normalized to
"/".  This simplifies the processing of paths.  It does mean that
contributors need to be aware of using path/filepath in any module other
than source or target is not recommended.  The current exception is
hugolib/config.go
2013-09-12 10:48:59 -07:00
Noah Campbell
6274aa0a64 Homepage "/" respects PublishDir
It wasn't taking the value of PublishDir into consideration for the
special case of the homepage "/".

Fixes #75
2013-09-05 09:57:25 -07:00
Noah Campbell
610c06e658 Introduce source.Filesystem
This provides an abstraction over how files are processed by Hugo.  This
allows for alternatives like CMS systems or Dropbox, etc.
2013-09-04 22:42:52 -07:00
Noah Campbell
d4d9da9f3a Remove page module dependence on opening files
The site is responsible for reading files, page only operates on
buffers.
2013-09-04 19:36:06 -07:00
Noah Campbell
cb00917af6 Expand the ShowPlan functionality 2013-09-03 20:52:50 -07:00
Noah Campbell
4004687fb2 Move to target.Filesystem
Moving the ugly urls logic to the target.  There is still UglyUrl logic
in page for the permlink but this is dealing with the generate of urls.
2013-09-03 20:01:55 -07:00
Noah Campbell
7919603fb5 Add Translate to target
Translate handles Ugly Urls.
2013-09-03 20:00:22 -07:00
Noah Campbell
c6ad532b94 Add file reporting to planner 2013-09-03 20:00:22 -07:00
Noah Campbell
13d2c55206 Adding Planner 2013-09-03 20:00:21 -07:00
Noah Campbell
79d9f82e79 Code reorg, helpers.go has been decomposed.
It started with wanting to move templates in template bundles and the
rest followed.  I did my best to start grouping related functions
together, but there are some that I missed.  There is also the method
Urlize that seems to be a special function used in both worlds.  I'll
need to revisit this method.
2013-09-03 16:16:07 -07:00
Noah Campbell
207d8fb7af Date rendering unit tests in pages
Tests to ensure rendering dates in templates is working correctly.
Actually, I was running into invalid templates not giving warnings when
I was trying to render a date.
2013-09-03 14:51:06 -07:00
Noah Campbell
3ecc698f5e Remove hugolib.HTML and hugolib.URL types
These types were not be rendered correctly by the html/template package.
Removing them gets the correct behavior.

Fixes #74
2013-09-03 12:43:56 -07:00
Noah Campbell
a591a10626 Include building hugo docs as part of test.
If the building of the doc fails, tarvis will fail.  This will help with
pull requests.
2013-09-03 11:29:43 -07:00
Fabrizio (Misto) Milo
ba82a20321 Add support for amber files
If a layout file ends with .amber it will interpreted as a Amber file

Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-09-01 19:51:32 -07:00
Fabrizio (Misto) Milo
ee5865f239 Abstract html/template dependency
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-09-01 19:51:27 -07:00
Fabrizio (Misto) Milo
0a9dc705f3 Use s everywhere for consistency
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-09-01 19:51:21 -07:00
Mark Sanborn
6c8e7edbb4 The <!--more--> (summary divider) now works even if it is on the same line as content
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-09-01 07:44:29 -07:00
Noah Campbell
4349216deb Small code cleanup 2013-08-31 20:00:57 -07:00
Noah Campbell
0fdea0c2c2 Return an error with WritePublic 2013-08-30 21:24:25 -07:00
Noah Campbell
097b782a80 Removing site.Directories.
Please revert if this is used somewhere.
2013-08-30 21:13:50 -07:00
Noah Campbell
b14b61af37 Externalize the writing of content to a target
Introducing the target module in hugo.  This provides the simple
interface for writing content given a label (filename) and a io.Reader
containing the content to be written.

If site.Target is not set, it defaults back to the original behavior of
writing to file system.

In hugolib/site_url_test.go I have an InMemoryTarget for testing
purposes and use it to see if the final output of a render matches.
2013-08-30 20:45:42 -07:00
Noah Campbell
bc3c229002 Ensure Section is set before returning Page object. 2013-08-30 20:13:22 -07:00
Noah Campbell
c32f401b15 Revert "Return errors when rendering"
This reverts commit e66ba5d2a7.

Fixed #69
2013-08-30 20:08:13 -07:00
Noah Campbell
a792ec09ce Cleanup formatting - go fmt ./...
Remember to run go fmt ./... before committing.  Looks sternly in mirror
2013-08-30 14:39:12 -07:00
Mark Sanborn
4ed43e8076 Fixed bug where Url specified in front matter as pretty url wouldnt render
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-08-30 14:39:11 -07:00
Fabrizio (Misto) Milo
3ab5245049 clean up logic
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-08-28 20:39:58 -07:00
Ross Lawley
1bb00b8c19 Refactored added RenderThingOrDefault and tests
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>

Conflicts:
	hugolib/site.go
2013-08-27 12:40:53 -07:00
Noah Campbell
554375b2ad Using new parser. 2013-08-25 20:27:03 -07:00
Hugo Duncan
1de1992664 Return any error reported by RenderHomePage
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-08-23 16:55:40 -07:00
Ross Lawley
9930011ea2 Wordpress summaries
Allow full control of summaries which can be rendered as html rather
than text.  Using a `<!--more-->` html comment in your markdown / rst
you can indiciate where the summary should end and have the summary
converted to html.

Signed-off-by: Noah Campbell <noahcampbell@gmail.com>

Conflicts:
	hugolib/page_test.go
2013-08-23 16:46:19 -07:00
Ross Lawley
7b1f0960e3 Add 404.html for gh-pages
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-08-23 16:38:35 -07:00
Noah Campbell
f28a8fa0c2 RenderThing test cases
Provide unit test support RenderThing.

One observation is that creating the site.Tmpl variable is a one time
event.  site.Tmpl doesn't like additional templates with the same name.
This means that updating a template while in --watch mode requires
throwing away the entire Site object and creating a new one.  Not that
this is a bad idea, but it is something I discovered while working on
these unit tests.
2013-08-23 16:21:28 -07:00
Noah Campbell
9d15262ee5 Test cases for ignoreDotFile
Meant to commit this earlier, but it's a basic unit test.
2013-08-23 14:57:21 -07:00
Noah Campbell
7461ed63ae Fix benchmark so the buffer is read each time.
The bytes.Buffer was exhausted after the first read.  Creating a new
reader each invocation catpures the correctly timing.
2013-08-23 14:16:37 -07:00
Noah Campbell
599e6672f7 Removing GetSection
Using GetXXX is not idiomatic to Go.  Also added a bunch of unit testing
around this method.
2013-08-23 14:14:54 -07:00
Noah Campbell
ae7112977d Skip "dot" files in layout
As a vim user, .filename.swp files pop up.  This change prevents hugo
from reading those files.
2013-08-23 13:58:52 -07:00
Hugo Duncan
301d2bafcd Print error if index value in a page is wrong type
This was causing a panic with no information displayed about the
page causing the error.
2013-08-20 16:39:26 -04:00
Steve Francia
c4bcdebc59 Merge pull request #44 from cactus/avoid-redirect-with-slugs
avoid possible redirects with non-ugly slug urls
2013-08-17 21:04:51 -07:00
Steve Francia
e2744d403c Merge pull request #43 from hugoduncan/feature/allow-xhtml-aliases
Enable aliases from .xhtml paths
2013-08-17 21:04:14 -07:00
Steve Francia
2542836bbc Merge pull request #41 from rozza/skipStatic
Skip Static directory if its in your content directory
2013-08-17 20:59:07 -07:00
Noah Campbell
c713beba4d Formatting cleanup 2013-08-17 23:52:16 -04:00
Noah Campbell
ec821739bc Removing the use of slash
An oversight on my behalf.  The FromSlash method is used when writing
out the public file name.  There is one place where the slashes are
required which is setting the output file.  I replaced those instances
with filepath.Join which should do the right thing depending on the OS.
2013-08-17 23:46:57 -04:00
Noah Campbell
8eca8f8aa0 Detect missed index from front matter 2013-08-17 23:45:03 -04:00
Noah Campbell
e66ba5d2a7 Return errors when rendering 2013-08-17 23:45:03 -04:00
elij
b9e835b101 avoid handling a redirect from slug to slug/
because the url lacks a trailing /, many webservers will issue a
redirect to the canonical url with trailing slash for directory index
w/index.htm(l).
Append a slash to avoid this.
2013-08-16 13:14:20 -07:00
Hugo Duncan
23a98ad05c Enable aliases from .xhtml paths
When redirecting an alias from a .xhtml path, served with default content type,
a redirect only works if the html element has a xmlns attribute.  This adds the
attribute when the alias path ends in .xhtml
2013-08-16 00:29:46 -04:00
Ross Lawley
0f143dcf14 Skip Static directory if its in your content directory
Allows organisation where all source files are in one directory:

```
`config.yaml`:

contentdir: "source"
staticdir: "source/static"
...

 .
	└── source
		├── post
		|	├── firstpost.md	// <- http://site.com/post/firstpost.html
		|	└── secondpost.md	// <- http://site.com/post/secondpost.html
		└── static
			└── css
				 └── site.css	// <- http://site.com/css/site.css
```
2013-08-15 20:05:46 +01:00