Commit graph

39 commits

Author SHA1 Message Date
digitalcraftsman
d3e829508b commands: Add helpful instuctions after "hugo new site"
Fixes #1164
2016-04-08 18:03:49 +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
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
Bjørn Erik Pedersen
74539dea87 Unexport the remaining vars in hugo command 2016-02-05 22:58:17 +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
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
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
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
Steve Francia
e29ede7055 Fix some of the "new site" tests 2015-12-08 17:38:48 -05: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
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
afbc18c09a Bump min_version to 0.15 for hugo new theme 2015-12-01 10:27:36 -07:00
Steve Francia
f045d7a611 Change the license to Apache 2.0 2015-11-23 22:16:36 -05:00
Bjørn Erik Pedersen
9d603ce88a Show usage when new site creation fails 2015-10-17 14:08:45 +02:00
Bjørn Erik Pedersen
ab7223df8c Improve error message on new site command 2015-10-17 14:05:48 +02:00
Safonov Nikita
5e97cf3020 Add force flag
If flag is passed the site will be created inside non-empty folder
only if there are no existent folders or config with the same name
hugo creates.

Resolves: #1163
2015-10-17 13:58:43 +02:00
Andy Williams
0f438d1852 Create minimal default.md in archetype file
fixes #315
To fix the cast error, create a minimal default.md in the archetype
folder.
2015-10-15 16:36:13 -04:00
digitalcraftsman
fd7b315572 Add a 404.html file if a new theme is created 2015-09-08 11:29:04 -04: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
bep
be3a3506c4 Allow forward slashes in Hugo new on Windows
Fixes  #1133
2015-05-12 18:12:58 +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
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
Anthony Fok
634548b9af Add new min_version field to theme.toml template 2015-03-10 09:49:42 -06:00
Anthony Fok
d10e05f2e3 [commands/new.go] Update theme.toml etc.
- Add copyright years and author to the top of the file

- Write the current year from time.Now() to LICENSE.md

- Correct comment regarding `os.MkdirAll(p, 0777)`

- In createConfig(), split the `map[string]string` definition into
  multiple lines to facilitate future expansion.  Also add a trailing
  slash to sample "baseurl" definition.

- Update theme.toml template to match that listed at
  https://github.com/spf13/hugoThemes/blob/master/README.md#themetoml

  See #883 for an equivalent `struct` implementation
2015-02-13 15:00:17 -07: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
Ahsanul Haque
b11838da3f Commented commands package 2014-12-12 00:05:02 +06:00
Joel Scoble
99463f6adf converted path 2 filepath 2014-11-13 22:39:07 -05:00
spf13
141f3e19e0 Migrating Hugo to Afero for filesystem calls. 2014-11-01 11:57:29 -04:00
Kartik Singhal
1614b82452 Correct desc for hugo new command 2014-10-02 13:47:25 -04:00
spf13
b9bba2b977 Updating Convert to handle dates properly for yaml and json
Fix bug with YAML & JSON with handling dates with 'new' and 'convert'
2014-05-29 18:45:19 -04:00
spf13
aeb06c7bcc Rename chrome to partials (in builder) 2014-05-27 18:30:25 -04:00
spf13
6b8244ba67 new site works in an empty directory now 2014-05-19 09:16:40 -04:00
spf13
6b9d4a93da Adding new commands (new site [path], new theme [name]) 2014-05-08 18:30:58 -04:00
spf13
28ffb92b36 Adding the new command and the create package 2014-05-02 01:06:01 -04:00