Skip to content
Browse files

Add .DevMode - a boolean to indicate if RunMode is a development mode.

Change the detailed error pages to use that instead of a test against
the RunMode

Fixes #82
  • Loading branch information...
1 parent 378fef3 commit 1381d141fcc99238d77b84445d1b7c736996b04f @robfig committed Mar 24, 2013
View
1 controller.go
@@ -43,6 +43,7 @@ func NewController(req *Request, resp *Response, ct *ControllerType) *Controller
Args: map[string]interface{}{},
RenderArgs: map[string]interface{}{
"RunMode": RunMode,
+ "DevMode": DevMode,
},
}
c.RenderArgs["Controller"] = c
View
1 mvc.go
@@ -86,6 +86,7 @@ func stubController(req *Request, resp *Response) *Controller {
Response: resp,
RenderArgs: map[string]interface{}{
"RunMode": RunMode,
+ "DevMode": DevMode,
},
}
}
View
9 revel.go
@@ -26,6 +26,7 @@ var (
Config *MergedConfig
RunMode string // Application-defined (by default, "dev" or "prod")
+ DevMode bool // if true, RunMode is a development mode.
// Revel installation details
RevelPath string // e.g. "/Users/robfig/gocode/src/revel"
@@ -124,6 +125,7 @@ func Init(mode, importPath, srcPath string) {
Config.SetSection(mode)
// Configure properties from app.conf
+ DevMode = Config.BoolDefault("mode.dev", false)
HttpPort = Config.IntDefault("http.port", 9000)
HttpAddr = Config.StringDefault("http.addr", "")
AppName = Config.StringDefault("app.name", "(not set)")
@@ -244,10 +246,11 @@ func addModule(name, importPath, modulePath string) {
Modules = append(Modules, Module{Name: name, ImportPath: importPath, Path: modulePath})
if codePath := path.Join(modulePath, "app"); DirExists(codePath) {
CodePaths = append(CodePaths, codePath)
+ if viewsPath := path.Join(modulePath, "app", "views"); DirExists(viewsPath) {
+ TemplatePaths = append(TemplatePaths, viewsPath)
+ }
}
- if viewsPath := path.Join(modulePath, "app", "views"); DirExists(viewsPath) {
- TemplatePaths = append(TemplatePaths, viewsPath)
- }
+
INFO.Print("Loaded module ", path.Base(modulePath))
// Hack: There is presently no way for the testrunner module to add the
View
1 samples/booking/conf/app.conf
@@ -27,6 +27,7 @@ module.jobs=github.com/robfig/revel/modules/jobs
module.static=github.com/robfig/revel/modules/static
[dev]
+mode.dev=true
watch=true
module.testrunner=github.com/robfig/revel/modules/testrunner
View
2 samples/chat/conf/app.conf
@@ -6,6 +6,7 @@ http.port=9000
module.static=github.com/robfig/revel/modules/static
[dev]
+mode.dev=true
results.pretty=true
watch=true
@@ -15,6 +16,7 @@ log.warn.output = stderr
log.error.output = stderr
[prod]
+mode.dev=false
results.pretty=false
watch=false
View
1 samples/facebook-oauth2/conf/app.conf
@@ -1,5 +1,6 @@
app.name=Facebook OAuth2
app.secret=ly2bgKNgQ7BSoWW8BZ33Tos9Z9hy2Ck6bFXotLxwSaXk60iXPqlZUKnJpGVoIHhs
module.static=github.com/robfig/revel/modules/static
+mode.dev=true
[dev]
[prod]
View
2 samples/i18n/conf/app.conf
@@ -11,6 +11,7 @@ i18n.cookie=%(cookie.prefix)s_LANG
i18n.default_language=en
[dev]
+mode.dev=true
results.pretty=true
results.staging=true
watch=true
@@ -24,6 +25,7 @@ log.warn.output = stderr
log.error.output = stderr
[prod]
+mode.dev=false
results.pretty=false
results.staging=false
watch=false
View
1 samples/twitter-oauth/conf/app.conf
@@ -1,4 +1,5 @@
app.secret=e227tafmfs0xrexah43hm34kkrcetav48nwk9x037wp87jkrp06m7n8wc8m7gbag
module.static=github.com/robfig/revel/modules/static
+mode.dev=true
[dev]
[prod]
View
1 samples/validation/conf/app.conf
@@ -1,5 +1,6 @@
app.name=Sample validation
app.secret=774a66ffb3d8113a2f730bbb33192251dc521ab0bee1bb0d88290299fe05c618
module.static=github.com/robfig/revel/modules/static
+mode.dev=true
[dev]
[prod]
View
2 skeleton/conf/app.conf.template
@@ -12,6 +12,7 @@ i18n.default_language=en
module.static=github.com/robfig/revel/modules/static
[dev]
+mode.dev=true
results.pretty=true
results.staging=true
watch=true
@@ -24,6 +25,7 @@ log.warn.output = stderr
log.error.output = stderr
[prod]
+mode.dev=false
results.pretty=false
results.staging=false
watch=false
View
2 templates/errors/404.html
@@ -5,7 +5,7 @@
</head>
<body>
-{{if eq .RunMode "dev"}}
+{{if .DevMode}}
{{template "errors/404-dev.html" .}}
View
6 templates/errors/500.html
@@ -4,7 +4,7 @@
<title>Application error</title>
</head>
<body>
- {{if eq .RunMode "dev"}}
+ {{if .DevMode}}
{{template "errors/500-dev.html" .}}
{{else}}
<h1>Oops, an error occured</h1>
@@ -14,7 +14,3 @@
{{end}}
</body>
</html>
-
-
-
-

0 comments on commit 1381d14

Please sign in to comment.
Something went wrong with that request. Please try again.