Add themesDir option to configuration
authordigitalcraftsman <digitalcraftsman@users.noreply.github.com>
Mon, 23 Nov 2015 19:44:59 +0000 (20:44 +0100)
committerSteve Francia <steve.francia@gmail.com>
Fri, 1 Jan 2016 19:46:40 +0000 (14:46 -0500)
themesDir can be used to change the default
path of the themes folder.

Fixes 1556

commands/hugo.go
commands/new.go
create/content.go
docs/content/overview/configuration.md
helpers/path.go
hugolib/site.go

index 1f86baa2b31d2c79ed3c7ba6d7ae5f3b4c5021f5..ff10ddde6547b02fd920428af3d414e3e093b8a5 100644 (file)
@@ -210,6 +210,7 @@ func LoadDefaultSettings() {
        viper.SetDefault("ArchetypeDir", "archetypes")
        viper.SetDefault("PublishDir", "public")
        viper.SetDefault("DataDir", "data")
+       viper.SetDefault("ThemesDir", "themes")
        viper.SetDefault("DefaultLayout", "post")
        viper.SetDefault("BuildDrafts", false)
        viper.SetDefault("BuildFuture", false)
@@ -514,7 +515,7 @@ func getDirList() []string {
        filepath.Walk(helpers.AbsPathify(viper.GetString("LayoutDir")), walker)
        filepath.Walk(helpers.AbsPathify(viper.GetString("StaticDir")), walker)
        if helpers.ThemeSet() {
-               filepath.Walk(helpers.AbsPathify("themes/"+viper.GetString("theme")), walker)
+               filepath.Walk(helpers.AbsPathify(viper.GetString("themesDir")+"/"+viper.GetString("theme")), walker)
        }
 
        return a
index a30c9f55b975b7aedada052bea04a98c0f8dba8a..8c2e4850f4ebf7121fa7583a3e284583d3a883cf 100644 (file)
@@ -176,8 +176,8 @@ func NewTheme(cmd *cobra.Command, args []string) error {
                return newUserError("theme name needs to be provided")
        }
 
-       createpath := helpers.AbsPathify(filepath.Join("themes", args[0]))
-       jww.INFO.Println("Creating theme at", createpath)
+       createpath := helpers.AbsPathify(filepath.Join(viper.GetString("themesDir"), args[0]))
+       jww.INFO.Println("creating theme at", createpath)
 
        if x, _ := helpers.Exists(createpath, hugofs.SourceFs); x {
                return newUserError(createpath, "already exists")
index 3607e0139b8a6645b32552b40797e5a793731f7b..6d38bbde1c7dfceaffc9e074e84f30f3ecb5fc84 100644 (file)
@@ -132,7 +132,7 @@ func FindArchetype(kind string) (outpath string) {
        search := []string{helpers.AbsPathify(viper.GetString("archetypeDir"))}
 
        if viper.GetString("theme") != "" {
-               themeDir := filepath.Join(helpers.AbsPathify("themes/"+viper.GetString("theme")), "/archetypes/")
+               themeDir := filepath.Join(helpers.AbsPathify(viper.GetString("themesDir")+"/"+viper.GetString("theme")), "/archetypes/")
                if _, err := os.Stat(themeDir); os.IsNotExist(err) {
                        jww.ERROR.Println("Unable to find archetypes directory for theme :", viper.GetString("theme"), "in", themeDir)
                } else {
index 7047eb55066f33a4c420314b65c9a7b04dedc015..70df35dfc935316eba02510cf873259f0f62a3e4 100644 (file)
@@ -130,7 +130,8 @@ Following is a list of Hugo-defined variables that you can configure and their c
     staticdir:                  "static"
     # display memory and timing of different steps of the program
     stepAnalysis:               false
-    # theme to use (located in /themes/THEMENAME/)
+    # theme to use (located by default in /themes/THEMENAME/)
+    themesdir = "themes"
     theme:                      ""
     title:                      ""
     # if true, use /filename.html instead of /filename/
index bab6c71f9553f33ed392df397c55504df420c982..0fce5690fdce74d3b578acc1b7bbc2e643b0c883 100644 (file)
@@ -142,7 +142,7 @@ func GetStaticDirPath() string {
 // If there is no theme, returns the empty string.
 func GetThemeDir() string {
        if ThemeSet() {
-               return AbsPathify(filepath.Join("themes", viper.GetString("theme")))
+               return AbsPathify(filepath.Join(viper.GetString("themesDir"), viper.GetString("theme")))
        }
        return ""
 }
index aedba14ced2a287ec0f3c9ef3811d0eeeb25f3a6..6a6760dbad66b89461d3f7fd9b6dc8f279f30f89 100644 (file)
@@ -495,7 +495,7 @@ func (s *Site) absDataDir() string {
 }
 
 func (s *Site) absThemeDir() string {
-       return helpers.AbsPathify("themes/" + viper.GetString("theme"))
+       return helpers.AbsPathify(viper.GetString("themesDir") + "/" + viper.GetString("theme"))
 }
 
 func (s *Site) absLayoutDir() string {