Commit graph

588 commits

Author SHA1 Message Date
Bjørn Erik Pedersen 3b42640e3f hugolib: Don't write zero-bytes files to disk
Fixes #2709
2016-11-20 14:59:21 +01:00
Bjørn Erik Pedersen 4d4c7791ac hugolib: Must update PathSpec on SiteInfo per language 2016-11-07 21:17:51 +01:00
Albert Nigmatzianov 85a2d81e3c commands, tpl: Get rid of repeating viper accesses
* all: Delete some blank lines
* commands, tpl: Get rid of repeating viper accesses
2016-11-07 00:10:32 +01:00
Bjørn Erik Pedersen 72156e403c hugolib: Simplify range 2016-11-05 17:28:13 +01:00
Bjørn Erik Pedersen 6a3d1037b3 Fix RSS Title regression
And add tests to make sure it doesn't happen again.

Fixes #2645
2016-10-28 14:46:33 +02:00
Albert Nigmatzianov f21e2f25c9 all: Unify case of config variable names
All config variables starts with low-case and uses camelCase.

If there is abbreviation at the beginning of the name, the whole
abbreviation will be written in low-case.
If there is abbreviation at the end of the name, the
whole abbreviation will be written in upper-case.
For example, rssURI.
2016-10-24 20:56:00 +02:00
Bjørn Erik Pedersen a10b2cd372 Avoid reading from Viper for path and URL funcs
The gain, given the "real sites benchmark" below, is obvious:

```
benchmark           old ns/op       new ns/op       delta
BenchmarkHugo-4     14497594101     13084156335     -9.75%

benchmark           old allocs     new allocs     delta
BenchmarkHugo-4     57404335       48282002       -15.89%

benchmark           old bytes       new bytes      delta
BenchmarkHugo-4     9933505624      9721984424     -2.13%
```

Fixes #2495
2016-10-24 13:45:30 +02:00
Bjørn Erik Pedersen 58f31d2769 Consolidate the Param methods
Maps in Viper, Hugo's config backing store, is now properly lower-cased not just on top level, the current situation.

While this is mostly a good thing, as you don't need to know the original casing to look up a value, it will be breaking for people doing direct lookups in the ´Site.Params` map.

We will try to find a solution to this "breakage", but the recommended method to get params values is via the `.Param` methods.

This method is now implemented on `Node`, `Page` and `Site` and is case-insensitive:

* Use `.Param "someKey" ` if you want page param with fall back to site param if not found on page.
* Use `.Site.Param "someKey"` to get a site param

See #2590
2016-10-17 19:36:58 +02:00
Nate Finch 10a773cde7 Implement support for alias templates
This change adds a canonical alias.html template that is used for page
redirects, and passes the page as data to the template under .Page

Fixes #2533
Closes #2576
2016-10-15 15:25:05 +02:00
Albert 8fa871a05f all: Remove dead code 2016-10-13 13:51:16 +02:00
Bjørn Erik Pedersen 998034faad Log on error in translation file
Fixes #2562
2016-10-12 16:54:29 +02:00
Bjørn Erik Pedersen bf0dfa3e2d Fix URL in multilanguage sitemap index
Fixes #2509
2016-09-30 16:24:57 +02:00
Bjørn Erik Pedersen a0167d838e Fix leaky goroutine
By making the err chan buffered so both go routines can return.

Also make sure that any errors are logged.

Fixes #2488
2016-09-23 19:04:19 +02:00
Bjørn Erik Pedersen 4a79fa0c33 Revert the "standardize author data"
There were some breaking changes etc. that is too late to fix for 0.17.

Let us think this through and add proper author support for Hugo 0.18.

Fixes #2464

Revert "docs: Add documentation for author profiles"

This reverts commit b6673e5309.

Revert "Add First Class Author Support"

This reverts commit cf978c0649.
2016-09-18 19:16:39 +02:00
Derek Perkins cf978c0649 Add First Class Author Support
Closes #1850
2016-09-17 00:49:24 +02:00
Bjørn Erik Pedersen b86a605bfb Make paginate settings configurable per language
Fixes #2449
2016-09-15 09:32:52 +02:00
Bjørn Erik Pedersen a7dc3c082e Support site menu per language
Fixes #2434
2016-09-12 20:59:03 +02:00
Bjørn Erik Pedersen ef3c4a56d8 Fix reload dir matching in theme
Fixes #2430
2016-09-11 20:00:38 +02:00
Bjørn Erik Pedersen 364e69ab7f Handle symlink change event
Hugo 0.16 announced support for symbolic links for the root folders, /content, /static etc., but this got broken pretty fast.

