Commit graph

995 commits

Author SHA1 Message Date
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
Anthony Fok 659f71e617 [Docs] Fix more missing . in example partial calls 2015-01-31 07:27:42 -07:00
Dan Hatch 20bed49f52 Fixed syntax error in 404.html template code 2015-01-31 01:01:50 -07: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
bep 4a9436c116 Some more .Date.IsZero checks in internal templates 2015-01-30 22:05:03 +01:00
bep 230e7c02c5 Remove _default prefix from SEO templates 2015-01-30 21:58:18 +01:00
spf13 8db3c0b0a6 page rendering and writing using BBP 2015-01-30 12:05:05 -08:00
Anthony Fok 3d60955e17 Use .Date.IsZero to skip unset date in embedded templates
Use `{{ if not .Date.IsZero }}` to print dates only when they are
defined.  This is to avoid things like

    <lastBuildDate>Mon, 01 Jan 0001 00:00:00 +0000</lastBuildDate>

and

    <lastmod>0001-01-01T00:00:00+00:00</lastmod>

showing up in index.xml (RSS) and sitemap.xml.

Pipe dates with ±hh:mm time zone through `safeHtml`
to prevent the `+` sign from turning into `&#43;`.

Also make some shuffling to avoid blank lines in the output.
2015-01-30 21:04:06 +01: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 4828fee11d transform chain using BBP 2015-01-30 11:39:06 -08:00
spf13 5441fc5dfc template render with BBP 2015-01-30 11:25:54 -08:00
spf13 2f2297bdb3 shortcodes using BBP 2015-01-30 11:19:46 -08:00
spf13 66ed5c5e02 Adding BufferPool. Implementing BP in ReaderTo{Bytes,String}(). 2015-01-30 11:12:07 -08:00
bep ba53799fdb url_path => urlPath 2015-01-30 16:21:46 +01:00
Dan Hersam 523f38a9a8 Fix for issue 839 and 490 on Windows
The paths were seen as changed but not static because of the backslashes in
ev.Name. Once the backslashes were added, I discovered that the JSON
sent to livereload was invalid and failed to work because it had backslashes.

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

With this fix, changes to a stylesheet are shown on the page, and if it's a
single file that changed, it's reflected in the browser without reloading the whole
page.
2015-01-30 14:18:17 +01:00
Anthony Fok d397bc4f43 [Docs] Complete the transition from "indexes" to "taxonomies" (almost)
Also mention `.Site.Indexes` → `.Site.Taxonomies` as well as
the upcoming `.Site.Recent` → `.Site.Pages` transitions.
2015-01-29 12:48:14 -07: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
Anthony Fok 82d4b8ab40 [Docs] Use OptiPNG to shrink PNG images losslessly
So they load slightly faster.  :-)
2015-01-28 13:25:07 -07:00
Anthony Fok 8e6cbe82f3 Some housekeeping of the Showcase and Press pages 2015-01-28 13:25:07 -07:00
bep 831fbd5e40 Add .mailmap to get a more correct author log 2015-01-28 16:50:36 +01:00
fundon ee1045ad42 ignore root path, no need strip traling slash 2015-01-28 09:43:43 +01:00
Dan Hersam 2d8e15a565 Version uses binary name instead of hugo
On Windows the binary name is hugo.exe and running hugo version results in
this error:
    GetFileAttributesEx D:\Dev\Go\gopath\bin\hugo: The system cannot find the file specified.

This fixes that error and allows the binary name to be something other
than hugo on any OS.
2015-01-28 09:43:12 +01:00
Dan Hersam 06b1a88358 Added three videos to documentation.
Created shortcode for YouTube videos and made the videos responsive in the
stylesheet.
2015-01-27 23:44:46 +01:00
bep e52a76f559 Use runtime.GOOS to identify Windows specific path tests 2015-01-27 23:01:32 +01:00
bep 0b5f8c8cb3 [doc] Improve paginator doc 2015-01-27 21:56:45 +01:00
bep 7c74a77db6 Replace assert.Equal(true/false) with assert.True/False 2015-01-27 19:47:22 +01:00
bep 251f5e9d40 Do not panic on permission denied
Replace panic with FATAL logging and graceful shutdown.

Fixes #837
2015-01-27 16:51:24 +01:00
bep 8ad4fd05d8 Split Windows and Unix specific path tests 2015-01-27 15:09:01 +01:00
bep b155e8b4cb Temporarily comment out breaking Windows test case 2015-01-27 12:12:35 +01:00
bep bedc2d8488 Introduce FilepathPathBridge
This commit introduces the new interface FilepathPathBridge to remove some code that differs only in their use of either the path or filepath package.
2015-01-27 11:44:41 +01:00
bep 5f9596e68c Add more tests to helper 2015-01-27 10:15:57 +01:00
bep 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 0c2297075a Linkify release notes 2015-01-26 20:42:08 +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 a6d22bcf7d Add documentation for pagination
See #750
2015-01-26 14:56:26 +01:00
bep c0fbe61484 Add Bootstrap-compatible pagination.html
See #750
2015-01-26 13:34:12 +01:00
bep 3628d0bbc6 Add pagination to release notes 2015-01-26 13:06:32 +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
Wade Wegner 39b2cdece0 Wrong URL for Github Pages 2015-01-25 23:00:16 -07: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
Kartik Singhal ea72f15f38 Correct wercker URL 2015-01-25 09:44:28 -07:00
Naoya Inada 57b4f3310b Fix inverse notation 2015-01-25 00:13:10 -07:00
Anthony Fok f6c0b472e9 Make Blackfriday smart fractions to really default to true
Fix my own bug in Pull Request #829,
commit eb686352b1
2015-01-24 22:06:15 +01:00
Anthony Fok eb686352b1 Add site-wide/per-page [blackfriday] fractions option
Make Blackfriday's `HTML_SMARTYPANTS_FRACTIONS` option
user-configurable.  Defaults to `true` as before.  See
discussions at:

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

Thanks to @bjornerik and @spf13 for laying the groundwork
making it easy to expose Blackfriday's underlying configurable
options.
2015-01-24 20:57:40 +01:00