smalruby-editor 0.2.1-x86-mingw32 → 0.2.2-x86-mingw32
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/LEGAL +4 -3
- data/app/assets/javascripts/blocks/character.js.coffee.erb +7 -3
- data/app/assets/javascripts/blocks/events.js.coffee.erb +7 -10
- data/app/assets/javascripts/blocks/hardware.js.coffee.erb +119 -31
- data/app/assets/javascripts/blocks/motion.js.coffee.erb +16 -20
- data/app/assets/javascripts/blocks/operators.js.coffee.erb +1 -1
- data/app/assets/javascripts/blocks/pen.js.coffee.erb +2 -1
- data/app/assets/javascripts/blocks/ruby.js.coffee.erb +3 -3
- data/app/assets/javascripts/blocks/sensing.js.coffee.erb +8 -8
- data/app/assets/javascripts/blocks/sound.js.coffee.erb +3 -1
- data/app/assets/javascripts/fix_blockly.js.erb +105 -0
- data/app/assets/javascripts/generators/ruby.js.coffee.erb +3 -0
- data/app/assets/javascripts/msg/en_us.js +67 -17
- data/app/assets/javascripts/msg/ja.js +151 -95
- data/app/assets/javascripts/{smalruby.js.coffee → smalruby.js.coffee.erb} +35 -16
- data/app/assets/javascripts/views/character_selector_view.js.coffee +2 -2
- data/app/assets/javascripts/views/{load_modal_view.js.coffee → load_modal_view.js.coffee.erb} +8 -2
- data/app/assets/javascripts/views/main_menu_view.js.coffee.erb +33 -48
- data/app/assets/javascripts/views/signin_modal_view.js.coffee.erb +43 -0
- data/app/assets/stylesheets/application.css +3 -1
- data/app/assets/stylesheets/toolbox.css.scss.erb +2 -56
- data/app/assets/stylesheets/toolbox_default.css.scss.erb +34 -0
- data/app/assets/stylesheets/toolbox_smalrubot_s1.css.scss.erb +31 -0
- data/app/assets/stylesheets/toolbox_smalrubot_v3.css.scss.erb +32 -0
- data/app/controllers/application_controller.rb +5 -0
- data/app/controllers/source_codes_controller.rb +6 -3
- data/app/helpers/application_helper.rb +12 -0
- data/app/helpers/editor_helper.rb +25 -0
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_action.rb +13 -0
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_action_with_sec.rb +14 -0
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_ir_photoreflector_value.rb +29 -0
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_led_turn_on_or_off.rb +22 -0
- data/app/views/editor/_block_tab.html.haml +7 -6
- data/app/views/editor/_reset_modal.html.haml +4 -4
- data/app/views/editor/_signin_modal.html.haml +8 -9
- data/app/views/editor/_toolbox_default.html.haml +504 -0
- data/app/views/editor/_toolbox_smalrubot_s1.html.haml +171 -0
- data/app/views/editor/_toolbox_smalrubot_v3.html.haml +177 -0
- data/app/views/editor/index.html.haml +12 -2
- data/app/views/layouts/application.html.erb +1 -0
- data/config/environments/production.rb +1 -0
- data/config/locales/en.yml +19 -16
- data/config/locales/ja.yml +28 -25
- data/demos/hardware_led.rb.xml +79 -79
- data/lib/smalruby_editor/config.rb +22 -0
- data/lib/smalruby_editor/version.rb +1 -1
- data/lib/smalruby_editor.rb +58 -0
- data/public/assets/application-71c4890fe0ea2e896fc0acff41cdb0ad.js +39 -0
- data/public/assets/application-71c4890fe0ea2e896fc0acff41cdb0ad.js.gz +0 -0
- data/public/assets/{application-d5358d75a2c4e570c749b333c59b55ab.css → application-c196e243630d74071981a16041bf391d.css} +1 -1
- data/public/assets/application-c196e243630d74071981a16041bf391d.css.gz +0 -0
- data/public/assets/blockly/msg/js/en_us-d5e1938b2d57c1df954f4411b9165d10.js +1 -0
- data/public/assets/blockly/msg/js/en_us-d5e1938b2d57c1df954f4411b9165d10.js.gz +0 -0
- data/public/assets/blockly/msg/js/ja-9f676d46458a2802b8f5a797c90ae8a4.js +1 -0
- data/public/assets/blockly/msg/js/ja-9f676d46458a2802b8f5a797c90ae8a4.js.gz +0 -0
- data/public/assets/manifest-f3d29c6d66b959abe4294a899733e4f0.json +1 -0
- data/public/assets/msg/en_us-213fb4a57884078038725a2991776f47.js +1 -0
- data/public/assets/msg/en_us-213fb4a57884078038725a2991776f47.js.gz +0 -0
- data/public/assets/msg/ja-aeface7456b479021e977a0387204036.js +1 -0
- data/public/assets/msg/ja-aeface7456b479021e977a0387204036.js.gz +0 -0
- data/public/assets/toolbox_default-e023d3f7a2cc7cc1f54a1224577b3c26.css +1 -0
- data/public/assets/toolbox_default-e023d3f7a2cc7cc1f54a1224577b3c26.css.gz +0 -0
- data/public/assets/toolbox_smalrubot_s1-18d28dc4b99723b60a3f538b742027df.css +1 -0
- data/public/assets/toolbox_smalrubot_s1-18d28dc4b99723b60a3f538b742027df.css.gz +0 -0
- data/public/assets/toolbox_smalrubot_v3-9af26ff13d4496890c4a391f65f95bcd.css +1 -0
- data/public/assets/toolbox_smalrubot_v3-9af26ff13d4496890c4a391f65f95bcd.css.gz +0 -0
- data/public/blockly/media/anon.jpeg +0 -0
- data/public/blockly/media/handclosed.cur +0 -0
- data/public/blockly/media/handdelete.cur +0 -0
- data/public/blockly/media/progress.gif +0 -0
- data/public/blockly/media/sprites.png +0 -0
- data/smalruby-editor.gemspec +2 -1
- data/spec/acceptance/base.feature +3 -3
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_action.feature +107 -0
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_action_with_sec.feature +151 -0
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_ir_photoreflector_value.feature +100 -0
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_led_turn_on_or_off.feature +73 -0
- data/spec/acceptance/ruby_mode/translate.feature +6 -6
- data/spec/acceptance/standalone/save.feature +3 -3
- data/spec/acceptance/standalone/signin.feature +1 -2
- data/spec/lib/smalruby_editor_spec.rb +21 -11
- data/spec/models/concerns/ruby_to_block/block/hardware__smalrubot_s1_spec.rb +279 -0
- data/vendor/assets/javascripts/blockly/blockly_compressed.js +995 -668
- data/vendor/assets/javascripts/blockly/blocks_compressed.js +138 -114
- data/vendor/assets/javascripts/blockly/msg/js/en_us.js +6 -6
- data/vendor/assets/javascripts/blockly/msg/js/ja.js +42 -28
- metadata +66 -25
- data/app/assets/javascripts/fix_blockly.js +0 -128
- data/app/assets/javascripts/views/signin_modal_view.js.coffee +0 -33
- data/app/views/editor/_toolbox.html.haml +0 -496
- data/public/assets/application-b305a6ea9e7c045a8e170bbf6fb09dd1.js +0 -35
- data/public/assets/application-b305a6ea9e7c045a8e170bbf6fb09dd1.js.gz +0 -0
- data/public/assets/application-d5358d75a2c4e570c749b333c59b55ab.css.gz +0 -0
- data/public/assets/blockly/msg/js/en_us-6f7333af29688596ef863fa36a22cb41.js +0 -1
- data/public/assets/blockly/msg/js/en_us-6f7333af29688596ef863fa36a22cb41.js.gz +0 -0
- data/public/assets/blockly/msg/js/ja-d2cbf808bda8180571bc5f39141a98fe.js +0 -1
- data/public/assets/blockly/msg/js/ja-d2cbf808bda8180571bc5f39141a98fe.js.gz +0 -0
- data/public/assets/manifest-b1b843b1334b3b973824ab66b1f7a077.json +0 -1
- data/public/assets/msg/en_us-c6f8f0084f38560bf933b742ede64a52.js +0 -1
- data/public/assets/msg/en_us-c6f8f0084f38560bf933b742ede64a52.js.gz +0 -0
- data/public/assets/msg/ja-3703e6ceebd04ae1f08b0e871800539d.js +0 -1
- data/public/assets/msg/ja-3703e6ceebd04ae1f08b0e871800539d.js.gz +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
@@ -1,3 +1,8 @@
|
|
1
|
+
<%
|
2
|
+
require 'smalruby_editor'
|
3
|
+
require 'smalruby_editor/blockly_message_helper'
|
4
|
+
%>
|
5
|
+
|
1
6
|
window.SmalrubyEditor = {}
|
2
7
|
window.changed = false
|
3
8
|
window.textEditor = null
|
@@ -16,7 +21,7 @@ window.successMessage = (title, msg = '', selector = '#messages') ->
|
|
16
21
|
window.errorMessage = (msg, selector = '#messages') ->
|
17
22
|
html = $('<div class="alert alert-error" style="display: none">')
|
18
23
|
.append('<button type="button" class="close" data-dismiss="alert">×</button>')
|
19
|
-
.append(
|
24
|
+
.append("<h4><i class=\"icon-exclamation-sign\"></i>#{<%= bm('common_error') %>}</h4>")
|
20
25
|
.append(msg)
|
21
26
|
$(selector).append(html)
|
22
27
|
html.fadeIn('slow')
|
@@ -30,12 +35,16 @@ window.Smalruby =
|
|
30
35
|
Collections: {}
|
31
36
|
Views: {}
|
32
37
|
Routers: {}
|
38
|
+
Features: []
|
39
|
+
|
40
|
+
username: null
|
41
|
+
|
33
42
|
initialize: ->
|
34
43
|
$.ajaxSetup
|
35
44
|
headers:
|
36
45
|
'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
|
37
46
|
|
38
|
-
# HACK: Underscore
|
47
|
+
# HACK: Underscoreのテンプレートの\<\%, \%\>はHamlと組み合わせたときに
|
39
48
|
# HTML要素の属性がHamlによってエスケープされてしまうため使いにく
|
40
49
|
# い。そこで、それぞれ{{, }}に変更する。
|
41
50
|
_.extend(_.templateSettings, {
|
@@ -44,17 +53,6 @@ window.Smalruby =
|
|
44
53
|
interpolate: /{{=([\s\S]+?)}}/
|
45
54
|
})
|
46
55
|
|
47
|
-
# HACK: 一度開いたジャンルを2回クリックしても閉じないように修正
|
48
|
-
Blockly.Toolbox.TreeNode.prototype.onMouseDown = (e) ->
|
49
|
-
if @hasChildren() && @isUserCollapsible_
|
50
|
-
@toggle()
|
51
|
-
@select()
|
52
|
-
else if @isSelected()
|
53
|
-
#@getTree().setSelectedItem(null)
|
54
|
-
else
|
55
|
-
@select()
|
56
|
-
@updateRow()
|
57
|
-
|
58
56
|
@Collections.CharacterSet = new Smalruby.CharacterSet()
|
59
57
|
|
60
58
|
@Views.MainMenuView = new Smalruby.MainMenuView()
|
@@ -72,7 +70,7 @@ window.Smalruby =
|
|
72
70
|
Smalruby.downloading = false
|
73
71
|
window.onbeforeunload = (event) ->
|
74
72
|
if !Smalruby.downloading && window.changed
|
75
|
-
return '
|
73
|
+
return <%= bm('.will_disapper_your_program') %>
|
76
74
|
else
|
77
75
|
Smalruby.downloading = false
|
78
76
|
return
|
@@ -85,8 +83,6 @@ window.Smalruby =
|
|
85
83
|
toolbox: document.getElementById('toolbox')
|
86
84
|
trashcan: true
|
87
85
|
|
88
|
-
Blockly.Toolbox.tree_.expandAll()
|
89
|
-
|
90
86
|
@blocklyFirst = true
|
91
87
|
@blocklyLoading = false
|
92
88
|
Blockly.addChangeListener =>
|
@@ -110,6 +106,7 @@ window.Smalruby =
|
|
110
106
|
textEditor.setTheme('ace/theme/clouds')
|
111
107
|
textEditor.setShowInvisibles(true)
|
112
108
|
textEditor.gotoLine(0, 0)
|
109
|
+
textEditor.setReadOnly(@isEnabled('readonly_ruby_mode'))
|
113
110
|
textEditor.on 'change', (e) =>
|
114
111
|
unless @translating
|
115
112
|
window.changed = true
|
@@ -120,6 +117,8 @@ window.Smalruby =
|
|
120
117
|
session.setTabSize(2)
|
121
118
|
session.setUseSoftTabs(true)
|
122
119
|
|
120
|
+
@addCharacterFromBeginning()
|
121
|
+
|
123
122
|
loadXml: (data, workspace = Blockly.mainWorkspace) ->
|
124
123
|
xml = Blockly.Xml.textToDom(data)
|
125
124
|
workspace.clear()
|
@@ -172,6 +171,7 @@ window.Smalruby =
|
|
172
171
|
$('#filename').val('')
|
173
172
|
window.textEditor.getSession().getDocument().setValue('')
|
174
173
|
window.textEditor.moveCursorTo(0, 0)
|
174
|
+
@addCharacterFromBeginning()
|
175
175
|
window.changed = false
|
176
176
|
|
177
177
|
# 国際化したメッセージを取得する
|
@@ -182,5 +182,24 @@ window.Smalruby =
|
|
182
182
|
else
|
183
183
|
name
|
184
184
|
|
185
|
+
addCharacterFromBeginning: ->
|
186
|
+
if @isEnabled('add_character_from_beginning')
|
187
|
+
constume = 'cat1.png'
|
188
|
+
c = new Smalruby.Character
|
189
|
+
name: @Collections.CharacterSet.uniqueName(constume)
|
190
|
+
costumes: [constume]
|
191
|
+
x: 200
|
192
|
+
y: 200
|
193
|
+
@Collections.CharacterSet.add(c)
|
194
|
+
@Views.CharacterSelectorView.prevBlock = null
|
195
|
+
@Views.CharacterSelectorView.addBlock_(c)
|
196
|
+
window.changed = false
|
197
|
+
|
198
|
+
isEnabled: (feature) ->
|
199
|
+
@Features.indexOf(feature) != -1
|
200
|
+
|
185
201
|
$(document).ready ->
|
186
202
|
Smalruby.initialize()
|
203
|
+
|
204
|
+
if Smalruby.username == null && Smalruby.isEnabled('must_signin')
|
205
|
+
Smalruby.Views.SigninModalView.render()
|
@@ -61,14 +61,14 @@ Smalruby.CharacterSelectorView = Backbone.View.extend({
|
|
61
61
|
@render()
|
62
62
|
|
63
63
|
addBlock_: (character) ->
|
64
|
-
newBlock =
|
64
|
+
newBlock = Blockly.Block.obtain(Blockly.mainWorkspace, 'character_new')
|
65
65
|
newBlock.setCharacter(character)
|
66
66
|
newBlock.initSvg()
|
67
67
|
newBlock.render()
|
68
68
|
@moveByNewBlock_(newBlock)
|
69
69
|
newBlock.select()
|
70
70
|
|
71
|
-
onStartBlock =
|
71
|
+
onStartBlock = Blockly.Block.obtain(Blockly.mainWorkspace, 'events_on_start')
|
72
72
|
onStartBlock.initSvg()
|
73
73
|
onStartBlock.render()
|
74
74
|
newBlock.getInput('DO').connection.connect(onStartBlock.previousConnection)
|
data/app/assets/javascripts/views/{load_modal_view.js.coffee → load_modal_view.js.coffee.erb}
RENAMED
@@ -1,4 +1,9 @@
|
|
1
|
-
|
1
|
+
<%
|
2
|
+
require 'smalruby_editor'
|
3
|
+
require 'smalruby_editor/blockly_message_helper'
|
4
|
+
%>
|
5
|
+
|
6
|
+
# load dialog view
|
2
7
|
Smalruby.LoadModalView = Backbone.View.extend
|
3
8
|
events:
|
4
9
|
'click #load-modal-ok-button': 'onOk'
|
@@ -26,6 +31,7 @@ Smalruby.LoadModalView = Backbone.View.extend
|
|
26
31
|
|
27
32
|
unblock = =>
|
28
33
|
@$el.find('.modal-body').unblock()
|
34
|
+
null # HACK: if return unblock(), does not call fail().
|
29
35
|
|
30
36
|
@$el.modal('show')
|
31
37
|
|
@@ -51,7 +57,7 @@ Smalruby.LoadModalView = Backbone.View.extend
|
|
51
57
|
.then(unblock, unblock)
|
52
58
|
.fail =>
|
53
59
|
@$el.modal('hide')
|
54
|
-
errorMessage('
|
60
|
+
errorMessage(<%= bm('.error') %>)
|
55
61
|
|
56
62
|
onOk: ->
|
57
63
|
switch @type
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'smalruby_editor/blockly_message_helper'
|
4
4
|
%>
|
5
5
|
|
6
|
-
#
|
6
|
+
# navigation menu view
|
7
7
|
Smalruby.MainMenuView = Backbone.View.extend
|
8
8
|
el: '#main-menu'
|
9
9
|
|
@@ -152,34 +152,26 @@ Smalruby.MainMenuView = Backbone.View.extend
|
|
152
152
|
clearMessages()
|
153
153
|
|
154
154
|
@blockUI
|
155
|
-
title:
|
156
|
-
"""
|
157
|
-
#{<%= bm('.download_blockui_title') %>}
|
158
|
-
"""
|
155
|
+
title: <%= bm('.download_blockui_title') %>
|
159
156
|
message: <%= bm('.download_blockui_message') %>
|
160
|
-
notice:
|
161
|
-
"""
|
162
|
-
ダウンロードしたプログラムは、<br>
|
163
|
-
Windowsだと「ruby #{sourceCode.get('filename')}」、<br>
|
164
|
-
Macだと「rsdl #{sourceCode.get('filename')}」で実行できます。
|
165
|
-
"""
|
166
157
|
|
167
158
|
sourceCode.save2()
|
168
159
|
.then (data) ->
|
169
160
|
window.changed = false
|
170
|
-
window.successMessage('
|
161
|
+
window.successMessage(goog.getMsg(<%= bm('.download_succeeded') %>,
|
162
|
+
{ filename: sourceCode.get('filename') }))
|
171
163
|
Smalruby.downloading = true
|
172
164
|
$('#download-link').click()
|
173
165
|
.then(@unblockUI, @unblockUI)
|
174
166
|
.fail ->
|
175
|
-
window.errorMessage('
|
167
|
+
window.errorMessage(<%= bm('.download_error') %>)
|
176
168
|
|
177
169
|
onLoadLocal: (e) ->
|
178
170
|
e.preventDefault()
|
179
171
|
|
180
172
|
# TODO: window.changed -> Smalruby.Models.SourceCode.changed
|
181
173
|
if window.changed
|
182
|
-
return unless confirm('
|
174
|
+
return unless confirm(<%= bm('.load_confirm') %>)
|
183
175
|
|
184
176
|
Smalruby.Views.LoadModalView.render()
|
185
177
|
|
@@ -188,7 +180,7 @@ Smalruby.MainMenuView = Backbone.View.extend
|
|
188
180
|
|
189
181
|
# TODO: window.changed -> Smalruby.Models.SourceCode.changed
|
190
182
|
if window.changed
|
191
|
-
return unless confirm('
|
183
|
+
return unless confirm(<%= bm('.load_confirm') %>)
|
192
184
|
$('input#load-file[name="source_code[file]"]').click()
|
193
185
|
|
194
186
|
onSave: (e) ->
|
@@ -196,7 +188,7 @@ Smalruby.MainMenuView = Backbone.View.extend
|
|
196
188
|
|
197
189
|
filename = $.trim($('#filename').val())
|
198
190
|
if filename.length <= 0
|
199
|
-
window.errorMessage('
|
191
|
+
window.errorMessage(<%= bm('.save_error_no_name') %>)
|
200
192
|
$('#filename').focus()
|
201
193
|
return
|
202
194
|
|
@@ -208,29 +200,23 @@ Smalruby.MainMenuView = Backbone.View.extend
|
|
208
200
|
clearMessages()
|
209
201
|
|
210
202
|
@blockUI
|
211
|
-
title:
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
message: 'プログラムをセーブしています。'
|
216
|
-
notice:
|
217
|
-
"""
|
218
|
-
プログラムの名前は「#{sourceCode.get('filename')}」です。<br>
|
219
|
-
プログラムはホームディレクトリにセーブします。<br>
|
220
|
-
"""
|
203
|
+
title: <%= bm('.save_blockui_title') %>
|
204
|
+
message: <%= bm('.save_blockui_message') %>
|
205
|
+
notice: goog.getMsg(<%= bm('.save_blockui_notice') %>,
|
206
|
+
{ filename: sourceCode.get('filename') })
|
221
207
|
|
222
|
-
errorMsg = '
|
208
|
+
errorMsg = <%= bm('.save_error_message') %>
|
223
209
|
sourceCode.save2()
|
224
210
|
.then (data) ->
|
225
211
|
sourceCode.write()
|
226
212
|
.then (data) =>
|
227
213
|
@confirmOverwrite_.call @, data, sourceCode, ->
|
228
|
-
errorMsg = '
|
214
|
+
errorMsg = <%= bm('.save_canceled') %>
|
229
215
|
.then(@unblockUI, @unblockUI)
|
230
216
|
.done ->
|
231
217
|
Smalruby.savedFilename = sourceCode.get('filename')
|
232
218
|
window.changed = false
|
233
|
-
window.successMessage('
|
219
|
+
window.successMessage(<%= bm('.save_succeeded') %>)
|
234
220
|
.fail ->
|
235
221
|
window.errorMessage(errorMsg)
|
236
222
|
|
@@ -242,31 +228,24 @@ Smalruby.MainMenuView = Backbone.View.extend
|
|
242
228
|
sourceCode = @getSourceCode()
|
243
229
|
|
244
230
|
@blockUI
|
245
|
-
title:
|
246
|
-
|
247
|
-
|
248
|
-
"""
|
249
|
-
message: 'プログラムの文法をチェックしています。'
|
250
|
-
notice:
|
251
|
-
"""
|
252
|
-
このチェックは簡易的なものですので、<br>
|
253
|
-
プログラムを動かすとエラーが見つかるかもしれません。
|
254
|
-
"""
|
231
|
+
title: <%= bm('.check_blockui_title') %>
|
232
|
+
message: <%= bm('.check_blockui_message') %>
|
233
|
+
notice: <%= bm('.check_blockui_notice') %>
|
255
234
|
|
256
235
|
sourceCode.check()
|
257
236
|
.then (data) ->
|
258
237
|
if data.length == 0
|
259
|
-
window.successMessage('
|
238
|
+
window.successMessage(<%= bm('.check_succeeded') %>, <%= bm('.check_succeeded_notice') %>)
|
260
239
|
else
|
261
240
|
for errorInfo in data
|
262
241
|
do (errorInfo) ->
|
263
|
-
msg = "#{errorInfo.row}
|
242
|
+
msg = "#{errorInfo.row}#{<%= bm('.common_lines') %>}"
|
264
243
|
if errorInfo.column > 0
|
265
|
-
msg += "
|
244
|
+
msg += "#{<%= bm('.common_comma') %>}#{errorInfo.column}#{<%= bm('.common_letters') %>}"
|
266
245
|
window.errorMessage(msg + ": #{errorInfo.message}")
|
267
246
|
.then(@unblockUI, @unblockUI)
|
268
247
|
.fail ->
|
269
|
-
errorMessage('
|
248
|
+
errorMessage(<%= bm('.check_error') %>)
|
270
249
|
|
271
250
|
onReset: (e) ->
|
272
251
|
e.preventDefault()
|
@@ -291,13 +270,17 @@ Smalruby.MainMenuView = Backbone.View.extend
|
|
291
270
|
})
|
292
271
|
.then(
|
293
272
|
(data) ->
|
273
|
+
Smalruby.username = null
|
294
274
|
$('#signin-button').show()
|
295
275
|
$('#signout-button').hide()
|
296
276
|
$('#username-label').text('')
|
297
277
|
$('#username-button').hide()
|
298
|
-
successMessage('
|
278
|
+
successMessage(<%= bm('.signout_succeeded') %>)
|
279
|
+
|
280
|
+
if Smalruby.isEnabled('must_signin')
|
281
|
+
Smalruby.Views.SigninModalView.render()
|
299
282
|
->
|
300
|
-
errorMessage('
|
283
|
+
errorMessage(<%= bm('.signout_error') %>)
|
301
284
|
)
|
302
285
|
|
303
286
|
onUsername: (e) ->
|
@@ -358,7 +341,8 @@ Smalruby.MainMenuView = Backbone.View.extend
|
|
358
341
|
confirmOverwrite_: (data, sourceCode, canceled = $.noop) ->
|
359
342
|
if data.source_code.error
|
360
343
|
if sourceCode.get('filename') == Smalruby.savedFilename ||
|
361
|
-
confirm(
|
344
|
+
confirm(goog.getMsg(<%= bm('.common_confirm_overwrite') %>,
|
345
|
+
{ filename: sourceCode.get('filename') }))
|
362
346
|
sourceCode.write(true)
|
363
347
|
else
|
364
348
|
canceled.call()
|
@@ -366,7 +350,8 @@ Smalruby.MainMenuView = Backbone.View.extend
|
|
366
350
|
|
367
351
|
load: (info) ->
|
368
352
|
if info.error
|
369
|
-
window.errorMessage(
|
353
|
+
window.errorMessage(goog.getMsg(<%= bm('.load_error') %>,
|
354
|
+
{ filename: info.filename, error: info.error }))
|
370
355
|
else
|
371
356
|
clearMessages()
|
372
357
|
|
@@ -395,4 +380,4 @@ Smalruby.MainMenuView = Backbone.View.extend
|
|
395
380
|
# TODO: window.changed -> Smalruby.Models.SourceCode.changed
|
396
381
|
window.changed = false
|
397
382
|
Smalruby.changedAfterTranslating = true
|
398
|
-
window.successMessage('
|
383
|
+
window.successMessage(<%= bm('.load_succeeded') %>)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<%
|
2
|
+
require 'smalruby_editor'
|
3
|
+
require 'smalruby_editor/blockly_message_helper'
|
4
|
+
%>
|
5
|
+
|
6
|
+
# signin dialog view
|
7
|
+
Smalruby.SigninModalView = Backbone.View.extend
|
8
|
+
events:
|
9
|
+
'click #signin-modal-ok-button': 'onOk' # FIXME: 本当は#signin-modal .ok-buttonを指定したいができなかった
|
10
|
+
|
11
|
+
initialize: ->
|
12
|
+
Smalruby.ignoreEnterKey(@$el)
|
13
|
+
@$el.on 'shown', =>
|
14
|
+
@$el.find('#signin-modal-username')
|
15
|
+
.focus()
|
16
|
+
|
17
|
+
render: ->
|
18
|
+
@$el.find('#signin-modal-username')
|
19
|
+
.val($('#username-label').text())
|
20
|
+
@$el.modal
|
21
|
+
backdrop: 'static'
|
22
|
+
@$el.modal('show')
|
23
|
+
|
24
|
+
onOk: (e) ->
|
25
|
+
username = @$el.find('input[name=username]').val()
|
26
|
+
if $.trim(username).length > 0
|
27
|
+
$.post('/sessions/', { username: username })
|
28
|
+
.then(
|
29
|
+
(data) ->
|
30
|
+
Smalruby.username = data
|
31
|
+
$('#signin-button').hide()
|
32
|
+
$('#signout-button').show()
|
33
|
+
$('#username-label').text(data)
|
34
|
+
$('#username-button').show()
|
35
|
+
successMessage(<%= bm('.signed_in') %>)
|
36
|
+
new $.Deferred().resolve().promise()
|
37
|
+
->
|
38
|
+
errorMessage(<%= bm('.error') %>)
|
39
|
+
new $.Deferred().resolve().promise()
|
40
|
+
)
|
41
|
+
.done =>
|
42
|
+
if Smalruby.username != null || !Smalruby.isEnabled('must_signin')
|
43
|
+
@$el.modal('hide')
|
@@ -1,58 +1,11 @@
|
|
1
|
-
|
2
|
-
|
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
|
-
require 'smalruby_editor'
|
27
|
-
colors = SmalrubyEditor::COLORS
|
28
|
-
|
29
|
-
hues = [
|
30
|
-
colors[:motion],
|
31
|
-
colors[:looks],
|
32
|
-
colors[:sound],
|
33
|
-
colors[:pen],
|
34
|
-
colors[:data],
|
35
|
-
colors[:events],
|
36
|
-
colors[:control],
|
37
|
-
colors[:sensing],
|
38
|
-
colors[:operators],
|
39
|
-
colors[:etc],
|
40
|
-
]
|
41
|
-
|
42
|
-
colors = hues.map { |h|
|
43
|
-
[hsv_to_rgb(h, 100, 80), hsv_to_rgb(h, 100, 100)]
|
44
|
-
}
|
45
|
-
|
46
|
-
colors.each.with_index(1) do |(color, active_color), index|
|
47
|
-
%>
|
1
|
+
div.blocklyTreeRoot {
|
2
|
+
padding: 0;
|
48
3
|
|
49
|
-
div[aria-level="1"][aria-posinset="<%= index %>"] {
|
50
4
|
.blocklyTreeRow {
|
51
5
|
margin-bottom: 1px;
|
52
6
|
padding-top: 1px;
|
53
7
|
padding-bottom: 1px;
|
54
8
|
color: white;
|
55
|
-
background-color: #<%= color %> !important;
|
56
9
|
|
57
10
|
span.blocklyTreeIcon, span.blocklyTreeLabel {
|
58
11
|
font-size: 14px;
|
@@ -61,12 +14,5 @@ div[aria-level="1"][aria-posinset="<%= index %>"] {
|
|
61
14
|
|
62
15
|
.blocklyTreeRow.blocklyTreeSelected {
|
63
16
|
font-weight: bold;
|
64
|
-
background-color: #<%= active_color %> !important;
|
65
17
|
}
|
66
18
|
}
|
67
|
-
|
68
|
-
<% end %>
|
69
|
-
|
70
|
-
div.blocklyTreeRoot {
|
71
|
-
padding: 0;
|
72
|
-
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<%
|
2
|
+
require 'smalruby_editor'
|
3
|
+
colors = SmalrubyEditor::COLORS
|
4
|
+
|
5
|
+
hues = [
|
6
|
+
colors[:motion],
|
7
|
+
colors[:looks],
|
8
|
+
colors[:sound],
|
9
|
+
colors[:pen],
|
10
|
+
colors[:data],
|
11
|
+
colors[:events],
|
12
|
+
colors[:control],
|
13
|
+
colors[:sensing],
|
14
|
+
colors[:operators],
|
15
|
+
colors[:etc],
|
16
|
+
]
|
17
|
+
|
18
|
+
colors = hues.map { |h|
|
19
|
+
[SmalrubyEditor.hsv_to_rgb(h, 100, 80),
|
20
|
+
SmalrubyEditor.hsv_to_rgb(h, 100, 100)]
|
21
|
+
}
|
22
|
+
|
23
|
+
colors.each.with_index(1) do |(color, active_color), index|
|
24
|
+
%>
|
25
|
+
div[aria-level="1"][aria-posinset="<%= index %>"] {
|
26
|
+
.blocklyTreeRow {
|
27
|
+
background-color: #<%= color %> !important;
|
28
|
+
}
|
29
|
+
|
30
|
+
.blocklyTreeRow.blocklyTreeSelected {
|
31
|
+
background-color: #<%= active_color %> !important;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
<% end %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<%
|
2
|
+
require 'smalruby_editor'
|
3
|
+
colors = SmalrubyEditor::COLORS
|
4
|
+
|
5
|
+
hues = [
|
6
|
+
colors[:motion],
|
7
|
+
colors[:looks],
|
8
|
+
colors[:data],
|
9
|
+
colors[:events],
|
10
|
+
colors[:control],
|
11
|
+
colors[:sensing],
|
12
|
+
colors[:operators],
|
13
|
+
]
|
14
|
+
|
15
|
+
colors = hues.map { |h|
|
16
|
+
[SmalrubyEditor.hsv_to_rgb(h, 100, 80),
|
17
|
+
SmalrubyEditor.hsv_to_rgb(h, 100, 100)]
|
18
|
+
}
|
19
|
+
|
20
|
+
colors.each.with_index(1) do |(color, active_color), index|
|
21
|
+
%>
|
22
|
+
div[aria-level="1"][aria-posinset="<%= index %>"] {
|
23
|
+
.blocklyTreeRow {
|
24
|
+
background-color: #<%= color %> !important;
|
25
|
+
}
|
26
|
+
|
27
|
+
.blocklyTreeRow.blocklyTreeSelected {
|
28
|
+
background-color: #<%= active_color %> !important;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
<% end %>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<%
|
2
|
+
require 'smalruby_editor'
|
3
|
+
colors = SmalrubyEditor::COLORS
|
4
|
+
|
5
|
+
hues = [
|
6
|
+
colors[:motion],
|
7
|
+
colors[:looks],
|
8
|
+
colors[:data],
|
9
|
+
colors[:events],
|
10
|
+
colors[:control],
|
11
|
+
colors[:sensing],
|
12
|
+
colors[:operators],
|
13
|
+
colors[:etc],
|
14
|
+
]
|
15
|
+
|
16
|
+
colors = hues.map { |h|
|
17
|
+
[SmalrubyEditor.hsv_to_rgb(h, 100, 80),
|
18
|
+
SmalrubyEditor.hsv_to_rgb(h, 100, 100)]
|
19
|
+
}
|
20
|
+
|
21
|
+
colors.each.with_index(1) do |(color, active_color), index|
|
22
|
+
%>
|
23
|
+
div[aria-level="1"][aria-posinset="<%= index %>"] {
|
24
|
+
.blocklyTreeRow {
|
25
|
+
background-color: #<%= color %> !important;
|
26
|
+
}
|
27
|
+
|
28
|
+
.blocklyTreeRow.blocklyTreeSelected {
|
29
|
+
background-color: #<%= active_color %> !important;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
<% end %>
|
@@ -10,6 +10,7 @@ class ApplicationController < ActionController::Base
|
|
10
10
|
helper_method :standalone?, :raspberrypi?
|
11
11
|
|
12
12
|
before_filter :set_locale
|
13
|
+
before_filter :reload_config if Rails.env.development?
|
13
14
|
|
14
15
|
private
|
15
16
|
|
@@ -51,4 +52,8 @@ class ApplicationController < ActionController::Base
|
|
51
52
|
fail "#{self.class.name}##{action_name}はstandaloneモードのみの機能です"
|
52
53
|
end
|
53
54
|
end
|
55
|
+
|
56
|
+
def reload_config
|
57
|
+
SmalrubyEditor::Config.reload!
|
58
|
+
end
|
54
59
|
end
|
@@ -69,7 +69,8 @@ class SourceCodesController < ApplicationController
|
|
69
69
|
if /\Atext\/plain/ =~ info[:type]
|
70
70
|
info[:data] = NKF.nkf('-w', f.read)
|
71
71
|
else
|
72
|
-
info[:error] = '
|
72
|
+
info[:error] = I18n.t('.not_ruby_program',
|
73
|
+
scope: 'controllers.source_codes')
|
73
74
|
end
|
74
75
|
|
75
76
|
render json: { source_code: info }, content_type: request.format
|
@@ -152,7 +153,9 @@ class SourceCodesController < ApplicationController
|
|
152
153
|
end
|
153
154
|
path = Pathname(s).expand_path.to_s
|
154
155
|
|
155
|
-
|
156
|
+
if File.exist?(path) && params[:force].blank?
|
157
|
+
fail I18n.t('.exist', scope: 'controllers.source_codes')
|
158
|
+
end
|
156
159
|
|
157
160
|
FileUtils.mkdir_p(File.dirname(path))
|
158
161
|
File.open(path, 'w') do |f|
|
@@ -203,7 +206,7 @@ class SourceCodesController < ApplicationController
|
|
203
206
|
else
|
204
207
|
info = {
|
205
208
|
filename: source_code_params[:filename],
|
206
|
-
error: '
|
209
|
+
error: I18n.t('.not_exist', scope: 'controllers.source_codes'),
|
207
210
|
}
|
208
211
|
end
|
209
212
|
|
@@ -14,4 +14,16 @@ module ApplicationHelper
|
|
14
14
|
I18n.locale
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
# name of Toolbox
|
19
|
+
def toolbox_name
|
20
|
+
SmalrubyEditor::Config.toolbox_name || 'default'
|
21
|
+
end
|
22
|
+
|
23
|
+
# css name of Toolbox
|
24
|
+
def toolbox_css_name
|
25
|
+
SmalrubyEditor::Config.toolbox_css_name ||
|
26
|
+
SmalrubyEditor::Config.toolbox_name ||
|
27
|
+
'default'
|
28
|
+
end
|
17
29
|
end
|
@@ -17,6 +17,20 @@ module EditorHelper
|
|
17
17
|
%(<field name="#{h name}">#{h value}</field>).html_safe
|
18
18
|
end
|
19
19
|
|
20
|
+
# push or down field for Toolbox
|
21
|
+
#
|
22
|
+
# @param [String] name field name
|
23
|
+
# @param [String] value :push or :down
|
24
|
+
# @return [String] XML
|
25
|
+
def toolbox_pod_field(name = 'POD', value = :down)
|
26
|
+
if value == :down
|
27
|
+
pod = 'down'
|
28
|
+
else
|
29
|
+
pod = 'push'
|
30
|
+
end
|
31
|
+
%(<field name="#{h name}">#{pod}</field>).html_safe
|
32
|
+
end
|
33
|
+
|
20
34
|
# ツールボックスのブロックに対して、PINの入力フィールドの値を設定する
|
21
35
|
#
|
22
36
|
# @param [String] value ピン
|
@@ -56,4 +70,15 @@ module EditorHelper
|
|
56
70
|
</value>
|
57
71
|
XML
|
58
72
|
end
|
73
|
+
|
74
|
+
# I18n.t wrapper for Toolbox that's defualt scope is
|
75
|
+
# 'editor.toolbox'.
|
76
|
+
def toolbox_t(*args)
|
77
|
+
if args.length == 1 && args.first[0] == '.'
|
78
|
+
t(args.first[1..-1], scope: 'editor.toolbox')
|
79
|
+
else
|
80
|
+
t(*args)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
alias_method :tt, :toolbox_t
|
59
84
|
end
|