The main problem this commit tries to solve is the matching of file change events to "what changed".

An example:

ContentDir: /mysites/site/content where /mysites/site/content is a symlink to /mycontent

/mycontent:

/mypost1.md
/post/mypost2.md

* A change to mypost1.md (on OS X) will trigger a file change event with name "/mycontent/mypost1.md"
* A change to mypost2.md gives event with name "/mysites/site/content/mypost2.md"

The first change will not trigger a correct update of Hugo before this commit. This commit fixes this by doing a two-step check:

1. Check if "/mysites/site/content/mypost2.md" is within /mysites/site/content
2. Check if  "/mysites/site/content/mypost2.md" is within the real path that /mysites/site/content points to

Fixes #2265
Closes #2273
2016-09-11 20:00:38 +02:00
Bjørn Erik Pedersen 43bf9ed38e Redirect to root when DefaultContentLanguageInSubdir = false
Fixes #2422
2016-09-09 17:42:02 +02:00
Bjørn Erik Pedersen 4df86a703a Fix paginator counter on x86-32
Atomic operations with 64 bit values must be aligned for 64-bit on x86-32.

According to the spec:

"The first word in a global variable or in an allocated struct or slice can be relied upon to be 64-bit aligned."

The above wasn't enough for the `paginationPageCount` on `SiteInfo`, maybe due to how `SiteInfo` is embedded.

This commit adds a 4 byte padding before the `uint64` that creates the correct alignment.

Fixes #2415
2016-09-09 14:31:49 +02:00
Bjørn Erik Pedersen ccb3040ad4 Fix pagination page counter on 32 bit
Updates #2415
2016-09-08 17:18:11 +03:00
Bjørn Erik Pedersen 35d2eac490 Fix go vet 1.7 issues
Updates #2309
2016-09-06 18:32:21 +03:00
Bjørn Erik Pedersen dc3618abcd Make sure the 404 node has .Data.Pages
Updates #2309
2016-09-06 18:32:21 +03:00
Bjørn Erik Pedersen 30d65fd48d Fix site reset for benchmarks etc.
Updates #2309
2016-09-06 18:32:21 +03:00
Bjørn Erik Pedersen b3563b40a4 Fix multilingual reload when shortcode changes
This commit also refines the partial rebuild logic, to make sure we do not do more work than needed.

Updates #2309
2016-09-06 18:32:21 +03:00
Bjørn Erik Pedersen a823b1572b Set lang template globals for each site when render shortcodes
We should get rid of these globals, but that is another month.
2016-09-06 18:32:21 +03:00
Bjørn Erik Pedersen 28696b5dca Small adjustment to SiteInfo init
After a visual inspection to make (pretty) sure it is correct re multiple languages.

Updates #2309
2016-09-06 18:32:20 +03:00
Bjørn Erik Pedersen 1bce8a854b Create a copy of the section node for RSS
So the Permalink gets correct when listing translations.

I have also checked the other relevant places to make sure we do not overwrite node values we need later.

Pointers can be tricky, but lesson learned is: A copy is cheap.

Updates #2309
2016-09-06 18:32:20 +03:00
Bjørn Erik Pedersen d8a256c155 Fix YAML loading of multilingual config
And some other minor fixes from code review.

Updates #2309
2016-09-06 18:32:20 +03:00
Bjørn Erik Pedersen a07293cf97 Create a Node map to get proper node translations
In a multi-language setup, before this commit the Node's Translations() method
would return some "dummy nodes" that would point to the correct page (Permalink),
but would not be the same as the node it points to -- it would not have the translated
title etc.

The node creation is, however, so mingled with rendering, whihc is too early to have any global state,
so the nodes has to be split in a prepare and a render phase. This commits does that with as small
a change as possible. This implementation is a temp solution until we fix #2297.

Updates #2309
2016-09-06 18:32:19 +03:00
Bjørn Erik Pedersen 8da040342e Render main content language in root by default
Fixes #2312
2016-09-06 18:32:18 +03:00
Bjørn Erik Pedersen d953e39e63 Add parent as owner to Site
And pull up common member vars like Tmpl and Multilinguage.

