aboutsummaryrefslogtreecommitdiffhomepage
path: root/helpers/pathspec.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2017-01-10 10:55:03 +0100
committerBjørn Erik Pedersen <[email protected]>2017-02-04 11:37:25 +0700
commitc71e1b106e6011d148cac899f83c4685dee33a22 (patch)
treec5c7090f0c2398c7771e4908ebcc97aa7714ffd2 /helpers/pathspec.go
parent0ada40591216572b0e4c6a8ab986b0aa4fb13c13 (diff)
downloadhugo-c71e1b106e6011d148cac899f83c4685dee33a22.tar.gz
hugo-c71e1b106e6011d148cac899f83c4685dee33a22.zip
all: Refactor to nonglobal file systems
Updates #2701 Fixes #2951
Diffstat (limited to 'helpers/pathspec.go')
-rw-r--r--helpers/pathspec.go28
1 files changed, 25 insertions, 3 deletions
diff --git a/helpers/pathspec.go b/helpers/pathspec.go
index d95dcde7a..0fc957b3b 100644
--- a/helpers/pathspec.go
+++ b/helpers/pathspec.go
@@ -13,6 +13,12 @@
package helpers
+import (
+ "fmt"
+
+ "github.com/spf13/hugo/hugofs"
+)
+
// PathSpec holds methods that decides how paths in URLs and files in Hugo should look like.
type PathSpec struct {
disablePathToLower bool
@@ -33,11 +39,27 @@ type PathSpec struct {
defaultContentLanguageInSubdir bool
defaultContentLanguage string
multilingual bool
+
+ // The file systems to use
+ fs *hugofs.Fs
+}
+
+func (p PathSpec) String() string {
+ return fmt.Sprintf("PathSpec, language %q, prefix %q, multilingual: %T", p.currentContentLanguage.Lang, p.getLanguagePrefix(), p.multilingual)
}
-// NewPathSpecFromConfig creats a new PathSpec from the given ConfigProvider.
-func NewPathSpecFromConfig(config ConfigProvider) *PathSpec {
+// NewPathSpec creats a new PathSpec from the given filesystems and ConfigProvider.
+func NewPathSpec(fs *hugofs.Fs, config ConfigProvider) *PathSpec {
+
+ currCl, ok := config.Get("currentContentLanguage").(*Language)
+
+ if !ok {
+ // TODO(bep) globals
+ currCl = NewLanguage("en")
+ }
+
return &PathSpec{
+ fs: fs,
disablePathToLower: config.GetBool("disablePathToLower"),
removePathAccents: config.GetBool("removePathAccents"),
uglyURLs: config.GetBool("uglyURLs"),
@@ -45,7 +67,7 @@ func NewPathSpecFromConfig(config ConfigProvider) *PathSpec {
multilingual: config.GetBool("multilingual"),
defaultContentLanguageInSubdir: config.GetBool("defaultContentLanguageInSubdir"),
defaultContentLanguage: config.GetString("defaultContentLanguage"),
- currentContentLanguage: config.Get("currentContentLanguage").(*Language),
+ currentContentLanguage: currCl,
paginatePath: config.GetString("paginatePath"),
}
}