smalruby-editor 0.2.1 → 0.2.2

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.

Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/LEGAL +4 -3
  3. data/app/assets/javascripts/blocks/character.js.coffee.erb +7 -3
  4. data/app/assets/javascripts/blocks/events.js.coffee.erb +7 -10
  5. data/app/assets/javascripts/blocks/hardware.js.coffee.erb +119 -31
  6. data/app/assets/javascripts/blocks/motion.js.coffee.erb +16 -20
  7. data/app/assets/javascripts/blocks/operators.js.coffee.erb +1 -1
  8. data/app/assets/javascripts/blocks/pen.js.coffee.erb +2 -1
  9. data/app/assets/javascripts/blocks/ruby.js.coffee.erb +3 -3
  10. data/app/assets/javascripts/blocks/sensing.js.coffee.erb +8 -8
  11. data/app/assets/javascripts/blocks/sound.js.coffee.erb +3 -1
  12. data/app/assets/javascripts/fix_blockly.js.erb +105 -0
  13. data/app/assets/javascripts/generators/ruby.js.coffee.erb +3 -0
  14. data/app/assets/javascripts/msg/en_us.js +67 -17
  15. data/app/assets/javascripts/msg/ja.js +151 -95
  16. data/app/assets/javascripts/{smalruby.js.coffee → smalruby.js.coffee.erb} +35 -16
  17. data/app/assets/javascripts/views/character_selector_view.js.coffee +2 -2
  18. data/app/assets/javascripts/views/{load_modal_view.js.coffee → load_modal_view.js.coffee.erb} +8 -2
  19. data/app/assets/javascripts/views/main_menu_view.js.coffee.erb +33 -48
  20. data/app/assets/javascripts/views/signin_modal_view.js.coffee.erb +43 -0
  21. data/app/assets/stylesheets/application.css +3 -1
  22. data/app/assets/stylesheets/toolbox.css.scss.erb +2 -56
  23. data/app/assets/stylesheets/toolbox_default.css.scss.erb +34 -0
  24. data/app/assets/stylesheets/toolbox_smalrubot_s1.css.scss.erb +31 -0
  25. data/app/assets/stylesheets/toolbox_smalrubot_v3.css.scss.erb +32 -0
  26. data/app/controllers/application_controller.rb +5 -0
  27. data/app/controllers/source_codes_controller.rb +6 -3
  28. data/app/helpers/application_helper.rb +12 -0
  29. data/app/helpers/editor_helper.rb +25 -0
  30. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_action.rb +13 -0
  31. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_action_with_sec.rb +14 -0
  32. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_ir_photoreflector_value.rb +29 -0
  33. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_led_turn_on_or_off.rb +22 -0
  34. data/app/views/editor/_block_tab.html.haml +7 -6
  35. data/app/views/editor/_reset_modal.html.haml +4 -4
  36. data/app/views/editor/_signin_modal.html.haml +8 -9
  37. data/app/views/editor/_toolbox_default.html.haml +504 -0
  38. data/app/views/editor/_toolbox_smalrubot_s1.html.haml +171 -0
  39. data/app/views/editor/_toolbox_smalrubot_v3.html.haml +177 -0
  40. data/app/views/editor/index.html.haml +12 -2
  41. data/app/views/layouts/application.html.erb +1 -0
  42. data/config/environments/production.rb +1 -0
  43. data/config/locales/en.yml +19 -16
  44. data/config/locales/ja.yml +28 -25
  45. data/demos/hardware_led.rb.xml +79 -79
  46. data/lib/smalruby_editor.rb +58 -0
  47. data/lib/smalruby_editor/config.rb +22 -0
  48. data/lib/smalruby_editor/version.rb +1 -1
  49. data/public/blockly/media/anon.jpeg +0 -0
  50. data/public/blockly/media/handclosed.cur +0 -0
  51. data/public/blockly/media/handdelete.cur +0 -0
  52. data/public/blockly/media/progress.gif +0 -0
  53. data/public/blockly/media/sprites.png +0 -0
  54. data/smalruby-editor.gemspec +2 -1
  55. data/spec/acceptance/base.feature +3 -3
  56. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_action.feature +107 -0
  57. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_action_with_sec.feature +151 -0
  58. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_ir_photoreflector_value.feature +100 -0
  59. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_led_turn_on_or_off.feature +73 -0
  60. data/spec/acceptance/ruby_mode/translate.feature +6 -6
  61. data/spec/acceptance/standalone/save.feature +3 -3
  62. data/spec/acceptance/standalone/signin.feature +1 -2
  63. data/spec/lib/smalruby_editor_spec.rb +21 -11
  64. data/spec/models/concerns/ruby_to_block/block/hardware__smalrubot_s1_spec.rb +279 -0
  65. data/vendor/assets/javascripts/blockly/blockly_compressed.js +995 -668
  66. data/vendor/assets/javascripts/blockly/blocks_compressed.js +138 -114
  67. data/vendor/assets/javascripts/blockly/msg/js/en_us.js +6 -6
  68. data/vendor/assets/javascripts/blockly/msg/js/ja.js +42 -28
  69. metadata +66 -25
  70. data/app/assets/javascripts/fix_blockly.js +0 -128
  71. data/app/assets/javascripts/views/signin_modal_view.js.coffee +0 -33
  72. data/app/views/editor/_toolbox.html.haml +0 -496
  73. data/public/blockly/media/trashbody.png +0 -0
  74. data/public/blockly/media/trashlid.png +0 -0
  75. data/public/blockly/media/tree.png +0 -0
