smalruby-editor 0.0.12 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of smalruby-editor might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/.travis.yml +2 -0
- data/LEGAL +32 -0
- data/Rakefile +1 -1
- data/app/assets/demos/default.xml +126 -0
- data/app/assets/demos/rgb_led_anode.xml +83 -0
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/javascripts/application.js +18 -1
- data/app/assets/javascripts/block_mode.js.coffee.erb +10 -0
- data/app/assets/javascripts/blocks/blockly.js.coffee.erb +34 -0
- data/app/assets/javascripts/blocks/character.js.coffee.erb +76 -0
- data/app/assets/javascripts/blocks/control.js.coffee.erb +180 -0
- data/app/assets/javascripts/blocks/data.js.coffee.erb +6 -0
- data/app/assets/javascripts/blocks/etc.js.coffee.erb +6 -0
- data/app/assets/javascripts/blocks/events.js.coffee.erb +82 -0
- data/app/assets/javascripts/blocks/hardware.js.coffee.erb +313 -0
- data/app/assets/javascripts/blocks/looks.js.coffee.erb +163 -0
- data/app/assets/javascripts/blocks/motion.js.coffee.erb +297 -0
- data/app/assets/javascripts/blocks/operators.js.coffee.erb +279 -0
- data/app/assets/javascripts/blocks/pen.js.coffee.erb +6 -0
- data/app/assets/javascripts/blocks/ruby.js.coffee.erb +74 -0
- data/app/assets/javascripts/blocks/sensing.js.coffee.erb +241 -0
- data/app/assets/javascripts/blocks/sound.js.coffee.erb +75 -0
- data/{public/favicon.ico → app/assets/javascripts/collections/.keep} +0 -0
- data/app/assets/javascripts/collections/character_set.js.coffee +12 -0
- data/app/assets/javascripts/generators/ruby.js.coffee.erb +188 -0
- data/app/assets/javascripts/models/.keep +0 -0
- data/app/assets/javascripts/models/character.js.coffee +66 -0
- data/app/assets/javascripts/models/scene.js.coffee +5 -0
- data/app/assets/javascripts/models/source_code.js.coffee +64 -0
- data/app/assets/javascripts/routers/.keep +0 -0
- data/app/assets/javascripts/ruby_mode.js.coffee.erb +12 -0
- data/app/assets/javascripts/smalruby.js.coffee +97 -0
- data/app/assets/javascripts/views/.keep +0 -0
- data/app/assets/javascripts/views/character_modal_view.js.coffee +148 -0
- data/app/assets/javascripts/views/character_selector_view.js.coffee +109 -0
- data/app/assets/javascripts/views/main_menu_view.js.coffee +264 -0
- data/app/assets/stylesheets/editor.css.scss +318 -2
- data/app/assets/stylesheets/toolbox.css.scss.erb +62 -0
- data/app/assets/templates/.keep +0 -0
- data/app/controllers/application_controller.rb +19 -0
- data/app/controllers/editor_controller.rb +4 -0
- data/app/controllers/source_codes_controller.rb +8 -2
- data/app/helpers/application_helper.rb +1 -0
- data/app/helpers/editor_helper.rb +46 -0
- data/app/models/source_code.rb +49 -6
- data/app/views/editor/_block_tab.html.haml +53 -0
- data/app/views/editor/_character_modal.html.haml +53 -0
- data/app/views/editor/_toolbox.html.haml +384 -0
- data/app/views/editor/demo.html.erb +16 -0
- data/app/views/editor/index.html.haml +60 -0
- data/app/views/layouts/application.html.erb +7 -0
- data/config/application.rb +1 -0
- data/config/initializers/teaspoon.rb +79 -0
- data/config/routes.rb +4 -0
- data/lib/smalruby_editor/version.rb +1 -1
- data/lib/tasks/gem.rake +7 -4
- data/lib/tasks/release.rake +43 -0
- data/public/apple-touch-icon.png +0 -0
- data/public/blockly/media/1x1.gif +0 -0
- data/public/blockly/media/click.mp3 +0 -0
- data/public/blockly/media/click.ogg +0 -0
- data/public/blockly/media/click.wav +0 -0
- data/public/blockly/media/delete.mp3 +0 -0
- data/public/blockly/media/delete.ogg +0 -0
- data/public/blockly/media/delete.wav +0 -0
- data/public/blockly/media/handclosed.cur +0 -0
- data/public/blockly/media/handopen.cur +0 -0
- data/public/blockly/media/quote0.png +0 -0
- data/public/blockly/media/quote1.png +0 -0
- data/public/blockly/media/trashbody.png +0 -0
- data/public/blockly/media/trashlid.png +0 -0
- data/public/blockly/media/tree.png +0 -0
- data/public/browserconfig.xml +1 -0
- data/public/large.png +0 -0
- data/public/smalruby/assets/ball1.png +0 -0
- data/public/smalruby/assets/ball2.png +0 -0
- data/public/smalruby/assets/ball3.png +0 -0
- data/public/smalruby/assets/ball4.png +0 -0
- data/public/smalruby/assets/ball5.png +0 -0
- data/public/smalruby/assets/ball6.png +0 -0
- data/public/smalruby/assets/car1.png +0 -0
- data/public/smalruby/assets/car2.png +0 -0
- data/public/smalruby/assets/car3.png +0 -0
- data/public/smalruby/assets/car4.png +0 -0
- data/public/smalruby/assets/cat1.png +0 -0
- data/public/smalruby/assets/cat2.png +0 -0
- data/public/smalruby/assets/cat3.png +0 -0
- data/public/smalruby/assets/frog1.png +0 -0
- data/public/smalruby/assets/piano_do.wav +0 -0
- data/public/smalruby/assets/piano_do_2.wav +0 -0
- data/public/smalruby/assets/piano_fa.wav +0 -0
- data/public/smalruby/assets/piano_mi.wav +0 -0
- data/public/smalruby/assets/piano_ra.wav +0 -0
- data/public/smalruby/assets/piano_re.wav +0 -0
- data/public/smalruby/assets/piano_si.wav +0 -0
- data/public/smalruby/assets/piano_so.wav +0 -0
- data/public/square.png +0 -0
- data/public/tiny.png +0 -0
- data/public/wide.png +0 -0
- data/smalruby-editor.gemspec +4 -0
- data/spec/acceptance/block_mode/blocks/character/new.feature +136 -0
- data/spec/acceptance/block_mode/blocks/control/await.feature +20 -0
- data/spec/acceptance/block_mode/blocks/control/await_until.feature +39 -0
- data/spec/acceptance/block_mode/blocks/control/break.feature +20 -0
- data/spec/acceptance/block_mode/blocks/control/if.feature +68 -0
- data/spec/acceptance/block_mode/blocks/control/if_else.feature +78 -0
- data/spec/acceptance/block_mode/blocks/control/loop.feature +45 -0
- data/spec/acceptance/block_mode/blocks/control/next.feature +20 -0
- data/spec/acceptance/block_mode/blocks/control/redo.feature +20 -0
- data/spec/acceptance/block_mode/blocks/control/sleep.feature +41 -0
- data/spec/acceptance/block_mode/blocks/control/times.feature +72 -0
- data/spec/acceptance/block_mode/blocks/control/until.feature +68 -0
- data/spec/acceptance/block_mode/blocks/events/on_click.feature +75 -0
- data/spec/acceptance/block_mode/blocks/events/on_hit.feature +83 -0
- data/spec/acceptance/block_mode/blocks/events/on_key_push_or_down.feature +171 -0
- data/spec/acceptance/block_mode/blocks/events/on_start.feature +75 -0
- data/spec/acceptance/block_mode/blocks/hardware/init_hardware.feature +44 -0
- data/spec/acceptance/block_mode/blocks/hardware/led_off.feature +75 -0
- data/spec/acceptance/block_mode/blocks/hardware/led_on.feature +75 -0
- data/spec/acceptance/block_mode/blocks/hardware/on_sensor_change.feature +81 -0
- data/spec/acceptance/block_mode/blocks/hardware/rgb_led_off.feature +81 -0
- data/spec/acceptance/block_mode/blocks/hardware/rgb_led_on.feature +87 -0
- data/spec/acceptance/block_mode/blocks/hardware/sensor_value.feature +100 -0
- data/spec/acceptance/block_mode/blocks/looks/hide.feature +69 -0
- data/spec/acceptance/block_mode/blocks/looks/say.feature +106 -0
- data/spec/acceptance/block_mode/blocks/looks/show.feature +69 -0
- data/spec/acceptance/block_mode/blocks/looks/vanish.feature +69 -0
- data/spec/acceptance/block_mode/blocks/motion/change_x_by.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/change_y_by.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/move.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/reach_wall.feature +98 -0
- data/spec/acceptance/block_mode/blocks/motion/rotate_left.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/rotate_right.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/self_angle.feature +92 -0
- data/spec/acceptance/block_mode/blocks/motion/self_x.feature +92 -0
- data/spec/acceptance/block_mode/blocks/motion/self_y.feature +92 -0
- data/spec/acceptance/block_mode/blocks/motion/set_angle.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/set_x.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/set_x_y.feature +95 -0
- data/spec/acceptance/block_mode/blocks/motion/set_y.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/turn.feature +69 -0
- data/spec/acceptance/block_mode/blocks/motion/turn_if_reach_wall.feature +69 -0
- data/spec/acceptance/block_mode/blocks/sensing/character_property.feature +114 -0
- data/spec/acceptance/block_mode/blocks/sensing/hit.feature +110 -0
- data/spec/acceptance/block_mode/blocks/sensing/input_key_push_or_down.feature +91 -0
- data/spec/acceptance/block_mode/blocks/sensing/input_mouse_pos_x.feature +39 -0
- data/spec/acceptance/block_mode/blocks/sensing/input_mouse_pos_y.feature +39 -0
- data/spec/acceptance/block_mode/blocks/sensing/input_mouse_push_or_down.feature +91 -0
- data/spec/acceptance/block_mode/blocks/sensing/time_now.feature +43 -0
- data/spec/acceptance/block_mode/blocks/sound/play.feature +81 -0
- data/spec/acceptance/block_mode/demo.feature +49 -0
- data/spec/acceptance/{text_editor → ruby_mode}/base.feature +11 -2
- data/spec/acceptance/{standalone → ruby_mode}/check.feature +8 -9
- data/spec/acceptance/ruby_mode/download.feature +33 -0
- data/spec/acceptance/{text_editor → ruby_mode}/load.feature +13 -13
- data/spec/acceptance/standalone/run.feature +17 -0
- data/spec/acceptance/standalone/save.feature +6 -6
- data/spec/helpers/editor_helper_spec.rb +110 -10
- data/spec/javascripts/collections/character_set_spec.coffee +41 -0
- data/spec/javascripts/models/character_spec.coffee +146 -0
- data/spec/javascripts/models/scene_spec.coffee +15 -0
- data/spec/javascripts/spec_helper.js +29 -0
- data/spec/spec_helper.rb +3 -8
- data/spec/steps/block_mode_steps.rb +37 -0
- data/spec/steps/global_variable.rb +30 -6
- data/spec/steps/text_editor_steps.rb +20 -2
- data/spec/teaspoon_env.rb +46 -0
- data/vendor/assets/javascripts/blockly/blockly_compressed.js +992 -0
- data/vendor/assets/javascripts/blockly/blocks_compressed.js +129 -0
- data/vendor/assets/javascripts/blockly/msg/js/ja.js +377 -0
- data/vendor/assets/javascripts/jquery.blockUI.js +619 -0
- metadata +290 -23
- data/app/assets/javascripts/editor.js.coffee.erb +0 -137
- data/app/views/editor/index.html.erb +0 -22
- data/spec/acceptance/text_editor/check.feature +0 -29
- data/spec/acceptance/text_editor/save.feature +0 -34
- data/spec/support/assets.rb +0 -18
@@ -2,18 +2,334 @@
|
|
2
2
|
// They will automatically be included in application.css.
|
3
3
|
// You can use Sass (SCSS) here: http://sass-lang.com/
|
4
4
|
|
5
|
+
$margin: 20px;
|
6
|
+
$character-size: 32px * 5;
|
7
|
+
$left-pane-width: $character-size + $margin * 2;
|
8
|
+
|
9
|
+
.dropdown-menu > li > a {
|
10
|
+
cursor: default;
|
11
|
+
}
|
12
|
+
|
5
13
|
#messages {
|
6
14
|
position: absolute;
|
7
15
|
right: 20px;
|
8
16
|
z-index: 9999;
|
9
17
|
}
|
10
18
|
|
11
|
-
|
19
|
+
.left-pane {
|
20
|
+
position: relative;
|
21
|
+
height: 100%;
|
22
|
+
float: left;
|
23
|
+
margin-left: -100%;
|
24
|
+
}
|
25
|
+
|
26
|
+
.right-pane {
|
27
|
+
position: relative;
|
28
|
+
height: 100%;
|
29
|
+
width: 100%;
|
30
|
+
float: left;
|
31
|
+
}
|
32
|
+
|
33
|
+
#modes-container {
|
12
34
|
position: absolute;
|
35
|
+
width: 100%;
|
13
36
|
left: 0;
|
14
37
|
top: 60px;
|
15
38
|
right: 0;
|
16
39
|
bottom: 0;
|
17
40
|
|
18
|
-
|
41
|
+
.modes-tab-pane {
|
42
|
+
position: relative;
|
43
|
+
height: 98%;
|
44
|
+
|
45
|
+
#block-tab-left-pane {
|
46
|
+
width: $left-pane-width;
|
47
|
+
|
48
|
+
#selectors-container {
|
49
|
+
position: relative;
|
50
|
+
margin-left: $margin;
|
51
|
+
width: $character-size;
|
52
|
+
height: 100%;
|
53
|
+
overflow: hidden;
|
54
|
+
|
55
|
+
ul.nav-pills {
|
56
|
+
margin: 0 0 4px 0;
|
57
|
+
font-size: 0.8em;
|
58
|
+
line-height: 1em;
|
59
|
+
|
60
|
+
li {
|
61
|
+
line-height: 12px;
|
62
|
+
|
63
|
+
a {
|
64
|
+
margin-right: 2px;
|
65
|
+
margin-tiop: 2px;
|
66
|
+
margin-bottom: 2px;
|
67
|
+
|
68
|
+
padding-top: 8px;
|
69
|
+
padding-bottom: 8px;
|
70
|
+
padding-right: 5px;
|
71
|
+
padding-left: 5px;
|
72
|
+
|
73
|
+
line-height: 12px;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
#selectors-tab-content {
|
79
|
+
$border-size: 5px;
|
80
|
+
$border-color: #0088cc;
|
81
|
+
|
82
|
+
position: absolute;
|
83
|
+
width: $character-size + $margin * 3;
|
84
|
+
top: 32px;
|
85
|
+
left: 0;
|
86
|
+
right: 0;
|
87
|
+
bottom: -2px;
|
88
|
+
overflow-y: scroll;
|
89
|
+
|
90
|
+
.selector-tab {
|
91
|
+
.item {
|
92
|
+
position: relative;
|
93
|
+
width: $character-size;
|
94
|
+
height: $character-size;
|
95
|
+
|
96
|
+
a {
|
97
|
+
text-decoration: none;
|
98
|
+
cursor: pointer;
|
99
|
+
font-size: 1.5em;
|
100
|
+
vertical-align: middle;
|
101
|
+
display: table-cell;
|
102
|
+
}
|
103
|
+
|
104
|
+
.item-info {
|
105
|
+
position: absolute;
|
106
|
+
left: 0;
|
107
|
+
top: 0;
|
108
|
+
right: 0;
|
109
|
+
bottom: 0;
|
110
|
+
width: $character-size;
|
111
|
+
height: $character-size;
|
112
|
+
|
113
|
+
color: gray;
|
114
|
+
|
115
|
+
.name {
|
116
|
+
position: absolute;
|
117
|
+
left: $border-size * 2;
|
118
|
+
top: $border-size * 2;
|
119
|
+
|
120
|
+
font-size: 1.5em;
|
121
|
+
}
|
122
|
+
|
123
|
+
.attributes {
|
124
|
+
position: absolute;
|
125
|
+
left: $border-size * 2;
|
126
|
+
bottom: $border-size * 2;
|
127
|
+
|
128
|
+
font-size: 0.8em;
|
129
|
+
line-height: 1.1em;
|
130
|
+
text-align: left;
|
131
|
+
}
|
132
|
+
|
133
|
+
a.add-block-button {
|
134
|
+
position: absolute;
|
135
|
+
right: $border-size * 2;
|
136
|
+
bottom: $border-size * 2;
|
137
|
+
padding-left: 0.5em;
|
138
|
+
padding-top: 0.5em;
|
139
|
+
|
140
|
+
font-size: 2em;
|
141
|
+
|
142
|
+
z-index: 1;
|
143
|
+
}
|
144
|
+
|
145
|
+
a.remove-button {
|
146
|
+
position: absolute;
|
147
|
+
right: $border-size * 2;
|
148
|
+
top: $border-size * 2;
|
149
|
+
padding-left: 0.5em;
|
150
|
+
padding-bottom: 0.5em;
|
151
|
+
|
152
|
+
z-index: 1;
|
153
|
+
}
|
154
|
+
}
|
155
|
+
|
156
|
+
a.character {
|
157
|
+
position: relative;
|
158
|
+
overflow: hidden;
|
159
|
+
display: table-cell;
|
160
|
+
text-align: center;
|
161
|
+
vertical-align: middle;
|
162
|
+
|
163
|
+
width: $character-size - $border-size * 2;
|
164
|
+
height: $character-size - $border-size * 2;
|
165
|
+
|
166
|
+
border: $border-size solid white;
|
167
|
+
|
168
|
+
img, div {
|
169
|
+
margin: -$border-size;
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
173
|
+
a.character:hover {
|
174
|
+
border: $border-size solid $border-color;
|
175
|
+
}
|
176
|
+
|
177
|
+
a#add-character-button.character {
|
178
|
+
text-align: center;
|
179
|
+
vertical-align: middle;
|
180
|
+
font-size: 1em;
|
181
|
+
|
182
|
+
border: $border-size dashed lightgray;
|
183
|
+
|
184
|
+
i {
|
185
|
+
font-size: 2em;
|
186
|
+
}
|
187
|
+
}
|
188
|
+
|
189
|
+
a#add-character-button.character:hover {
|
190
|
+
border: $border-size dashed $border-color;
|
191
|
+
}
|
192
|
+
}
|
193
|
+
}
|
194
|
+
}
|
195
|
+
}
|
196
|
+
}
|
197
|
+
|
198
|
+
#block-tab-right-pane {
|
199
|
+
#blockly-div {
|
200
|
+
margin-left: $left-pane-width;
|
201
|
+
position: absolute;
|
202
|
+
left: 0;
|
203
|
+
top: 0;
|
204
|
+
right: $margin;
|
205
|
+
bottom: 0;
|
206
|
+
|
207
|
+
-ms-touch-action: none;
|
208
|
+
|
209
|
+
svg.blocklySvg {
|
210
|
+
overflow: hidden;
|
211
|
+
}
|
212
|
+
}
|
213
|
+
}
|
214
|
+
|
215
|
+
#text-editor {
|
216
|
+
position: absolute;
|
217
|
+
left: 0;
|
218
|
+
top: 0;
|
219
|
+
right: 0;
|
220
|
+
bottom: 0;
|
221
|
+
|
222
|
+
font-size: 16pt;
|
223
|
+
}
|
224
|
+
}
|
225
|
+
}
|
226
|
+
|
227
|
+
#character-modal {
|
228
|
+
$modal-frame-size: 1px;
|
229
|
+
$modal-body-margin: 15px;
|
230
|
+
|
231
|
+
$modal-margin: $modal-frame-size + $modal-body-margin;
|
232
|
+
|
233
|
+
$preview-width: 320px;
|
234
|
+
$preview-height: 240px;
|
235
|
+
|
236
|
+
$attributes-height: 160px;
|
237
|
+
|
238
|
+
$left-pane-width: $preview-width;
|
239
|
+
$right-pane-width: $character-size * 3 + $modal-body-margin;
|
240
|
+
|
241
|
+
$modal-width: $left-pane-width + $right-pane-width + $modal-margin * 2;
|
242
|
+
$modal-height: $preview-height + $attributes-height + $modal-margin * 2;
|
243
|
+
|
244
|
+
width: $modal-width;
|
245
|
+
height: $modal-height;
|
246
|
+
margin-left: -($modal-width / 2);
|
247
|
+
|
248
|
+
.modal-body {
|
249
|
+
position: relative;
|
250
|
+
height: 100%;
|
251
|
+
max-height: $modal-height - $modal-body-margin * 2;
|
252
|
+
|
253
|
+
#character-modal-left-pane {
|
254
|
+
width: $left-pane-width;
|
255
|
+
overflow: hidden;
|
256
|
+
|
257
|
+
#character-modal-preview {
|
258
|
+
position: relative;
|
259
|
+
|
260
|
+
width: $preview-width;
|
261
|
+
height: $preview-height;
|
262
|
+
background-color: black;
|
263
|
+
overflow: hidden;
|
264
|
+
|
265
|
+
#character-modal-character {
|
266
|
+
position: absolute;
|
267
|
+
|
268
|
+
-ms-touch-action: none;
|
269
|
+
|
270
|
+
img {
|
271
|
+
width: 100%;
|
272
|
+
height: 100%;
|
273
|
+
}
|
274
|
+
}
|
275
|
+
}
|
276
|
+
|
277
|
+
#character-modal-attributes {
|
278
|
+
position: absolute;
|
279
|
+
width: $preview-width;
|
280
|
+
top: $preview-height + $modal-body-margin;
|
281
|
+
left: 0;
|
282
|
+
right: 0;
|
283
|
+
bottom: 0;
|
284
|
+
|
285
|
+
#character-modal-form {
|
286
|
+
margin-bottom: 0;
|
287
|
+
|
288
|
+
.control-group {
|
289
|
+
margin-bottom: 8px;
|
290
|
+
|
291
|
+
.control-label {
|
292
|
+
width: 100px;
|
293
|
+
}
|
294
|
+
|
295
|
+
.controls {
|
296
|
+
margin-left: 100px + $modal-body-margin;
|
297
|
+
|
298
|
+
input[type=range] {
|
299
|
+
padding: 0;
|
300
|
+
}
|
301
|
+
}
|
302
|
+
}
|
303
|
+
}
|
304
|
+
}
|
305
|
+
}
|
306
|
+
|
307
|
+
#character-modal-right-pane {
|
308
|
+
overflow: hidden;
|
309
|
+
|
310
|
+
#character-modal-costume-selector {
|
311
|
+
margin-left: $left-pane-width;
|
312
|
+
position: absolute;
|
313
|
+
left: 0;
|
314
|
+
top: 0;
|
315
|
+
right: 0;
|
316
|
+
bottom: 0;
|
317
|
+
width: $right-pane-width + $modal-body-margin * 2;
|
318
|
+
overflow-y: scroll;
|
319
|
+
|
320
|
+
ul.thumbnails {
|
321
|
+
margin: 0 0 10px 0;
|
322
|
+
|
323
|
+
li {
|
324
|
+
margin-left: $modal-body-margin;
|
325
|
+
margin-bottom: $modal-body-margin;
|
326
|
+
|
327
|
+
a.active {
|
328
|
+
background-color: #0088cc;
|
329
|
+
}
|
330
|
+
}
|
331
|
+
}
|
332
|
+
}
|
333
|
+
}
|
334
|
+
}
|
19
335
|
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
<%
|
2
|
+
# hsv_to_rgb メソッドは http://c4se.hatenablog.com/entry/2013/08/04/190937 をほぼコピーした
|
3
|
+
def hsv_to_rgb(h, s, v)
|
4
|
+
s /= 100.0
|
5
|
+
v /= 100.0
|
6
|
+
c = v * s
|
7
|
+
x = c * (1 - ((h / 60.0) % 2 - 1).abs)
|
8
|
+
m = v - c
|
9
|
+
r, g, b = *(
|
10
|
+
case
|
11
|
+
when h < 60 then [c, x, 0]
|
12
|
+
when h < 120 then [x, c, 0]
|
13
|
+
when h < 180 then [0, c, x]
|
14
|
+
when h < 240 then [0, x, c]
|
15
|
+
when h < 300 then [x, 0, c]
|
16
|
+
else [c, 0, x]
|
17
|
+
end
|
18
|
+
)
|
19
|
+
[r, g, b].map { |channel|
|
20
|
+
((channel + m) * 255).ceil
|
21
|
+
}.map { |c|
|
22
|
+
'%02x' % c
|
23
|
+
}.join
|
24
|
+
end
|
25
|
+
|
26
|
+
hues = %w(
|
27
|
+
225
|
28
|
+
264
|
29
|
+
296
|
30
|
+
33
|
31
|
+
43
|
32
|
+
43
|
33
|
+
43
|
34
|
+
200
|
35
|
+
93
|
36
|
+
93
|
37
|
+
340
|
38
|
+
208
|
39
|
+
).map(&:to_i)
|
40
|
+
|
41
|
+
colors = hues.map { |h|
|
42
|
+
[hsv_to_rgb(h, 100, 80), hsv_to_rgb(h, 100, 100)]
|
43
|
+
}
|
44
|
+
|
45
|
+
colors.each.with_index(1) do |(color, active_color), index|
|
46
|
+
%>
|
47
|
+
|
48
|
+
#\:<%= '%x' % index %> {
|
49
|
+
.blocklyTreeRow {
|
50
|
+
padding-top: 0.25em;
|
51
|
+
padding-bottom: 0.25em;
|
52
|
+
border-left: 0.75em solid #<%= color %>;
|
53
|
+
}
|
54
|
+
|
55
|
+
.blocklyTreeRow.blocklyTreeSelected {
|
56
|
+
color: white;
|
57
|
+
font-weight: bold;
|
58
|
+
background-color: #<%= active_color %> !important;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
<% end %>
|
File without changes
|
@@ -1,5 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
class ApplicationController < ActionController::Base
|
2
3
|
# Prevent CSRF attacks by raising an exception.
|
3
4
|
# For APIs, you may want to use :null_session instead.
|
4
5
|
protect_from_forgery with: :exception
|
6
|
+
|
7
|
+
helper_method :standalone?
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
# スタンドアローンモードかどうかを返す
|
12
|
+
def standalone?
|
13
|
+
return false if Rails.env == 'production'
|
14
|
+
return true if Rails.env == 'standalone'
|
15
|
+
|
16
|
+
if Rails.env != 'test' &&
|
17
|
+
(ENV['SMALRUBY_EDITOR_STANDALONE_MODE'] ||
|
18
|
+
File.exist?(Rails.root.join('tmp', 'standalone')))
|
19
|
+
true
|
20
|
+
else
|
21
|
+
false
|
22
|
+
end
|
23
|
+
end
|
5
24
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'nkf'
|
3
3
|
|
4
4
|
class SourceCodesController < ApplicationController
|
5
|
-
before_filter :check_whether_standalone, only: :write
|
5
|
+
before_filter :check_whether_standalone, only: [:write, :run]
|
6
6
|
|
7
7
|
def check
|
8
8
|
render json: SourceCode.new(source_code_params).check_syntax
|
@@ -51,10 +51,16 @@ class SourceCodesController < ApplicationController
|
|
51
51
|
render json: { source_code: info }, content_type: request.format
|
52
52
|
end
|
53
53
|
|
54
|
+
def run
|
55
|
+
source_code = SourceCode.new(source_code_params)
|
56
|
+
path = Pathname("~/#{source_code.filename}").expand_path
|
57
|
+
render json: source_code.run(path)
|
58
|
+
end
|
59
|
+
|
54
60
|
private
|
55
61
|
|
56
62
|
def check_whether_standalone
|
57
|
-
unless
|
63
|
+
unless standalone?
|
58
64
|
fail "#{self.class.name}##{action_name}はstandaloneモードのみの機能です"
|
59
65
|
end
|
60
66
|
end
|