Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Thorax client

  • Loading branch information...
commit 48a5de4f9338d1b7d57a42a59138cba864b80fba 1 parent b5b5500
Craig Walls authored
Showing with 191 additions and 57 deletions.
  1. +28 −0 thorax-lumbar-client/src/main/java/com/springsource/s2gx/OptionsHeadersFilter.java
  2. +6 −0 thorax-lumbar-client/src/main/thorax/js/collections/Sessions.js
  3. +3 −0  thorax-lumbar-client/src/main/thorax/js/models/Session.js
  4. +0 −6 thorax-lumbar-client/src/main/thorax/js/routers/hello_world.js
  5. +8 −0 thorax-lumbar-client/src/main/thorax/js/routers/s2gx.js
  6. +0 −3  thorax-lumbar-client/src/main/thorax/js/views/hello_world/index.js
  7. +9 −0 thorax-lumbar-client/src/main/thorax/js/views/s2gx/Sessions.js
  8. +120 −38 thorax-lumbar-client/src/main/thorax/lumbar.json
  9. +1 −1  thorax-lumbar-client/src/main/thorax/package.json
  10. +2 −2 thorax-lumbar-client/src/main/thorax/static/mobile/index.html
  11. +2 −2 thorax-lumbar-client/src/main/thorax/static/tablet/index.html
  12. +0 −1  thorax-lumbar-client/src/main/thorax/static/web/index.html
  13. +0 −3  thorax-lumbar-client/src/main/thorax/styles/hello_world.styl
  14. +0 −1  thorax-lumbar-client/src/main/thorax/templates/hello_world/index.handlebars
  15. +1 −0  thorax-lumbar-client/src/main/thorax/templates/s2gx/Sessions-item.handlebars
  16. +1 −0  thorax-lumbar-client/src/main/thorax/templates/s2gx/Sessions.handlebars
  17. +10 −0 thorax-lumbar-client/src/main/webapp/WEB-INF/web.xml