Or: the final multilingual TODO-fixes.

See #2309
2016-09-06 18:32:18 +03:00
Bjørn Erik Pedersen 9798a95670 Make the check command work in multilingual mode
Or: some more multilingual TODO-fixes.

See #2309
2016-09-06 18:32:18 +03:00
Bjørn Erik Pedersen 6b552db75f Make sure drafts etc. are not processed
See #2309
2016-09-06 18:32:18 +03:00
Bjørn Erik Pedersen e56ecab157 Multilingual TODO-fixes, take 1
See #2309
2016-09-06 18:32:18 +03:00
Bjørn Erik Pedersen 506e131f28 Fix the shortcode ref tests
See #2309
2016-09-06 18:32:18 +03:00
Bjørn Erik Pedersen 54141f71dd Improve language handling in URLs
The current "rendering language" is needed outside of Site. This commit moves the Language type to the helpers package, and then used to get correct correct language configuration in the markdownify template func.
This commit also adds two new template funcs: relLangURL and absLangURL.

See #2309
2016-09-06 18:32:18 +03:00
Bjørn Erik Pedersen 2079a23dd8 Make it possible to configure Blackfroday per language
See #2309
2016-09-06 18:32:17 +03:00
Bjørn Erik Pedersen 8b657a11ee Get the list commands up to multi-site level
This commit also unexports some Site methods, making it clear what the external build API really is.

See #2312
2016-09-06 18:32:17 +03:00
Bjørn Erik Pedersen 90de511017 Make taxonomies configurable per language
See #2312
2016-09-06 18:32:17 +03:00
Bjørn Erik Pedersen b6fcb3d0bb Add sitemap index for multilingual sites
See #2309
2016-09-06 18:32:17 +03:00
Bjørn Erik Pedersen d572071784 Redirect to main language from root
See #2312
See #2309
2016-09-06 18:32:17 +03:00
Bjørn Erik Pedersen f0b91852ea Rework the multilingual docs
And in the same go adjusted some minor parts of the language API:

Add LanguagePrefix alias to Node and rename the Multilingual config section to Languages.

See #2309
2016-09-06 18:32:17 +03:00
Bjørn Erik Pedersen ed0985404d Render the shortcodes as late as possible
This is needed to make shortcode users happy with the new multilanguage support,
but it will also solve many other related posts about "stuff not available in the shortcode".

We will have to revisit this re the handler chain at some point, but that will be easier
now as the integration test story has improved so much.

As part of this commit, the site-building tests in page_test.go is refreshed, they now
tests for all the rendering engines (when available), and all of them now uses the
same code-path as used in production.

Fixes #1229
Fixes #2323
Fixes ##1076
2016-09-06 18:32:16 +03:00
Bjørn Erik Pedersen 708bc78770 Optimize the multilanguage build process
Work In Progress!

This commit makes a rework of the build and rebuild process to better suit a multi-site setup.

This also includes a complete overhaul of the site tests. Previous these were a messy mix that
were testing just small parts of the build chain, some of it testing code-paths not even used in
"real life". Now all tests that depends on a built site follows the same and real production code path.

See #2309
Closes #2211
Closes #477
Closes #1744
2016-09-06 18:32:16 +03:00
Bjørn Erik Pedersen 3a02807970 Add Translations and AllTranslations to Node
This commit also consolidates URLs on Node vs Page, so now .Permalink should be interoperable.

Note that this implementations should be fairly short-livded, waiting for #2297, but the API should be stable.
2016-09-06 18:32:16 +03:00
Bjørn Erik Pedersen 52bf8f9095 Rework the i18n template func handling
Setting the language to use when loading the language bundles just doesn't work.
The template system is unfortanetely a global, and the last languate processed won ...
2016-09-06 18:32:16 +03:00
Bjørn Erik Pedersen 75dd596e6c Introduce HugoSites type
And a Hugo global variable which contains the site under build.

This is really needed to get some level of control of the "multiple languages" in play.

There are still work related to this scattered around, but that will come.

