Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

config changes, added data stuff

  • Loading branch information...
commit ca0c5777d281941cbfcbbb58a056841cda63e211 1 parent c3d0fee
@Kevnz authored
View
48 _site/collections.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>YMVC Collections Test</title>
+ <meta name="description" content="Page for testing YMVC Collections">
+ <meta name="author" content="">
+ <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">
+ <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.3.0/build/cssreset/reset-min.css">
+ <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.3.0/build/cssbase/base-min.css">
+ <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.3.0/build/cssfonts/fonts-min.css">
+ <script type="text/javascript" src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script>
+ <script type="text/javascript" src="/scripts/config.js"></script>
+ </head>
+ <!--[if lt IE 7 ]><body class="ie6 yui3-skin-sam"><![endif]-->
+ <!--[if IE 7 ]><body class="ie7 yui3-skin-sam yui-skin-sam"><![endif]-->
+ <!--[if IE 8 ]><body class="ie8 yui3-skin-sam yui-skin-sam"><![endif]-->
+ <!--[if IE 9 ]><body class="ie9 yui3-skin-sam yui-skin-sam"><![endif]-->
+ <!--[if (gt IE 9)|!(IE)]><!--> <body class="yui3-skin-sam yui-skin-sam"><!--<![endif]-->
+ <header> </header>
+ <footer> </footer>
+
+ <script>
+ YUI(ymvc_Config).use('ymvc-model','ymvc-collection','base','console', function(Y){
+ new Y.Console().render();
+
+
+ var collection = new Y.Collection({model:Y.Model, url:'/data/models'});
+
+ Y.log(collection);
+
+
+
+ var model = new Y.Model({title:'Test', id: 1}) ;
+
+
+ //var todo = new ToDoModel();
+ Y.log(model);
+ //collection sample
+
+
+
+
+ });
+
+ </script>
+ </body>
+</html>
View
61 _site/scripts/Collection.js
@@ -1,22 +1,57 @@
YUI.add('ymvc-collection', function(Y){
- var Collection = Y.Base.create('TestModel', Y.Base, [], {
+
+
+ var Collection = function(config){
+
+ Collection.superclass.constructor.apply(this, arguments);
+ }
+ Collection.NAME = 'ymvc-collection';
+ Collection.ATTRS = {
+ model:{value:null},
+ url:{value:null}
+ }
+ Y.extend(Collection, Y.Base, {
initializer:function(){
- Y.log('in the initializer','info', 'ymvc-model');
+ Y.log('in the initializer','info', 'ymvc-collection');
+ var uri = this.get('url');
+ var cfg, request;
+ cfg = {
+ sync: true,
+ arguments: { 'foo' : 'bar' }
+ };
+
+ /*
+ * var request will contain the following fields, when the
+ * transaction is complete:
+ * - id
+ * - status
+ * - statusText
+ * - getResponseHeader()
+ * - getAllResponseHeaders()
+ * - responseText
+ * - responseXML
+ * - arguments
+ */
+ Y.log('gonna get ' + uri);
+ request = Y.io(uri, cfg);
+ var data = Y.JSON.parse(request.responseText);
+ var modType = this.get('model');
+ var items = [];
+
+ for (var i=0; i < data.length; i++) {
+ items.push(new modType(data[i]));
+ };
+
+ this.set('Collection', items);
+ Y.log(this.get('Collection')[0].get('title'));
+
},
- toJson: function(){
+ toJson: function() {
return this.getAttrs();
},
- },{
- ATTRS :{
- model:{value:null},
- url:{value:null}
- }
- }
+ }
);
Y.Collection = Collection;
-
-
-
- }, '0.0.1', {requires:['base', 'substitute']});
+ }, '0.0.1', {requires:['base', 'substitute', 'io-base','ymvc-model','json-parse']});
View
28 _site/scripts/config.js
@@ -1,16 +1,18 @@
var ymvc_Config = {
- modules: {
- 'ymvc-model' :{
- fullpath: '/scripts/model.js',
- requires:['base', 'substitute']
- },
- 'ymvc-controller' : {
- fullpath: '/scripts/controller.js',
- requires:['base', 'substitute']
- },
- 'ymvc-template-widget': {
- fullpath: '/scripts/template-widget.js',
- requires:['widget', 'substitute']
+
+
+ groups : {
+ ymvc : {
+ base : 'http://ymvc.dev/scripts/',
+ root : '/scripts/',
+ patterns: {
+ 'ymvc-' : {
+ configFn : function( me ) {
+ me.path = me.name.replace (/ymvc-/g, "") + '.js'
+ }
+ }
+ }
+ }
}
- }
+
};
View
7 _site/scripts/model.js
@@ -1,9 +1,14 @@
YUI.add('ymvc-model', function(Y){
- var Model = Y.Base.create('TestModel', Y.Base, [], {
+ var Model = Y.Base.create('Model', Y.Base, [], {
initializer:function(){
Y.log('in the initializer','info', 'ymvc-model');
},
+ add: function(props){
+ for (var i = props.length - 1; i >= 0; i--){
+ this.addAttr( props[i], {value:null});
+ };
+ },
toJson: function(){
return this.getAttrs();
},
View
49 _site/tests/api.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>title</title>
+ <meta name="description" content="Page that contains How the api for using YMVC should look">
+ <meta name="author" content="">
+ <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">
+ <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.3.0/build/cssreset/reset-min.css">
+ <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.3.0/build/cssbase/base-min.css">
+ <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.3.0/build/cssfonts/fonts-min.css">
+ <script type="text/javascript" src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script>
+ <script type="text/javascript" src="/scripts/config.js"></script>
+ </head>
+ <!--[if lt IE 7 ]><body class="ie6 yui3-skin-sam"><![endif]-->
+ <!--[if IE 7 ]><body class="ie7 yui3-skin-sam yui-skin-sam"><![endif]-->
+ <!--[if IE 8 ]><body class="ie8 yui3-skin-sam yui-skin-sam"><![endif]-->
+ <!--[if IE 9 ]><body class="ie9 yui3-skin-sam yui-skin-sam"><![endif]-->
+ <!--[if (gt IE 9)|!(IE)]><!--> <body class="yui3-skin-sam yui-skin-sam"><!--<![endif]-->
+ <header> </header>
+ <footer> </footer>
+
+ <script>
+ YUI(ymvc_Config).use('ymvc-template-widget','ymvc-model','ymvc-controller','base','console', function(Y){
+ new Y.Console().render();
+ //collection sample
+ var items = new Y.Collection({model:Y.Models.ToDo, url:'/data/todos'});
+ items.load();
+
+ //ToDo Controller extends Controller
+ var controller = new Y.ToDoController({data:todos, widget:Y.Widgets.ToDos});
+
+
+ controller.index();
+
+
+ Y.on('domready', function(){
+ var myModel = new Y.Model({title:'test', id:1234 });
+ Y.log(myModel);
+ Y.log(myModel.get('title'));
+ var myWidget = new Y.TemplatedWidget({srcNode:'#test-container', model : myModel });
+ myWidget.render();
+
+ });
+ });
+
+ </script>
+ </body>
+</html>
View
2  config.ru
@@ -1,3 +1,3 @@
require 'static'
-run Sinatra::Application
+run Sinatra::Application
View
44 resources/base.html
@@ -1,27 +1,23 @@
-
-
<!DOCTYPE html>
<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>title</title>
- <meta name="description" content="">
- <meta name="author" content="">
-<!-- Mobile Viewport Fix j.mp/mobileviewport & davidbcalhoun.com/2010/viewport-metatag device-width : Occupy full width of the screen in its current orientation initial-scale = 1.0 retains dimensions instead of zooming out if page height > device height maximum-scale = 1.0 retains dimensions instead of zooming in if page width < device width -->
- <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">
-
- <!-- Place favicon.ico and apple-touch-icon.png in the root of your domain and delete these references -->
- <link rel="shortcut icon" href="/favicon.ico">
- <link rel="apple-touch-icon" href="/apple-touch-icon.png">
- <script type="text/javascript" src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script>
- </head>
- <!--[if lt IE 7 ]><body class="ie6 yui3-skin-sam"><![endif]-->
- <!--[if IE 7 ]><body class="ie7 yui3-skin-sam yui-skin-sam"><![endif]-->
- <!--[if IE 8 ]><body class="ie8"yui3-skin-sam yui-skin-sam><![endif]-->
- <!--[if IE 9 ]><body class="ie9yui3-skin-sam yui-skin-sam"><![endif]-->
- <!--[if (gt IE 9)|!(IE)]><!--> <body class="yui3-skin-sam yui-skin-sam"><!--<![endif]-->
- <header> </header>
- <footer> </footer>
-
- </body>
+ <head>
+ <meta charset="utf-8">
+ <title>title</title>
+ <meta name="description" content="">
+ <meta name="author" content="">
+ <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">
+ <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.3.0/build/cssreset/reset-min.css">
+ <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.3.0/build/cssbase/base-min.css">
+ <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.3.0/build/cssfonts/fonts-min.css">
+ <script type="text/javascript" src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script>
+ <script type="text/javascript" src="/scripts/config.js"></script>
+ </head>
+ <!--[if lt IE 7 ]><body class="ie6 yui3-skin-sam"><![endif]-->
+ <!--[if IE 7 ]><body class="ie7 yui3-skin-sam yui-skin-sam"><![endif]-->
+ <!--[if IE 8 ]><body class="ie8 yui3-skin-sam yui-skin-sam"><![endif]-->
+ <!--[if IE 9 ]><body class="ie9 yui3-skin-sam yui-skin-sam"><![endif]-->
+ <!--[if (gt IE 9)|!(IE)]><!--> <body class="yui3-skin-sam yui-skin-sam"><!--<![endif]-->
+ <header> </header>
+ <footer> </footer>
+ </body>
</html>
View
14 static.rb
@@ -5,9 +5,9 @@
require 'json'
require 'supermodel'
-class Person < SuperModel::Base
+class ToDo < SuperModel::Base
include SuperModel::RandomID
- attributes :title
+ attributes :title, :description
validates_presence_of :name
end
@@ -22,9 +22,17 @@ class Person < SuperModel::Base
get '/data/todos' do
content_type :json
- [{ :title => 'My ToDo', :description=>'This would be a description' }, {:title => 'Another ToDo', :description => 'This would be a description' }].to_json
+ [{ :title => 'My ToDo', :description=>'This would be a description' }, {:title => 'Another ToDo', :description => 'This would be a description' }].to_json
end
+get '/data/models' do
+ content_type :json
+ [{ :title => 'Item 1', :id => '1' },
+ {:title => 'Item 2', :id => '2' },
+ {:title=>'Item 3', :id=>'3'},
+ {:title=>'Item 4', :id=>'4'}].to_json
+end
+
helpers do
def request_info
Please sign in to comment.
Something went wrong with that request. Please try again.