Skip to content

Commit

Permalink
Fix load templates on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Sep 25, 2017
1 parent 7b67b99 commit 66ff8cb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
5 changes: 2 additions & 3 deletions backends/yaml/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"strings"

Expand All @@ -24,10 +23,10 @@ func New(paths ...string) *Backend {
defer file.Close()
if fileInfo, err := file.Stat(); err == nil {
if fileInfo.IsDir() {
yamlFiles, _ := filepath.Glob(path.Join(p, "*.yaml"))
yamlFiles, _ := filepath.Glob(filepath.Join(p, "*.yaml"))
backend.files = append(backend.files, yamlFiles...)

ymlFiles, _ := filepath.Glob(path.Join(p, "*.yml"))
ymlFiles, _ := filepath.Glob(filepath.Join(p, "*.yml"))
backend.files = append(backend.files, ymlFiles...)
} else if fileInfo.Mode().IsRegular() {
backend.files = append(backend.files, p)
Expand Down
5 changes: 2 additions & 3 deletions exchange_actions/exchange_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/csv"
"fmt"
"os"
"path"
"path/filepath"
"runtime/debug"
"sort"
Expand Down Expand Up @@ -50,7 +49,7 @@ func RegisterExchangeJobs(I18n *i18n.I18n, Worker *worker.Worker) {
translationKeys []string
translationsMap = map[string]bool{}
filename = fmt.Sprintf("/downloads/translations.%v.csv", time.Now().UnixNano())
fullFilename = path.Join("public", filename)
fullFilename = filepath.Join("public", filename)
i18nTranslations = I18n.LoadTranslations()
scope = arg.(*ExportTranslationArgument).Scope
)
Expand Down Expand Up @@ -140,7 +139,7 @@ func RegisterExchangeJobs(I18n *i18n.I18n, Worker *worker.Worker) {
Handler: func(arg interface{}, qorJob worker.QorJobInterface) (err error) {
importTranslationArgument := arg.(*ImportTranslationArgument)
qorJob.AddLog("Importing translations...")
if csvfile, err := os.Open(path.Join("public", importTranslationArgument.TranslationsFile.URL())); err == nil {
if csvfile, err := os.Open(filepath.Join("public", importTranslationArgument.TranslationsFile.URL())); err == nil {
reader := csv.NewReader(csvfile)
reader.TrimLeadingSpace = true
if records, err := reader.ReadAll(); err == nil {
Expand Down
8 changes: 4 additions & 4 deletions i18n.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"io/ioutil"
"net/http"
"os"
"path"
"path/filepath"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -205,21 +205,21 @@ func RenderInlineEditAssets(isIncludeJQuery bool, isIncludeExtendAssetLib bool)
}

if isIncludeExtendAssetLib {
if extendLib, err := ioutil.ReadFile(path.Join(gopath, "src/github.com/qor/i18n/views/themes/i18n/inline-edit-libs.tmpl")); err == nil {
if extendLib, err := ioutil.ReadFile(filepath.Join(gopath, "src/github.com/qor/i18n/views/themes/i18n/inline-edit-libs.tmpl")); err == nil {
content += string(extendLib)
} else {
hasError = true
}

if css, err := ioutil.ReadFile(path.Join(gopath, "src/github.com/qor/i18n/views/themes/i18n/assets/stylesheets/i18n-inline.css")); err == nil {
if css, err := ioutil.ReadFile(filepath.Join(gopath, "src/github.com/qor/i18n/views/themes/i18n/assets/stylesheets/i18n-inline.css")); err == nil {
content += fmt.Sprintf("<style>%s</style>", string(css))
} else {
hasError = true
}

}

if js, err := ioutil.ReadFile(path.Join(gopath, "src/github.com/qor/i18n/views/themes/i18n/assets/javascripts/i18n-inline.js")); err == nil {
if js, err := ioutil.ReadFile(filepath.Join(gopath, "src/github.com/qor/i18n/views/themes/i18n/assets/javascripts/i18n-inline.js")); err == nil {
content += fmt.Sprintf("<script type=\"text/javascript\">%s</script>", string(js))
} else {
hasError = true
Expand Down

0 comments on commit 66ff8cb

Please sign in to comment.