Commit graph

186 commits

Author SHA1 Message Date
Anthony Fok 4047ca5c3c Search current directory for config file by default
As of 2015-08-16, Viper no longer searches the CWD
for config file by default to avoid unintended surprises,
but Hugo relies on the original behaviour.

Fixed by calling

    viper.AddConfigPath(".")

at the appropriate place.

See https://github.com/spf13/viper/issues/73 for more information.

Fixes #1363
2015-08-19 00:36:22 -06:00
Anthony Fok 29c9a40a8d Implement hugo --theme=[Tab][Tab] bash completion
using the new BashCompSubdirsInDir annotation in spf13/cobra.
2015-08-11 15:08:10 +02:00
Anthony Fok 7555e364d0 Print feedback for hugo genautocomplete 2015-08-09 17:59:44 +02:00
Anthony Fok c69835daba Print feedback for hugo gendoc 2015-08-09 17:58:01 +02:00
Anthony Fok fee5519129 Use spf13/pflag's new SetAnnotation helper
And make our bash completion code more compact.
2015-08-09 17:56:15 +02:00
Bjørn Erik Pedersen b05a292c21 Revert "Fix some Go code doc issues"
This reverts commit de7dd70bbc.

Broke the code fence feat.
2015-08-07 20:09:40 +02:00
Bjørn Erik Pedersen de7dd70bbc Fix some Go code doc issues 2015-08-06 22:58:10 +02:00
Anthony Fok f2ab0b2608 Improve formatting of Hugo command descriptions
Trying to make them look good both in the terminal (`hugo help [command]`)
and in the web browser (http://gohugo.io/commands/).  :-)
2015-08-04 03:19:57 -06:00
Anthony Fok e64e571b67 Bump hugo new theme template min_version to 0.14 2015-08-04 02:59:57 -06:00
Scott C Wilson 72ecd0cdc7 Ignore non-presence of "layouts" directory in watch logic
Fixes #691
2015-07-25 21:50:24 +02:00
Scott C Wilson c00a1fcb7f Add a check for the setting of watch flag in config file
Fixes #1074
2015-07-20 14:20:07 +02:00
Bjørn Erik Pedersen 354192d2b8 Log missing theme as FATAL
See #1234
2015-07-13 10:38:28 +02:00
Scott C Wilson 029cdb68f5 Checks to ensure theme directory, if specified, exists
See #1234
2015-07-13 10:31:59 +02:00
Andrew Brampton c139c6e1ef Add support for GitHub-flavoured markdown code fences for highlighting
This commit adds a new PygmentsCodeFences config option (default false), which if true will allow GitHub style backtick code fences around code, which will then be rendered by Pygments.

For example:

``` language
your code
```

can be used instead of {{< highlight language >}}your code {{< /highlight >}}.

Fixes #362
2015-07-08 08:12:52 +02:00
Bjørn Erik Pedersen 033a13e10e Fix watcher detecting changes as static when no theme
There have been some changes to the ´helpers.GetThemesDirPath()´ so it now returns an empty string when no theme.

This is correct, but it broke the watch service (at lest on OSX), as `strings.HasPrefix("", "somestring") evaluates to true somehow, and content changes are incorrectly branded as static.

There are other issues in there, but that will come later ...

See #1236
2015-06-28 19:27:28 +02:00
Bjørn Erik Pedersen 4b7c1342fd Make removal of accents in taxonomy and section paths optional
And default off.

Fixes #1180
2015-06-16 19:25:48 +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 be2842da18 Fix formatting in hugo command description 2015-05-21 20:05:29 +02:00
bep be831d7409 Fix CLI command description for the top level
And regenerate the commands doc.
2015-05-21 13:30:11 +02:00
spf13 fd5cf9ac8d Better organization of loading defaults 2015-05-20 18:50:32 -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 599d1b9786 Add gendoc command
Using the new, great auto-doc in Cobra.

This commit also contains a current result of that command added to a commands section in docs.

Fixes #1136
2015-05-19 10:57:21 -04:00
bep befa26b152 Remove trailing spaces in completionfile flag 2015-05-16 19:52:09 +02:00
bep be9224d720 Add Bash completion
Add a new command, genautocomplete, wich generates a Bash completion script (zsh and others later).

The script is by default written to `/etc/bash_completion.d/hugo.sh`; this can be set in `--completionfile=/some/file`.

Fixes #438
2015-05-16 18:04:59 +02:00
Andre R 84f4c21d4a Fix datePublished to publishdate 2015-05-16 15:58:37 +02:00
bep bee9718ac1 Do not shout about missing baseURL if relativeURLs is set 2015-05-16 15:42:15 +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
bep be3a3506c4 Allow forward slashes in Hugo new on Windows
Fixes  #1133
2015-05-12 18:12:58 +02:00
bep bef0f281d1 Make sure that complete server URL is logged on startup
Fixes #1113
2015-05-09 08:03:06 +02:00
Joel Scoble b4871787f0 add undraft command 2015-05-08 22:18:51 -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
Dana H. P'Simer fd08e16ec8 Add RSSUri to specify the name of the RSS file 2015-05-07 22:20:00 +02:00
Liam Bowen 2bfa9fb72b Make server bind interface configurable.
Bind by default to 127.0.0.1. Previously it always bound to all interfaces.

Always have log message display that the server is available on the
interface to which it is bound, instead of the baseUrl.

Fixes #1097
2015-05-07 22:04:40 +02:00
bep bee521c68f Try to make it more visible that you have to set baseUrl 2015-05-02 00:24:47 +02:00
bep be29c0bfbd Print ERROR on theme vs Hugo version mismatch
Fixes #1070
2015-04-28 20:39:25 +02:00
bep bebb1b9d5d Fix spelling mistake in comment 2015-04-07 15:17:24 +02:00
bep be31b9e287 Add custom Windows mousestrap message
Fixes #1022
2015-04-07 13:01:11 +02:00
bep be57ec5331 Fix the last Go Vet error 2015-04-03 22:18:08 +02:00
Dylan MacKenzie 99a18b21fc List directories being watched when server is run
Fixes part of issue 1030. Previously hugo only listed the content
directory as being watched. Now we list all files being watched
according to `commands.getDirList()`. We also introduce a RemoveSubpaths
function and test in the helpers module to reduce noise in the command
line output by not showing subdirectories of ones already being watched.

For example, instead of:
`Watching for changes in $HOME/blog/content`
We get:
`Watching for changes in
$HOME/blog/{data,content,layouts,static,themes/my-theme}`
2015-04-02 12:52:08 +02:00
bep beaf5db3ff Use helpers.FilePathSeparator const 2015-03-28 21:46:06 +01:00
Nuno Antunes 61a02c4df8 Fix section name guessing on Windows 2015-03-28 21:43:55 +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
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 fbcda03029 Do not ERROR-log missing /data dir
Fixes #930
2015-03-12 21:44:36 +01: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
Anthony Fok b9b70fb6b0 Skip directories like node_modules from the watchlist
A local `node_modules` directory can easily contain
tens of thousands of files, easily exhausting the tiny
default max open files limit especially on OS X Yosemite,
in spite of the fact that  Hugo already had code in place
since February 2014 to try to raise the maxfiles ulimit.

Also skip `.git` and `bower_components` directories.

The file watching situation will improve when
https://github.com/go-fsnotify/fsevents become ready,
but until then, we will be thrifty.  :-)

Thanks to @chibicode for the suggestion.

See #168 for continued discussions.
2015-03-10 16:55:23 -06:00
Anthony Fok 81695717e6 Switch from fsnotify.v0 to fsnotify.v1 API (watcher)
Fixes #357
See also #761
2015-03-10 09:59:55 -06:00
Anthony Fok 634548b9af Add new min_version field to theme.toml template 2015-03-10 09:49:42 -06:00
bep e685dfc0c6 Apply some more Golint suggestions 2015-03-06 18:07:50 +01:00
bep 224a2ddf3c Fix some Go Lint errors 2015-03-06 15:58:14 +01:00