woyo-server 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/woyo/server/server.rb +155 -29
- data/lib/woyo/server/version.rb +1 -1
- data/public/server/css/server.css +6 -6
- data/public/server/ember-1.6.1-kit/README.md +36 -0
- data/public/server/ember-1.6.1-kit/css/normalize.css +406 -0
- data/public/server/ember-1.6.1-kit/css/style.css +4 -0
- data/public/server/ember-1.6.1-kit/index.html +31 -0
- data/public/server/ember-1.6.1-kit/js/app.js +11 -0
- data/public/server/ember-1.6.1-kit/js/libs/ember-1.6.1.js +46762 -0
- data/public/server/ember-1.6.1-kit/js/libs/ember-data-1.0.0-beta.8.js +12053 -0
- data/public/server/ember-1.6.1-kit/js/libs/handlebars-1.1.2.js +2595 -0
- data/public/server/ember-1.6.1-kit/js/libs/jquery-1.10.2.js +9789 -0
- data/public/server/ember-1.6.1-kit/tests/runner.css +14 -0
- data/public/server/ember-1.6.1-kit/tests/runner.js +13 -0
- data/public/server/ember-1.6.1-kit/tests/tests.js +31 -0
- data/public/server/ember-1.6.1-kit/tests/vendor/qunit-1.12.0.css +244 -0
- data/public/server/ember-1.6.1-kit/tests/vendor/qunit-1.12.0.js +2212 -0
- data/public/server/ember-1.7.0/ember.js +48219 -0
- data/public/server/ember-animate-0.3.5/README.md +112 -0
- data/public/server/ember-animate-0.3.5/bower.json +25 -0
- data/public/server/ember-animate-0.3.5/ember-animate.js +256 -0
- data/public/server/ember-data-1.0.0-beta.9/ember-data.js +12877 -0
- data/public/server/handlebars-1.1.2/handlebars.js +2595 -0
- data/public/server/jquery-1.10.2/jquery.js +9789 -0
- data/public/server/js/play.js +246 -0
- data/public/server/js/server.js +5 -65
- data/todo.txt +17 -10
- data/views/server/layout.erb +37 -0
- data/views/server/play.erb +74 -0
- data/views/server/start.erb +22 -0
- metadata +29 -10
- data/views/server/actions.haml +0 -6
- data/views/server/item.haml +0 -7
- data/views/server/layout.haml +0 -25
- data/views/server/location.haml +0 -8
- data/views/server/way.haml +0 -6
- data/views/server/world.haml +0 -15
@@ -0,0 +1,246 @@
|
|
1
|
+
|
2
|
+
App = Ember.Application.create({
|
3
|
+
LOG_TRANSITIONS: true
|
4
|
+
});
|
5
|
+
|
6
|
+
App.IndexRoute = Ember.Route.extend({
|
7
|
+
beforeModel: function() {
|
8
|
+
this.transitionTo('location', initial_location_id);
|
9
|
+
}
|
10
|
+
});
|
11
|
+
|
12
|
+
App.Router.map(function() {
|
13
|
+
this.resource('location', { path: '/location/:location_id' }); //, function() {
|
14
|
+
});
|
15
|
+
|
16
|
+
// location
|
17
|
+
|
18
|
+
App.LocationRoute = Ember.Route.extend({
|
19
|
+
model: function(params) {
|
20
|
+
return this.store.find('location', params.location_id);
|
21
|
+
}
|
22
|
+
});
|
23
|
+
|
24
|
+
App.LocationController = Ember.ObjectController.extend({
|
25
|
+
});
|
26
|
+
|
27
|
+
App.LocationView = Ember.View.extend({
|
28
|
+
willAnimateIn : function () {
|
29
|
+
console.log('location willAnimateIn');
|
30
|
+
this.$().css("opacity", 0);
|
31
|
+
},
|
32
|
+
animateIn : function (done) {
|
33
|
+
console.log('location animateIn');
|
34
|
+
this.$().fadeTo(woyo.time.page_in, 1, done);
|
35
|
+
},
|
36
|
+
animateOut : function (done) {
|
37
|
+
console.log('location animateIn');
|
38
|
+
this.$().fadeTo(woyo.time.page_out, 0, done);
|
39
|
+
}
|
40
|
+
})
|
41
|
+
|
42
|
+
App.Location = DS.Model.extend({
|
43
|
+
name: DS.attr(),
|
44
|
+
description: DS.attr(),
|
45
|
+
items: DS.hasMany('item', {async:true}),
|
46
|
+
ways: DS.hasMany('way', {async:true})
|
47
|
+
});
|
48
|
+
|
49
|
+
// way
|
50
|
+
|
51
|
+
App.WayController = Ember.ObjectController.extend({
|
52
|
+
});
|
53
|
+
|
54
|
+
App.WayView = Ember.View.extend({
|
55
|
+
willAnimateIn: function () {
|
56
|
+
console.log('way willAnimateIn');
|
57
|
+
this.$().css("opacity", 0);
|
58
|
+
},
|
59
|
+
animateIn: function (done) {
|
60
|
+
console.log('way animateIn');
|
61
|
+
this.$().fadeTo(woyo.time.page_in, 1, done);
|
62
|
+
},
|
63
|
+
animateOut: function (done) {
|
64
|
+
console.log('way animateOut');
|
65
|
+
this.$().fadeTo(woyo.time.page_out, 0, done);
|
66
|
+
}
|
67
|
+
});
|
68
|
+
|
69
|
+
App.Way = DS.Model.extend({
|
70
|
+
location: DS.belongsTo('location'),
|
71
|
+
name: DS.attr(),
|
72
|
+
description: DS.attr(),
|
73
|
+
actions: DS.hasMany('action', {async:false}),
|
74
|
+
div_id: function() { return 'way-' + this.get('id'); }.property('id')
|
75
|
+
});
|
76
|
+
|
77
|
+
// item
|
78
|
+
|
79
|
+
App.ItemRoute = Ember.Route.extend({
|
80
|
+
beforeModel: function() {
|
81
|
+
console.log("item beforeModel");
|
82
|
+
},
|
83
|
+
// model: function(params) {
|
84
|
+
// return this.store.find('item', params.item_id);
|
85
|
+
// },
|
86
|
+
afterModel: function() {
|
87
|
+
console.log("item afterModel");
|
88
|
+
}
|
89
|
+
});
|
90
|
+
|
91
|
+
App.ItemController = Ember.ObjectController.extend({
|
92
|
+
});
|
93
|
+
|
94
|
+
App.ItemView = Ember.View.extend({
|
95
|
+
willAnimateIn: function () {
|
96
|
+
console.log('item willAnimateIn');
|
97
|
+
this.$().css("opacity", 0);
|
98
|
+
},
|
99
|
+
animateIn: function (done) {
|
100
|
+
console.log('item animateIn');
|
101
|
+
this.$().fadeTo(woyo.time.page_in, 1, done);
|
102
|
+
},
|
103
|
+
animateOut: function (done) {
|
104
|
+
console.log('item animateOut');
|
105
|
+
this.$().fadeTo(woyo.time.page_out, 0, done);
|
106
|
+
}
|
107
|
+
});
|
108
|
+
|
109
|
+
App.Item = DS.Model.extend({
|
110
|
+
location: DS.belongsTo('location'),
|
111
|
+
name: DS.attr(),
|
112
|
+
description: DS.attr(),
|
113
|
+
actions: DS.hasMany('action', {async:false}),
|
114
|
+
div_id: function() { return 'item-' + this.get('id'); }.property('id'),
|
115
|
+
didLoad: function() {
|
116
|
+
console.log('item didLoad');
|
117
|
+
}
|
118
|
+
});
|
119
|
+
|
120
|
+
// action
|
121
|
+
|
122
|
+
App.ActionController = Ember.ObjectController.extend({
|
123
|
+
actions: {
|
124
|
+
execute: function() {
|
125
|
+
this.get( 'execution' ).reload().then( function( execution ) {
|
126
|
+
var changes = execution.get('changes');
|
127
|
+
var result = execution.get('result')
|
128
|
+
var action = execution.get('action');
|
129
|
+
var owner = action.get('owner');
|
130
|
+
var location = owner.get('location');
|
131
|
+
// todo: make this work for all changes...
|
132
|
+
// todo: transitions for changes to ember bound fields ?
|
133
|
+
for ( change in changes ) {
|
134
|
+
if ( change == "description" || change == "name" ) {
|
135
|
+
location.set( change, changes[change] );
|
136
|
+
}
|
137
|
+
if ( change == "item" ) {
|
138
|
+
var items_changed = changes.item;
|
139
|
+
for ( item_id in items_changed ) {
|
140
|
+
var item = location.get( 'items' ).findProperty( 'id', item_id );
|
141
|
+
if ( item ) {
|
142
|
+
attrs_changed = items_changed[item_id];
|
143
|
+
for ( attr_id in attrs_changed ) {
|
144
|
+
var attr = item.get(attr_id);
|
145
|
+
if ( attr ) {
|
146
|
+
item.set( attr_id, attrs_changed[attr_id] );
|
147
|
+
};
|
148
|
+
};
|
149
|
+
};
|
150
|
+
};
|
151
|
+
};
|
152
|
+
if ( change == "way" ) {
|
153
|
+
var ways_changed = changes.way;
|
154
|
+
for ( way_id in ways_changed ) {
|
155
|
+
var way = location.get( 'ways' ).findProperty( 'id', way_id );
|
156
|
+
if ( way ) {
|
157
|
+
attrs_changed = ways_changed[way_id];
|
158
|
+
for ( attr_id in attrs_changed ) {
|
159
|
+
var attr = way.get(attr_id);
|
160
|
+
if ( attr ) {
|
161
|
+
way.set( attr_id, attrs_changed[attr_id] );
|
162
|
+
};
|
163
|
+
};
|
164
|
+
};
|
165
|
+
};
|
166
|
+
};
|
167
|
+
};
|
168
|
+
if ( result.location ) {
|
169
|
+
setTimeout(function(){ window.location.assign("/play"); }, woyo.time.go_delay);
|
170
|
+
} else {
|
171
|
+
setTimeout(function(){ execution.set( 'display_describe', null ); }, woyo.time.action_delay);
|
172
|
+
};
|
173
|
+
});
|
174
|
+
}
|
175
|
+
}
|
176
|
+
});
|
177
|
+
|
178
|
+
App.ActionView = Ember.View.extend({
|
179
|
+
willAnimateIn: function () {
|
180
|
+
console.log('action willAnimateIn');
|
181
|
+
this.$().css("opacity", 0);
|
182
|
+
},
|
183
|
+
animateIn: function (done) {
|
184
|
+
console.log('action animateIn');
|
185
|
+
this.$().fadeTo(woyo.time.page_in, 1, done);
|
186
|
+
},
|
187
|
+
animateOut: function (done) {
|
188
|
+
console.log('action animateOut');
|
189
|
+
this.$().fadeTo(woyo.time.page_out, 0, done);
|
190
|
+
}
|
191
|
+
});
|
192
|
+
|
193
|
+
App.Action = DS.Model.extend({
|
194
|
+
item: DS.belongsTo('item'),
|
195
|
+
way: DS.belongsTo('way'),
|
196
|
+
name: DS.attr(),
|
197
|
+
description: DS.attr(),
|
198
|
+
execution: DS.belongsTo('execution', {async:false}),
|
199
|
+
owner: function() { return this.get('item') || this.get('way'); }.property('item','way'),
|
200
|
+
display_description: function() { return this.get('description') || this.get('name'); }.property('description','way')
|
201
|
+
});
|
202
|
+
|
203
|
+
// execution
|
204
|
+
|
205
|
+
App.ExecutionController = Ember.ObjectController.extend({
|
206
|
+
});
|
207
|
+
|
208
|
+
App.ExecutionView = Ember.View.extend({
|
209
|
+
willAnimateIn: function () {
|
210
|
+
console.log('execution willAnimateIn');
|
211
|
+
this.$().css("opacity", 0);
|
212
|
+
},
|
213
|
+
animateIn: function (done) {
|
214
|
+
console.log('execution animateIn');
|
215
|
+
this.$().fadeTo(woyo.time.page_in, 1, done);
|
216
|
+
},
|
217
|
+
animateOut: function (done) {
|
218
|
+
console.log('execution animateOut');
|
219
|
+
this.$().fadeTo(woyo.time.page_out, 0, done);
|
220
|
+
}
|
221
|
+
});
|
222
|
+
|
223
|
+
App.Execution = DS.Model.extend({
|
224
|
+
action: DS.belongsTo('action'),
|
225
|
+
result: DS.attr(),
|
226
|
+
describe: DS.attr(),
|
227
|
+
changes: DS.attr(),
|
228
|
+
display_describe: function(key, value, old) {
|
229
|
+
// computed property to display describe lets me erase the displayed value without making the record dirty
|
230
|
+
// a clean record permits reload from the server for subsequent action executions
|
231
|
+
if ( arguments.length == 1 ) {
|
232
|
+
return this.get('describe');
|
233
|
+
} else {
|
234
|
+
return value;
|
235
|
+
}
|
236
|
+
}.property('describe')
|
237
|
+
});
|
238
|
+
|
239
|
+
// functions
|
240
|
+
|
241
|
+
function hold(delay_time){
|
242
|
+
var dfd = $.Deferred();
|
243
|
+
setTimeout(function(){ dfd.resolve(); }, delay_time);
|
244
|
+
return dfd.promise();
|
245
|
+
}
|
246
|
+
|
data/public/server/js/server.js
CHANGED
@@ -3,78 +3,18 @@ $(document).foundation();
|
|
3
3
|
|
4
4
|
$(document).ready( function() {
|
5
5
|
|
6
|
-
|
6
|
+
woyo = {
|
7
7
|
time: {
|
8
8
|
page_in: 1000,
|
9
9
|
page_out: 1000,
|
10
10
|
go_slide: 1000,
|
11
11
|
go_fade: 1000,
|
12
|
-
go_delay: 2000
|
12
|
+
go_delay: 2000,
|
13
|
+
action_slide: 1000,
|
14
|
+
action_fade: 1000,
|
15
|
+
action_delay: 2000
|
13
16
|
}
|
14
17
|
};
|
15
18
|
|
16
|
-
$("body").fadeIn(woyo.time.page_in);
|
17
|
-
|
18
|
-
$(".way .go").click( function() {
|
19
|
-
$go_link = $(this);
|
20
|
-
go_url = $go_link.attr("href");
|
21
|
-
$.get( go_url, function(json) {
|
22
|
-
if ( json.going.length > 0 ) {
|
23
|
-
$go_link
|
24
|
-
.siblings(".going")
|
25
|
-
.text(json.going)
|
26
|
-
.slideDown(woyo.time.go_slide)
|
27
|
-
.animate({opacity: 1}, woyo.time.go_fade)
|
28
|
-
.delay(woyo.time.go_delay)
|
29
|
-
.queue( function(next) {
|
30
|
-
if ( json.go == true ) {
|
31
|
-
$("body").fadeOut(woyo.time.page_out, function() {
|
32
|
-
window.location.reload(true);
|
33
|
-
});
|
34
|
-
};
|
35
|
-
next();
|
36
|
-
});
|
37
|
-
} else {
|
38
|
-
if ( json.go == true ) {
|
39
|
-
$("body").fadeOut(woyo.time.page_out, function() {
|
40
|
-
window.location.reload(true);
|
41
|
-
});
|
42
|
-
};
|
43
|
-
};
|
44
|
-
});
|
45
|
-
return false;
|
46
|
-
});
|
47
|
-
|
48
|
-
$("a.do").click( function() {
|
49
|
-
owner = $("#" + $(this).parent().attr("owner_element"));
|
50
|
-
do_url = $(this).attr("href");
|
51
|
-
$.get( do_url, function(json) {
|
52
|
-
// todo: handle multiple texts in describe array not just a string
|
53
|
-
if ( json.describe.length > 0 ) {
|
54
|
-
owner
|
55
|
-
.children(".describe-actions")
|
56
|
-
.text(json.describe)
|
57
|
-
.slideDown(woyo.time.go_slide)
|
58
|
-
.animate({opacity: 1}, woyo.time.go_fade)
|
59
|
-
.delay(woyo.time.go_delay)
|
60
|
-
.queue( function(next) {
|
61
|
-
if ( json.changes.length > 0 ) {
|
62
|
-
$("body").fadeOut(woyo.time.page_out, function() {
|
63
|
-
window.location.reload(true);
|
64
|
-
});
|
65
|
-
};
|
66
|
-
next();
|
67
|
-
});
|
68
|
-
} else {
|
69
|
-
if ( json.changes.length > 0 ) {
|
70
|
-
$("body").fadeOut(woyo.time.page_out, function() {
|
71
|
-
window.location.reload(true);
|
72
|
-
});
|
73
|
-
};
|
74
|
-
};
|
75
|
-
});
|
76
|
-
return false;
|
77
|
-
});
|
78
|
-
|
79
19
|
});
|
80
20
|
|
data/todo.txt
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
|
3
|
+
/ loads page
|
4
|
+
locations [ :id1, :id2, ... ]
|
5
|
+
location/:id { id: :id, name: 'name' description: [ 'text1', 'text2', ... ] }
|
6
|
+
location/:id/ways [ :id1, :id2, ... ]
|
7
|
+
location/:id/way/:id { id: :id, name: 'name', description: [ 'text1', 'text2', ... ], to: :to_id }
|
8
|
+
location/:id/items [ :id1, :id2, ... ]
|
9
|
+
location/:id/item/:id { id: :id, name: 'name', description: [ 'text1', 'text2', ... ] }
|
10
|
+
location/:id/item/:id/actions [ :id1, :id2, ... ]
|
11
|
+
location/:id/item/:id/actions/:id { id: :id, name: 'name', description: [ 'text1', 'text2', ... ] }
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
3
19
|
! Multiline descriptions
|
4
20
|
<br/> => <br/> # html in text
|
5
21
|
<br> => <br/> # html in text + fixup tag ?
|
@@ -8,13 +24,4 @@
|
|
8
24
|
\n => <br/> # convert
|
9
25
|
\n\n => </p><p ... > # convert - set params for new paragraph
|
10
26
|
|
11
|
-
Debugger
|
12
|
-
Use haml tenplate for default page including layout.haml
|
13
|
-
Test location description states
|
14
|
-
Document DSL attributes and groups usage
|
15
|
-
-> way descriptions
|
16
|
-
-> way going
|
17
|
-
-> location descriptions
|
18
|
-
Auto generate DSL docs from tests ?
|
19
|
-
Test worlds in separate files - useful for manual testing
|
20
27
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<html>
|
2
|
+
|
3
|
+
<head>
|
4
|
+
|
5
|
+
<meta charset="utf-8"></meta>
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0"></meta>
|
7
|
+
<link rel="stylesheet" href="/foundation-5.2.2/css/foundation.css"></link>
|
8
|
+
<link rel="stylesheet" href="/css/server.css"></link>
|
9
|
+
<script src="/foundation-5.2.2/js/vendor/modernizr.js"></script>
|
10
|
+
|
11
|
+
<title>
|
12
|
+
<%= case
|
13
|
+
when @world
|
14
|
+
@world.name
|
15
|
+
when @location
|
16
|
+
@location.name
|
17
|
+
end %>
|
18
|
+
</title>
|
19
|
+
|
20
|
+
</head>
|
21
|
+
|
22
|
+
<body>
|
23
|
+
|
24
|
+
<script src="/foundation-5.2.2/js/vendor/jquery.js"/></script>
|
25
|
+
<script src="/foundation-5.2.2/js/foundation.min.js"></script>
|
26
|
+
<script src="/handlebars-1.1.2/handlebars.js"></script>
|
27
|
+
<script src="/ember-1.7.0/ember.js"></script>
|
28
|
+
<script src="/ember-data-1.0.0-beta.9/ember-data.js"></script>
|
29
|
+
<script src="/ember-animate-0.3.5/ember-animate.js"></script>
|
30
|
+
<script src="/js/server.js"></script>
|
31
|
+
|
32
|
+
<%= yield %>
|
33
|
+
|
34
|
+
</body>
|
35
|
+
|
36
|
+
</html>
|
37
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
|
2
|
+
<script type="text/x-handlebars">
|
3
|
+
<div class="row">
|
4
|
+
<div class="large-12 columns">
|
5
|
+
{{outlet}}
|
6
|
+
</div>
|
7
|
+
</div>
|
8
|
+
</script>
|
9
|
+
|
10
|
+
<script type="text/x-handlebars" data-template-name="location">
|
11
|
+
<div class="row">
|
12
|
+
<div class="large-12 columns">
|
13
|
+
<h1>{{name}}</h1>
|
14
|
+
<p>{{description}}</p>
|
15
|
+
{{#each item in items}}
|
16
|
+
{{render "item" item}}
|
17
|
+
{{/each}}
|
18
|
+
{{#each way in ways}}
|
19
|
+
{{render "way" way}}
|
20
|
+
{{/each}}
|
21
|
+
</div>
|
22
|
+
</div>
|
23
|
+
</script>
|
24
|
+
|
25
|
+
<script type="text/x-handlebars" data-template-name="item">
|
26
|
+
<div class="row">
|
27
|
+
<div class="large-12 columns">
|
28
|
+
<div {{bind-attr id=item.div_id}}>
|
29
|
+
<p class="description">{{description}}</p>
|
30
|
+
{{#each action in actions}}
|
31
|
+
{{render "execution" action.execution}}
|
32
|
+
{{/each}}
|
33
|
+
<ul>
|
34
|
+
{{#each action in actions}}
|
35
|
+
{{render "action" action}}
|
36
|
+
{{/each}}
|
37
|
+
</ul>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
</div>
|
41
|
+
</script>
|
42
|
+
|
43
|
+
<script type="text/x-handlebars" data-template-name="way">
|
44
|
+
<div class="row">
|
45
|
+
<div class="large-12 columns">
|
46
|
+
<div {{bind-attr id=way.div_id}}>
|
47
|
+
<p class="description">{{description}}</p>
|
48
|
+
{{#each action in actions}}
|
49
|
+
{{render "execution" action.execution}}
|
50
|
+
{{/each}}
|
51
|
+
<ul>
|
52
|
+
{{#each action in actions}}
|
53
|
+
{{render "action" action}}
|
54
|
+
{{/each}}
|
55
|
+
</ul>
|
56
|
+
</div>
|
57
|
+
</div>
|
58
|
+
</div>
|
59
|
+
</script>
|
60
|
+
|
61
|
+
<script type="text/x-handlebars" data-template-name="action">
|
62
|
+
<li class="action"><a {{action 'execute'}}>{{display_description}}</a></li>
|
63
|
+
</script>
|
64
|
+
|
65
|
+
<script type="text/x-handlebars" data-template-name="execution">
|
66
|
+
<p class="describe-execution">{{display_describe}}</p>
|
67
|
+
</script>
|
68
|
+
|
69
|
+
<script type="text/javascript">
|
70
|
+
<%= "var initial_location_id = '#{@location.id}';" %>
|
71
|
+
</script>
|
72
|
+
|
73
|
+
<script src="/js/play.js"></script>
|
74
|
+
|