Commit graph

377 commits

Author SHA1 Message Date
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
20c4311df4 Switch to a more up to date TOML library
Fixes #2089
2016-08-20 20:33:06 +01:00
Bjørn Erik Pedersen
97c37732b4 Add a global Reset func
So we can do some benchmarking.
2016-08-16 12:50:26 +02:00
Kishin Yagami
661c9787ea commands: Suppress 'missing static' error
Fixes #2311
2016-08-14 00:35:43 +02:00
Jeremy Brown
d7f364c27e Fix for meminterval not using specified interval
Hugo seems to ignore the meminterval I specify and always uses it's default of 100ms.
This seems to be because Hugo tries to take the meminterval from the command line
(an Int) and converts it to a String and passes it to time.ParseDuration. If you pass a
different meminterval (such as `1000` as above) it will fail (time.ParseDuration requires
some units) and use the default instead.

Changed `meminterval` to be a String and added better documentation for valid time units.

Resolves: #2325
2016-08-02 19:48:07 +02:00
Bjørn Erik Pedersen
4ddd5361c1 Use the Afero source fs where relevant
Fixes #2319
2016-07-30 15:37:03 +02:00
Pedro Melo
3e1b579c17 Be less aggressive with CHMOD filesystem events
On 4679fbee41, rebuild was disabled on
CHMOD filesystem events, but the code is overly aggressive.

In some situations, specially with older Mac's (using a Late 2008
Macbook), the events we receive might be aggregated. On my
particular laptop, I get this events:

    INFO: 2016/07/26 18:08:51 hugo.go:737: Received System Events: ["<path>": WRITE|CHMOD]

These events are ignored because the code only checks for Chmod. This
commit fixes this by checking that the event is also not a Write or Create.

Related to #1587.
2016-07-26 22:18:15 +02:00
Alexandre Bourget
32d82a4496 Ignore emacs temp files 2016-07-11 02:01:45 +02:00
Vincent Batoufflet
b8af06f26a Make auto-date disabled by default
Fixes #2244
Closes #2260
2016-07-08 14:43:10 +02:00
Bjørn Erik Pedersen
b581bbd856 Make config flag global
Fixes #2261
2016-07-07 18:06:48 +02:00
Cameron Moore
ca6b26fe65 commands: Allow schema-less baseURL on command line
Fixes #1632
2016-06-29 23:08:55 -06:00
Bjørn Erik Pedersen
1accd3ba88 Fix example for autocomplete
See #2235
2016-06-22 13:59:53 +02:00
Hanchen Wang
c52bb4efbe commands: Specify os port generic errors
Closes #2217
2016-06-16 15:28:06 +02:00
Bjørn Erik Pedersen
aa690c8e95 commands: Fix charsets in mimetypes
Fixes #2218
2016-06-15 19:34:21 +02:00
Hanchen Wang
5461a5e03d commands: Add listExpiredCmd for expired pages 2016-06-14 15:45:26 +02:00
Hanchen Wang
51f7cd9bde commands: Add buildExpired flag 2016-06-14 15:45:26 +02:00
Bjørn Erik Pedersen
683888ebc8 Change hugo to Hugo in help text 2016-06-09 16:03:25 +02:00
Steve Francia
d1cf262b74 Ignore __jb_tmp___ files created by IntelliJ 2016-06-02 23:47:01 +02:00
Steve Francia
f8e4a0608c Annotate temp files that Hugo ignores 2016-06-02 23:47:01 +02:00
Bjørn Erik Pedersen
b5030782ae Ignore Byword temp files
Fixes #2126
2016-05-06 20:30:03 +02:00
Bjørn Erik Pedersen
2b02a402a0 commands: Sett mime type for CSS in Hugo server
Fixes #2104
2016-04-27 21:40:35 +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
b7fd410245 commands: Support config from ENV
So

```bash
env HUGO_TITLE="Some Title" hugo server
```

Will change the `title`.

Fixes #2090
2016-04-18 18:45:37 +02:00
Robert Basic
24cb0d1f58 tpl: Do not write to cache when ignoring cache
Fixes #2067
Closes #2069
2016-04-14 10:48:26 +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
digitalcraftsman
d3e829508b commands: Add helpful instuctions after "hugo new site"
Fixes #1164
2016-04-08 18:03:49 +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
Philipp Oppermann
43b5dfabb5 Disable syntax guessing for PygmentsCodeFences by default
This disables highlighting for fenced code blocks without explicitly specified language. It also introduces a new `PygmentsCodeFencesGuessSyntax` config option (defaulting to false).

To enable syntax guessing again, add the following to your config file: `PygmentsCodeFencesGuessSyntax = true`