@@ -0,0 +1,171 @@
1
+ %xml{:id => 'toolbox', :style => 'display: none'}
2
+ %category{:name => tt('.motion')}
3
+ - category = 'hardware'
4
+ - subcategory = 'smalrubot_s1'
5
+ %block{type: "#{category}_#{subcategory}_action"}
6
+ %field{name: 'ACTION'}<
7
+ forward
8
+
9
+ %block{type: "#{category}_#{subcategory}_action_with_sec"}
10
+ %field{name: 'ACTION'}<
11
+ forward
12
+ = toolbox_number_value('SEC', 0.5)
13
+
14
+ - category = 'looks'
15
+ %category{:name => tt('.looks')}
16
+ %block{:type => "#{category}_say"}
17
+ %value{name: 'TEXT'}
18
+ - category = 'hardware'
19
+ - subcategory = 'smalrubot_s1'
20
+ %block{type: "#{category}_#{subcategory}_ir_photoreflector_value"}
21
+ - category = 'hardware'
22
+ - subcategory = 'smalrubot_s1'
23
+ %block{type: "#{category}_#{subcategory}_led_turn_on_or_off"}
24
+ %field{name: 'OOO'}<
25
+ turn_on
26
+
27
+ %category{:name => tt('.data'), :custom => 'VARIABLE'}
28
+
29
+ - category = 'events'
30
+ %category{:name => tt('.events')}
31
+ -# まずは
32
+ %block{:type => "#{category}_on_start"}
33
+
34
+ -# キーボードの[▼キー]が[▼押された/押され続けている]とき
35
+ %block{:type => "#{category}_on_key_push_or_down"}
36
+ = toolbox_key_field
37
+ = toolbox_pod_field
38
+
39
+ - category = 'control'
40
+ %category{:name => tt('.control')}
41
+ -# ずっと
42
+ %block{:type => "#{category}_loop"}
43
+
44
+ -# ( )回繰り返す
45
+ %block{:type => "#{category}_times"}
46
+ = toolbox_number_value('COUNT', 10)
47
+
48
+ -# < >まで繰り返す
49
+ %block{:type => "#{category}_until"}
50
+
51
+ -# 繰り返しから脱出する
52
+ %block{:type => "#{category}_break"}
53
+
54
+ -# 次の繰り返しにジャンプする
55
+ %block{:type => "#{category}_next"}
56
+
57
+ -# 現在の繰り返しをやり直す
58
+ %block{:type => "#{category}_redo"}
59
+
60
+ -# ( )秒待つ
61
+ %block{:type => "#{category}_sleep"}
62
+ = toolbox_number_value('SEC', 1)
63
+
64
+ -# < >まで待つ
65
+ %block{:type => "#{category}_await_until"}
66
+
67
+ -# ほんの少し待つ
68
+ %block{:type => "#{category}_await"}
69
+
70
+ -# もし< >なら
71
+ %block{:type => "#{category}_if"}
72
+
73
+ -# もし< >なら~でなければ
74
+ %block{:type => "#{category}_if_else"}
75
+
76
+ - category = 'sensing'
77
+ %category{:name => tt('.sensing')}
78
+ -# 条件:キーボードの[▼キー]が[▼押された]
79
+ %block{:type => "#{category}_input_key_push_or_down"}
80
+ = toolbox_key_field
81
+ = toolbox_pod_field
82
+
83
+ -# 条件:マウスの[▼左ボタン]が[▼押された]
84
+ %block{:type => "#{category}_input_mouse_push_or_down"}
85
+ = toolbox_pod_field
86
+
87
+ -# [ ]と聞いて待つ
88
+ -#%block{:type => "#{category}_ask"}
89
+ -# = toolbox_text_value('TEXT', 'あなたのお名前は?')
90
+
91
+ -# 変数:答え
92
+ -#%block{:type => "#{category}_answer"}
93
+
94
+ -# 変数:タイマー
95
+ -#%block{:type => "#{category}_timer_count"}
96
+
97
+ -# タイマーをリセット
98
+ -#%block{:type => "#{category}_timer_reset"}
99
+
100
+ - category = 'hardware'
101
+ - subcategory = 'smalrubot_s1'
102
+ %block{type: "#{category}_#{subcategory}_ir_photoreflector_value"}
103
+
104
+ - category = 'operators'
105
+ %category{:name => tt('.operators')}
106
+ -# 条件:( ) < ( )
107
+ %block{:type => "#{category}_compare_gt"}
108
+
109
+ -# 条件:( ) <= ( )
110
+ %block{:type => "#{category}_compare_gte"}
111
+
112
+ -# 条件:( ) = ( )
113
+ %block{:type => "#{category}_compare_eq"}
114
+
115
+ -# 条件:( ) >= ( )
116
+ %block{:type => "#{category}_compare_lte"}
117
+
118
+ -# 条件:( ) > ( )
119
+ %block{:type => "#{category}_compare_lt"}
120
+
121
+ -# 条件:< > かつ < >
122
+ %block{:type => "#{category}_and"}
123
+
124
+ -# 条件:< > または < >
125
+ %block{:type => "#{category}_or"}
126
+
127
+ -# 条件:< > ではない
128
+ %block{:type => "#{category}_negate"}
129
+
130
+ -# 条件:真
131
+ %block{:type => "#{category}_true"}
132
+
133
+ -# 条件:偽
134
+ %block{:type => "#{category}_false"}
135
+
136
+ -# 変数:( ) + ( )
137
+ %block{:type => "#{category}_add"}
138
+
139
+ -# 変数:( ) - ( )
140
+ %block{:type => "#{category}_minus"}
141
+
142
+ -# 変数:( ) * ( )
143
+ %block{:type => "#{category}_multiply"}
144
+
145
+ -# 変数:( ) / ( )
146
+ %block{:type => "#{category}_divide"}
147
+
148
+ -# 変数:( )から( )までの乱数
149
+ %block{:type => "#{category}_rand"}
150
+ = toolbox_number_value('A', 1)
151
+ = toolbox_number_value('B', 10)
152
+
153
+ -# 変数:( )を( )で割った余り
154
+ %block{:type => "#{category}_modulo"}
155
+ = toolbox_number_value('A', 5)
156
+ = toolbox_number_value('B', 2)
157
+
158
+ -# 変数:( )を丸める
159
+ %block{:type => "#{category}_round"}
160
+ = toolbox_number_value('A', 0.5)
161
+
162
+ -# 変数:( )の[▼数学関数]
163
+ %block{:type => "#{category}_math_method"}
164
+ = toolbox_number_value('NUM', 9)
165
+ %field{:name => 'METHOD'}<
166
+ Math.sqrt(%num%)
167
+
168
+ -# 数値
169
+ %block{:type => 'math_number'}
170
+ %field{:name => 'NUM'}<
171
+ 0
@@ -0,0 +1,177 @@
1
+ %xml{:id => 'toolbox', :style => 'display: none'}
2
+ %category{:name => tt('.motion')}
3
+ - category = 'hardware'
4
+ - subcategory = 'smalrubot_v3'
5
+ %block{type: "#{category}_#{subcategory}_action"}
6
+ %field{name: 'ACTION'}<
7
+ forward
8
+
9
+ %block{type: "#{category}_#{subcategory}_action_with_sec"}
10
+ %field{name: 'ACTION'}<
11
+ forward
12
+ = toolbox_number_value('SEC', 0.5)
13
+
14
+ %block{type: "#{category}_#{subcategory}_motor_set_speed"}
15
+ = toolbox_number_value('SPEED', 100)
16
+
17
+ %category{:name => tt('.looks')}
18
+ - category = 'hardware'
19
+ - subcategory = 'smalrubot_v3'
20
+ %block{type: "#{category}_#{subcategory}_led_turn_on_or_off"}
21
+ %field{name: 'COLOUR'}<
22
+ red
23
+ %field{name: 'OOO'}<
24
+ turn_on
25
+
26
+ %category{:name => tt('.data'), :custom => 'VARIABLE'}
27
+
28
+ - category = 'events'
29
+ %category{:name => tt('.events')}
30
+ -# まずは
31
+ %block{:type => "#{category}_on_start"}
32
+
33
+ -# キーボードの[▼キー]が[▼押された/押され続けている]とき
34
+ %block{:type => "#{category}_on_key_push_or_down"}
35
+ = toolbox_key_field
36
+ = toolbox_pod_field
37
+
38
+ - category = 'control'
39
+ %category{:name => tt('.control')}
40
+ -# ずっと
41
+ %block{:type => "#{category}_loop"}
42
+
43
+ -# ( )回繰り返す
44
+ %block{:type => "#{category}_times"}
45
+ = toolbox_number_value('COUNT', 10)
46
+
47
+ -# < >まで繰り返す
48
+ %block{:type => "#{category}_until"}
49
+
50
+ -# 繰り返しから脱出する
51
+ %block{:type => "#{category}_break"}
52
+
53
+ -# 次の繰り返しにジャンプする
54
+ %block{:type => "#{category}_next"}
55
+
56
+ -# 現在の繰り返しをやり直す
57
+ %block{:type => "#{category}_redo"}
58
+
59
+ -# ( )秒待つ
60
+ %block{:type => "#{category}_sleep"}
61
+ = toolbox_number_value('SEC', 1)
62
+
63
+ -# < >まで待つ
64
+ %block{:type => "#{category}_await_until"}
65
+
66
+ -# ほんの少し待つ
67
+ %block{:type => "#{category}_await"}
68
+
69
+ -# もし< >なら
70
+ %block{:type => "#{category}_if"}
71
+
72
+ -# もし< >なら~でなければ
73
+ %block{:type => "#{category}_if_else"}
74
+
75
+ - category = 'sensing'
76
+ %category{:name => tt('.sensing')}
77
+ -# 条件:キーボードの[▼キー]が[▼押された]
78
+ %block{:type => "#{category}_input_key_push_or_down"}
79
+ = toolbox_key_field
80
+ = toolbox_pod_field
81
+
82
+ -# 条件:マウスの[▼左ボタン]が[▼押された]
83
+ %block{:type => "#{category}_input_mouse_push_or_down"}
84
+ = toolbox_pod_field
85
+
86
+ -# [ ]と聞いて待つ
87
+ -#%block{:type => "#{category}_ask"}
88
+ -# = toolbox_text_value('TEXT', 'あなたのお名前は?')
89
+
90
+ -# 変数:答え
91
+ -#%block{:type => "#{category}_answer"}
92
+
93
+ -# 変数:タイマー
94
+ -#%block{:type => "#{category}_timer_count"}
95
+
96
+ -# タイマーをリセット
97
+ -#%block{:type => "#{category}_timer_reset"}
98
+
99
+ - category = 'hardware'
100
+ - subcategory = 'smalrubot_v3'
101
+ %block{type: "#{category}_#{subcategory}_touch_sensor_pressed_or_released"}
102
+ %block{type: "#{category}_#{subcategory}_light_sensor_value"}
103
+ %block{type: "#{category}_#{subcategory}_motor_speed"}
104
+
105
+ - category = 'operators'
106
+ %category{:name => tt('.operators')}
107
+ -# 条件:( ) < ( )
108
+ %block{:type => "#{category}_compare_gt"}
109
+
110
+ -# 条件:( ) <= ( )
111
+ %block{:type => "#{category}_compare_gte"}
112
+
113
+ -# 条件:( ) = ( )
114
+ %block{:type => "#{category}_compare_eq"}
115
+
116
+ -# 条件:( ) >= ( )
117
+ %block{:type => "#{category}_compare_lte"}
118
+
119
+ -# 条件:( ) > ( )
120
+ %block{:type => "#{category}_compare_lt"}
121
+
122
+ -# 条件:< > かつ < >
123
+ %block{:type => "#{category}_and"}
124
+
125
+ -# 条件:< > または < >
126
+ %block{:type => "#{category}_or"}
127
+
128
+ -# 条件:< > ではない
129
+ %block{:type => "#{category}_negate"}
130
+
131
+ -# 条件:真
132
+ %block{:type => "#{category}_true"}
133
+
134
+ -# 条件:偽
135
+ %block{:type => "#{category}_false"}
136
+
137
+ -# 変数:( ) + ( )
138
+ %block{:type => "#{category}_add"}
139
+
140
+ -# 変数:( ) - ( )
141
+ %block{:type => "#{category}_minus"}
142
+
143
+ -# 変数:( ) * ( )
144
+ %block{:type => "#{category}_multiply"}
145
+
146
+ -# 変数:( ) / ( )
147
+ %block{:type => "#{category}_divide"}
148
+
149
+ -# 変数:( )から( )までの乱数
150
+ %block{:type => "#{category}_rand"}
151
+ = toolbox_number_value('A', 1)
152
+ = toolbox_number_value('B', 10)
153
+
154
+ -# 変数:( )を( )で割った余り
155
+ %block{:type => "#{category}_modulo"}
156
+ = toolbox_number_value('A', 5)
157
+ = toolbox_number_value('B', 2)
158
+
159
+ -# 変数:( )を丸める
160
+ %block{:type => "#{category}_round"}
161
+ = toolbox_number_value('A', 0.5)
162
+
163
+ -# 変数:( )の[▼数学関数]
164
+ %block{:type => "#{category}_math_method"}
165
+ = toolbox_number_value('NUM', 9)
166
+ %field{:name => 'METHOD'}<
167
+ Math.sqrt(%num%)
168
+
169
+ -# 数値
170
+ %block{:type => 'math_number'}
171
+ %field{:name => 'NUM'}<
172
+ 0
173
+
174
+ %category{:name => tt('.etc')}
175
+ - category = 'hardware'
176
+ -# ハードウェアを準備する
177
+ %block{:type => "#{category}_init_hardware"}
@@ -126,5 +126,15 @@
126
126
  = render 'reset_modal'
