Commit graph

251 commits

Author SHA1 Message Date
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 5f84bc02cd add preliminary support for content/index.md file to be homepage content 2015-06-17 10:47:49 -04: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
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 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
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
bep bec90e0850 Make page 1 alias ugly
When `uglyurls = true`

Fixes #1121
2015-05-10 18:28:44 +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 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
Dana H. P'Simer fd08e16ec8 Add RSSUri to specify the name of the RSS file 2015-05-07 22:20:00 +02:00
bep beb32af7a2 Do not fail on unknown files in /data
Fixes #1068
2015-04-22 18:35:56 +02:00
bep bed053071e Remove unused types Shortcode and ShortcodeFunc 2015-04-18 00:31:56 +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 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
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 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 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
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 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 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 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 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
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
spf13 8db3c0b0a6 page rendering and writing using BBP 2015-01-30 12:05:05 -08:00
spf13 b4c507287a site's XML generation using BBP 2015-01-30 11:51:06 -08: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
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 1cc6386937 Make ref and relref respect plainIdAnchors
Fixes #813
2015-01-21 14:35:33 +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
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