Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/target
diff options
context:
space:
mode:
authorspf13 <steve.francia@gmail.com>2014-05-01 21:13:11 +0400
committerspf13 <steve.francia@gmail.com>2014-05-01 21:13:11 +0400
commit58f8b43feed9a487e63b61352226d934743ebafe (patch)
tree7b7b856dc44a4bacad986b408b16346ca69c33d6 /target
parentf271faea066c47817c8a9a62ef5509a151452d6a (diff)
moving writeToDisk to helpers to make it more accessible
Diffstat (limited to 'target')
-rw-r--r--target/file.go27
-rw-r--r--target/htmlredirect.go5
2 files changed, 6 insertions, 26 deletions
diff --git a/target/file.go b/target/file.go
index f3d2b0b62..f70558098 100644
--- a/target/file.go
+++ b/target/file.go
@@ -3,9 +3,9 @@ package target
import (
"fmt"
"io"
- "os"
"path"
- "path/filepath"
+
+ "github.com/spf13/hugo/helpers"
)
type Publisher interface {
@@ -34,28 +34,7 @@ func (fs *Filesystem) Publish(path string, r io.Reader) (err error) {
return
}
- return writeToDisk(translated, r)
-}
-
-func writeToDisk(translated string, r io.Reader) (err error) {
- path, _ := filepath.Split(translated)
- ospath := filepath.FromSlash(path)
-
- if ospath != "" {
- err = os.MkdirAll(ospath, 0777) // rwx, rw, r
- if err != nil {
- panic(err)
- }
- }
-
- file, err := os.Create(translated)
- if err != nil {
- return
- }
- defer file.Close()
-
- _, err = io.Copy(file, r)
- return
+ return helpers.WriteToDisk(translated, r)
}
func (fs *Filesystem) Translate(src string) (dest string, err error) {
diff --git a/target/htmlredirect.go b/target/htmlredirect.go
index 55f4896e1..73a769f87 100644
--- a/target/htmlredirect.go
+++ b/target/htmlredirect.go
@@ -2,10 +2,11 @@ package target
import (
"bytes"
- "github.com/spf13/hugo/helpers"
"html/template"
"path"
"strings"
+
+ "github.com/spf13/hugo/helpers"
)
const ALIAS = "<!DOCTYPE html><html><head><link rel=\"canonical\" href=\"{{ .Permalink }}\"/><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" /><meta http-equiv=\"refresh\" content=\"0;url={{ .Permalink }}\" /></head></html>"
@@ -67,5 +68,5 @@ func (h *HTMLRedirectAlias) Publish(path string, permalink template.HTML) (err e
return
}
- return writeToDisk(path, buffer)
+ return helpers.WriteToDisk(path, buffer)
}