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 bd582ad

Browse filesBrowse files
committed
Merge pull request revel#573 from tpjg/approot
Add AppRoot to allow changing the root path of an application
2 parents f157814 + ab6d16a commit bd582ad
Copy full SHA for bd582ad

File tree

Expand file treeCollapse file tree

4 files changed

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

4 files changed

+11
-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
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func parseRoutes(routesPath, joinedPath, content string, validate bool) ([]*Rout
212212
if strings.HasSuffix(joinedPath, "/") && strings.HasPrefix(path, "/") {
213213
joinedPath = joinedPath[0 : len(joinedPath)-1]
214214
}
215-
path = strings.Join([]string{joinedPath, path}, "")
215+
path = strings.Join([]string{AppRoot, joinedPath, path}, "")
216216

217217
// This will import the module routes under the path described in the
218218
// 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
@@ -453,12 +453,15 @@ func (gotmpl GoTemplate) Content() []string {
453453

454454
// Return a url capable of invoking a given controller method:
455455
// "Application.ShowApp 123" => "/app/123"
456-
func ReverseUrl(args ...interface{}) (string, error) {
456+
func ReverseUrl(args ...interface{}) (template.URL, error) {
457457
if len(args) == 0 {
458458
return "", fmt.Errorf("no arguments provided to reverse route")
459459
}
460460

461461
action := args[0].(string)
462+
if action == "Root" {
463+
return template.URL(AppRoot), nil
464+
}
462465
actionSplit := strings.Split(action, ".")
463466
if len(actionSplit) != 2 {
464467
return "", fmt.Errorf("reversing '%s', expected 'Controller.Action'", action)
@@ -476,7 +479,7 @@ func ReverseUrl(args ...interface{}) (string, error) {
476479
Unbind(argsByName, c.MethodType.Args[i].Name, argValue)
477480
}
478481

479-
return MainRouter.Reverse(args[0].(string), argsByName).Url, nil
482+
return template.URL(MainRouter.Reverse(args[0].(string), argsByName).Url), nil
480483
}
481484

482485
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.