jtalk-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/.gitignore +2 -0
  2. data/.rvmrc +4 -0
  3. data/CHANGELOG.md +3 -0
  4. data/Gemfile +2 -0
  5. data/Gemfile.lock +97 -0
  6. data/LICENSE +7 -0
  7. data/README.md +13 -0
  8. data/Rakefile +15 -0
  9. data/app/assets/.DS_Store +0 -0
  10. data/app/assets/javascripts/.DS_Store +0 -0
  11. data/app/assets/javascripts/codemirror/codemirror.js +2144 -0
  12. data/app/assets/javascripts/codemirror/overlay.js +51 -0
  13. data/app/assets/javascripts/codemirror/runmode.js +27 -0
  14. data/app/assets/javascripts/codemirror/smalltalk/index.html +56 -0
  15. data/app/assets/javascripts/codemirror/smalltalk/smalltalk.js +134 -0
  16. data/app/assets/javascripts/html5.js +35 -0
  17. data/app/assets/javascripts/jquery.js +8981 -0
  18. data/app/assets/javascripts/jquery.textarea.js +267 -0
  19. data/app/assets/javascripts/jquery.tmpl.js +503 -0
  20. data/app/assets/javascripts/jquery.ui.js +272 -0
  21. data/app/assets/javascripts/json2.js +481 -0
  22. data/app/assets/javascripts/jtalk-development.js.coffee +4 -0
  23. data/app/assets/javascripts/jtalk-todos.js.coffee +4 -0
  24. data/app/assets/javascripts/jtalk.js.coffee +16 -0
  25. data/app/assets/javascripts/jtalk_core/boot.js +466 -0
  26. data/app/assets/javascripts/jtalk_core/st/.DS_Store +0 -0
  27. data/app/assets/javascripts/jtalk_core/st/Benchfib.js +159 -0
  28. data/app/assets/javascripts/jtalk_core/st/Canvas.js +1479 -0
  29. data/app/assets/javascripts/jtalk_core/st/Compiler.js +1587 -0
  30. data/app/assets/javascripts/jtalk_core/st/Examples.js +863 -0
  31. data/app/assets/javascripts/jtalk_core/st/HTML5.js +54 -0
  32. data/app/assets/javascripts/jtalk_core/st/IDE.js +3457 -0
  33. data/app/assets/javascripts/jtalk_core/st/JQuery.js +898 -0
  34. data/app/assets/javascripts/jtalk_core/st/Kernel.js +6761 -0
  35. data/app/assets/javascripts/jtalk_core/st/Parser.js +1655 -0
  36. data/app/assets/javascripts/jtalk_core/st/SUnit.js +1059 -0
  37. data/app/assets/stylesheets/codemirror.css +67 -0
  38. data/app/assets/stylesheets/codemirror_jtalk.css +21 -0
  39. data/app/assets/stylesheets/jtalk.css +369 -0
  40. data/app/assets/stylesheets/sunit.css +65 -0
  41. data/config/routes.rb +10 -0
  42. data/examples/todos/.gitignore +5 -0
  43. data/examples/todos/.rvmrc +4 -0
  44. data/examples/todos/Gemfile +11 -0
  45. data/examples/todos/Gemfile.lock +125 -0
  46. data/examples/todos/README +261 -0
  47. data/examples/todos/Rakefile +15 -0
  48. data/examples/todos/app/assets/images/rails.png +0 -0
  49. data/examples/todos/app/assets/javascripts/application.js.coffee +5 -0
  50. data/examples/todos/app/assets/javascripts/jtalk/Examples.deploy.js +863 -0
  51. data/examples/todos/app/assets/javascripts/jtalk/Examples.js +863 -0
  52. data/examples/todos/app/assets/smalltalk/Examples.st +397 -0
  53. data/examples/todos/app/assets/stylesheets/application.css +8 -0
  54. data/examples/todos/app/assets/stylesheets/jtalk-todos.css +154 -0
  55. data/examples/todos/app/controllers/application_controller.rb +3 -0
  56. data/examples/todos/app/controllers/todos_controller.rb +5 -0
  57. data/examples/todos/app/helpers/application_helper.rb +2 -0
  58. data/examples/todos/app/models/.gitkeep +0 -0
  59. data/examples/todos/app/views/todos/index.html.haml +16 -0
  60. data/examples/todos/config.ru +4 -0
  61. data/examples/todos/config/application.rb +31 -0
  62. data/examples/todos/config/boot.rb +6 -0
  63. data/examples/todos/config/database.yml +25 -0
  64. data/examples/todos/config/environment.rb +5 -0
  65. data/examples/todos/config/environments/development.rb +27 -0
  66. data/examples/todos/config/environments/production.rb +60 -0
  67. data/examples/todos/config/environments/test.rb +42 -0
  68. data/examples/todos/config/initializers/backtrace_silencers.rb +7 -0
  69. data/examples/todos/config/initializers/inflections.rb +10 -0
  70. data/examples/todos/config/initializers/mime_types.rb +5 -0
  71. data/examples/todos/config/initializers/secret_token.rb +7 -0
  72. data/examples/todos/config/initializers/session_store.rb +8 -0
  73. data/examples/todos/config/initializers/wrap_parameters.rb +14 -0
  74. data/examples/todos/config/locales/en.yml +5 -0
  75. data/examples/todos/config/routes.rb +3 -0
  76. data/examples/todos/log/.gitkeep +0 -0
  77. data/examples/todos/public/404.html +26 -0
  78. data/examples/todos/public/422.html +26 -0
  79. data/examples/todos/public/500.html +26 -0
  80. data/examples/todos/public/favicon.ico +0 -0
  81. data/examples/todos/public/robots.txt +5 -0
  82. data/examples/todos/script/rails +6 -0
  83. data/examples/todos/vendor/assets/stylesheets/.gitkeep +0 -0
  84. data/examples/todos/vendor/plugins/.gitkeep +0 -0
  85. data/jtalk-rails.gemspec +21 -0
  86. data/lib/jtalk-rails.rb +1 -0
  87. data/lib/jtalk/rails.rb +30 -0
  88. data/lib/jtalk/rails/engine.rb +12 -0
  89. data/lib/jtalk/rails/version.rb +6 -0
  90. metadata +167 -0
