Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert the string of attempted windows fixes to get back into a known…

… good state for Linux/OSX.

Instead, use the smallest fix that has been reported to work.
  • Loading branch information...
commit 5fb04bac0a3d8d79cfafb10f0a9f72963a4e3776 1 parent 27cd203
@robfig authored
View
21 cmd/build.go
@@ -5,6 +5,7 @@ import (
"github.com/robfig/revel"
"github.com/robfig/revel/harness"
"os"
+ "path"
"path/filepath"
)
@@ -51,12 +52,12 @@ func buildApp(args []string) {
// - app
// Revel and the app are in a directory structure mirroring import path
- srcPath := filepath.Join(destPath, "src")
- tmpRevelPath := filepath.Join(srcPath, filepath.FromSlash(revel.REVEL_IMPORT_PATH))
- mustCopyFile(filepath.Join(destPath, filepath.Base(app.BinaryPath)), app.BinaryPath)
- mustCopyDir(filepath.Join(tmpRevelPath, "conf"), filepath.Join(revel.RevelPath, "conf"), nil)
- mustCopyDir(filepath.Join(tmpRevelPath, "templates"), filepath.Join(revel.RevelPath, "templates"), nil)
- mustCopyDir(filepath.Join(srcPath, filepath.FromSlash(appImportPath)), revel.BasePath, nil)
+ srcPath := path.Join(destPath, "src")
+ tmpRevelPath := path.Join(srcPath, filepath.FromSlash(revel.REVEL_IMPORT_PATH))
+ mustCopyFile(path.Join(destPath, filepath.Base(app.BinaryPath)), app.BinaryPath)
+ mustCopyDir(path.Join(tmpRevelPath, "conf"), path.Join(revel.RevelPath, "conf"), nil)
+ mustCopyDir(path.Join(tmpRevelPath, "templates"), path.Join(revel.RevelPath, "templates"), nil)
+ mustCopyDir(path.Join(srcPath, filepath.FromSlash(appImportPath)), revel.BasePath, nil)
tmplData := map[string]interface{}{
"BinName": filepath.Base(app.BinaryPath),
@@ -64,12 +65,12 @@ func buildApp(args []string) {
}
mustRenderTemplate(
- filepath.Join(destPath, "run.sh"),
- filepath.Join(revel.RevelPath, "cmd", "package_run.sh.template"),
+ path.Join(destPath, "run.sh"),
+ path.Join(revel.RevelPath, "cmd", "package_run.sh.template"),
tmplData)
mustRenderTemplate(
- filepath.Join(destPath, "run.bat"),
- filepath.Join(revel.RevelPath, "cmd", "package_run.bat.template"),
+ path.Join(destPath, "run.bat"),
+ path.Join(revel.RevelPath, "cmd", "package_run.bat.template"),
tmplData)
}
View
4 cmd/clean.go
@@ -4,7 +4,7 @@ import (
"fmt"
"go/build"
"os"
- "path/filepath"
+ "path"
)
var cmdClean = &Command{
@@ -38,7 +38,7 @@ func cleanApp(args []string) {
}
// Remove the app/tmp directory.
- tmpDir := filepath.Join(appPkg.Dir, "app", "tmp")
+ tmpDir := path.Join(appPkg.Dir, "app", "tmp")
fmt.Println("Removing:", tmpDir)
err = os.RemoveAll(tmpDir)
if err != nil {
View
11 cmd/new.go
@@ -6,6 +6,7 @@ import (
"go/build"
"math/rand"
"os"
+ "path"
"path/filepath"
)
@@ -45,7 +46,7 @@ func newApp(args []string) {
}
importPath := args[0]
- if filepath.IsAbs(importPath) {
+ if path.IsAbs(importPath) {
errorf("Abort: '%s' looks like a directory. Please provide a Go import path instead.",
importPath)
}
@@ -62,12 +63,12 @@ func newApp(args []string) {
return
}
- srcRoot := filepath.Join(filepath.SplitList(gopath)[0], "src")
- appDir := filepath.Join(srcRoot, filepath.FromSlash(importPath))
+ srcRoot := path.Join(filepath.SplitList(gopath)[0], "src")
+ appDir := path.Join(srcRoot, filepath.FromSlash(importPath))
err = os.MkdirAll(appDir, 0777)
panicOnError(err, "Failed to create directory "+appDir)
- skeletonBase = filepath.Join(revelPkg.Dir, "skeleton")
+ skeletonBase = path.Join(revelPkg.Dir, "skeleton")
mustCopyDir(appDir, skeletonBase, map[string]interface{}{
// app.conf
"AppName": filepath.Base(appDir),
@@ -76,7 +77,7 @@ func newApp(args []string) {
// Dotfiles are skipped by mustCopyDir, so we have to explicitly copy the .gitignore.
gitignore := ".gitignore"
- mustCopyFile(filepath.Join(appDir, gitignore), filepath.Join(skeletonBase, gitignore))
+ mustCopyFile(path.Join(appDir, gitignore), path.Join(skeletonBase, gitignore))
fmt.Fprintln(os.Stdout, "Your application is ready:\n ", appDir)
fmt.Fprintln(os.Stdout, "\nYou can run it with:\n revel run", importPath)
View
14 cmd/test.go
@@ -9,7 +9,7 @@ import (
"io/ioutil"
"net/http"
"os"
- "path/filepath"
+ "path"
"strings"
"time"
)
@@ -59,7 +59,7 @@ func testApp(args []string) {
if !testRunnerFound {
errorf(`Error: The testrunner module is not running.
-You can add it to a run mode configuration with the following line:
+You can add it to a run mode configuration with the following line:
module.testrunner = github.com/robfig/revel/modules/testrunner
@@ -67,7 +67,7 @@ You can add it to a run mode configuration with the following line:
}
// Create a directory to hold the test result files.
- resultPath := filepath.Join(revel.BasePath, "test-results")
+ resultPath := path.Join(revel.BasePath, "test-results")
if err = os.RemoveAll(resultPath); err != nil {
errorf("Failed to remove test result directory %s: %s", resultPath, err)
}
@@ -76,7 +76,7 @@ You can add it to a run mode configuration with the following line:
}
// Direct all the output into a file in the test-results directory.
- file, err := os.OpenFile(filepath.Join(resultPath, "app.log"), os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
+ file, err := os.OpenFile(path.Join(resultPath, "app.log"), os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err != nil {
errorf("Failed to create log file: %s", err)
}
@@ -155,7 +155,7 @@ You can add it to a run mode configuration with the following line:
fmt.Printf("%8s%3s%6ds\n", suiteResultStr, suiteAlert, int(time.Since(startTime).Seconds()))
// Create the result HTML file.
- suiteResultFilename := filepath.Join(resultPath,
+ suiteResultFilename := path.Join(resultPath,
fmt.Sprintf("%s.%s.html", suite.Name, strings.ToLower(suiteResultStr)))
suiteResultFile, err := os.Create(suiteResultFilename)
if err != nil {
@@ -177,8 +177,8 @@ You can add it to a run mode configuration with the following line:
}
func writeResultFile(resultPath, name, content string) {
- if err := ioutil.WriteFile(filepath.Join(resultPath, name), []byte(content), 0666); err != nil {
- errorf("Failed to write result file %s: %s", filepath.Join(resultPath, name), err)
+ if err := ioutil.WriteFile(path.Join(resultPath, name), []byte(content), 0666); err != nil {
+ errorf("Failed to write result file %s: %s", path.Join(resultPath, name), err)
}
}
View
5 cmd/util.go
@@ -7,6 +7,7 @@ import (
"github.com/robfig/revel"
"io"
"os"
+ "path"
"path/filepath"
"strings"
"text/template"
@@ -63,7 +64,7 @@ func mustCopyDir(destDir, srcDir string, data map[string]interface{}) error {
// Get the relative path from the source base, and the corresponding path in
// the dest directory.
relSrcPath := strings.TrimLeft(srcPath[len(srcDir):], string(os.PathSeparator))
- destPath := filepath.Join(destDir, relSrcPath)
+ destPath := path.Join(destDir, relSrcPath)
// Skip dot files and dot directories.
if strings.HasPrefix(relSrcPath, ".") {
@@ -75,7 +76,7 @@ func mustCopyDir(destDir, srcDir string, data map[string]interface{}) error {
// Create a subdirectory if necessary.
if info.IsDir() {
- err := os.MkdirAll(filepath.Join(destDir, relSrcPath), 0777)
+ err := os.MkdirAll(path.Join(destDir, relSrcPath), 0777)
if !os.IsExist(err) {
panicOnError(err, "Failed to create directory")
}
View
4 config.go
@@ -3,7 +3,7 @@ package revel
import (
"errors"
"github.com/robfig/config"
- "path/filepath"
+ "path"
"strings"
)
@@ -19,7 +19,7 @@ type MergedConfig struct {
func LoadConfig(confName string) (*MergedConfig, error) {
var err error
for _, confPath := range ConfPaths {
- conf, err := config.ReadDefault(filepath.Join(confPath, confName))
+ conf, err := config.ReadDefault(path.Join(confPath, confName))
if err == nil {
return &MergedConfig{conf, ""}, nil
}
View
8 harness/build.go
@@ -41,7 +41,7 @@ func Build() (app *App, compileError *revel.Error) {
})
// Create a fresh temp dir.
- tmpPath := filepath.Join(revel.AppPath, "tmp")
+ tmpPath := path.Join(revel.AppPath, "tmp")
err := os.RemoveAll(tmpPath)
if err != nil {
revel.ERROR.Println("Failed to remove tmp dir:", err)
@@ -52,7 +52,7 @@ func Build() (app *App, compileError *revel.Error) {
}
// Create the main.go file
- controllersFile, err := os.Create(filepath.Join(tmpPath, "main.go"))
+ controllersFile, err := os.Create(path.Join(tmpPath, "main.go"))
defer controllersFile.Close()
if err != nil {
revel.ERROR.Fatalf("Failed to create main.go: %v", err)
@@ -77,7 +77,7 @@ func Build() (app *App, compileError *revel.Error) {
if err != nil {
revel.ERROR.Fatalln("Failure importing", revel.ImportPath)
}
- binName := filepath.Join(pkg.BinDir, path.Base(revel.BasePath))
+ binName := path.Join(pkg.BinDir, path.Base(revel.BasePath))
if runtime.GOOS == "windows" {
binName += ".exe"
}
@@ -86,7 +86,7 @@ func Build() (app *App, compileError *revel.Error) {
for {
buildCmd := exec.Command(goPath, "build",
"-tags", buildTags,
- "-o", binName, filepath.Join(revel.ImportPath, "app", "tmp"))
+ "-o", binName, path.Join(revel.ImportPath, "app", "tmp"))
revel.TRACE.Println("Exec:", buildCmd.Args)
output, err := buildCmd.CombinedOutput()
View
3  i18n.go
@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/robfig/config"
"os"
+ "path"
"path/filepath"
"regexp"
"strings"
@@ -87,7 +88,7 @@ func parseLocale(locale string) (language, region string) {
// Load the messages when Revel boots.
func init() {
- InitHooks = append(InitHooks, func() { loadMessages(filepath.Join(BasePath, messageFilesDirectory)) })
+ InitHooks = append(InitHooks, func() { loadMessages(path.Join(BasePath, messageFilesDirectory)) })
}
// Recursively read and cache all available messages from all message files on the given path.
View
22 revel.go
@@ -92,21 +92,21 @@ func Init(mode, importPath, srcPath string) {
revelSourcePath = SourcePath
}
- RevelPath = filepath.Join(revelSourcePath, filepath.FromSlash(REVEL_IMPORT_PATH))
- BasePath = filepath.Join(SourcePath, filepath.FromSlash(importPath))
- AppPath = filepath.Join(BasePath, "app")
- ViewsPath = filepath.Join(AppPath, "views")
+ RevelPath = path.Join(revelSourcePath, filepath.FromSlash(REVEL_IMPORT_PATH))
+ BasePath = path.Join(SourcePath, filepath.FromSlash(importPath))
+ AppPath = path.Join(BasePath, "app")
+ ViewsPath = path.Join(AppPath, "views")
CodePaths = []string{AppPath}
ConfPaths = []string{
- filepath.Join(BasePath, "conf"),
- filepath.Join(RevelPath, "conf"),
+ path.Join(BasePath, "conf"),
+ path.Join(RevelPath, "conf"),
}
TemplatePaths = []string{
ViewsPath,
- filepath.Join(RevelPath, "templates"),
+ path.Join(RevelPath, "templates"),
}
// Load app.conf
@@ -237,18 +237,18 @@ func loadModules() {
func addModule(name, importPath, modulePath string) {
Modules = append(Modules, Module{Name: name, ImportPath: importPath, Path: modulePath})
- if codePath := filepath.Join(modulePath, "app"); DirExists(codePath) {
+ if codePath := path.Join(modulePath, "app"); DirExists(codePath) {
CodePaths = append(CodePaths, codePath)
}
- if viewsPath := filepath.Join(modulePath, "app", "views"); DirExists(viewsPath) {
+ if viewsPath := path.Join(modulePath, "app", "views"); DirExists(viewsPath) {
TemplatePaths = append(TemplatePaths, viewsPath)
}
- INFO.Print("Loaded module ", filepath.Base(modulePath))
+ INFO.Print("Loaded module ", path.Base(modulePath))
// Hack: There is presently no way for the testrunner module to add the
// "test" subdirectory to the CodePaths. So this does it instead.
if importPath == "github.com/robfig/revel/modules/testrunner" {
- CodePaths = append(CodePaths, filepath.Join(BasePath, "tests"))
+ CodePaths = append(CodePaths, path.Join(BasePath, "tests"))
}
}
View
10 router.go
@@ -5,7 +5,7 @@ import (
"io/ioutil"
"net/http"
"net/url"
- "path/filepath"
+ "path"
"regexp"
"strings"
)
@@ -131,11 +131,11 @@ func (r *Route) Match(method string, reqPath string) *RouteMatch {
// Check if it is specifying a module.. if so, look there instead.
// This is a tenative syntax: "staticDir:moduleName:(directory)"
var basePath, dirName string
- if i := strings.Index(r.staticDir, ":"); i != -1 && !filepath.IsAbs(r.staticDir) {
+ if i := strings.Index(r.staticDir, ":"); i != -1 {
moduleName, dirName := r.staticDir[:i], r.staticDir[i+1:]
for _, module := range Modules {
if module.Name == moduleName {
- basePath = filepath.Join(module.Path, dirName)
+ basePath = path.Join(module.Path, dirName)
}
}
if basePath == "" {
@@ -144,12 +144,12 @@ func (r *Route) Match(method string, reqPath string) *RouteMatch {
}
} else {
dirName = r.staticDir
- if !filepath.IsAbs(dirName) {
+ if !path.IsAbs(dirName) {
basePath = BasePath
}
}
return &RouteMatch{
- StaticFilename: filepath.Join(basePath, dirName, matches[1]),
+ StaticFilename: path.Join(basePath, dirName, matches[1]),
}
}
View
25 router_test.go
@@ -4,9 +4,7 @@ import (
"fmt"
"net/http"
"net/url"
- "path/filepath"
"regexp"
- "runtime"
"testing"
)
@@ -158,22 +156,18 @@ func TestComputeRoute(t *testing.T) {
// Router Tests
-var TEST_ROUTES string
-
-func init() {
- TEST_ROUTES = fmt.Sprintf(`
+const TEST_ROUTES = `
# This is a comment
GET / Application.Index
GET /app/{id}/? Application.Show
POST /app/{id} Application.Save
GET /public/ staticDir:www
-GET /photos/ staticDir:%s
+GET /photos/ staticDir:/Users/robfig/Photos/
* /{controller}/{action} {controller}.{action}
GET /favicon.ico 404
-`, osPath("/Users/robfig/Photos/"))
-}
+`
var routeMatchTestCases = map[*http.Request]*RouteMatch{
&http.Request{
@@ -223,7 +217,7 @@ var routeMatchTestCases = map[*http.Request]*RouteMatch{
ControllerName: "",
MethodName: "",
Params: map[string]string{},
- StaticFilename: osPath("/BasePath/www/style.css"),
+ StaticFilename: "/BasePath/www/style.css",
},
&http.Request{
@@ -233,7 +227,7 @@ var routeMatchTestCases = map[*http.Request]*RouteMatch{
ControllerName: "",
MethodName: "",
Params: map[string]string{},
- StaticFilename: osPath("/Users/robfig/Photos/Rob/profile.png"),
+ StaticFilename: "/Users/robfig/Photos/Rob/profile.png",
},
&http.Request{
@@ -259,7 +253,7 @@ var routeMatchTestCases = map[*http.Request]*RouteMatch{
}
func TestRouteMatches(t *testing.T) {
- BasePath = osPath("/BasePath")
+ BasePath = "/BasePath"
router := NewRouter("")
router.parse(TEST_ROUTES, false)
for req, expected := range routeMatchTestCases {
@@ -362,10 +356,3 @@ func eq(t *testing.T, name string, a, b interface{}) bool {
}
return true
}
-
-func osPath(unixPath string) string {
- if runtime.GOOS == "windows" {
- return "C:" + filepath.FromSlash(unixPath)
- }
- return unixPath
-}
View
4 server.go
@@ -5,7 +5,7 @@ import (
"fmt"
"net/http"
"net/url"
- "path/filepath"
+ "path"
"reflect"
"time"
)
@@ -111,7 +111,7 @@ func Run(port int) {
port = HttpPort
}
- MainRouter = NewRouter(filepath.Join(BasePath, "conf", "routes"))
+ MainRouter = NewRouter(path.Join(BasePath, "conf", "routes"))
MainTemplateLoader = NewTemplateLoader(TemplatePaths)
// The "watch" config variable can turn on and off all watching.
View
3  util_test.go
@@ -1,6 +1,7 @@
package revel
import (
+ "path"
"path/filepath"
"testing"
)
@@ -14,7 +15,7 @@ func TestContentTypeByFilename(t *testing.T) {
"hello.world.c": "text/x-c; charset=utf-8",
}
srcPath, _ := findSrcPaths(REVEL_IMPORT_PATH)
- ConfPaths = []string{filepath.Join(
+ ConfPaths = []string{path.Join(
srcPath,
filepath.FromSlash(REVEL_IMPORT_PATH),
"conf"),
Please sign in to comment.
Something went wrong with that request. Please try again.