mumuki-gobstones-runner 2.4.1 → 2.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3eae1a47ac206d6de39e4858bfcc94777c6414420cd88d6c5d0124b494dffec5
4
- data.tar.gz: baea256cd8be5c4fe0fe5c04c8d88013882907ae4420ec56e918fba08aa3638a
3
+ metadata.gz: d96082c599e490cc9fb4852f5abeb3e1d1028dae114a164439c012de51b21f0f
4
+ data.tar.gz: 0ec06a7c118e46a253a6b1c5629743f06557df5a2a08c659a70316b22e2c36d9
5
5
  SHA512:
6
- metadata.gz: 0d5898de7105cbfe6ffa05070a12d22d7869975d4330cc4e57d44e246e021d435d675d75e5675a367010a9c6902d3ab0d338a91eb214f071acbea1bbffe49723
7
- data.tar.gz: 17114df8ed403b4af65145a36108b9a7b95fb8484bc73773d63da13c10882786bd13839d165c60c1a695f14f892241f06633549e10ee3a24b9fb05aa8c39545e
6
+ metadata.gz: 1de5ceb45cd458d6ab9f9d15ee9e43a58b020892334986b890f52383e11d5bfa3cc4055d4e5a70f56a5a571c52308bf7a3207da2fbb22be159f3cc46d34544d5
7
+ data.tar.gz: 3926c4c075c955982333d363b3423cecc9cc77ff52249fd9147c58fc9943499a74dd0b63dd4cfa43f3df66a5b2b27652a840b53a9a1fe2f4cdbe432752ee78c2
@@ -13,6 +13,10 @@ class Mumukit::Server::App < Sinatra::Base
13
13
  get_asset route, Gobstones::CodeRunner.assets_path_for(path), type
14
14
  end
15
15
 
16
+ def self.get_local_svg(name, asset_type)
17
+ get_local_asset "#{asset_type}/#{name}.svg", "lib/public/#{name}.svg", 'image/svg+xml'
18
+ end
19
+
16
20
  ['polymer', 'polymer-mini', 'polymer-micro'].each { |name|
17
21
  get_board_asset "#{name}.html", "htmls/vendor/#{name}.html", 'text/html'
18
22
  }
@@ -22,12 +26,18 @@ class Mumukit::Server::App < Sinatra::Base
22
26
 
23
27
  get_submit_asset 'editor/gobstones-code-runner.html', 'htmls/gobstones-code-runner.html', 'text/html'
24
28
 
29
+ get_local_asset 'layout/layout.html', 'lib/render/layout/layout.html', 'text/html'
25
30
  get_local_asset 'editor/editor.js', 'lib/render/editor/editor.js', 'application/javascript'
26
31
  get_local_asset 'editor/editor.css', 'lib/render/editor/editor.css', 'text/css'
27
32
  get_local_asset 'editor/editor.html', 'lib/render/editor/editor.html', 'text/html'
28
33
  get_local_asset 'editor/hammer.min.js', 'lib/render/editor/hammer.min.js', 'application/javascript'
29
34
  get_local_asset 'boom.png', 'lib/public/boom.png', 'image/png'
30
- ['red', 'blue', 'green', 'black', 'attires_enabled', 'attires_disabled'].each { |name|
31
- get_local_asset "editor/#{name}.svg", "lib/public/#{name}.svg", 'image/svg+xml'
32
- }
35
+
36
+ ['red', 'blue', 'green', 'black'].each do |name|
37
+ get_local_svg(name, 'editor')
38
+ end
39
+
40
+ ['attires_enabled', 'attires_disabled'].each do |name|
41
+ get_local_svg(name, 'layout')
42
+ end
33
43
  end
@@ -5,7 +5,7 @@ I18n.load_translations_path File.join(__dir__, 'locales', '*.yml')
5
5
 
6
6
  Mumukit.runner_name = 'gobstones'
7
7
  Mumukit.configure do |config|
8
- config.docker_image = 'mumuki/mumuki-gobstones-worker:6.0'
8
+ config.docker_image = 'mumuki/mumuki-gobstones-worker:9.0'
9
9
  config.content_type = 'html'
10
10
  config.structured = true
11
11
  end
