From 7d951ac382a97f8f664cf8c57ef1990e58d144c9 Mon Sep 17 00:00:00 2001 From: Andreas Voeth Date: Wed, 6 Aug 2014 02:45:49 +0200 Subject: [PATCH] Added context path to javascipt sources and ajax request instead of using relative paths --- build.sbt | 2 +- src/main/js/liftproxy.js | 3 ++- .../scala/net/liftmodules/ng/Angular.scala | 3 ++- test-project/build.sbt | 2 +- .../main/scala/bootstrap/liftweb/Boot.scala | 3 ++- .../src/main/webapp/subdir/index.html | 23 +++++++++++++++++++ 6 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 test-project/src/main/webapp/subdir/index.html diff --git a/build.sbt b/build.sbt index 1eaa8667..183bb155 100644 --- a/build.sbt +++ b/build.sbt @@ -4,7 +4,7 @@ organization := "net.liftmodules" homepage := Some(url("https://github.com/joescii/lift-ng")) -version := "0.4.6" +version := "0.4.7" liftVersion <<= liftVersion ?? "2.5.1" diff --git a/src/main/js/liftproxy.js b/src/main/js/liftproxy.js index 7eeaaffe..abbb3b64 100644 --- a/src/main/js/liftproxy.js +++ b/src/main/js/liftproxy.js @@ -43,7 +43,8 @@ angular return q.promise; }; - return $http.post('ajax_request/' + lift_page + '/', req, { + return $http.post(net_liftmodules_ng.contextPath + '/ajax_request/' + lift_page + '/', req, { + //return $http.post('ajax_request/' + lift_page + '/', req, { headers : { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' } diff --git a/src/main/scala/net/liftmodules/ng/Angular.scala b/src/main/scala/net/liftmodules/ng/Angular.scala index 36c737ae..c2c49c0a 100644 --- a/src/main/scala/net/liftmodules/ng/Angular.scala +++ b/src/main/scala/net/liftmodules/ng/Angular.scala @@ -89,7 +89,7 @@ object Angular extends DispatchSnippet { } private val liftproxySrc = - "classpath/net/liftmodules/ng/js/liftproxy-"+BuildInfo.version + (Props.mode match { + LiftRules.context.path + "/classpath/net/liftmodules/ng/js/liftproxy-"+BuildInfo.version + (Props.mode match { case RunModes.Development => ".js" case _ => ".min.js" }) @@ -108,6 +108,7 @@ object Angular extends DispatchSnippet { val liftproxy = if(includeJsScript) else NodeSeq.Empty val jsModule = Script(JsRaw( "var net_liftmodules_ng=net_liftmodules_ng||{};" + + "net_liftmodules_ng.contextPath=net_liftmodules_ng.contextPath||\"" + LiftRules.context.path + "\";" + "net_liftmodules_ng.version=net_liftmodules_ng.version||\"" + BuildInfo.version + "\";" + "net_liftmodules_ng.jsPath=net_liftmodules_ng.jsPath||\"" + liftproxySrc +"\";" )) diff --git a/test-project/build.sbt b/test-project/build.sbt index e53b92fe..7b77edbc 100644 --- a/test-project/build.sbt +++ b/test-project/build.sbt @@ -2,7 +2,7 @@ name := "ng-test" organization := "net.liftmodules" -version := "0.4.6" +version := "0.4.7" liftVersion <<= liftVersion ?? "2.5.1" diff --git a/test-project/src/main/scala/bootstrap/liftweb/Boot.scala b/test-project/src/main/scala/bootstrap/liftweb/Boot.scala index 63c59adf..7588c309 100644 --- a/test-project/src/main/scala/bootstrap/liftweb/Boot.scala +++ b/test-project/src/main/scala/bootstrap/liftweb/Boot.scala @@ -39,7 +39,8 @@ class Boot { Menu.i("Actors - Scope") / "actorsScope", Menu.i("Actors - Assignment") / "actorsAssignment", Menu.i("Delay") / "delay", - Menu.i("head.js") / "head-js" + Menu.i("head.js") / "head-js", + Menu.i("Subdir") / "subdir" / "index" ) // set the sitemap. Note if you don't want access control for diff --git a/test-project/src/main/webapp/subdir/index.html b/test-project/src/main/webapp/subdir/index.html new file mode 100644 index 00000000..d33672c9 --- /dev/null +++ b/test-project/src/main/webapp/subdir/index.html @@ -0,0 +1,23 @@ + + + Home + +
+ + + + + +

Static service tests (in Subdir)

+
+
+ OutputStr + OutputInt + OutputStrField + OutputIntField +
+
+
+ + +