This commit is contained in:
Henrique Dias
2015-09-20 20:42:22 +01:00
parent 69efc2d70f
commit 6df32165b1
8 changed files with 192 additions and 86 deletions

View File

@@ -2,8 +2,10 @@ package utils
import (
"errors"
"io"
"log"
"net/http"
"os"
"reflect"
"strings"
"text/template"
@@ -12,6 +14,30 @@ import (
"github.com/hacdias/caddy-hugo/assets"
)
// CopyFile is used to copy a file
func CopyFile(old, new string) error {
// Open the file and create a new one
r, err := os.Open(old)
if err != nil {
return err
}
defer r.Close()
w, err := os.Create(new)
if err != nil {
return err
}
defer w.Close()
// Copy the content
_, err = io.Copy(w, r)
if err != nil {
return err
}
return nil
}
// CanBeEdited checks if a filename has a supported extension
func CanBeEdited(filename string) bool {
extensions := [...]string{".markdown", ".md",