Commit graph

10 commits

Author SHA1 Message Date
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 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
Bjørn Erik Pedersen d1bec54293 Do not fail on unknown Jekyll file
Fixes #1705
2015-12-14 15:30:58 +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 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
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