With this commit, the multilingual feature is starting to work.
2016-09-06 18:32:16 +03:00
Bjørn Erik Pedersen 618948e4a8 Reset translation slice on rebuild
Also add all translations, including the current, to the slice. We filter later.
2016-09-06 18:32:16 +03:00
Bjørn Erik Pedersen c4e7c37055 Add Translations and AllTranslations methods to Page
Will revisit Node later.
2016-09-06 18:32:15 +03:00
Bjørn Erik Pedersen 06d12ab895 Add proper Language and Languages types 2016-09-06 18:32:15 +03:00
Alexandre Bourget ec33732fbe Add multilingual support in Hugo
Implements:
* support to render:
  * content/post/whatever.en.md to /en/2015/12/22/whatever/index.html
  * content/post/whatever.fr.md to /fr/2015/12/22/whatever/index.html
* gets enabled when `Multilingual:` is specified in config.
* support having language switchers in templates, that know
  where the translated page is (with .Page.Translations)
  (when you're on /en/about/, you can have a "Francais" link pointing to
   /fr/a-propos/)
  * all translations are in the `.Page.Translations` map, including the current one.
* easily tweak themes to support Multilingual mode
* renders in a single swift, no need for two config files.

Adds a couple of variables useful for multilingual sites

Adds documentation (content/multilingual.md)

Added language prefixing for all URL generation/permalinking see in the
code base.

Implements i18n. Leverages the great github.com/nicksnyder/go-i18n lib.. thanks Nick.
* Adds "i18n" and "T" template functions..
2016-09-06 18:32:15 +03:00
Bjørn Erik Pedersen a0859dc672 Make LazyFileReader use the Afero source fs
Fixes #2317
2016-07-30 15:21:02 +02:00
Bjørn Erik Pedersen ef9b915680 Revert "Throw a noisy error when a post has no layout"
We have to figure out another way. There are perfectly valid reasons not having a layout for a page (I have have some broken sites as result of this).

See #1313

This reverts commit b15934008f.
2016-07-14 11:29:21 +02:00
Aditya Bhargava b15934008f Throw a noisy error when a post has no layout
Fixes #1313
2016-07-13 23:57:18 +02:00
Bjørn Erik Pedersen 8588103316 Unexport ShouldBuild and AssertShouldBuild 2016-06-14 15:53:49 +02:00
Hanchen Wang eeaafb4b26 hugolib: futureStats plural 2016-06-14 15:45:27 +02:00
Hanchen Wang 673e41bf6a hugolib: Add expiredStats to build feedback 2016-06-14 15:45:26 +02:00
Hanchen Wang 32c0e3fd1f hugolib: Bug fix futureStats 2016-06-14 15:45:26 +02:00
Hanchen Wang 6472f158a4 hugelib: Add expiredCount as a Site variable 2016-06-14 15:45:25 +02:00
Bjørn Erik Pedersen a7f51703c4 Add Hugo generator tag to home page if not present
Fixes #2182
2016-06-04 21:55:56 -04:00
Steve Francia f94cd2813d Handle errors during rereading properly
Without this fix, any error during rereading would cause Hugo to hang.
Fixes #2168
Closes #2179
2016-06-02 23:47:30 +02:00
Sven Dowideit 22683a3b66 Make alias redirect output URL's relative
Closes #2093
2016-04-22 08:14:19 +02:00
Anthony Fok 9ddf52021b Update import path of fsnotify
Rename "gopkg.in/fsnotify.v1" to "github.com/fsnotify/fsnotify"
per upstream recommendation.

See https://github.com/fsnotify/fsnotify/issues/108 for rationale.
2016-04-20 22:28:26 +08:00
Bjørn Erik Pedersen c0cf1a7e37 Fix section menus for lazy blogger
IsMenuCurrent was always returning false for the top level entries.

Fixes #2065
2016-04-10 13:49:32 +02:00
digitalcraftsman b7efbdc12f hugolib: Add option to disable rendering of 404 page
Fixes #1889
Closes #2037
2016-04-09 20:25:59 +02:00
nitoyon 72bda5ad26 Move section initialization to Site.assembleSections
Closes #1527
2016-04-09 20:13:35 +02:00
Bjørn Erik Pedersen f2ff77f3ac Make Hugo build without Mercurial
By creating a fork of the Bitbucket inflect repo. It hasn't changed since 2013,
so it must be considered pretty stable.

Fixes #2062
2016-04-08 21:11:44 +02:00
Bjørn Erik Pedersen 1c3c148b38 hugolib: Un-export internal Site-methods
These are obviously internal and for the most part undocumented, creating lots of GoLint warnings.