28 thorax-lumbar-client/src/main/java/com/springsource/s2gx/OptionsHeadersFilter.java
View
@@ -0,0 +1,28 @@
+package com.springsource.s2gx;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletResponse;
+
+public class OptionsHeadersFilter implements Filter {
+
+ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
+ HttpServletResponse response = (HttpServletResponse) res;
+ response.setHeader("Access-Control-Allow-Origin", "*");
+ response.setHeader("Access-Control-Allow-Methods", "GET,POST,DELETE,PUT");
+ response.setHeader("Access-Control-Max-Age", "360");
+ response.setHeader("Access-Control-Allow-Headers", "Content-Type,x-requested-with,Authorization");
+ chain.doFilter(req, res);
+ }
+
+ public void init(FilterConfig filterConfig) {}
+
+ public void destroy() {}
+
+}
6 thorax-lumbar-client/src/main/thorax/js/collections/Sessions.js
View
@@ -0,0 +1,6 @@
+S2GX.Collection.extend({
+ name: "Sessions",
+ model: S2GX.Models.Session,
+ url: 'http://localhost:8080/thorax-client/sessions'
+
+});
3  thorax-lumbar-client/src/main/thorax/js/models/Session.js
View
@@ -0,0 +1,3 @@
+S2GX.Model.extend({
+ name: "Session"
+});
6 thorax-lumbar-client/src/main/thorax/js/routers/hello_world.js
View
@@ -1,6 +0,0 @@
-Application.Router.create(module, {
- index: function() {
- var view = this.view('hello_world/index');
- this.setView(view);
- }
-});
8 thorax-lumbar-client/src/main/thorax/js/routers/s2gx.js
View
@@ -0,0 +1,8 @@
+S2GX.Router.create(module, {
+ sessions: function() {
+ alert("X: " + cache.sessions.length);
+ var view = this.view('s2gx/Sessions');
+ view.setCollection(cache.sessions);
+ this.setView(view);
+ }
+});
3  thorax-lumbar-client/src/main/thorax/js/views/hello_world/index.js
View
@@ -1,3 +0,0 @@
-Application.View.extend({
- name: 'hello_world/index'
-});
9 thorax-lumbar-client/src/main/thorax/js/views/s2gx/Sessions.js
View
@@ -0,0 +1,9 @@
+// setup the local session cache
+var cache = {
+ sessions: new S2GX.Collections.Sessions()
+};
+cache.sessions.fetch();
+
+S2GX.View.extend({
+ name: 's2gx/Sessions'
+});
158 thorax-lumbar-client/src/main/thorax/lumbar.json
View
@@ -1,81 +1,163 @@
{
"application": {
- "name": "Application",
+ "name": "S2GX",
"module": "base"
},
- "platforms": [ "mobile", "tablet", "web" ],
+ "platforms": [
+ "mobile",
+ "tablet",
+ "web"
+ ],
"packages": {
"web": {
- "platforms": [ "web" ],
+ "platforms": [
+ "web"
+ ],
"combine": false
},
- "native-hello-world": {
- "platforms": [ "mobile", "tablet" ],
- "modules": [ "base", "hello_world" ],
+ "native-s2gx": {
+ "platforms": [
+ "mobile",
+ "tablet"
+ ],
+ "modules": [
+ "base",
+ "s2gx"
+ ],
"combine": true
}
},
"modules": {
"base": {
"scripts": [
- {"src": "js/lib/zepto.js", "global": true},
- {"src": "js/lib/underscore.js", "global": true},
- {"src": "js/lib/backbone.js", "global": true},
- {"src": "js/lib/handlebars.js", "global": true},
- {"src": "js/lib/thorax.js", "global": true},
- {"src": "js/lib/script.js", "global": true},
- {"src": "js/lib/lumbar-loader.js", "platform": "web"},
- {"src": "js/lib/lumbar-loader-events.js", "platform": "web"},
- {"src": "js/lib/lumbar-loader-standard.js", "platform": "web"},
- {"src": "js/lib/lumbar-loader-backbone.js", "platform": "web"},
+ {
+ "src": "js/lib/zepto.js",
+ "global": true
+ },
+ {
+ "src": "js/lib/underscore.js",
+ "global": true
+ },
+ {
+ "src": "js/lib/backbone.js",
+ "global": true
+ },
+ {
+ "src": "js/lib/handlebars.js",
+ "global": true
+ },
+ {
+ "src": "js/lib/thorax.js",
+ "global": true
+ },
+ {
+ "src": "js/lib/script.js",
+ "global": true
+ },
+ {
+ "src": "js/lib/lumbar-loader.js",
+ "platform": "web"
+ },
+ {
+ "src": "js/lib/lumbar-loader-events.js",
+ "platform": "web"
+ },
+ {
+ "src": "js/lib/lumbar-loader-standard.js",
+ "platform": "web"
+ },
+ {
+ "src": "js/lib/lumbar-loader-backbone.js",
+ "platform": "web"
+ },
"js/init.js",
"js/router.js",
"js/model.js",
"js/collection.js",
"js/view.js",
- {"src": "js/bridge.js", "platforms": ["mobile", "tablet"]},
- {"src": "js/bridge-mobile.js", "platform": "mobile"},
- {"src": "js/bridge-tablet.js", "platforms": ["tablet"]},
- {"module-map": true, "platforms": ["web"]}
+ {
+ "src": "js/bridge.js",
+ "platforms": [
+ "mobile",
+ "tablet"
+ ]
+ },
+ {
+ "src": "js/bridge-mobile.js",
+ "platform": "mobile"
+ },
+ {
+ "src": "js/bridge-tablet.js",
+ "platforms": [
+ "tablet"
+ ]
+ },
+ {
+ "module-map": true,
+ "platforms": [
+ "web"
+ ]
+ }
],
"styles": [
"styles/base.styl",
- {"src": "styles/mobile.styl", "platform": "mobile"},
- {"src": "styles/tablet.styl", "platform": "tablet"},
- {"src": "styles/web.styl", "platform": "web"}
+ {
+ "src": "styles/mobile.styl",
+ "platform": "mobile"
+ },
+ {
+ "src": "styles/tablet.styl",
+ "platform": "tablet"
+ },
+ {
+ "src": "styles/web.styl",
+ "platform": "web"
+ }
],
"static": [
- {"src": "static/#{platform}/index.html", "dest": "index.html"}
+ {
+ "src": "static/#{platform}/index.html",
+ "dest": "index.html"
+ }
]
},
- "hello_world": {
+ "s2gx": {
"routes": {
- "": "index",
- "hello": "index"
+ "": "sessions",
+ "sessions": "sessions"
},
"scripts": [
- "js/views/hello_world",
- "js/routers/hello_world.js"
- ],
- "styles": [
- "styles/hello_world.styl"
+ "js/models/Session.js",
+ "js/collections/Sessions.js",
+ "js/views/s2gx/Sessions.js",
+ "js/routers/s2gx.js"
]
}
},
"templates": {
- "js/views/hello_world/index.js": [
- "templates/hello_world/index.handlebars"
+ "js/views/s2gx/Sessions.js": [
+ "templates/s2gx/Sessions.handlebars",
+ "templates/s2gx/Sessions-item.handlebars"
]
},
"styles": {
"pixelDensity": {
- "mobile": [ 1, 2 ],
- "tablet" : [ 1, 2 ],
- "web": [ 1, 2 ]
+ "mobile": [
+ 1,
+ 2
+ ],
+ "tablet": [
+ 1,
+ 2
+ ],
+ "web": [
+ 1,
+ 2
+ ]
},
"includes": [
"nib",
"styles/include/global.styl"
]
}
-}
+}
2  thorax-lumbar-client/src/main/thorax/package.json
View
@@ -9,4 +9,4 @@
"scripts": {
"start": "node server.js --watch"
}
-}
+}
4 thorax-lumbar-client/src/main/thorax/static/mobile/index.html
View
@@ -2,10 +2,10 @@
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
- <link rel="stylesheet" href="native-hello-world.css" type="text/css">
+ <link rel="stylesheet" href="native-s2gx.css" type="text/css">
</head>
<body>
<div class="layout"></div>
- <script type="text/javascript" src="native-hello-world.js"></script>
+ <script type="text/javascript" src="native-s2gx.js"></script>
</body>
</html>
4 thorax-lumbar-client/src/main/thorax/static/tablet/index.html
View
@@ -2,10 +2,10 @@
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
- <link rel="stylesheet" href="native-hello-world.css" type="text/css">
+ <link rel="stylesheet" href="native-s2gx.css" type="text/css">
</head>
<body>
<div class="layout"></div>
- <script type="text/javascript" src="native-hello-world.js"></script>
+ <script type="text/javascript" src="native-s2gx.js"></script>
</body>
</html>
1  thorax-lumbar-client/src/main/thorax/static/web/index.html
View
@@ -4,7 +4,6 @@
<title>Lumbar Example</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="base.css" type="text/css">
- <link rel="stylesheet" href="hello_world.css" type="text/css">
</head>
<body>
<div class="layout"></div>
3  thorax-lumbar-client/src/main/thorax/styles/hello_world.styl
View
@@ -1,3 +0,0 @@
-.footer
- background red
- color white
1  thorax-lumbar-client/src/main/thorax/templates/hello_world/index.handlebars
View
@@ -1 +0,0 @@
-<h1>Hello world!</h1>
1  thorax-lumbar-client/src/main/thorax/templates/s2gx/Sessions-item.handlebars
View
@@ -0,0 +1 @@
+<li>{{title}}</li>
1  thorax-lumbar-client/src/main/thorax/templates/s2gx/Sessions.handlebars
View
@@ -0,0 +1 @@
+<h2>Sessions</h2>
10 thorax-lumbar-client/src/main/webapp/WEB-INF/web.xml
View
@@ -41,4 +41,14 @@
<servlet-name>appServlet</servlet-name>
</filter-mapping>
+ <filter>
+ <filter-name>optionsHeadersFilter</filter-name>
+ <filter-class>com.springsource.s2gx.OptionsHeadersFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>optionsHeadersFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
</web-app>
Please sign in to comment.
Something went wrong with that request. Please try again.