Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

rev -> revel. Fixes #54

  • Loading branch information...
commit f164930331cab02ab1db335f9e7aa51ab52ab2bd 1 parent 93a30e6
@robfig authored
Showing with 303 additions and 304 deletions.
  1. +1 −1  binder.go
  2. +1 −1  binder_test.go
  3. +8 −8 cmd/build.go
  4. +1 −1  cmd/new.go
  5. +3 −3 cmd/package.go
  6. +6 −6 cmd/run.go
  7. +7 −7 cmd/test.go
  8. +1 −1  cmd/util.go
  9. +1 −1  config.go
  10. +2 −2 controller.go
  11. +1 −1  errors.go
  12. +1 −1  field.go
  13. +1 −1  flash.go
  14. +9 −9 harness/app.go
  15. +37 −37 harness/build.go
  16. +20 −20 harness/harness.go
  17. +22 −22 harness/reflect.go
  18. +8 −8 harness/reflect_test.go
  19. +1 −1  http.go
  20. +1 −1  i18n.go
  21. +1 −1  i18n_test.go
  22. +1 −1  init.go
  23. +10 −10 intercept.go
  24. +1 −1  intercept_test.go
  25. +1 −1  libs.go
  26. +9 −9 modules/db/app/db.go
  27. +11 −11 modules/testrunner/app/controllers/testrunner.go
  28. +7 −7 modules/testrunner/app/plugin.go
  29. +1 −1  modules/testrunner/public/css/bootstrap.css
  30. +3 −3 mvc.go
  31. +1 −1  mvc_test.go
  32. +1 −1  params.go
  33. +1 −1  plugin.go
  34. +1 −1  results.go
  35. +1 −2  revel.go
  36. +1 −1  router.go
  37. +1 −1  router_test.go
  38. +6 −6 samples/booking/app/controllers/app.go
  39. +9 −9 samples/booking/app/controllers/hotels.go
  40. +6 −6 samples/booking/app/controllers/init.go
  41. +4 −4 samples/booking/app/models/booking.go
  42. +14 −14 samples/booking/app/models/hotel.go
  43. +11 −11 samples/booking/app/models/user.go
  44. +1 −1  samples/booking/tests/apptest.go
  45. +3 −3 samples/chat/app/controllers/app.go
  46. +5 −5 samples/chat/app/controllers/longpolling.go
  47. +5 −5 samples/chat/app/controllers/refresh.go
  48. +3 −3 samples/chat/app/controllers/websocket.go
  49. +8 −8 samples/facebook-oauth2/app/controllers/app.go
  50. +2 −2 samples/i18n/app/controllers/app.go
  51. +1 −1  samples/i18n/public/css/bootstrap.css
  52. +1 −1  samples/i18n/tests/apptest.go
  53. +11 −11 samples/twitter-oauth/app/controllers/app.go
  54. +2 −2 samples/validation/app/controllers/app.go
  55. +3 −3 samples/validation/app/controllers/sample1.go
  56. +3 −3 samples/validation/app/controllers/sample2.go
  57. +3 −3 samples/validation/app/controllers/sample3.go
  58. +3 −3 samples/validation/app/controllers/sample4.go
  59. +1 −1  samples/validation/app/models/user.go
  60. +1 −1  server.go
  61. +1 −1  session.go
  62. +2 −2 skeleton/app/controllers/app.go
  63. +1 −1  skeleton/public/css/bootstrap.css
  64. +1 −1  skeleton/tests/apptest.go
  65. +2 −2 template.go
  66. +1 −1  tests.go
  67. +1 −1  util.go
  68. +1 −1  util_test.go
  69. +1 −1  validation.go
  70. +1 −1  validators.go
  71. +1 −1  watcher.go
