Commit graph

148 commits

Author SHA1 Message Date
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
Fabiano Frizzo a291f3c5d9 Copy only the static files changed
Update on the watcher copy static to copy only the
changed files and add an flag forceSyncStatic to
copy all statics always a static is changed

See #1644 #1559
2015-12-23 18:49:06 -05:00
Steve Francia 277425bada Ignore temp files created by IntelliJ when saving 2015-12-23 17:45:39 -05:00
Anthony Fok de82404d35 Fix hugo server "Watching for changes" path display
especially when the given `--source` path is a relative directory.

Also, when `--source` is specified, make WorkingDir an absolute path
from the very beginning, to be consistent with the case when `--source`
is not given.  Otherwise, the function name helpers.AbsPathify(), which
prepends WorkingDir to a relative path, does not really make sense.

Fixes #1721
2015-12-19 05:19:31 -07:00
Anthony Fok 3574304c68 Improve some random feedback messages
Also clean up a couple random comments.
2015-12-16 21:26:51 -07:00
Anthony Fok 9c39593dee Move cobra.MousetrapHelpText to hugo_windows.go
Fix build error due to Cobra API change, see
spf13/cobra#195: Compile mousetrap only on Windows
2015-12-16 21:26:47 -07: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 cd062623bd Fix crash with "config", "check" and "benchmark"
The crash was introduced by commit 00d04774 in PR #1652
where access to NoTimes was attempted even though --noTimes
was not defined for the config, check and benchmark commands.

Special thanks to @bep for the heads-up!

See also #1624 - CLI UX: Flags shouldn't be global
2015-12-03 12:02:38 -07:00
Anthony Fok 00d04774f0 Change most global flags into local ones
This is to ensure that only the relevant command-line flags
for a certain Hugo subcommand is shown to the end user,
reducing clutter and improving user experience.

Fixes #1624 - CLI UX: Flags shouldn't be global
2015-12-03 00:36:38 -07:00
Anthony Fok c9526f6e3f Revise format for "Unable to locate Config file" error 2015-12-03 00:28:09 -07:00
Bjørn Erik Pedersen be28d9d943 Fix some errors with format patterns
See #1502
2015-12-02 23:37:40 +01:00
Anthony Fok d48781badf One more error fix in the server command
And some other small code clean-up.

See #1502
2015-12-02 11:56:36 -07: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 666ddd2377 Enable dirname and filename completion for more flags
These flags are:

 * --source (-s), --cacheDir, --destination (-d) and --logFile
 * --completionfile and --dir.
2015-12-02 02:24:49 -07:00
Tatsushi Demachi e989468341 Make noTimes command flag work
Hugo command provides "noTimes" flag but it doesn't affect synced files
timestamp regardless of whether the flag is specified or not.

This fixes it by adding a flag check and overwriting configuration if it
is specified.

Fix #1583
2015-12-01 10:01:44 -07:00
Tatsushi Demachi 6c8103144f Copy static dir files without theme's static dir
Hugo command doesn't copy site's "static" directory files to "public"
directory if a specified theme doesn't have "static" directory because
theme's "static" directory checking always returns an error.

This fixes it by just showing a warning message about theme's "static"
directory absence and not skipping following processes.

Fix #1655
2015-12-01 10:01:21 -07:00
Steve Francia f045d7a611 Change the license to Apache 2.0 2015-11-23 22:16:36 -05:00
Andrew Brampton c3931ef748 Add PygmentsOptions option
This allows default pygments settings to be used, if none are explictly set per shortcode.

Fixes #1260
2015-11-23 17:50:54 +01:00
Bjørn Erik Pedersen 3d09de8910 Restructure the gen commands
Fixes #1603
2015-11-23 16:51:12 +01:00
Anthony Fok 098a0c819a Add commands/genman.go to autogenerate man pages
Fixes #1369
2015-11-22 18:54:44 +01:00
Bjørn Erik Pedersen 4679fbee41 Do not rebuild on extra Spotlight filesystem events
Write and rename operations are often followed by CHMOD.
There may be valid use cases for rebuilding the site on CHMOD,
but that will require more complex logic than this simple conditional.

On OS X this seems to be related to Spotlight, see:
https://github.com/go-fsnotify/fsnotify/issues/15

A workaround is to put your site(s) on the Spotlight exception list,
but that may be a little mysterious for most end users.

So, for now, we skip reload on CHMOD.

This small commit will be a 100% improvement for most OS X-users.

Fixes #1587
2015-11-18 22:59:32 +01:00
spf13 cb48425f2d No double slash when destination set to '/' 2015-11-16 21:56:14 -05:00
spf13 ef0b9b511c Handle sync (file copy) errors better) 2015-11-16 21:56:14 -05:00
Bjørn Erik Pedersen 3bbd02a1ca Print parse errors from Viper 2015-11-11 22:47:24 +01:00
spf13 bccf957e36 Add support for dynamic reloading of config file when watching 2015-11-09 23:31:52 -05:00
Kato Kazuyoshi 3a412543f6 The missing static directory shouldn't fail the build
The lack of the directory would be worth to warn, since the directory is
created by "huge new site". But it doesn't have to fail the build.

This change fixes #759.
2015-10-17 13:50:37 +02:00
Bjørn Erik Pedersen 63d9859c09 Expose canonifyURLs as a command flag
Needed by the theme site.
2015-10-10 10:53:13 +02:00
coderzh 823334875d WordCount and Summary support CJK Language
* add global `hasCJKLanguage` flag, if true, turn on auto-detecting CJKLanguage
 * add `isCJKLanguage` frontmatter to force specify whether is CJKLanguage or not
 * For .Summary: If isCJKLanguage is true, use the runes as basis for truncation, else keep as today.
 * For WordCount: If isCJKLanguage is true, use the runes as basis for calculation, else keep as today.
 * Unexport RuneCount

Fixes #1377
2015-10-07 15:14:57 +02:00
Bjørn Erik Pedersen b25ba8b095 Let Cobra do the usage error logging
Fixes #1472
2015-10-05 20:26:49 +02:00
coderzh 9a2f6c62a6 Hugo import from jekyll
usage: hugo import jekyll jekyll_root_path target_path

Implemented:
 * Create new hugo site
 * Create config.yaml
 * Convert all markdown contents.
 * Copy all other files and folders to static

Fixes #101
2015-10-04 20:02:53 +02:00
Bjørn Erik Pedersen 218554e363 Rename NormalizeHugoFlagsFunc to NormalizeHugoFlags
It IS a func.
2015-10-02 06:48:02 +02:00
Bjørn Erik Pedersen f5308da320 Move isThemeVsHugoVersionMismatch to /commands
To prevent potential package cycles in /helpers.
2015-09-14 17:31:39 +02:00
Anthony Fok d05b297e61 Add helpers.NormalizeHugoFlagsFunc() to handle flag name changes
It currently handles --baseUrl to --baseURL, and --uglyUrls to --uglyURLs.

Special thanks to Eric Paris (@eparis) for writing the
"normalized name" support in Cobra, and for showing us
how it is used in Kubernetes.

See Issue #959
2015-09-13 05:20:14 -06: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
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 fee5519129 Use spf13/pflag's new SetAnnotation helper
And make our bash completion code more compact.
2015-08-09 17:56:15 +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
Scott C Wilson 72ecd0cdc7 Ignore non-presence of "layouts" directory in watch logic
Fixes #691
2015-07-25 21:50:24 +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
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 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