Commit graph

458 commits

Author SHA1 Message Date
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