This is a breaking change.
2016-04-04 22:19:36 +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
digitalcraftsman
7c81c86bdd commands: Apply Golint rules 2016-03-24 23:34:12 +01:00
Bjørn Erik Pedersen
a7953e25bb commands: Apply Golint rules to hugo.go 2016-03-24 14:24:22 +01:00
Bjørn Erik Pedersen
1cb7ed6ac7 parser: Spring code cleaning 2016-03-23 14:51:16 +01:00
Bjørn Erik Pedersen
9cf93e11f8 commands: Fix remaining Golint warning 2016-03-23 00:06:10 +01:00
Bjørn Erik Pedersen
283b866386 commands: Do not use named return vals in Jekyll import 2016-03-22 23:44:02 +01:00
srinivasreddy
c54df37f6a source: Remove unnecessary else condition 2016-03-22 19:47:47 +01:00
Bjørn Erik Pedersen
e5aa477491 Add support for symbolic links for content, layout, static, theme
Note: This is for the content roots only, but that should satisfy most needs.

Fixes #1855
2016-03-21 19:13:29 -04:00
Cameron Moore
9323707b32 create: Refactor NewContent to be testable
NewContent is refactored to use the afero.Fs interface that should allow
full testing.  This commit also pulls the metadata creation logic out of
NewContent and into a separate function to decrease the cyclomatic
complexity of NewContent.
2016-03-20 23:51:17 +01:00
Bjørn Erik Pedersen
c21dc16dbe commands: Remove unused code 2016-03-14 15:24:42 +01:00
John Ku
0ab4162413 Ability to config layout and content dir via cli
fixes spf13/hugo#1598
2016-03-11 23:42:27 +01:00
Bjørn Erik Pedersen
cafb784799 Add emoji support
This uses the Emoji map from https://github.com/kyokomi/emoji -- but with a custom replacement implementation.

The built-in are fine for most use cases, but in Hugo we do care about pure speed.

The benchmarks below are skewed in Hugo's direction as the source and result is a byte slice,
Kyokomi's implementation works best with strings.

Curious: The easy-to-use `strings.Replacer` is also plenty fast.

```
BenchmarkEmojiKyokomiFprint-4  	   20000	     86038 ns/op	   33960 B/op	     117 allocs/op
BenchmarkEmojiKyokomiSprint-4  	   20000	     83252 ns/op	   38232 B/op	     122 allocs/op
BenchmarkEmojiStringsReplacer-4	  100000	     21092 ns/op	   17248 B/op	      25 allocs/op
BenchmarkHugoEmoji-4           	  500000	      5728 ns/op	     624 B/op	      13 allocs/op
```

Fixes #1891
2016-03-11 15:51:37 -06:00
Bjørn Erik Pedersen
c8c6f5d05b Add json mime extension type 2016-03-06 14:10:06 +01:00
Bjørn Erik Pedersen
80e1fd29ab Log fsync errors 2016-03-01 16:38:56 +01:00
Bjørn Erik Pedersen
1f61f40328 Use flagChanged in all places 2016-02-27 18:01:01 +01:00
Bjørn Erik Pedersen
9349a889e2 Do not try to find available port if set by user
He/she probably really meant it.

Fixes #1901
2016-02-27 16:58:42 +01:00
Bjørn Erik Pedersen
8c84048033 Force full rebuild when site config changes
Fixes #1840
2016-02-14 15:16:55 +01:00
Henrique Dias
ad176055d9 Export MainSite var
Fixes hacdias/caddy-hugo#46
2016-02-14 13:50:03 +01:00
Anthony Fok
2d11551c53 Ignore temporary file "4913" created by Vim 2016-02-13 00:03:29 +08:00
Anthony Fok
1f326ad914 Fix bash-completion for Hugo builder flags such as --theme
by placing their SetAnnotation() calls after their definitions.

See #1824 and 87ca0d0
2016-02-06 23:49:45 +08:00
Bjørn Erik Pedersen
eebf00f702 Re-export HugoCmd
Caddy depends on it.

Fixes #1827
2016-02-06 12:40:16 +01:00
Bjørn Erik Pedersen
61197f9f29 Order the hugo comand flag vars 2016-02-05 23:25:07 +01:00
Bjørn Erik Pedersen
74539dea87 Unexport the remaining vars in hugo command 2016-02-05 22:58:17 +01:00
Cameron Moore
a89b2f41d6 commands: Get BaseURL from viper in server mode
Fixes #1821
2016-02-05 20:38:02 -06:00
Bjørn Erik Pedersen
3b596b85d1 Add renderToMemory flag
Only useful for benchmark testing as the rendered content will be ... invisible.
2016-02-05 21:30:48 +01:00
Bjørn Erik Pedersen
87ca0d0cbe Clean flags
* Reduce the amount of global flags
* Unexport all flag vars and commands vars
* Some other minor flag cleaning
2016-02-05 21:18:45 +01:00
Anthony Fok
ca0c67dc69 Fix a minor typo discovered by Lintian (Debian) 2016-01-30 16:46:48 +08:00
Steve Francia
d158f7e339 Provide more detail on static sync when running with verbose 2016-01-29 16:54:33 -05:00
Anthony Fok
e8eb618166 Do not call watchConfig() when not in watch mode
See #1772