See #1160
See #2014
2016-04-08 17:55:23 +02:00
Sven Dowideit 1648e327c0 Document and clean SourceRelativeLinksEval code 2016-04-07 20:10:38 +02:00
Bjørn Erik Pedersen 54750b0780 Do not create robots.txt by default
Meny people, including me, have a custom robots.txt in static.

Also remove that option from the command line; it doesn't feel
important enough.

Fixes ##2049
2016-04-05 22:20:39 +02:00
Bjørn Erik Pedersen b678e90db7 Use to most specific interface in WriteDestPage 2016-04-02 00:04:08 +02:00
Bjørn Erik Pedersen 4f66f790b1 Add readFile template func
This also includes a refactor of the hugofs package and its usage.

The motivation for that is:

The Afero filesystems are brilliant. Hugo's way of adding a dozen of global variables for the different filesystems was a mistake. In readFile (and also in some other places in Hugo today) we need a way to restrict the access inside the working dir. We could use ioutil.ReadFile and implement the path checking, checking the base path and the dots ("..") etc. But it is obviously better to use an Afero BasePathFs combined witha ReadOnlyFs. We could create a use-once-filesystem and handle the initialization ourselves, but since this is also useful to others and the initialization depends on some other global state (which would mean to create a new file system on every invocation), we might as well do it properly and encapsulate the predefined set of filesystems. This change also leads the way, if needed, to encapsulate the file systems in a struct, making it possible to have several file system sets in action at once (parallel multilanguage site building? With Moore's law and all...)

Fixes #1551
2016-03-31 21:24:18 +02:00
Bjørn Erik Pedersen 8aec5ee2dd hugolib: Some more unexports 2016-03-25 03:12:31 +01:00
Bjørn Erik Pedersen fa1a9653e5 hugolib: Taxonomy GoDoc cleanup 2016-03-24 16:01:25 +01:00
Bjørn Erik Pedersen faf2e50685 Do some minor code cleaning of Site
* Unexport some methods/fields
* Add some godoc

Still plenty to do here.
2016-03-23 09:43:04 +01:00
Bjørn Erik Pedersen dc7d8a9eac Spring cleaning of the menu code 2016-03-23 00:29:39 +01:00
Bjørn Erik Pedersen de8fc8761a Re-render shortcode on template or data file change
Fixes  #1971
2016-03-21 21:09:25 -04:00
Bjørn Erik Pedersen 3529152efe Return early from appendThemeTemplates 2016-03-17 23:36:11 +01:00
Bjørn Erik Pedersen 70739c972e Remove unnecessary type conversions 2016-03-14 20:35:50 +01:00
Bjørn Erik Pedersen dea185aa9b hugolib: Remove unused code 2016-03-14 15:41:03 +01:00
Ján Koščo be3519fac0 Use default sitemap configuration for homepage
Fixes #1304
2016-03-10 11:02:00 +01:00
Bjørn Erik Pedersen 973393c99e Create template clone for late template execution
Fixing some breaking blogs on Go 1.6

Fixes #1879
2016-03-09 14:37:58 +01:00
Bjørn Erik Pedersen c7acc318b5 Add some missing resets on rebuild
Fixes #1928
Fixes #1929
2016-03-06 16:33:32 +01:00
Bjørn Erik Pedersen 023992abad Unexport the target handlers
These are of no interest outside the package.
2016-03-05 20:56:38 +01:00
Bjørn Erik Pedersen 27f8d8f963 Allow URL with extension in frontmatter
Fixes #1923
2016-03-05 20:50:53 +01:00
Bjørn Erik Pedersen ccd2f4c32b Prevent capitalized taxonomy labels
Fixes #1880
2016-03-03 21:54:23 +01:00
Bjørn Erik Pedersen 6b922750f3 Revert "Create template clone for late template execution"
This reverts commit 93b04e67f6.
2016-02-28 12:15:33 +01:00
Bjørn Erik Pedersen 93b04e67f6 Create template clone for late template execution
Fixing some breaking blogs on Go 1.6