View
2  binder.go
@@ -1,4 +1,4 @@
-package rev
+package revel
import (
"io"
View
2  binder_test.go
@@ -1,4 +1,4 @@
-package rev
+package revel
import (
"fmt"
View
16 cmd/build.go
@@ -35,8 +35,8 @@ func buildApp(args []string) {
}
appImportPath, destPath := args[0], args[1]
- if !rev.Initialized {
- rev.Init("", appImportPath, "")
+ if !revel.Initialized {
+ revel.Init("", appImportPath, "")
}
os.RemoveAll(destPath)
@@ -53,11 +53,11 @@ func buildApp(args []string) {
// Revel and the app are in a directory structure mirroring import path
srcPath := path.Join(destPath, "src")
- tmpRevelPath := path.Join(srcPath, filepath.FromSlash(rev.REVEL_IMPORT_PATH))
+ 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(rev.RevelPath, "conf"), nil)
- mustCopyDir(path.Join(tmpRevelPath, "templates"), path.Join(rev.RevelPath, "templates"), nil)
- mustCopyDir(path.Join(srcPath, filepath.FromSlash(appImportPath)), rev.BasePath, nil)
+ 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),
@@ -66,11 +66,11 @@ func buildApp(args []string) {
mustRenderTemplate(
path.Join(destPath, "run.sh"),
- path.Join(rev.RevelPath, "cmd", "package_run.sh.template"),
+ path.Join(revel.RevelPath, "cmd", "package_run.sh.template"),
tmplData)
mustRenderTemplate(
path.Join(destPath, "run.bat"),
- path.Join(rev.RevelPath, "cmd", "package_run.bat.template"),
+ path.Join(revel.RevelPath, "cmd", "package_run.bat.template"),
tmplData)
}
View
2  cmd/new.go
@@ -57,7 +57,7 @@ func newApp(args []string) {
return
}
- revelPkg, err := build.Import(rev.REVEL_IMPORT_PATH, "", build.FindOnly)
+ revelPkg, err := build.Import(revel.REVEL_IMPORT_PATH, "", build.FindOnly)
if err != nil {
fmt.Fprintf(os.Stderr, "Abort: Could not find Revel source code: %s\n", err)
return
View
6 cmd/package.go
@@ -32,14 +32,14 @@ func packageApp(args []string) {
}
appImportPath := args[0]
- rev.Init("", appImportPath, "")
+ revel.Init("", appImportPath, "")
// Remove the archive if it already exists.
- destFile := path.Base(rev.BasePath) + ".zip"
+ destFile := path.Base(revel.BasePath) + ".zip"
os.Remove(destFile)
// Collect stuff in a temp directory.
- tmpDir, err := ioutil.TempDir("", path.Base(rev.BasePath))
+ tmpDir, err := ioutil.TempDir("", path.Base(revel.BasePath))
panicOnError(err, "Failed to get temp dir")
buildApp([]string{args[0], tmpDir})
View
12 cmd/run.go
@@ -42,10 +42,10 @@ func runApp(args []string) {
}
// Find and parse app.conf
- rev.Init(mode, args[0], "")
+ revel.Init(mode, args[0], "")
// Determine the override port, if any.
- port := rev.HttpPort
+ port := revel.HttpPort
if len(args) == 3 {
var err error
if port, err = strconv.Atoi(args[2]); err != nil {
@@ -53,12 +53,12 @@ func runApp(args []string) {
}
}
- rev.INFO.Printf("Running %s (%s) in %s mode\n", rev.AppName, rev.ImportPath, mode)
- rev.TRACE.Println("Base path:", rev.BasePath)
+ revel.INFO.Printf("Running %s (%s) in %s mode\n", revel.AppName, revel.ImportPath, mode)
+ revel.TRACE.Println("Base path:", revel.BasePath)
// If the app is run in "watched" mode, use the harness to run it.
- if rev.Config.BoolDefault("watch", true) && rev.Config.BoolDefault("watch.code", true) {
- rev.HttpPort = port
+ if revel.Config.BoolDefault("watch", true) && revel.Config.BoolDefault("watch.code", true) {
+ revel.HttpPort = port
harness.NewHarness().Run() // Never returns.
}
View
14 cmd/test.go
@@ -46,11 +46,11 @@ func testApp(args []string) {
}
// Find and parse app.conf
- rev.Init(mode, args[0], "")
+ revel.Init(mode, args[0], "")
// Ensure that the testrunner is loaded in this mode.
testRunnerFound := false
- for _, module := range rev.Modules {
+ for _, module := range revel.Modules {
if module.ImportPath == "github.com/robfig/revel/modules/testrunner" {
testRunnerFound = true
break
@@ -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 := path.Join(rev.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)
}
@@ -92,11 +92,11 @@ You can add it to a run mode configuration with the following line:
// Start the app...
cmd.Start()
defer cmd.Kill()
- rev.INFO.Printf("Testing %s (%s) in %s mode\n", rev.AppName, rev.ImportPath, mode)
+ revel.INFO.Printf("Testing %s (%s) in %s mode\n", revel.AppName, revel.ImportPath, mode)
// Get a list of tests.
var testSuites []controllers.TestSuiteDesc
- baseUrl := fmt.Sprintf("http://127.0.0.1:%d", rev.HttpPort)
+ baseUrl := fmt.Sprintf("http://127.0.0.1:%d", revel.HttpPort)
resp, err := http.Get(baseUrl + "/@tests.list")
if err != nil {
errorf("Failed to request test list: %s", err)
@@ -108,7 +108,7 @@ You can add it to a run mode configuration with the following line:
fmt.Println()
// Load the result template, which we execute for each suite.
- TemplateLoader := rev.NewTemplateLoader(rev.TemplatePaths)
+ TemplateLoader := revel.NewTemplateLoader(revel.TemplatePaths)
if err := TemplateLoader.Refresh(); err != nil {
errorf("Failed to compile templates: %s", err)
}
@@ -117,7 +117,7 @@ You can add it to a run mode configuration with the following line:
errorf("Failed to load suite result template: %s", err)
}
- // Run each suite.
+ // Run each suite.
overallSuccess := true
for _, suite := range testSuites {
// Print the name of the suite we're running.
View
2  cmd/util.go
@@ -16,7 +16,7 @@ import (
type LoggedError struct{ error }
func panicOnError(err error, msg string) {
- if revErr, ok := err.(*rev.Error); (ok && revErr != nil) || (!ok && err != nil) {
+ if revErr, ok := err.(*revel.Error); (ok && revErr != nil) || (!ok && err != nil) {
fmt.Fprintf(os.Stderr, "Abort: %s: %s\n", msg, err)
panic(LoggedError{err})
}
View
2  config.go
@@ -1,4 +1,4 @@
-package rev
+package revel
import (
"errors"
View
4 controller.go
@@ -1,4 +1,4 @@
-package rev
+package revel
import (
"database/sql"
@@ -141,7 +141,7 @@ func (c *Controller) RenderError(err error) Result {
//
// For example:
//
-// func (c Users) ShowUser(id int) rev.Result {
+// func (c Users) ShowUser(id int) revel.Result {
// user := loadUser(id)
// return c.Render(user)
// }
View
2  errors.go
@@ -1,4 +1,4 @@
-package rev
+package revel
import (
"fmt"
View
2  field.go
@@ -1,4 +1,4 @@
-package rev
+package revel
import (
"reflect"
View
2  flash.go
@@ -1,4 +1,4 @@
-package rev
+package revel
import (
"fmt"
View
18 harness/app.go
@@ -35,7 +35,7 @@ func (a *App) Kill() {
}
// AppCmd manages the running of a Revel app server.
-// It requires rev.Init to have been called previously.
+// It requires revel.Init to have been called previously.
type AppCmd struct {
*exec.Cmd
}
@@ -43,8 +43,8 @@ type AppCmd struct {
func NewAppCmd(binPath string, port int) AppCmd {
cmd := exec.Command(binPath,
fmt.Sprintf("-port=%d", port),
- fmt.Sprintf("-importPath=%s", rev.ImportPath),
- fmt.Sprintf("-runMode=%s", rev.RunMode))
+ fmt.Sprintf("-importPath=%s", revel.ImportPath),
+ fmt.Sprintf("-runMode=%s", revel.RunMode))
cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
return AppCmd{cmd}
}
@@ -53,9 +53,9 @@ func NewAppCmd(binPath string, port int) AppCmd {
func (cmd AppCmd) Start() error {
listeningWriter := startupListeningWriter{os.Stdout, make(chan bool)}
cmd.Stdout = listeningWriter
- rev.TRACE.Println("Exec app:", cmd.Path, cmd.Args)
+ revel.TRACE.Println("Exec app:", cmd.Path, cmd.Args)
if err := cmd.Cmd.Start(); err != nil {
- rev.ERROR.Fatalln("Error running:", err)
+ revel.ERROR.Fatalln("Error running:", err)
}
select {
@@ -74,19 +74,19 @@ func (cmd AppCmd) Start() error {
// Run the app server inline. Never returns.
func (cmd AppCmd) Run() {
- rev.TRACE.Println("Exec app:", cmd.Path, cmd.Args)
+ revel.TRACE.Println("Exec app:", cmd.Path, cmd.Args)
if err := cmd.Cmd.Run(); err != nil {
- rev.ERROR.Fatalln("Error running:", err)
+ revel.ERROR.Fatalln("Error running:", err)
}
}
// Terminate the app server if it's running.
func (cmd AppCmd) Kill() {
if cmd.Cmd != nil && (cmd.ProcessState == nil || !cmd.ProcessState.Exited()) {
- rev.TRACE.Println("Killing revel server pid", cmd.Process.Pid)
+ revel.TRACE.Println("Killing revel server pid", cmd.Process.Pid)
err := cmd.Process.Kill()
if err != nil {
- rev.ERROR.Fatalln("Failed to kill revel server:", err)
+ revel.ERROR.Fatalln("Failed to kill revel server:", err)
}
}
}
View
74 harness/build.go
@@ -19,21 +19,21 @@ var importErrorPattern = regexp.MustCompile("import \"([^\"]+)\": cannot find pa
// Build the app:
// 1. Generate the the main.go file.
// 2. Run the appropriate "go build" command.
-// Requires that rev.Init has been called previously.
+// Requires that revel.Init has been called previously.
// Returns the path to the built binary, and an error if there was a problem building it.
-func Build() (app *App, compileError *rev.Error) {
- sourceInfo, compileError := ProcessSource(rev.CodePaths)
+func Build() (app *App, compileError *revel.Error) {
+ sourceInfo, compileError := ProcessSource(revel.CodePaths)
if compileError != nil {
return nil, compileError
}
// Add the db.import to the import paths.
- if dbImportPath, found := rev.Config.String("db.import"); found {
+ if dbImportPath, found := revel.Config.String("db.import"); found {
sourceInfo.InitImportPaths = append(sourceInfo.InitImportPaths, dbImportPath)
}
tmpl := template.Must(template.New("").Parse(REGISTER_CONTROLLERS))
- registerControllerSource := rev.ExecuteTemplate(tmpl, map[string]interface{}{
+ registerControllerSource := revel.ExecuteTemplate(tmpl, map[string]interface{}{
"Controllers": sourceInfo.ControllerSpecs,
"ValidationKeys": sourceInfo.ValidationKeys,
"ImportPaths": calcImportAliases(sourceInfo),
@@ -41,43 +41,43 @@ func Build() (app *App, compileError *rev.Error) {
})
// Create a fresh temp dir.
- tmpPath := path.Join(rev.AppPath, "tmp")
+ tmpPath := path.Join(revel.AppPath, "tmp")
err := os.RemoveAll(tmpPath)
if err != nil {
- rev.ERROR.Println("Failed to remove tmp dir:", err)
+ revel.ERROR.Println("Failed to remove tmp dir:", err)
}
err = os.Mkdir(tmpPath, 0777)
if err != nil {
- rev.ERROR.Fatalf("Failed to make tmp directory: %v", err)
+ revel.ERROR.Fatalf("Failed to make tmp directory: %v", err)
}
// Create the main.go file
controllersFile, err := os.Create(path.Join(tmpPath, "main.go"))
defer controllersFile.Close()
if err != nil {
- rev.ERROR.Fatalf("Failed to create main.go: %v", err)
+ revel.ERROR.Fatalf("Failed to create main.go: %v", err)
}
_, err = controllersFile.WriteString(registerControllerSource)
if err != nil {
- rev.ERROR.Fatalf("Failed to write to main.go: %v", err)
+ revel.ERROR.Fatalf("Failed to write to main.go: %v", err)
}
// Read build config.
- buildTags := rev.Config.StringDefault("build.tags", "")
+ buildTags := revel.Config.StringDefault("build.tags", "")
// Build the user program (all code under app).
// It relies on the user having "go" installed.
goPath, err := exec.LookPath("go")
if err != nil {
- rev.ERROR.Fatalf("Go executable not found in PATH.")
+ revel.ERROR.Fatalf("Go executable not found in PATH.")
}
ctx := build.Default
- pkg, err := ctx.Import(rev.ImportPath, "", build.FindOnly)
+ pkg, err := ctx.Import(revel.ImportPath, "", build.FindOnly)
if err != nil {
- rev.ERROR.Fatalln("Failure importing", rev.ImportPath)
+ revel.ERROR.Fatalln("Failure importing", revel.ImportPath)
}
- binName := path.Join(pkg.BinDir, path.Base(rev.BasePath))
+ binName := path.Join(pkg.BinDir, path.Base(revel.BasePath))
if runtime.GOOS == "windows" {
binName += ".exe"
}
@@ -86,15 +86,15 @@ func Build() (app *App, compileError *rev.Error) {
for {
buildCmd := exec.Command(goPath, "build",
"-tags", buildTags,
- "-o", binName, path.Join(rev.ImportPath, "app", "tmp"))
- rev.TRACE.Println("Exec:", buildCmd.Args)
+ "-o", binName, path.Join(revel.ImportPath, "app", "tmp"))
+ revel.TRACE.Println("Exec:", buildCmd.Args)
output, err := buildCmd.CombinedOutput()
// If the build succeeded, we're done.
if err == nil {
return NewApp(binName), nil
}
- rev.TRACE.Println(string(output))
+ revel.TRACE.Println(string(output))
// See if it was an import error that we can go get.
matches := importErrorPattern.FindStringSubmatch(string(output))
@@ -111,16 +111,16 @@ func Build() (app *App, compileError *rev.Error) {
// Execute "go get <pkg>"
getCmd := exec.Command(goPath, "get", pkgName)
- rev.TRACE.Println("Exec:", getCmd.Args)
+ revel.TRACE.Println("Exec:", getCmd.Args)
getOutput, err := getCmd.CombinedOutput()
if err != nil {
- rev.TRACE.Println(string(getOutput))
+ revel.TRACE.Println(string(getOutput))
return nil, newCompileError(output)
}
// Success getting the import, attempt to build again.
}
- rev.ERROR.Fatalf("Not reachable")
+ revel.ERROR.Fatalf("Not reachable")
return nil, nil
}
@@ -186,12 +186,12 @@ func containsValue(m map[string]string, val string) bool {
// Parse the output of the "go build" command.
// Return a detailed Error.
-func newCompileError(output []byte) *rev.Error {
+func newCompileError(output []byte) *revel.Error {
errorMatch := regexp.MustCompile(`(?m)^([^:#]+):(\d+):(\d+:)? (.*)$`).
FindSubmatch(output)
if errorMatch == nil {
- rev.ERROR.Println("Failed to parse build errors:\n", string(output))
- return &rev.Error{
+ revel.ERROR.Println("Failed to parse build errors:\n", string(output))
+ return &revel.Error{
SourceType: "Go code",
Title: "Go Compilation Error",
Description: "See console for build error.",
@@ -204,7 +204,7 @@ func newCompileError(output []byte) *rev.Error {
absFilename, _ = filepath.Abs(relFilename)
line, _ = strconv.Atoi(string(errorMatch[2]))
description = string(errorMatch[4])
- compileError = &rev.Error{
+ compileError = &revel.Error{
SourceType: "Go code",
Title: "Go Compilation Error",
Path: relFilename,
@@ -213,10 +213,10 @@ func newCompileError(output []byte) *rev.Error {
}
)
- fileStr, err := rev.ReadLines(absFilename)
+ fileStr, err := revel.ReadLines(absFilename)
if err != nil {
compileError.MetaError = absFilename + ": " + err.Error()
- rev.ERROR.Println(compileError.MetaError)
+ revel.ERROR.Println(compileError.MetaError)
return compileError
}
@@ -245,15 +245,15 @@ var (
func main() {
flag.Parse()
- rev.Init(*runMode, *importPath, *srcPath)
- rev.INFO.Println("Running revel server")
+ revel.Init(*runMode, *importPath, *srcPath)
+ revel.INFO.Println("Running revel server")
{{range $i, $c := .Controllers}}
- rev.RegisterController((*{{index $.ImportPaths .ImportPath}}.{{.StructName}})(nil),
- []*rev.MethodType{
- {{range .MethodSpecs}}&rev.MethodType{
+ revel.RegisterController((*{{index $.ImportPaths .ImportPath}}.{{.StructName}})(nil),
+ []*revel.MethodType{
+ {{range .MethodSpecs}}&revel.MethodType{
Name: "{{.Name}}",
- Args: []*rev.MethodArg{ {{range .Args}}
- &rev.MethodArg{Name: "{{.Name}}", Type: reflect.TypeOf((*{{index $.ImportPaths .ImportPath | .TypeExpr.TypeName}})(nil)) },{{end}}
+ Args: []*revel.MethodArg{ {{range .Args}}
+ &revel.MethodArg{Name: "{{.Name}}", Type: reflect.TypeOf((*{{index $.ImportPaths .ImportPath | .TypeExpr.TypeName}})(nil)) },{{end}}
},
RenderArgNames: map[int][]string{ {{range .RenderCalls}}
{{.Line}}: []string{ {{range .Names}}
@@ -264,15 +264,15 @@ func main() {
{{end}}
})
{{end}}
- rev.DefaultValidationKeys = map[string]map[int]string{ {{range $path, $lines := .ValidationKeys}}
+ revel.DefaultValidationKeys = map[string]map[int]string{ {{range $path, $lines := .ValidationKeys}}
"{{$path}}": { {{range $line, $key := $lines}}
{{$line}}: "{{$key}}",{{end}}
},{{end}}
}
- rev.TestSuites = []interface{}{ {{range .TestSuites}}
+ revel.TestSuites = []interface{}{ {{range .TestSuites}}
(*{{index $.ImportPaths .ImportPath}}.{{.StructName}})(nil),{{end}}
}
- rev.Run(*port)
+ revel.Run(*port)
}
`
View
40 harness/harness.go
@@ -25,7 +25,7 @@ import (
)
var (
- watcher *rev.Watcher
+ watcher *revel.Watcher
doNotWatch = []string{"tmp", "views"}
lastRequestHadError int32
@@ -41,7 +41,7 @@ type Harness struct {
}
func renderError(w http.ResponseWriter, r *http.Request, err error) {
- rev.RenderError(rev.NewRequest(r), rev.NewResponse(w), err)
+ revel.RenderError(revel.NewRequest(r), revel.NewResponse(w), err)
}
// ServeHTTP handles all requests.
@@ -75,11 +75,11 @@ func (hp *Harness) ServeHTTP(w http.ResponseWriter, r *http.Request) {
func NewHarness() *Harness {
// Get a template loader to render errors.
// Prefer the app's views/errors directory, and fall back to the stock error pages.
- rev.MainTemplateLoader = rev.NewTemplateLoader(rev.TemplatePaths)
- rev.MainTemplateLoader.Refresh()
+ revel.MainTemplateLoader = revel.NewTemplateLoader(revel.TemplatePaths)
+ revel.MainTemplateLoader.Refresh()
- addr := rev.HttpAddr
- port := rev.Config.IntDefault("harness.port", 0)
+ addr := revel.HttpAddr
+ port := revel.Config.IntDefault("harness.port", 0)
if port == 0 {
port = getFreePort()
@@ -96,12 +96,12 @@ func NewHarness() *Harness {
}
// Rebuild the Revel application and run it on the given port.
-func (h *Harness) Refresh() (err *rev.Error) {
+func (h *Harness) Refresh() (err *revel.Error) {
if h.app != nil {
h.app.Kill()
}
- rev.TRACE.Println("Rebuild")
+ revel.TRACE.Println("Rebuild")
h.app, err = Build()
if err != nil {
return
@@ -109,7 +109,7 @@ func (h *Harness) Refresh() (err *rev.Error) {
h.app.Port = h.port
if err2 := h.app.Cmd().Start(); err2 != nil {
- return &rev.Error{
+ return &revel.Error{
Title: "App failed to start up",
Description: err2.Error(),
}
@@ -119,7 +119,7 @@ func (h *Harness) Refresh() (err *rev.Error) {
}
func (h *Harness) WatchDir(info os.FileInfo) bool {
- return !rev.ContainsString(doNotWatch, info.Name())
+ return !revel.ContainsString(doNotWatch, info.Name())
}
func (h *Harness) WatchFile(filename string) bool {
@@ -129,14 +129,14 @@ func (h *Harness) WatchFile(filename string) bool {
// Run the harness, which listens for requests and proxies them to the app
// server, which it runs and rebuilds as necessary.
func (h *Harness) Run() {
- watcher = rev.NewWatcher()
- watcher.Listen(h, rev.CodePaths...)
+ watcher = revel.NewWatcher()
+ watcher.Listen(h, revel.CodePaths...)
go func() {
- rev.INFO.Printf("Listening on %s:%d", rev.HttpAddr, rev.HttpPort)
- err := http.ListenAndServe(fmt.Sprintf("%s:%d", rev.HttpAddr, rev.HttpPort), h)
+ revel.INFO.Printf("Listening on %s:%d", revel.HttpAddr, revel.HttpPort)
+ err := http.ListenAndServe(fmt.Sprintf("%s:%d", revel.HttpAddr, revel.HttpPort), h)
if err != nil {
- rev.ERROR.Fatalln("Failed to start reverse proxy:", err)
+ revel.ERROR.Fatalln("Failed to start reverse proxy:", err)
}
}()
@@ -154,13 +154,13 @@ func (h *Harness) Run() {
func getFreePort() (port int) {
conn, err := net.Listen("tcp", ":0")
if err != nil {
- rev.ERROR.Fatal(err)
+ revel.ERROR.Fatal(err)
}
port = conn.Addr().(*net.TCPAddr).Port
err = conn.Close()
if err != nil {
- rev.ERROR.Fatal(err)
+ revel.ERROR.Fatal(err)
}
return port
}
@@ -171,7 +171,7 @@ func proxyWebsocket(w http.ResponseWriter, r *http.Request, host string) {
d, err := net.Dial("tcp", host)
if err != nil {
http.Error(w, "Error contacting backend server.", 500)
- rev.ERROR.Printf("Error dialing websocket backend %s: %v", host, err)
+ revel.ERROR.Printf("Error dialing websocket backend %s: %v", host, err)
return
}
hj, ok := w.(http.Hijacker)
@@ -181,7 +181,7 @@ func proxyWebsocket(w http.ResponseWriter, r *http.Request, host string) {
}
nc, _, err := hj.Hijack()
if err != nil {
- rev.ERROR.Printf("Hijack error: %v", err)
+ revel.ERROR.Printf("Hijack error: %v", err)
return
}
defer nc.Close()
@@ -189,7 +189,7 @@ func proxyWebsocket(w http.ResponseWriter, r *http.Request, host string) {
err = r.Write(d)
if err != nil {
- rev.ERROR.Printf("Error copying request to target: %v", err)
+ revel.ERROR.Printf("Error copying request to target: %v", err)
return
}
View
44 harness/reflect.go
@@ -21,7 +21,7 @@ import (
// about the app source code, used to generate main.go.
type SourceInfo struct {
// ControllerSpecs lists type info for all structs found under
- // app/controllers/... that embed (directly or indirectly) rev.Controller.
+ // app/controllers/... that embed (directly or indirectly) revel.Controller.
ControllerSpecs []*TypeInfo
// ValidationKeys provides a two-level lookup. The keys are:
// 1. The fully-qualified function name,
@@ -44,7 +44,7 @@ type TypeInfo struct {
PackageName string // e.g. "controllers"
MethodSpecs []*MethodSpec
- // Used internally to identify controllers that indirectly embed *rev.Controller.
+ // Used internally to identify controllers that indirectly embed *revel.Controller.
embeddedTypes []*embeddedTypeName
}
@@ -78,16 +78,16 @@ type methodMap map[string][]*MethodSpec
// Parse the app controllers directory and return a list of the controller types found.
// Returns a CompileError if the parsing fails.
-func ProcessSource(roots []string) (*SourceInfo, *rev.Error) {
+func ProcessSource(roots []string) (*SourceInfo, *revel.Error) {
var (
srcInfo *SourceInfo
- compileError *rev.Error
+ compileError *revel.Error
)
for _, root := range roots {
rootImportPath := importPathFromPath(root)
if rootImportPath == "" {
- rev.WARN.Println("Skipping code path", root)
+ revel.WARN.Println("Skipping code path", root)
continue
}
@@ -117,14 +117,14 @@ func ProcessSource(roots []string) (*SourceInfo, *rev.Error) {
if err != nil {
if errList, ok := err.(scanner.ErrorList); ok {
var pos token.Position = errList[0].Pos
- compileError = &rev.Error{
+ compileError = &revel.Error{
SourceType: ".go source",
Title: "Go Compilation Error",
Path: pos.Filename,
Description: errList[0].Msg,
Line: pos.Line,
Column: pos.Column,
- SourceLines: rev.MustReadLines(pos.Filename),
+ SourceLines: revel.MustReadLines(pos.Filename),
}
return compileError
}
@@ -224,8 +224,8 @@ func processPackage(fset *token.FileSet, pkgImportPath, pkgPath string, pkg *ast
}
}
- // Filter the struct specs to just the ones that embed rev.Controller.
- controllerSpecs := findTypesThatEmbed(rev.REVEL_IMPORT_PATH+".Controller", structSpecs)
+ // Filter the struct specs to just the ones that embed revel.Controller.
+ controllerSpecs := findTypesThatEmbed(revel.REVEL_IMPORT_PATH+".Controller", structSpecs)
// Add the method specs to them.
for _, spec := range controllerSpecs {
@@ -235,7 +235,7 @@ func processPackage(fset *token.FileSet, pkgImportPath, pkgPath string, pkg *ast
return &SourceInfo{
ControllerSpecs: controllerSpecs,
ValidationKeys: validationKeys,
- TestSuites: findTypesThatEmbed(rev.REVEL_IMPORT_PATH+".TestSuite", structSpecs),
+ TestSuites: findTypesThatEmbed(revel.REVEL_IMPORT_PATH+".TestSuite", structSpecs),
InitImportPaths: initImportPaths,
}
}
@@ -287,7 +287,7 @@ func addImports(imports map[string]string, decl ast.Decl, srcDir string) {
if pkgAlias == "" {
pkg, err := build.Import(fullPath, srcDir, 0)
if err != nil {
- rev.TRACE.Println("Could not find import:", fullPath)
+ revel.TRACE.Println("Could not find import:", fullPath)
continue
}
pkgAlias = pkg.Name
@@ -410,7 +410,7 @@ func appendAction(fset *token.FileSet, mm methodMap, decl ast.Decl, pkgImportPat
if selExpr.Sel.Name != "Result" {
return
}
- if pkgIdent, ok := selExpr.X.(*ast.Ident); !ok || imports[pkgIdent.Name] != rev.REVEL_IMPORT_PATH {
+ if pkgIdent, ok := selExpr.X.(*ast.Ident); !ok || imports[pkgIdent.Name] != revel.REVEL_IMPORT_PATH {
return
}
@@ -505,7 +505,7 @@ func getValidationKeys(fset *token.FileSet, funcDecl *ast.FuncDecl, imports map[
var (
lineKeys = make(map[int]string)
- // Check the func parameters and the receiver's members for the *rev.Validation type.
+ // Check the func parameters and the receiver's members for the *revel.Validation type.
validationParam = getValidationParameter(funcDecl, imports)
)
@@ -560,15 +560,15 @@ func getValidationKeys(fset *token.FileSet, funcDecl *ast.FuncDecl, imports map[
return lineKeys
}
-// Check to see if there is a *rev.Validation as an argument.
+// Check to see if there is a *revel.Validation as an argument.
func getValidationParameter(funcDecl *ast.FuncDecl, imports map[string]string) *ast.Object {
for _, field := range funcDecl.Type.Params.List {
- starExpr, ok := field.Type.(*ast.StarExpr) // e.g. *rev.Validation
+ starExpr, ok := field.Type.(*ast.StarExpr) // e.g. *revel.Validation
if !ok {
continue
}
- selExpr, ok := starExpr.X.(*ast.SelectorExpr) // e.g. rev.Validation
+ selExpr, ok := starExpr.X.(*ast.SelectorExpr) // e.g. revel.Validation
if !ok {
continue
}
@@ -578,7 +578,7 @@ func getValidationParameter(funcDecl *ast.FuncDecl, imports map[string]string) *
continue
}
- if selExpr.Sel.Name == "Validation" && imports[xIdent.Name] == rev.REVEL_IMPORT_PATH {
+ if selExpr.Sel.Name == "Validation" && imports[xIdent.Name] == revel.REVEL_IMPORT_PATH {
return field.Names[0].Obj
}
}
@@ -606,7 +606,7 @@ func getStructTypeDecl(decl ast.Decl) (spec *ast.TypeSpec, found bool) {
}
if len(genDecl.Specs) != 1 {
- rev.TRACE.Printf("Surprising: Decl does not have 1 Spec: %v", genDecl)
+ revel.TRACE.Printf("Surprising: Decl does not have 1 Spec: %v", genDecl)
return
}
@@ -626,7 +626,7 @@ func findTypesThatEmbed(targetType string, specs []*TypeInfo) (filtered []*TypeI
controllerSimpleName := nodeQueue[0]
nodeQueue = nodeQueue[1:]
for _, spec := range specs {
- if rev.ContainsString(nodeQueue, spec.String()) {
+ if revel.ContainsString(nodeQueue, spec.String()) {
continue // Already added
}
@@ -656,7 +656,7 @@ type TypeExpr struct {
// TypeName returns the fully-qualified type name for this expression.
// The caller may optionally specify a package name to override the default.
func (e TypeExpr) TypeName(pkgOverride string) string {
- pkgName := rev.FirstNonEmpty(pkgOverride, e.PkgName)
+ pkgName := revel.FirstNonEmpty(pkgOverride, e.PkgName)
if pkgName == "" {
return e.Expr
}
@@ -728,10 +728,10 @@ func importPathFromPath(root string) string {
srcPath := path.Join(build.Default.GOROOT, "src", "pkg")
if strings.HasPrefix(root, srcPath) {
- rev.WARN.Println("Code path should be in GOPATH, but is in GOROOT:", root)
+ revel.WARN.Println("Code path should be in GOPATH, but is in GOROOT:", root)
return filepath.ToSlash(root[len(srcPath)+1:])
}
- rev.ERROR.Println("Unexpected! Code path is not in GOPATH:", root)
+ revel.ERROR.Println("Unexpected! Code path is not in GOPATH:", root)
return ""
}
View
16 harness/reflect_test.go
@@ -15,7 +15,7 @@ import (
const validationKeysSource = `
package test
-func (c *Application) testFunc(a, b int, user models.User) rev.Result {
+func (c *Application) testFunc(a, b int, user models.User) revel.Result {
// Line 5
c.Validation.Required(a)
c.Validation.Required(a).Message("Error message")
@@ -36,7 +36,7 @@ func (c *Application) testFunc(a, b int, user models.User) rev.Result {
c.Validation.Required(b == 5)
}
-func (m Model) Validate(v *rev.Validation) {
+func (m Model) Validate(v *revel.Validation) {
// Line 26
v.Required(m.name)
v.Required(m.name == "something").
@@ -75,7 +75,7 @@ func TestGetValidationKeys(t *testing.T) {
}
for i, decl := range file.Decls {
- lineKeys := getValidationKeys(fset, decl.(*ast.FuncDecl), map[string]string{"rev": rev.REVEL_IMPORT_PATH})
+ lineKeys := getValidationKeys(fset, decl.(*ast.FuncDecl), map[string]string{"rev": revel.REVEL_IMPORT_PATH})
for k, v := range expectedValidationKeys[i] {
if lineKeys[k] != v {
t.Errorf("Not found - %d: %v - Actual Map: %v", k, v, lineKeys)
@@ -137,8 +137,8 @@ func TestTypeExpr(t *testing.T) {
}
func TestProcessBookingSource(t *testing.T) {
- rev.Init("", "github.com/robfig/revel/samples/booking", "")
- sourceInfo, err := ProcessSource([]string{rev.AppPath})
+ revel.Init("", "github.com/robfig/revel/samples/booking", "")
+ sourceInfo, err := ProcessSource([]string{revel.AppPath})
if err != nil {
t.Fatal("Failed to process booking source with error:", err)
}
@@ -175,12 +175,12 @@ NEXT_TEST:
}
func BenchmarkProcessBookingSource(b *testing.B) {
- rev.Init("", "github.com/robfig/revel/samples/booking", "")
- rev.TRACE = log.New(ioutil.Discard, "", 0)
+ revel.Init("", "github.com/robfig/revel/samples/booking", "")
+ revel.TRACE = log.New(ioutil.Discard, "", 0)
b.ResetTimer()
for i := 0; i < b.N; i++ {
- _, err := ProcessSource(rev.CodePaths)
+ _, err := ProcessSource(revel.CodePaths)
if err != nil {
b.Error("Unexpected error:", err)
}
View
2  http.go
@@ -1,4 +1,4 @@
-package rev
+package revel
import (
"bytes"
View
2  i18n.go
@@ -1,4 +1,4 @@
-package rev
+package revel
import (
"fmt"
View
2  i18n_test.go
@@ -1,4 +1,4 @@
-package rev
+package revel
import (
"io/ioutil"
View
2  init.go
@@ -1,4 +1,4 @@
-package rev
+package revel
func init() {
RegisterPlugin(SessionPlugin{})
View
20 intercept.go
@@ -1,4 +1,4 @@
-package rev
+package revel
import (
"log"
@@ -26,13 +26,13 @@ import (
//
// Func Interceptors may apply to any / all Controllers.
//
-// func example(*rev.Controller) rev.Result
+// func example(*revel.Controller) revel.Result
//
// Method Interceptors are provided so that properties can be set on application
// controllers.
//
-// func (c AppController) example() rev.Result
-// func (c *AppController) example() rev.Result
+// func (c AppController) example() revel.Result
+// func (c *AppController) example() revel.Result
//
type InterceptorFunc func(*Controller) Result
type InterceptorMethod interface{}
@@ -131,7 +131,7 @@ var interceptors []*Interception
// Install a general interceptor.
// This can be applied to any Controller.
// It must have the signature of:
-// func example(c *rev.Controller) rev.Result
+// func example(c *revel.Controller) revel.Result
func InterceptFunc(intc InterceptorFunc, when InterceptTime, target interface{}) {
interceptors = append(interceptors, &Interception{
When: when,
@@ -143,13 +143,13 @@ func InterceptFunc(intc InterceptorFunc, when InterceptTime, target interface{})
}
// Install an interceptor method that applies to its own Controller.
-// func (c AppController) example() rev.Result
-// func (c *AppController) example() rev.Result
+// func (c AppController) example() revel.Result
+// func (c *AppController) example() revel.Result
func InterceptMethod(intc InterceptorMethod, when InterceptTime) {
methodType := reflect.TypeOf(intc)
if methodType.Kind() != reflect.Func || methodType.NumOut() != 1 || methodType.NumIn() != 1 {
log.Fatalln("Interceptor method should have signature like",
- "'func (c *AppController) example() rev.Result' but was", methodType)
+ "'func (c *AppController) example() revel.Result' but was", methodType)
}
interceptors = append(interceptors, &Interception{
When: when,
@@ -177,7 +177,7 @@ func getInterceptors(when InterceptTime, val reflect.Value) []*Interception {
// Also, convert between any difference in indirection.
// If the target couldn't be found, the returned Value will have IsValid() == false
func findTarget(val reflect.Value, target reflect.Type) reflect.Value {
- // Look through the embedded types (until we reach the *rev.Controller at the top).
+ // Look through the embedded types (until we reach the *revel.Controller at the top).
for {
// Check if val is of a similar type to the target type.
if val.Type() == target {
@@ -190,7 +190,7 @@ func findTarget(val reflect.Value, target reflect.Type) reflect.Value {
return val.Addr()
}
- // If we reached the *rev.Controller and still didn't find what we were
+ // If we reached the *revel.Controller and still didn't find what we were
// looking for, give up.
if val.Type() == controllerPtrType {
break
View
2  intercept_test.go
@@ -1,4 +1,4 @@
-package rev
+package revel
import (
"reflect"
View
2  libs.go
@@ -1,4 +1,4 @@
-package rev
+package revel
import (
"crypto/hmac"
View
18 modules/db/app/db.go
@@ -16,29 +16,29 @@ var (
)
type DbPlugin struct {
- rev.EmptyPlugin
+ revel.EmptyPlugin
}
func (p DbPlugin) OnAppStart() {
// Read configuration.
var found bool
- if Driver, found = rev.Config.String("db.driver"); !found {
- rev.ERROR.Fatal("No db.driver found.")
+ if Driver, found = revel.Config.String("db.driver"); !found {
+ revel.ERROR.Fatal("No db.driver found.")
}
- if Spec, found = rev.Config.String("db.spec"); !found {
- rev.ERROR.Fatal("No db.spec found.")
+ if Spec, found = revel.Config.String("db.spec"); !found {
+ revel.ERROR.Fatal("No db.spec found.")
}
// Open a connection.
var err error
Db, err = sql.Open(Driver, Spec)
if err != nil {
- rev.ERROR.Fatal(err)
+ revel.ERROR.Fatal(err)
}
}
// Begin a transaction.
-func (p DbPlugin) BeforeRequest(c *rev.Controller) {
+func (p DbPlugin) BeforeRequest(c *revel.Controller) {
txn, err := Db.Begin()
if err != nil {
panic(err)
@@ -47,7 +47,7 @@ func (p DbPlugin) BeforeRequest(c *rev.Controller) {
}
// Commit the active transaction.
-func (p DbPlugin) AfterRequest(c *rev.Controller) {
+func (p DbPlugin) AfterRequest(c *revel.Controller) {
if err := c.Txn.Commit(); err != nil {
if err != sql.ErrTxDone {
panic(err)
@@ -57,7 +57,7 @@ func (p DbPlugin) AfterRequest(c *rev.Controller) {
}
// Rollback the active transaction, if any.
-func (p DbPlugin) OnException(c *rev.Controller, err interface{}) {
+func (p DbPlugin) OnException(c *revel.Controller, err interface{}) {
if c.Txn == nil {
return
}
View
22 modules/testrunner/app/controllers/testrunner.go
@@ -12,7 +12,7 @@ import (
)
type TestRunner struct {
- *rev.Controller
+ *revel.Controller
}
type TestSuiteDesc struct {
@@ -38,18 +38,18 @@ type TestResult struct {
var NONE = []reflect.Value{}
-func (c TestRunner) Index() rev.Result {
+func (c TestRunner) Index() revel.Result {
var testSuites []TestSuiteDesc
- for _, testSuite := range rev.TestSuites {
+ for _, testSuite := range revel.TestSuites {
testSuites = append(testSuites, DescribeSuite(testSuite))
}
return c.Render(testSuites)
}
// Run runs a single test, given by the argument.
-func (c TestRunner) Run(suite, test string) rev.Result {
+func (c TestRunner) Run(suite, test string) revel.Result {
result := TestResult{Name: test}
- for _, testSuite := range rev.TestSuites {
+ for _, testSuite := range revel.TestSuites {
t := reflect.TypeOf(testSuite).Elem()
if t.Name() != suite {
continue
@@ -60,12 +60,12 @@ func (c TestRunner) Run(suite, test string) rev.Result {
func() {
defer func() {
if err := recover(); err != nil {
- error := rev.NewErrorFromPanic(err)
+ error := revel.NewErrorFromPanic(err)
if error == nil {
result.ErrorHtml = template.HTML(html.EscapeString(fmt.Sprint(err)))
} else {
var buffer bytes.Buffer
- tmpl, _ := rev.MainTemplateLoader.Template("TestRunner/FailureDetail.html")
+ tmpl, _ := revel.MainTemplateLoader.Template("TestRunner/FailureDetail.html")
tmpl.Render(&buffer, error)
result.ErrorHtml = template.HTML(buffer.String())
}
@@ -74,7 +74,7 @@ func (c TestRunner) Run(suite, test string) rev.Result {
// Initialize the test suite with a NewTestSuite()
testSuiteInstance := v.Elem().FieldByName("TestSuite")
- testSuiteInstance.Set(reflect.ValueOf(rev.NewTestSuite()))
+ testSuiteInstance.Set(reflect.ValueOf(revel.NewTestSuite()))
// Call Before(), call the test, and call After().
if m := v.MethodByName("Before"); m.IsValid() {
@@ -95,9 +95,9 @@ func (c TestRunner) Run(suite, test string) rev.Result {
// List returns a JSON list of test suites and tests.
// Used by the "test" command line tool.
-func (c TestRunner) List() rev.Result {
+func (c TestRunner) List() revel.Result {
var testSuites []TestSuiteDesc
- for _, testSuite := range rev.TestSuites {
+ for _, testSuite := range revel.TestSuites {
testSuites = append(testSuites, DescribeSuite(testSuite))
}
return c.RenderJson(testSuites)
@@ -136,5 +136,5 @@ func DescribeSuite(testSuite interface{}) TestSuiteDesc {
}
func init() {
- rev.RegisterPlugin(app.TestRunnerPlugin{})
+ revel.RegisterPlugin(app.TestRunnerPlugin{})
}
View
14 modules/testrunner/app/plugin.go
@@ -6,15 +6,15 @@ import (
)
type TestRunnerPlugin struct {
- rev.EmptyPlugin
+ revel.EmptyPlugin
}
-func (t TestRunnerPlugin) OnRoutesLoaded(router *rev.Router) {
- router.Routes = append([]*rev.Route{
- rev.NewRoute("GET", "/@tests", "TestRunner.Index"),
- rev.NewRoute("GET", "/@tests.list", "TestRunner.List"),
- rev.NewRoute("GET", "/@tests/public/", "staticDir:testrunner:public"),
- rev.NewRoute("GET", "/@tests/{suite}/{test}", "TestRunner.Run"),
+func (t TestRunnerPlugin) OnRoutesLoaded(router *revel.Router) {
+ router.Routes = append([]*revel.Route{
+ revel.NewRoute("GET", "/@tests", "TestRunner.Index"),
+ revel.NewRoute("GET", "/@tests.list", "TestRunner.List"),
+ revel.NewRoute("GET", "/@tests/public/", "staticDir:testrunner:public"),
+ revel.NewRoute("GET", "/@tests/{suite}/{test}", "TestRunner.Run"),
}, router.Routes...)
fmt.Println("Go to /@tests to run the tests.")
}
View
2  modules/testrunner/public/css/bootstrap.css
@@ -5656,7 +5656,7 @@ a.badge:hover {
}
.carousel .next.left,
-.carousel .prev.right {
+.carousel .prevel.right {
left: 0;
}
View
6 mvc.go
@@ -1,4 +1,4 @@
-package rev
+package revel
import (
"reflect"
@@ -36,12 +36,12 @@ func NewAppController(req *Request, resp *Response, controllerName, methodName s
// This is a helper that initializes (zeros) a new app controller value.
// Generally, everything is set to its zero value, except:
// 1. Embedded controller pointers are newed up.
-// 2. The rev.Controller embedded type is set to the value provided.
+// 2. The revel.Controller embedded type is set to the value provided.
// Returns a value representing a pointer to the new app controller.
func initNewAppController(appControllerType reflect.Type, c *Controller) reflect.Value {
// It might be a multi-level embedding, so we have to create new controllers
// at every level of the hierarchy.
- // ASSUME: the first field in each type is the way up to rev.Controller.
+ // ASSUME: the first field in each type is the way up to revel.Controller.
appControllerPtr := reflect.New(appControllerType)
ptr := appControllerPtr
for {
View
2  mvc_test.go
@@ -1,4 +1,4 @@
-package rev
+package revel
import (
"bytes"
View
2  params.go
@@ -1,4 +1,4 @@
-package rev
+package revel
import (
"mime/multipart"
View
2  plugin.go
@@ -1,4 +1,4 @@
-package rev
+package revel
// An plugin that allows the user to inject behavior at various points in the request cycle.
type Plugin interface {
View
2  results.go
@@ -1,4 +1,4 @@
-package rev
+package revel
import (
"bytes"
View
3  revel.go
@@ -1,4 +1,4 @@
-package rev
+package revel
import (
"github.com/robfig/goconfig/config"
@@ -197,7 +197,6 @@ func newLogger(wr io.Writer) *log.Logger {
// findSrcPaths uses the "go/build" package to find the source root for Revel
// and the app.
func findSrcPaths(importPath string) (revelSourcePath, appSourcePath string) {
- log.Println("findSrcpaths:", importPath)
if gopath := os.Getenv("GOPATH"); gopath == "" {
ERROR.Fatalln("GOPATH environment variable is not set. ",
"Please refer to http://golang.org/doc/code.html to configure your Go environment.")
View
2  router.go
@@ -1,4 +1,4 @@
-package rev
+package revel
import (
"fmt"
View
2  router_test.go
@@ -1,4 +1,4 @@
-package rev
+package revel
import (
"fmt"
View
12 samples/booking/app/controllers/app.go
@@ -10,7 +10,7 @@ type Application struct {
GorpController
}
-func (c Application) AddUser() rev.Result {
+func (c Application) AddUser() revel.Result {
if user := c.connected(); user != nil {
c.RenderArgs["user"] = user
}
@@ -38,7 +38,7 @@ func (c Application) getUser(username string) *models.User {
return users[0].(*models.User)
}
-func (c Application) Index() rev.Result {
+func (c Application) Index() revel.Result {
if c.connected() != nil {
return c.Redirect(Hotels.Index)
}
@@ -46,11 +46,11 @@ func (c Application) Index() rev.Result {
return c.Render()
}
-func (c Application) Register() rev.Result {
+func (c Application) Register() revel.Result {
return c.Render()
}
-func (c Application) SaveUser(user models.User, verifyPassword string) rev.Result {
+func (c Application) SaveUser(user models.User, verifyPassword string) revel.Result {
c.Validation.Required(verifyPassword)
c.Validation.Required(verifyPassword == user.Password).
Message("Password does not match")
@@ -74,7 +74,7 @@ func (c Application) SaveUser(user models.User, verifyPassword string) rev.Resul
return c.Redirect(Hotels.Index)
}
-func (c Application) Login(username, password string) rev.Result {
+func (c Application) Login(username, password string) revel.Result {
user := c.getUser(username)
if user != nil {
err := bcrypt.CompareHashAndPassword(user.HashedPassword, []byte(password))
@@ -90,7 +90,7 @@ func (c Application) Login(username, password string) rev.Result {
return c.Redirect(Application.Index)
}
-func (c Application) Logout() rev.Result {
+func (c Application) Logout() revel.Result {
for k := range c.Session {
delete(c.Session, k)
}
View
18 samples/booking/app/controllers/hotels.go
@@ -12,7 +12,7 @@ type Hotels struct {
Application
}
-func (c Hotels) checkUser() rev.Result {
+func (c Hotels) checkUser() revel.Result {
if user := c.connected(); user == nil {
c.Flash.Error("Please log in first")
return c.Redirect(Application.Index)
@@ -20,7 +20,7 @@ func (c Hotels) checkUser() rev.Result {
return nil
}
-func (c Hotels) Index() rev.Result {
+func (c Hotels) Index() revel.Result {
results, err := c.Txn.Select(models.Booking{},
`select * from Booking where UserId = ?`, c.connected().UserId)
if err != nil {
@@ -36,7 +36,7 @@ func (c Hotels) Index() rev.Result {
return c.Render(bookings)
}
-func (c Hotels) List(search string, size, page int) rev.Result {
+func (c Hotels) List(search string, size, page int) revel.Result {
if page == 0 {
page = 1
}
@@ -76,7 +76,7 @@ func (c Hotels) loadHotelById(id int) *models.Hotel {
return h.(*models.Hotel)
}
-func (c Hotels) Show(id int) rev.Result {
+func (c Hotels) Show(id int) revel.Result {
var title string
hotel := c.loadHotelById(id)
if hotel == nil {
@@ -88,11 +88,11 @@ func (c Hotels) Show(id int) rev.Result {
return c.Render(title, hotel)
}
-func (c Hotels) Settings() rev.Result {
+func (c Hotels) Settings() revel.Result {
return c.Render()
}
-func (c Hotels) SaveSettings(password, verifyPassword string) rev.Result {
+func (c Hotels) SaveSettings(password, verifyPassword string) revel.Result {
models.ValidatePassword(c.Validation, password)
c.Validation.Required(verifyPassword).
Message("Please verify your password")
@@ -113,7 +113,7 @@ func (c Hotels) SaveSettings(password, verifyPassword string) rev.Result {
return c.Redirect(Hotels.Index)
}
-func (c Hotels) ConfirmBooking(id int, booking models.Booking) rev.Result {
+func (c Hotels) ConfirmBooking(id int, booking models.Booking) revel.Result {
hotel := c.loadHotelById(id)
title := fmt.Sprintf("Confirm %s booking", hotel.Name)
booking.Hotel = hotel
@@ -139,7 +139,7 @@ func (c Hotels) ConfirmBooking(id int, booking models.Booking) rev.Result {
return c.Render(title, hotel, booking)
}
-func (c Hotels) CancelBooking(id int) rev.Result {
+func (c Hotels) CancelBooking(id int) revel.Result {
_, err := c.Txn.Delete(&models.Booking{BookingId: id})
if err != nil {
panic(err)
@@ -148,7 +148,7 @@ func (c Hotels) CancelBooking(id int) rev.Result {
return c.Redirect(Hotels.Index)
}
-func (c Hotels) Book(id int) rev.Result {
+func (c Hotels) Book(id int) revel.Result {
hotel := c.loadHotelById(id)
title := "Book " + hotel.Name
// if hotel == nil {
View
12 samples/booking/app/controllers/init.go
@@ -3,10 +3,10 @@ package controllers
import "github.com/robfig/revel"
func init() {
- rev.RegisterPlugin(GorpPlugin{})
- rev.InterceptMethod((*GorpController).Begin, rev.BEFORE)
- rev.InterceptMethod(Application.AddUser, rev.BEFORE)
- rev.InterceptMethod(Hotels.checkUser, rev.BEFORE)
- rev.InterceptMethod((*GorpController).Commit, rev.AFTER)
- rev.InterceptMethod((*GorpController).Rollback, rev.FINALLY)
+ revel.RegisterPlugin(GorpPlugin{})
+ revel.InterceptMethod((*GorpController).Begin, revel.BEFORE)
+ revel.InterceptMethod(Application.AddUser, revel.BEFORE)
+ revel.InterceptMethod(Hotels.checkUser, revel.BEFORE)
+ revel.InterceptMethod((*GorpController).Commit, revel.AFTER)
+ revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY)
}
View
8 samples/booking/app/models/booking.go
@@ -30,7 +30,7 @@ type Booking struct {
// TODO: Make an interface for Validate() and then validation can pass in the
// key prefix ("booking.")
-func (booking Booking) Validate(v *rev.Validation) {
+func (booking Booking) Validate(v *revel.Validation) {
v.Required(booking.User)
v.Required(booking.Hotel)
v.Required(booking.CheckInDate)
@@ -40,9 +40,9 @@ func (booking Booking) Validate(v *rev.Validation) {
Message("Credit card number must be numeric and 16 digits")
v.Check(booking.NameOnCard,
- rev.Required{},
- rev.MinSize{3},
- rev.MaxSize{70},
+ revel.Required{},
+ revel.MinSize{3},
+ revel.MaxSize{70},
)
}
View
28 samples/booking/app/models/hotel.go
@@ -12,34 +12,34 @@ type Hotel struct {
Price int
}
-func (hotel *Hotel) Validate(v *rev.Validation) {
+func (hotel *Hotel) Validate(v *revel.Validation) {
v.Check(hotel.Name,
- rev.Required{},
- rev.MaxSize{50},
+ revel.Required{},
+ revel.MaxSize{50},
)
v.MaxSize(hotel.Address, 100)
v.Check(hotel.City,
- rev.Required{},
- rev.MaxSize{40},
+ revel.Required{},
+ revel.MaxSize{40},
)
v.Check(hotel.State,
- rev.Required{},
- rev.MaxSize{6},
- rev.MinSize{2},
+ revel.Required{},
+ revel.MaxSize{6},
+ revel.MinSize{2},
)
v.Check(hotel.Zip,
- rev.Required{},
- rev.MaxSize{6},
- rev.MinSize{5},
+ revel.Required{},
+ revel.MaxSize{6},
+ revel.MinSize{5},
)
v.Check(hotel.Country,
- rev.Required{},
- rev.MaxSize{40},
- rev.MinSize{2},
+ revel.Required{},
+ revel.MaxSize{40},
+ revel.MinSize{2},
)
}
View
22 samples/booking/app/models/user.go
@@ -19,27 +19,27 @@ func (u *User) String() string {
var userRegex = regexp.MustCompile("^\\w*$")
-func (user *User) Validate(v *rev.Validation) {
+func (user *User) Validate(v *revel.Validation) {
v.Check(user.Username,
- rev.Required{},
- rev.MaxSize{15},
- rev.MinSize{4},
- rev.Match{userRegex},
+ revel.Required{},
+ revel.MaxSize{15},
+ revel.MinSize{4},
+ revel.Match{userRegex},
)
ValidatePassword(v, user.Password).
Key("user.Password")
v.Check(user.Name,
- rev.Required{},
- rev.MaxSize{100},
+ revel.Required{},
+ revel.MaxSize{100},
)
}
-func ValidatePassword(v *rev.Validation, password string) *rev.ValidationResult {
+func ValidatePassword(v *revel.Validation, password string) *revel.ValidationResult {
return v.Check(password,
- rev.Required{},
- rev.MaxSize{15},
- rev.MinSize{5},
+ revel.Required{},
+ revel.MaxSize{15},
+ revel.MinSize{5},
)
}
View
2  samples/booking/tests/apptest.go
@@ -3,7 +3,7 @@ package tests
import "github.com/robfig/revel"
type ApplicationTest struct {
- rev.TestSuite
+ revel.TestSuite
}
func (t ApplicationTest) Before() {
View
6 samples/chat/app/controllers/app.go
@@ -5,14 +5,14 @@ import (
)
type Application struct {
- *rev.Controller
+ *revel.Controller
}
-func (c Application) Index() rev.Result {
+func (c Application) Index() revel.Result {
return c.Render()
}
-func (c Application) EnterDemo(user, demo string) rev.Result {
+func (c Application) EnterDemo(user, demo string) revel.Result {
c.Validation.Required(user)
c.Validation.Required(demo)
View
10 samples/chat/app/controllers/longpolling.go
@@ -6,20 +6,20 @@ import (
)
type LongPolling struct {
- *rev.Controller
+ *revel.Controller
}
-func (c LongPolling) Room(user string) rev.Result {
+func (c LongPolling) Room(user string) revel.Result {
chatroom.Join(user)
return c.Render(user)
}
-func (c LongPolling) Say(user, message string) rev.Result {
+func (c LongPolling) Say(user, message string) revel.Result {
chatroom.Say(user, message)
return nil
}
-func (c LongPolling) WaitMessages(lastReceived int) rev.Result {
+func (c LongPolling) WaitMessages(lastReceived int) revel.Result {
subscription := chatroom.Subscribe()
defer subscription.Cancel()
@@ -41,7 +41,7 @@ func (c LongPolling) WaitMessages(lastReceived int) rev.Result {
return c.RenderJson([]chatroom.Event{event})
}
-func (c LongPolling) Leave(user string) rev.Result {
+func (c LongPolling) Leave(user string) revel.Result {
chatroom.Leave(user)
return c.Redirect(Application.Index)
}
View
10 samples/chat/app/controllers/refresh.go
@@ -6,15 +6,15 @@ import (
)
type Refresh struct {
- *rev.Controller
+ *revel.Controller
}
-func (c Refresh) Index(user string) rev.Result {
+func (c Refresh) Index(user string) revel.Result {
chatroom.Join(user)
return c.Room(user)
}
-func (c Refresh) Room(user string) rev.Result {
+func (c Refresh) Room(user string) revel.Result {
subscription := chatroom.Subscribe()
defer subscription.Cancel()
events := subscription.Archive
@@ -26,12 +26,12 @@ func (c Refresh) Room(user string) rev.Result {
return c.Render(user, events)
}
-func (c Refresh) Say(user, message string) rev.Result {
+func (c Refresh) Say(user, message string) revel.Result {
chatroom.Say(user, message)
return c.Room(user)
}
-func (c Refresh) Leave(user string) rev.Result {
+func (c Refresh) Leave(user string) revel.Result {
chatroom.Leave(user)
return c.Redirect(Application.Index)
}
View
6 samples/chat/app/controllers/websocket.go
@@ -7,14 +7,14 @@ import (
)
type WebSocket struct {
- *rev.Controller
+ *revel.Controller
}
-func (c WebSocket) Room(user string) rev.Result {
+func (c WebSocket) Room(user string) revel.Result {
return c.Render(user)
}
-func (c WebSocket) RoomSocket(user string, ws *websocket.Conn) rev.Result {
+func (c WebSocket) RoomSocket(user string, ws *websocket.Conn) revel.Result {
// Join the room.
subscription := chatroom.Subscribe()
defer subscription.Cancel()
View
16 samples/facebook-oauth2/app/controllers/app.go
@@ -12,7 +12,7 @@ import (
)
type Application struct {
- *rev.Controller
+ *revel.Controller
}
// The following keys correspond to a test application
@@ -28,7 +28,7 @@ var FACEBOOK = &oauth.Config{
RedirectURL: "http://loisant.org:9000/Application/Auth",
}
-func (c Application) Index() rev.Result {
+func (c Application) Index() revel.Result {
u := c.connected()
me := map[string]interface{}{}
if u != nil && u.AccessToken != "" {
@@ -36,20 +36,20 @@ func (c Application) Index() rev.Result {
url.QueryEscape(u.AccessToken))
defer resp.Body.Close()
if err := json.NewDecoder(resp.Body).Decode(&me); err != nil {
- rev.ERROR.Println(err)
+ revel.ERROR.Println(err)
}
- rev.INFO.Println(me)
+ revel.INFO.Println(me)
}
authUrl := FACEBOOK.AuthCodeURL("foo")
return c.Render(me, authUrl)
}
-func (c Application) Auth(code string) rev.Result {
+func (c Application) Auth(code string) revel.Result {
t := &oauth.Transport{Config: FACEBOOK}
tok, err := t.Exchange(code)
if err != nil {
- rev.ERROR.Println(err)
+ revel.ERROR.Println(err)
return c.Redirect(Application.Index)
}
@@ -58,7 +58,7 @@ func (c Application) Auth(code string) rev.Result {
return c.Redirect(Application.Index)
}
-func setuser(c *rev.Controller) rev.Result {
+func setuser(c *revel.Controller) revel.Result {
var user *models.User
if _, ok := c.Session["uid"]; ok {
uid, _ := strconv.ParseInt(c.Session["uid"], 10, 0)
@@ -73,7 +73,7 @@ func setuser(c *rev.Controller) rev.Result {
}
func init() {
- rev.InterceptFunc(setuser, rev.BEFORE, &Application{})
+ revel.InterceptFunc(setuser, revel.BEFORE, &Application{})
}
func (c Application) connected() *models.User {
View
4 samples/i18n/app/controllers/app.go
@@ -3,10 +3,10 @@ package controllers
import "github.com/robfig/revel"
type Application struct {
- *rev.Controller
+ *revel.Controller
}
-func (c Application) Index() rev.Result {
+func (c Application) Index() revel.Result {
// Localization information
c.RenderArgs["acceptLanguageHeader"] = c.Request.Header.Get("Accept-Language")
c.RenderArgs["acceptLanguageHeaderParsed"] = c.Request.AcceptLanguages.String()
View
2  samples/i18n/public/css/bootstrap.css
@@ -5656,7 +5656,7 @@ a.badge:hover {
}
.carousel .next.left,
-.carousel .prev.right {
+.carousel .prevel.right {
left: 0;
}
View
2  samples/i18n/tests/apptest.go
@@ -3,7 +3,7 @@ package tests
import "github.com/robfig/revel"
type ApplicationTest struct {
- rev.TestSuite
+ revel.TestSuite
}
func (t ApplicationTest) Before() {
View
22 samples/twitter-oauth/app/controllers/app.go
@@ -19,10 +19,10 @@ var TWITTER = oauth.NewConsumer(
)
type Application struct {
- *rev.Controller
+ *revel.Controller
}
-func (c Application) Index() rev.Result {
+func (c Application) Index() revel.Result {
user := getUser()
if user.AccessToken == nil {
return c.Render()
@@ -34,7 +34,7 @@ func (c Application) Index() rev.Result {
map[string]string{"count": "10"},
user.AccessToken)
if err != nil {
- rev.ERROR.Println(err)
+ revel.ERROR.Println(err)
return c.Render()
}
defer resp.Body.Close()
@@ -45,32 +45,32 @@ func (c Application) Index() rev.Result {
}{}
err = json.NewDecoder(resp.Body).Decode(&mentions)
if err != nil {
- rev.ERROR.Println(err)
+ revel.ERROR.Println(err)
}
- rev.INFO.Println(mentions)
+ revel.INFO.Println(mentions)
return c.Render(mentions)
}
-func (c Application) SetStatus(status string) rev.Result {
+func (c Application) SetStatus(status string) revel.Result {
resp, err := TWITTER.PostForm(
"http://api.twitter.com/1/statuses/update.json",
map[string]string{"status": status},
getUser().AccessToken,
)
if err != nil {
- rev.ERROR.Println(err)
+ revel.ERROR.Println(err)
return c.RenderError(err)
}
defer resp.Body.Close()
bodyBytes, _ := ioutil.ReadAll(resp.Body)
- rev.INFO.Println(string(bodyBytes))
+ revel.INFO.Println(string(bodyBytes))
c.Response.ContentType = "application/json"
return c.RenderText(string(bodyBytes))
}
// Twitter authentication
-func (c Application) Authenticate(oauth_verifier string) rev.Result {
+func (c Application) Authenticate(oauth_verifier string) revel.Result {
user := getUser()
if oauth_verifier != "" {
// We got the verifier; now get the access token, store it and back to index
@@ -78,7 +78,7 @@ func (c Application) Authenticate(oauth_verifier string) rev.Result {
if err == nil {
user.AccessToken = accessToken
} else {