Also, force DisableLiveReload to true when running "hugo --watch"
(build-only non-server mode) to prevent livereload.ForceRefresh(),
which would end up blocking watchConfig() forever, from being called
because livereload.Initialize() is never called in this case.

This fixes the bug where "hugo --watch" could only reload config.toml
once before it gets stuck for good at livereload.ForceRefresh().

This is also consistent with Hugo's existing behaviour:
Non-server "hugo --watch" has never injected livereload.js
since the inception of the "watch" feature in Hugo v0.12.
2016-01-29 16:21:55 -05:00
Steve Francia
c438f45629 Add flag --cleanDestinationDir=false to retain prior behavior 2016-01-29 16:14:23 -05:00
Bjørn Erik Pedersen
5def6d9aee Make the watch logger less chatty 2016-01-28 15:33:41 +01:00
Bjørn Erik Pedersen
12876ec991 Fix hugo benchmark
Appending to the site 13 times doesn't sound realistic.
2016-01-27 22:28:05 +01:00
Steve Francia
d08e4c87a7 Rewrite commentary on static event handling 2016-01-26 14:56:42 -05:00
Steve Francia
b0b4b82165 Permit directory removal during static sync 2016-01-26 14:33:56 -05:00
Steve Francia
db18fd1582 Ignore .DS_Store changes (thumbnail cache file on mac) 2016-01-26 14:33:51 -05:00
Steve Francia
9413cf8499 Handle self rename operations gracefully 2016-01-26 14:33:08 -05:00
Steve Francia
74c90553b4 Static file incremental sync improvements
in tandem with Afero improvements
2016-01-26 14:31:43 -05:00
Steve Francia
7e196a8294 Handle remove & rename source operations incrementally 2016-01-26 14:30:28 -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
f3aa93fa48 Ignore temp files created by IntelliJ when saving 2016-01-25 14:41:47 -05:00
Steve Francia
ed3015c350 update server to match latest afero 2016-01-11 21:45:05 -05:00
Ivan Fraixedes
9a6dc6c791 Add embeded template for robots.txt 2016-01-05 23:36:16 +01:00
Gerben Castel
6cdb8109cf Allow renaming of sitemap.xml 2016-01-04 12:28:49 -05:00
Fabiano Frizzo
8f6f13104e Copy static files changed
Fix watcher copy static theme files for
changed files

See #1644 #1559
2016-01-04 10:32:21 -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
Steve Francia
1d6286b094 update to use cobra's sub package doc 2015-12-24 10:31:44 -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
e1af7cb9d0 Use MkdirAll instead of Mkdir in hugo gen doc
Also print a feedback if the path does not exist and needs to be created.
2015-12-19 06:08:01 -07: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
Anthony Fok
c1e134f1c2 Add --source flag back to hugo new command
v0.15 had it, but I removed it inadvertently for 0.16-DEV
in commit 00d04774 in PR #1652.

Also add directory bash-completion for `--source`
for `hugo convert`, `hugo list` and `hugo new`.

See #1624, #1589
2015-12-16 00:00:05 -07:00
Bjørn Erik Pedersen
d1bec54293 Do not fail on unknown Jekyll file
Fixes #1705
2015-12-14 15:30:58 +01:00
Anthony Fok
8509727fe8 Add copyright header to that source files that don’t have one.
See #1646
2015-12-10 15:19:38 -07:00
Steve Francia
e29ede7055 Fix some of the "new site" tests 2015-12-08 17:38:48 -05:00
Bjørn Erik Pedersen
56d6c0be5a Turn off failing new site test
Until @spf13 gets some free time in his busy calendar.

See #1680
2015-12-08 19:25:34 +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
inondle
f6fdfcd429 Added 'themes' as a default new site directory
Fixes #1507
2015-12-04 02:19:53 -07: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
c1b5a48f4e Add sanity checks for hugo import jekyll
Also add `--force` flag copied from `hugo new site`.

Fixes #1625
2015-12-03 00:39:00 -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
c5287e7817 Some more error fixes in commands
See #1502
2015-12-02 16:27:08 +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
75c61236f1 Move import jekyll functions to import_jekyll.go
Also rename import_test.go to import_jekyll_test.go
2015-12-02 03:39:10 -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