@@ -0,0 +1,397 @@
1
+ Widget subclass: #Counter
2
+ instanceVariableNames: 'count header'
3
+ category: 'Examples'!
4
+
5
+ !Counter methodsFor: 'actions'!
6
+
7
+ increase
8
+ count := count + 1.
9
+ header contents: [:html | html with: count asString]
10
+ !
11
+
12
+ decrease
13
+ count := count - 1.
14
+ header contents: [:html | html with: count asString]
15
+ ! !
16
+
17
+ !Counter methodsFor: 'initialization'!
18
+
19
+ initialize
20
+ super initialize.
21
+ count := 0
22
+ ! !
23
+
24
+ !Counter methodsFor: 'rendering'!
25
+
26
+ renderOn: html
27
+ header := html h1
28
+ with: count asString;
29
+ yourself.
30
+ html button
31
+ with: '++';
32
+ onClick: [self increase].
33
+ html button
34
+ with: '--';
35
+ onClick: [self decrease]
36
+ ! !
37
+
38
+ Widget subclass: #Tetris
39
+ instanceVariableNames: 'renderingContext timer speed score rows movingPiece'
40
+ category: 'Examples'!
41
+
42
+ !Tetris methodsFor: 'accessing'!
43
+
44
+ width
45
+ ^self class width
46
+ !
47
+
48
+ height
49
+ ^self class height
50
+ !
51
+
52
+ squares
53
+ ^self class squares
54
+ !
55
+
56
+ gluePiece: aPiece
57
+ aPiece glueOn: self
58
+ !
59
+
60
+ rows
61
+ "An array of rows. Each row is a collection of points."
62
+ ^rows
63
+ !
64
+
65
+ addRow: aCollection
66
+ self rows add: aCollection
67
+ ! !
68
+
69
+ !Tetris methodsFor: 'actions'!
70
+
71
+ startNewGame
72
+ self newGame.
73
+ timer ifNotNil: [timer clearInterval].
74
+ timer := [self nextStep] valueWithInterval: speed
75
+ !
76
+
77
+ nextStep
78
+ movingPiece ifNil: [self newPiece].
79
+ (movingPiece canMoveIn: self)
80
+ ifTrue: [movingPiece position: movingPiece position + (0@1)]
81
+ ifFalse: [self newPiece].
82
+ self redraw
83
+ !
84
+
85
+ redraw
86
+ renderingContext clearRectFrom: 0@ self width to: 0@ self height.
87
+ self
88
+ drawMap;
89
+ drawPiece
90
+ !
91
+
92
+ drawMap
93
+ renderingContext
94
+ fillStyle: '#fafafa';
95
+ fillRectFrom: 0@0 to: self width@self height.
96
+ renderingContext
97
+ lineWidth: 0.5;
98
+ strokeStyle: '#999'.
99
+ 0 to: self class squares x do: [:each | | x |
100
+ x := each * self class squareSize.
101
+ self drawLineFrom: x@0 to: x@self height].
102
+ 0 to: self class squares y do: [:each | | y |
103
+ y := each * self class squareSize.
104
+ self drawLineFrom: 0@y to: self width@y].
105
+ !
106
+
107
+ drawLineFrom: aPoint to: anotherPoint
108
+ renderingContext
109
+ beginPath;
110
+ moveTo: aPoint;
111
+ lineTo: anotherPoint;
112
+ stroke
113
+ !
114
+
115
+ newGame
116
+ rows := #().
117
+ movingPiece := nil.
118
+ speed := 200.
119
+ score := 0
120
+ !
121
+
122
+ newPiece
123
+ movingPiece := TetrisPiece atRandom
124
+ !
125
+
126
+ drawRows
127
+ self rows do: [:each |].
128
+ movingPiece ifNotNil: [movingPiece drawOn: renderingContext]
129
+ !
130
+
131
+ drawPiece
132
+ movingPiece ifNotNil: [
133
+ movingPiece drawOn: renderingContext]
134
+ ! !
135
+
136
+ !Tetris methodsFor: 'initialization'!
137
+
138
+ initialize
139
+ super initialize.
140
+ self newGame
141
+ ! !
142
+
143
+ !Tetris methodsFor: 'rendering'!
144
+
145
+ renderOn: html
146
+ html div
147
+ class: 'tetris';
148
+ with: [
149
+ html h3 with: 'Tetris'.
150
+ self renderCanvasOn: html.
151
+ self renderButtonsOn: html]
152
+ !
153
+
154
+ renderCanvasOn: html
155
+ | canvas |
156
+ canvas := html canvas.
157
+ canvas at: 'width' put: self width asString.
158
+ canvas at: 'height' put: self height asString.
159
+ renderingContext := CanvasRenderingContext tagBrush: canvas.
160
+ self redraw
161
+ !
162
+
163
+ renderButtonsOn: html
164
+ html div
165
+ class: 'tetris_buttons';
166
+ with: [
167
+ html button
168
+ with: 'New game';
169
+ onClick: [self startNewGame].
170
+ html button
171
+ with: 'play/pause';
172
+ onClick: [self update]]
173
+ ! !
174
+
175
+ !Tetris class methodsFor: 'accessing'!
176
+
177
+ squareSize
178
+ ^22
179
+ !
180
+
181
+ width
182
+ ^self squareSize * (self squares x)
183
+ !
184
+
185
+ height
186
+ ^self squareSize * (self squares y)
187
+ !
188
+
189
+ squares
190
+ ^10@15
191
+ ! !
192
+
193
+ Widget subclass: #TetrisPiece
194
+ instanceVariableNames: 'rotation position'
195
+ category: 'Examples'!
196
+
197
+ !TetrisPiece methodsFor: 'accessing'!
198
+
199
+ rotation
200
+ ^rotation ifNil: [rotation := 1]
201
+ !
202
+
203
+ rotation: aNumber
204
+ rotation := aNumber
205
+ !
206
+
207
+ position
208
+ ^position ifNil: [(Tetris squares x / 2) -1 @ 0]
209
+ !
210
+
211
+ position: aPoint
212
+ ^position := aPoint
213
+ !
214
+
215
+ bounds
216
+ self subclassResponsibility
217
+ !
218
+
219
+ color
220
+ ^'#afa'
221
+ !
222
+
223
+ height
224
+ ^2
225
+ ! !
226
+
227
+ !TetrisPiece methodsFor: 'drawing'!
228
+
229
+ drawOn: aRenderingContext
230
+ aRenderingContext fillStyle: self color.
231
+ self bounds do: [:each |
232
+ aRenderingContext
233
+ fillRectFrom: each + self position* Tetris squareSize to: 1@1 * Tetris squareSize;
234
+ strokeStyle: '#999';
235
+ lineWidth: 2;
236
+ strokeRectFrom: each + self position* Tetris squareSize to: 1@1 * Tetris squareSize]
237
+ ! !
238
+
239
+ !TetrisPiece methodsFor: 'testing'!
240
+
241
+ canMove
242
+ ^self position y < (Tetris squares y - self height)
243
+ !
244
+
245
+ canMoveIn: aTetris
246
+ ^self position y < (aTetris squares y - self height)
247
+ ! !
248
+
249
+ !TetrisPiece class methodsFor: 'instance creation'!
250
+
251
+ atRandom
252
+ ^(self subclasses at: self subclasses size atRandom) new
253
+ ! !
254
+
255
+ TetrisPiece subclass: #TetrisPieceO
256
+ instanceVariableNames: ''
257
+ category: 'Examples'!
258
+
259
+ !TetrisPieceO methodsFor: 'accessing'!
260
+
261
+ bounds
262
+ ^Array new
263
+ add: 0@0;
264
+ add: 0@1;
265
+ add: 1@0;
266
+ add: 1@1;
267
+ yourself
268
+ ! !
269
+
270
+ TetrisPiece subclass: #TetrisPieceL
271
+ instanceVariableNames: ''
272
+ category: 'Examples'!
273
+
274
+ !TetrisPieceL methodsFor: 'accessing'!
275
+
276
+ bounds
277
+ ^Array new
278
+ add: 0@0;
279
+ add: 0@1;
280
+ add: 0@2;
281
+ add: 1@2;
282
+ yourself
283
+ !
284
+
285
+ color
286
+ ^'#ffa'
287
+ !
288
+
289
+ height
290
+ ^3
291
+ ! !
292
+
293
+ TetrisPiece subclass: #TetrisPieceJ
294
+ instanceVariableNames: ''
295
+ category: 'Examples'!
296
+
297
+ !TetrisPieceJ methodsFor: 'accessing'!
298
+
299
+ color
300
+ ^'#aaf'
301
+ !
302
+
303
+ bounds
304
+ ^Array new
305
+ add: 1@0;
306
+ add: 1@1;
307
+ add: 1@2;
308
+ add: 0@2;
309
+ yourself
310
+ !
311
+
312
+ height
313
+ ^3
314
+ ! !
315
+
316
+ TetrisPiece subclass: #TetrisPieceI
317
+ instanceVariableNames: ''
318
+ category: 'Examples'!
319
+
320
+ !TetrisPieceI methodsFor: 'accessing'!
321
+
322
+ color
323
+ ^'#faa'
324
+ !
325
+
326
+ bounds
327
+ ^Array new
328
+ add: 0@0;
329
+ add: 0@1;
330
+ add: 0@2;
331
+ add: 0@3;
332
+ yourself
333
+ !
334
+
335
+ height
336
+ ^4
337
+ ! !
338
+
339
+ TetrisPiece subclass: #TetrisPieceT
340
+ instanceVariableNames: ''
341
+ category: 'Examples'!
342
+
343
+ !TetrisPieceT methodsFor: 'accessing'!
344
+
345
+ bounds
346
+ ^Array new
347
+ add: 0@0;
348
+ add: 1@0;
349
+ add: 2@0;
350
+ add: 1@1;
351
+ yourself
352
+ !
353
+
354
+ color
355
+ ^'#aaf'
356
+ ! !
357
+
358
+ Widget subclass: #Todos
359
+ instanceVariableNames: ''
360
+ category: 'Examples'!
361
+
362
+ !Todos methodsFor: 'not yet classified'!
363
+
364
+ renderOn: html
365
+ html div id: 'views'; with: [
366
+ html div id: 'tasks'; with: [
367
+ html h1 with: 'Todos'.
368
+ self renderFormOn: html.
369
+ html div class: 'items'.
370
+ self renderFooterOn: html]]
371
+ !
372
+
373
+ renderFormOn: html
374
+ html form
375
+ with: [
376
+ html input
377
+ at: 'type' put: 'text';
378
+ at: 'placeholder' put: 'What needs to be done?' ];
379
+ onSubmit: [ <alert('hi')> ]
380
+ !
381
+
382
+ renderFooterOn: html
383
+ html footer with: [
384
+ html a class: 'clear'; with: 'Clear completed'.
385
+ html div
386
+ class: 'count';
387
+ with: [html span class: 'countVal'];
388
+ append: ' left']
389
+ ! !
390
+
391
+ !Todos class methodsFor: 'not yet classified'!
392
+
393
+ renderDefault
394
+
395
+ '#todos-app' asJQuery append: self new
396
+ ! !
397
+
@@ -0,0 +1,8 @@
1
+ /*
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
5
+ *= require_self
6
+ *= require jtalk
7
+ *= require jtalk-todos
8
+ */
@@ -0,0 +1,154 @@
1
+ html, body {
2
+ margin: 0;
3
+ padding: 0;
4
+ }
5
+
6
+ body {
7
+ font-family: "Helvetica Neue", helvetica, arial, sans-serif;
8
+ font-size: 14px;
9
+ line-height: 1.4em;
10
+ background: #eeeeee;
11
+ color: #333333;
12
+ }
13
+
14
+ #views {
15
+ width: 520px;
16
+ margin: 0 auto 40px auto;
17
+ background: white;
18
+
19
+ -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
20
+ -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
21
+ -o-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
22
+ box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
23
+
24
+ -moz-border-radius: 0 0 5px 5px;
25
+ -o-border-radius: 0 0 5px 5px;
26
+ -webkit-border-radius: 0 0 5px 5px;
27
+ border-radius: 0 0 5px 5px;
28
+ }
29
+
30
+ #tasks {
31
+ padding: 20px;
32
+ }
33
+
34
+ #tasks h1 {
35
+ font-size: 36px;
36
+ font-weight: bold;
37
+ text-align: center;
38
+ padding: 0 0 10px 0;
39
+ }
40
+
41
+ #tasks input[type="text"] {
42
+ width: 466px;
43
+ font-size: 24px;
44
+ font-family: inherit;
45
+ line-height: 1.4em;
46
+ border: 0;
47
+ outline: none;
48
+ padding: 6px;
49
+ border: 1px solid #999999;
50
+
51
+ -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
52
+ -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
53
+ -o-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
54
+ box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
55
+ }
56
+
57
+ #tasks input::-webkit-input-placeholder {
58
+ font-style: italic;
59
+ }
60
+
61
+ #tasks .items {
62
+ margin: 10px 0;
63
+ list-style: none;
64
+ }
65
+
66
+ #tasks .item {
67
+ padding: 15px 20px 15px 0;
68
+ position: relative;
69
+ font-size: 24px;
70
+ border-bottom: 1px solid #cccccc;
71
+ }
72
+
73
+ #tasks .item.done span {
74
+ color: #777777;
75
+ text-decoration: line-through;
76
+ }
77
+
78
+ #tasks .item .destroy {
79
+ position: absolute;
80
+ right: 10px;
81
+ top: 16px;
82
+ display: none;
83
+ cursor: pointer;
84
+ width: 20px;
85
+ height: 20px;
86
+ background: url(../images/destroy.png) no-repeat center center;
87
+ }
88
+
89
+ #tasks .item:hover .destroy {
90
+ display: block;
91
+ }
92
+
93
+ #tasks .item .edit { display: none; }
94
+ #tasks .item.editing .edit { display: block; }
95
+ #tasks .item.editing .view { display: none; }
96
+
97
+ #tasks footer {
98
+ display: block;
99
+ margin: 20px -20px -20px -20px;
100
+ overflow: hidden;
101
+
102
+ color: #555555;
103
+ background: #f4fce8;
104
+ border-top: 1px solid #ededed;
105
+ padding: 0 20px;
106
+ line-height: 36px;
107
+
108
+ -moz-border-radius: 0 0 5px 5px;
109
+ -o-border-radius: 0 0 5px 5px;
110
+ -webkit-border-radius: 0 0 5px 5px;
111
+ border-radius: 0 0 5px 5px;
112
+ }
113
+
114
+ #tasks .clear {
115
+ display: block;
116
+ float: right;
117
+ line-height: 20px;
118
+ text-decoration: none;
119
+
120
+ background: rgba(0, 0, 0, 0.1);
121
+ color: #555555;
122
+ font-size: 11px;
123
+ margin-top: 8px;
124
+ padding: 0 10px 1px;
125
+
126
+ -moz-border-radius: 12px;
127
+ -webkit-border-radius: 12px;
128
+ -o-border-radius: 12px;
129
+ border-radius: 12px;
130
+
131
+ -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0 0;
132
+ -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0 0;
133
+ -o-box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0 0;
134
+ box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0 0;
135
+
136
+ cursor: pointer;
137
+ }
138
+
139
+ #tasks .clear:hover {
140
+ background: rgba(0, 0, 0, 0.15);
141
+ -moz-box-shadow: rgba(0, 0, 0, 0.3) 0 -1px 0 0;
142
+ -webkit-box-shadow: rgba(0, 0, 0, 0.3) 0 -1px 0 0;
143
+ -o-box-shadow: rgba(0, 0, 0, 0.3) 0 -1px 0 0;
144
+ box-shadow: rgba(0, 0, 0, 0.3) 0 -1px 0 0;
145
+ }
146
+
147
+ #tasks .clear:active {
148
+ position: relative;
149
+ top: 1px;
150
+ }
151
+
152
+ #tasks .count span {
153
+ font-weight: bold;
154
+ }