@@ -12,7 +12,8 @@ class GobstonesMetadataHook < Mumukit::Hook
12
12
  layout_assets_urls: {
13
13
  html: [
14
14
  'assets/polymer.html',
15
- 'assets/gs-board.html'
15
+ 'assets/gs-board.html',
16
+ 'assets/layout/layout.html'
16
17
  ]
17
18
  },
18
19
  editor_assets_urls: {
@@ -48,6 +48,7 @@
48
48
  </div>
49
49
  <% end %>
50
50
 
51
+ <gs-attire-toggle-button></gs-attire-toggle-button>
51
52
  </div>
52
53
 
53
54
  <% if @result[:reason] %>
@@ -189,7 +189,7 @@
189
189
  });
190
190
 
191
191
  const hasCustomToolbox = $('gs-toolbox').length;
192
- if(!hasCustomToolbox) mumuki.assetsLoadedFor('editor');
192
+ if(!hasCustomToolbox) this.enableContextButton();
193
193
  });
194
194
  };
195
195
 
@@ -229,6 +229,15 @@
229
229
  }
230
230
  },
231
231
 
232
+ enableContextButton() {
233
+ if(typeof mumuki !== "undefined" && mumuki.kids && mumuki.assetsLoadedFor) {
234
+ return mumuki.assetsLoadedFor('editor');
235
+ } else {
236
+ return postpone(this.enableContextButton.bind(this));
237
+ }
238
+
239
+ },
240
+
232
241
  getBlockly: function () {
233
242
  return this.$.blocklyElement;
234
243
  },
@@ -757,30 +766,6 @@
757
766
  </script>
758
767
  </dom-module>
759
768
 
760
- <dom-module id="gs-attire">
761
- <script>
762
- Polymer({
763
- is: 'gs-attire',
764
- properties: {
765
- attireUrl: Object,
766
- observer: '_attireChanged'
767
- },
768
-
769
- attached: function () {
770
- this._setAttire();
771
- },
772
- _attireChanged: function () {
773
- this._setAttire();
774
- },
775
- _setAttire: function () {
776
- $.getJSON(this.attireUrl, function (attire) {
777
- GobstonesBoard && GobstonesBoard.setDefaultAttire(attire);
778
- });
779
- }
780
- });
781
- </script>
782
- </dom-module>
783
-
784
769
  <dom-module id="gs-toolbox">
785
770
  <script>
786
771
  Polymer({
@@ -804,7 +789,7 @@
804
789
  blockly.toolbox = { defaultToolbox: toolboxXml };
805
790
  editor.setTeacherActions(blockly);
806
791
  }).always(function () {
807
- mumuki.assetsLoadedFor('editor');
792
+ editor.enableContextButton();
808
793
  });
809
794
  }
810
795
  });
@@ -1020,7 +1005,7 @@
1020
1005
  if(this.configLoaded) this._createSwipeListener();
1021
1006
  },