127
127
 
128
128
  - if raspberrypi?
129
- %script{type: "text/javascript"}
130
- $(function() { $('div[aria-level="1"][aria-posinset="4"],div[aria-level="1"][aria-posinset="10"]').hide(); });
129
+ :javascript
130
+ $(function() {
131
+ $('div[aria-level="1"][aria-posinset="4"],div[aria-level="1"][aria-posinset="10"]').hide();
132
+ });
133
+
134
+ - if session[:username]
135
+ :javascript
136
+ window.Smalruby.username = '#{h session[:username]}';
137
+
138
+ - if SmalrubyEditor::Config.features.is_a?(Array)
139
+ :javascript
140
+ window.Smalruby.Features = #{SmalrubyEditor::Config.features.to_json};
@@ -13,6 +13,7 @@
13
13
  <meta name="msapplication-wide310x150logo" content="wide.png" />
14
14
  <meta name="msapplication-square310x310logo" content="large.png" />
15
15
  <%= stylesheet_link_tag "application", media: "all" %>
16
+ <%= stylesheet_link_tag "toolbox_#{toolbox_css_name}", media: "all" %>
16
17
  <%= javascript_include_tag "application" %>
17
18
  <%= javascript_include_tag "blockly/msg/js/#{blockly_message_locale_name}" %>