Fixes #1879
2016-02-28 11:51:51 +01:00
Bjørn Erik Pedersen 804603155f Check for the presence of pages before setting dates
See #1903
2016-02-27 23:25:41 +01:00
Bjørn Erik Pedersen 75cf324322 Set Date and Lastmod for main home page
Fixes #1903
2016-02-27 23:21:07 +01:00
Tatsushi Demachi e9853642e5 Listen channel before sending values to it
The 'results' channel is not listend before sending error values in a
loop checking IsRenderable or not. This fixes it.
2016-02-20 14:03:06 +09:00
Bjørn Erik Pedersen 50182cd06b Remove superfluous Errorf 2016-02-16 02:05:59 +01:00
Derek Perkins bac1ba4655 Fix spelling and go vet errors 2016-02-13 19:08:48 +08:00
Tatsushi Demachi 68e2e63d92 Fix Hugo hang up with empty content directory
Site.ReadPagesFromSource returns nil chan error value when a site
content directory is empty but its receiver expects to be passed
something error values via the channel.

This fixes it by returning a channel which will be immediately closed.

Fix #1797
2016-02-03 08:19:02 +09:00
Anthony Fok 57eebbf243 Use FEEDBACK instead of ERROR for empty home page warning
jww.ERROR.Println() seems to have become too verbose,
making the warning message intended for new users
a lot less readable.
2016-01-30 17:39:17 +08:00
Bjørn Erik Pedersen 5def6d9aee Make the watch logger less chatty 2016-01-28 15:33:41 +01:00
Steve Francia 9413cf8499 Handle self rename operations gracefully 2016-01-26 14:33:08 -05:00
Steve Francia 7e196a8294 Handle remove & rename source operations incrementally 2016-01-26 14:30:28 -05:00
Steve Francia e01c340915 A single file can be replaced in site.Files 2016-01-26 14:29:37 -05:00
Steve Francia 45e5091428 Process only the source content that has changed 2016-01-26 14:28:53 -05:00
Steve Francia 9f3796a31d Read/reread individual source content files
next is incremental conversion
2016-01-26 14:26:23 -05:00
Steve Francia ca6ca4f4fc Separate handling content, data and template changes
Data & Templates reading independently
Need to work on page source reading and other source files
2016-01-26 14:25:39 -05:00
Steve Francia bcc42c0549 Separate reading source and processing source operations 2016-01-25 14:41:47 -05:00
Bjørn Erik Pedersen 3526afc773 Fix some Go vet errors 2016-01-16 00:28:48 +01:00
Ivan Fraixedes 9a6dc6c791 Add embeded template for robots.txt 2016-01-05 23:36:16 +01:00
Daniel Martí 7c5a1fd16b Replace *bytes.Buffer with io.Writer in rendering
Found via github.com/mvdan/interfacer.
2016-01-05 23:32:03 +01:00
Alexandre Bourget dcad066025 Small refactor: don't call p.Permalink() for all aliases, call it only
once and only if necessary.
2016-01-04 12:41:06 -05:00
Gerben Castel 6cdb8109cf Allow renaming of sitemap.xml 2016-01-04 12:28:49 -05:00
Sven Dowideit 0f6b334b67 Source file based relative linking
ala GitHub repository markdown for both md files and non-md files

Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
2016-01-01 15:23:11 -05:00
digitalcraftsman 47587321d9 Add themesDir option to configuration
themesDir can be used to change the default
path of the themes folder.

Fixes 1556
2016-01-01 14:46:40 -05:00
Bjørn Erik Pedersen 8cea428802 Fix data race in non-renderable pages
Fixes #1601
2015-12-18 11:24:35 +01:00
Bjørn Erik Pedersen e445c35d6a Fix copyright headers in source files
Still need to add some missing headers and an AUTHORS file.

See #1646
2015-12-07 19:57:01 +01:00
Anthony Fok f13db9328b Sort and remove "" from "Available templates" list 2015-12-06 23:23:54 -07:00
gunnaraasen d35d82060f Remove transformation of menu URLs
Fixes #1239
2015-12-06 15:25:23 +01:00
Bjørn Erik Pedersen 3f0f7eed68 Improve error handling in commands
Cobra, the CLI commander in use in Hugo, has some long awaited improvements in the error handling department.
This enables a more centralized error handling approach.

This commit introduces that by changing all the command funcs to `RunE`:

* The core part of the error logging, usage logging and `os.Exit(-1)` is now performed in one place and that one place only.
* The usage text is now only shown on invalid arguments etc. (user errors)

Fixes #1502
2015-12-02 07:07:05 -07:00
Anthony Fok 0d1d33d7f3 Print error when /index.html is zero-length
Also print warning (in verbose mode) for other empty pages.