1022
1007
  _createSwipeListener: function () {
1023
- if(typeof Hammer === "undefined") return postpone(this._createSwipeListener);
1008
+ if(typeof Hammer === "undefined") return postpone(this._createSwipeListener.bind(this));
1024
1009
  const $swipeListenerArea = $('.mu-initial-state gs-board')[0];
1025
1010
  const hammer = new Hammer($swipeListenerArea);
1026
1011
  hammer.get('swipe').set({direction: Hammer.DIRECTION_ALL});
@@ -1057,7 +1042,7 @@
1057
1042
 
1058
1043
  _createKeyboardConfig: function () {
1059
1044
  if(typeof GobstonesKeyboard === 'undefined') GobstonesKeyboard = {};
1060
- if(typeof Hammer === "undefined") return postpone(this._createKeyboardConfig);
1045
+ if(typeof Hammer === "undefined") return postpone(this._createKeyboardConfig.bind(this));
1061
1046
  GobstonesKeyboard.keyboardMap = {
1062
1047
  [Hammer.DIRECTION_LEFT]: 37,
1063
1048
  [Hammer.DIRECTION_UP]: 38,
@@ -1081,81 +1066,3 @@
1081
1066
  </script>
1082
1067
  </dom-module>
1083
1068
 
1084
- <dom-module id="gs-attire-toggle-button">
1085
- <style>
1086
- .button {
1087
- position: absolute;
1088
- cursor: pointer;
1089
- top: -2px;
1090
- right: 0;
1091
- -ms-transform-origin: right center;
1092
- -webkit-transform-origin: right center;
1093
- transform-origin: right center;
1094
- }
1095
- </style>
1096
-
1097
- <template>
1098
- <template is="dom-if" if="{{shouldDisplay}}">
1099
- <div class="button" on-click="_onButtonClick">
1100
- <template is="dom-if" if="{{isEnabled}}">
1101
- <img src="./attires_enabled.svg">
1102
- </template>
1103
- <template is="dom-if" if="{{!isEnabled}}">
1104
- <img src="./attires_disabled.svg">
1105
- </template>
1106
- </div>
1107
- </template>
1108
- </template>
1109
-
1110
- <script>
1111
- Polymer({
1112
- is: 'gs-attire-toggle-button',
1113
- properties: {
1114
- isEnabled: {
1115
- type: Boolean,
1116
- value: true
1117
- }
1118
- },
1119
-
1120
- ready: function () {
1121
- document.addEventListener('board-attire-changed', this._updateVisibility.bind(this));
1122
- this._relocateButton();
1123
- },
1124
-
1125
- _updateVisibility: function () {
1126
- this.boards = $(".mu-kids-states").find("gs-board");
1127
- this.shouldDisplay = this.boards.toArray().some(board => board.attire);
1128
- },
1129
-
1130
- _onButtonClick: function () {
1131
- this.isEnabled = !this.isEnabled;
1132
-
1133
- this.boards.each((__, board) => {
1134
- if (board.attire) board.set("attire.enabled", this.isEnabled);
1135
- gbsBoardRemoveBorder(board);
1136
- });
1137
- },
1138
-
1139
- _getEditor: function () {
1140
- return $("mu-gobstones-custom-editor")[0];
1141
- },
1142
-
1143
- _relocateButton: function () {
1144
- const $container = $('.mu-kids-gbs-board-initial');
1145
- if(!$container.length || this._getEditor().interactiveMode) return;
1146
- const $header = $('.mu-initial-state-header');
1147
- const headerWidth = $header.width() || $container.width();
1148
- const $attireToggle = $container.find('.button.gs-attire-toggle-button');
1149
- if(!$attireToggle.length) return setTimeout(() => this._relocateButton());
1150
- const margin = 4; // Leave a margin between text and image
1151
- const maxSize = 65.75; // Original width
1152
- mumuki.resize(() => {
1153
- $attireToggle.css('transform', 'scale(1)');
1154
- let buttonSize = (($container.width() - headerWidth) / 2) - margin;
1155
- let scaleX = Math.min(buttonSize, maxSize) / $attireToggle.width();
1156
- $attireToggle.css('transform', `scale(${scaleX})`);
1157
- });
1158
- },
1159
- });
1160
- </script>
1161
- </dom-module>
@@ -0,0 +1,109 @@
1
+ <dom-module id="gs-attire">
2
+ <script>
3
+ Polymer({
4
+ is: 'gs-attire',
5
+ properties: {
6
+ attireUrl: Object,
7
+ observer: '_attireChanged'
8
+ },
9
+
10
+ attached: function () {
11
+ this._setAttire();
12
+ },
13
+ _attireChanged: function () {
14
+ this._setAttire();
15
+ },
16
+ _setAttire: function () {
17
+ $.getJSON(this.attireUrl, function (attire) {
18
+ GobstonesBoard && GobstonesBoard.setDefaultAttire(attire);
19
+ });
20
+ }
21
+ });
22
+ </script>
23
+ </dom-module>
24
+
25
+ <dom-module id="gs-attire-toggle-button">
26
+ <style>
27
+ :host-context(.mu-kids-states) .button {
28
+ position: absolute;
29
+ cursor: pointer;
30
+ top: -2px;
31
+ right: 0;
32
+ -ms-transform-origin: right center;
33
+ -webkit-transform-origin: right center;
34
+ transform-origin: right center;
35
+ }
36
+
37
+ :host-context(.boards-container) .button {
38
+ cursor: pointer;
39
+ margin-top: -8px;
40
+ }
41
+ </style>
42
+
43
+ <template>
44
+ <template is="dom-if" if="{{shouldDisplay}}">
45
+ <div class="button" on-click="_onButtonClick">
46
+ <template is="dom-if" if="{{isEnabled}}">
47
+ <img src="./attires_enabled.svg">
48
+ </template>
49
+ <template is="dom-if" if="{{!isEnabled}}">
50
+ <img src="./attires_disabled.svg">
51
+ </template>
52
+ </div>
53
+ </template>
54
+ </template>
55
+
56
+ <script>
57
+ Polymer({
58
+ is: 'gs-attire-toggle-button',
59
+ properties: {
60
+ isEnabled: {
61
+ type: Boolean,
62
+ value: true
63
+ }
64
+ },
65
+
66
+ ready: function () {
67
+ this._updateVisibility();
68
+ document.addEventListener('board-attire-changed', this._updateVisibility.bind(this));
69
+ this._relocateButton();
70
+ },
71
+
72
+ _updateVisibility: function () {
73
+ this.boards = $(this).parents(".mu-kids-states, .boards-container").find("gs-board");
74
+ this.shouldDisplay = this.boards.toArray().some(board => board.attire);
75
+ },
76
+
77
+ _onButtonClick: function () {
78
+ this.isEnabled = !this.isEnabled;
79
+
80
+ this.boards.each((__, board) => {
81
+ if (board.attire) board.set("attire.enabled", this.isEnabled);
82
+ board.updateStyles();
83
+ });
84
+ },
85
+
86
+ _getEditor: function () {
87
+ return $("mu-gobstones-custom-editor")[0];
88
+ },
89
+
90
+ _relocateButton: function () {
91
+ const $container = $('.mu-kids-gbs-board-initial');
92
+ if(!$container.length || this._getEditor().interactiveMode) return;
93
+ const $header = $('.mu-initial-state-header');
94
+ const headerWidth = $header.width() || $container.width();
95
+ const $attireToggle = $container.find('.button.gs-attire-toggle-button');
96
+ if(!$attireToggle.length) return setTimeout(() => this._relocateButton());
97
+ const margin = 4; // Leave a margin between text and image
98
+ const maxSize = 65.75; // Original width
99
+ mumuki.resize(() => {
100
+ $attireToggle.css('transform', 'scale(1)');
101
+ let buttonSize = (($container.width() - headerWidth) / 2) - margin;
102
+ let scaleX = Math.min(buttonSize, maxSize) / $attireToggle.width();
103
+ $attireToggle.css('transform', `scale(${scaleX})`);
104
+ });
105
+ },
106
+ });
107
+ </script>
108
+ </dom-module>
109
+
@@ -1,3 +1,3 @@
1
1
  module GobstonesVersionHook
2
- VERSION = '2.4.1'
2
+ VERSION = '2.7.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumuki-gobstones-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Alfonso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-08 00:00:00.000000000 Z
11
+ date: 2020-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mumukit
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.18'
47
+ version: '1.19'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.18'
54
+ version: '1.19'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: gobstones-blockly
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -84,16 +84,22 @@ dependencies:
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1.7'
90
+ - - "<"
91
+ - !ruby/object:Gem::Version
92
+ version: '3'
90
93
  type: :development
91
94
  prerelease: false
92
95
  version_requirements: !ruby/object:Gem::Requirement
93
96
  requirements:
94
- - - "~>"
97
+ - - ">="
95
98
  - !ruby/object:Gem::Version
96
99
  version: '1.7'
100
+ - - "<"
101
+ - !ruby/object:Gem::Version
102
+ version: '3'
97
103
  - !ruby/object:Gem::Dependency
98
104
  name: rake
99
105
  requirement: !ruby/object:Gem::Requirement
@@ -187,6 +193,7 @@ files:
187
193
  - lib/render/editor/hammer.min.js
188
194
  - lib/render/html_board.rb
189
195
  - lib/render/html_renderer.rb
196
+ - lib/render/layout/layout.html
190
197
  - lib/render/with_renderer.rb
191
198
  - lib/test_hook.rb
192
199
  - lib/version_hook.rb
@@ -209,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
216
  - !ruby/object:Gem::Version
210
217
  version: '0'
211
218
  requirements: []
212
- rubygems_version: 3.0.4
219
+ rubygems_version: 3.0.8
213
220
  signing_key:
214
221
  specification_version: 4
215
222
  summary: Gobstones Runner for Mumuki