Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8f5aad1

Browse filesBrowse files
author
Timo Gatsonides
committed
Add AppRoot to allow changing the root path of an application
1 parent df5d88d commit 8f5aad1
Copy full SHA for 8f5aad1

File tree

Expand file treeCollapse file tree

4 files changed

+15
-6
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+15
-6
lines changed

‎modules/testrunner/app/views/TestRunner/Index.html

Copy file name to clipboardExpand all lines: modules/testrunner/app/views/TestRunner/Index.html
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<head>
44
<title>Revel Test Runner</title>
55
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6-
<link href="/@tests/public/css/bootstrap.css" type="text/css" rel="stylesheet"></link>
7-
<script src="/@tests/public/js/jquery-1.9.1.min.js" type="text/javascript"></script>
6+
<link href="{{url `Root`}}/@tests/public/css/bootstrap.css" type="text/css" rel="stylesheet"></link>
7+
<script src="{{url `Root`}}/@tests/public/js/jquery-1.9.1.min.js" type="text/javascript"></script>
88
<style>
99
header { padding:20px 0; background-color:#ADD8E6 }
1010
.passed td { background-color: #90EE90 !important; }
@@ -62,7 +62,7 @@ <h1>Test Runner</h1>
6262
var resultCell = row.children(".result");
6363
$.ajax({
6464
dataType: "json",
65-
url: "/@tests/"+suite+"/"+test,
65+
url: "{{url `Root`}}/@tests/"+suite+"/"+test,
6666
async: false,
6767
success: function(result) {
6868
row.attr("class", result.Passed ? "passed" : "failed");

‎revel.go

Copy file name to clipboardExpand all lines: revel.go
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func (r *revelLogs) Write(p []byte) (n int, err error) {
3030
var (
3131
// App details
3232
AppName string // e.g. "sample"
33+
AppRoot string // e.g. "/app1"
3334
BasePath string // e.g. "/Users/robfig/gocode/src/corp/sample"
3435
AppPath string // e.g. "/Users/robfig/gocode/src/corp/sample/app"
3536
ViewsPath string // e.g. "/Users/robfig/gocode/src/corp/sample/app/views"
@@ -178,6 +179,7 @@ func Init(mode, importPath, srcPath string) {
178179
}
179180

180181
AppName = Config.StringDefault("app.name", "(not set)")
182+
AppRoot = Config.StringDefault("app.root", "")
181183
CookiePrefix = Config.StringDefault("cookie.prefix", "REVEL")
182184
CookieHttpOnly = Config.BoolDefault("cookie.httponly", false)
183185
CookieSecure = Config.BoolDefault("cookie.secure", false)

‎router.go

Copy file name to clipboardExpand all lines: router.go
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,11 @@ func parseRoutes(routesPath, joinedPath, content string, validate bool) ([]*Rout
205205
if strings.HasSuffix(joinedPath, "/") && strings.HasPrefix(path, "/") {
206206
joinedPath = joinedPath[0 : len(joinedPath)-1]
207207
}
208-
path = strings.Join([]string{joinedPath, path}, "")
208+
if AppRoot == "" {
209+
path = strings.Join([]string{joinedPath, path}, "")
210+
} else {
211+
path = strings.Join([]string{AppRoot, joinedPath, path}, "")
212+
}
209213

210214
// This will import the module routes under the path described in the
211215
// routes file (joinedPath param). e.g. "* /jobs module:jobs" -> all

‎template.go

Copy file name to clipboardExpand all lines: template.go
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,16 @@ func (gotmpl GoTemplate) Content() []string {
391391

392392
// Return a url capable of invoking a given controller method:
393393
// "Application.ShowApp 123" => "/app/123"
394-
func ReverseUrl(args ...interface{}) (string, error) {
394+
func ReverseUrl(args ...interface{}) (template.URL, error) {
395395
if len(args) == 0 {
396396
return "", fmt.Errorf("no arguments provided to reverse route")
397397
}
398398

399399
action := args[0].(string)
400400
actionSplit := strings.Split(action, ".")
401+
if len(actionSplit) == 1 && actionSplit[0] == "Root" {
402+
return template.URL(AppRoot), nil
403+
}
401404
if len(actionSplit) != 2 {
402405
return "", fmt.Errorf("reversing '%s', expected 'Controller.Action'", action)
403406
}
@@ -414,7 +417,7 @@ func ReverseUrl(args ...interface{}) (string, error) {
414417
Unbind(argsByName, c.MethodType.Args[i].Name, argValue)
415418
}
416419

417-
return MainRouter.Reverse(args[0].(string), argsByName).Url, nil
420+
return template.URL(MainRouter.Reverse(args[0].(string), argsByName).Url), nil
418421
}
419422

420423
func Slug(text string) string {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.