See #947
2015-12-01 21:03:17 -07:00
Anthony Fok f8302768c7 Run go fmt hugolib/site.go 2015-12-01 21:01:19 -07:00
Steve Francia f045d7a611 Change the license to Apache 2.0 2015-11-23 22:16:36 -05:00
Kato Kazuyoshi 99acbb2eb2 Permalink on Node and Page should be of string
This change fixes #1384.
2015-11-23 17:41:29 +01:00
Cameron Moore 3abb2675c5 Add RSSLink to SiteInfo 2015-11-20 23:38:15 +01:00
spf13 5c1204c24b simplify rssuri logic 2015-11-15 11:05:16 -05:00
digitalcraftsman 9dbb6dc50d Add internal Google Analytics template
This commits also adds the GoogleAnalytics
variable to insert the tracking code.

Fixes #1424.
2015-11-04 17:11:38 -05:00
Bjørn Erik Pedersen 5bda0398e7 Export Page.Layout
And at the same time rename and unexport the badly named `Layout()` func. That method is not very usable outside the package.

Fixes #1539
2015-11-02 17:24:50 +01:00
Kato Kazuyoshi 698019a552 Disable LiveReload when Hugo is not running as a server
This change fixes #1410.
2015-10-15 16:36:14 -04:00
Anthony Fok e71bef79e5 Validate aliases to prevent directory traversal etc.
Add validation before creating aliases:

 * Prevent creating aliases outside webroot (public/ dir)
 * Skip empty "" alias
 * Skip "/" → "/index.html", which gets overwritten anyway
 * Refuse to create Windows-invalid filenames on Windows;
   warn on other platforms
 * In case of invalid aliases, after skipping them,
   return `err = nil` to prevent the error passing up
   all the way to `hugolib.Render()` and causing Hugo to abort.
 * Update alias tests.

Fixes #701: Add support for alias with whitespace
Fixes #1418: Add validation for alias
2015-09-13 18:08:42 +02:00
chrongzhang 52d94fa675 Add config option "disablePathToLower"
Enabling this prevents lowercasing of the path/url.

Fixes #557
2015-09-01 15:26:02 +02:00
Bjørn Erik Pedersen 04b4c996ac Reset Scratch for 404
The 404 pages etc. need a better solution, but fix this issue for now.

Fixes #1336
2015-08-07 20:30:01 +02:00
Anthony Fok b0416e9bef Strip trailing whitespace in code 2015-08-04 11:59:32 -06:00
Anthony Fok 252ea96d1d Remove deprecated fields and methods for v0.15
Special thanks to @bep for his guidance and
for making sure all of the Hugo themes get updated.

Fixes #1172
2015-07-30 13:33:38 +02:00
Ryan Clarke 18d69d7f8c Fix periods in taxonomies create bad paths
Fixes #1188
2015-07-25 21:43:20 +02:00
Edward Vielmetti c8477c4f6e Fix typo: "taxononomy" -> "taxonomy" 2015-07-19 19:36:23 +02:00
Bjørn Erik Pedersen 1a94148d06 Add paginator support for page groups
Fixed #1274
2015-07-18 14:53:52 +02:00
delputnam 9b3d0cf5bf Added missing "Social" section to SiteInfo
I could be wrong here, but it looks to me like .Site.Social.facebook is used in tpl/template_embedded.go, but the variable is never set. I've added a line to initializeSiteInfo to map the info from config into this variable.
2015-07-02 19:26:01 +02:00
Bjørn Erik Pedersen 664a97819f 404 is homeless
Fixes #1235
2015-06-28 10:43:43 +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 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
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 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
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
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
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
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
spf13 8a5dd06ad0 Use page.Markup to determine which PageHandler to use if it's set. 2014-11-04 00:44:30 -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
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
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 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
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
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
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 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
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 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 1b5f59b071 go fmt site.go 2014-08-25 13:13:11 -04:00
Chase Adams 348e123c9f Update 404 to be compiled to .html instead of directory 2014-08-25 09:38:08 -04:00
Joel Scoble c750a95e22 support for futre/draft summary info output 2014-08-20 14:21:15 -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
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
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
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
Vincent Batoufflet 667a047cea Fix date issue with home page in Sitemap 2014-05-10 15:33:18 -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
spf13 1302ef9f63 Making site page initialization a bit more granular and accessible 2014-05-01 13:20:58 -04: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