18
19
  <%= javascript_include_tag "msg/#{blockly_message_locale_name}" %>
@@ -67,6 +67,7 @@ SmalrubyEditor::Application.configure do
67
67
  config.assets.precompile += %w(
68
68
  blockly/msg/js/*.js
69
69
  msg/*.js
70
+ toolbox_*.css
70
71
  )
71
72
 
72
73
  # Ignore bad email addresses and do not raise email delivery errors.
@@ -3,6 +3,15 @@ en:
3
3
  smalruby_editor: "Smalruby v%{version}"
4
4
  "ok": "OK"
5
5
  cancel: "Cancel"
6
+ reset: &reset "Reset"
7
+ login: &login "Login"
8
+ name: "Name"
9
+
10
+ controllers:
11
+ source_codes:
12
+ not_ruby_program: " isn't ruby program."
13
+ not_exist: " does not exist."
14
+ exist: " already exist."
6
15
 
7
16
  editor:
8
17
  index:
@@ -13,9 +22,9 @@ en:
13
22
  load: "Load"
14
23
  save: "Save"
15
24
  check: "Check"
16
- reset: "Reset"
25
+ reset: *reset
17
26
  logout: "Logout"
18
- login: "Login"
27
+ login: *login
19
28
 
20
29
  block_tab:
21
30
  character: "Character"
@@ -25,29 +34,15 @@ en:
25
34
 
26
35
  toolbox:
27
36
  motion: "Motion"
28
- motion_move: "Move"
29
- motion_rotate: "Rotate"
30
- motion_actuator: "Actuator"
31
37
  looks: "Looks"
32
38
  sound: "Sound"
33
39
  pen: "Pen"
34
40
  data: "Data"
35
- data_variables: "Variables"
36
41
  events: "Events"
37
42
  control: "Control"
38
- control_loop: "Loop"
39
- control_wait: "Wait"
40
- control_if: "If-Then"
41
43
  sensing: "Sensing"
42
- sensing_general: "General"
43
- sensing_hardware: "Hardware"
44
44
  operators: "Operators"
45
- operators_calculate: "Calculate"
46
- operators_string: "String"
47
- operators_condition: "Condition"
48
45
  etc: "More Blocks"
49
- etc_ruby: "Ruby"
50
- etc_hardware: "Hardware"
51
46
  hello: "Hello!"
52
47
  world: "world"
53
48
  text: "text"
@@ -64,3 +59,11 @@ en:
64
59
  find_program: "Find program"
65
60
  computer: "From this computer..."
66
61
  remix: "Remix"
62
+
63
+ reset_modal:
64
+ title: "Are you sure you want to reset ?"
65
+ message: "Your program will disappear!"
66
+
67
+ signin_modal:
68
+ message: "Input your name<br>not to mix with other people's program."
69
+ username_placeholder: "username, ID, nickname, etc..."