arcabouco 0.1.8 → 0.1.9

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
  SHA1:
3
- metadata.gz: 9aea2be4d85009f866944b1f8a785007e187aa03
4
- data.tar.gz: 362555b74f0b1df0dc7d8548953c9f8b00614a9c
3
+ metadata.gz: e9a1bcd56e1eb2b7c3cd521d93157d328342962d
4
+ data.tar.gz: c5644f61064f469f5a3c4b5300290eb9e91bb9e2
5
5
  SHA512:
6
- metadata.gz: 6b01cd01e988a4325108201538348a1d12da261c65d2e59fac514c42824e415745360a7bf3c315c99b94020e8c0d07e4fc1b2d97a3d27fa9dbd6a6286f624739
7
- data.tar.gz: 86d708581bc6a359f595636cadd0f13b9fe363a62c290c2bf330361079f3037ca3af9551bd0ff526275e50c6f31856e830d72fcf8fa47897c5800d08a7c17844
6
+ metadata.gz: 07703107a4b62121bd4454ab0e3c1550babad2248e4b1329362eb176e28bf5851b887f87ffa3912bfc323a3ae6a1a1e99a5edbc51deeee7144eda2e5715ae466
7
+ data.tar.gz: 82dc6c9f793c1b99ff826c5ad869ee4a54cf1abddcbe523e46217946feafa0ced0bd0bf395bb8840b1fa6d8feb2cfabd16019d7e13070cd42b45b6bb4fbd71ca
@@ -40,7 +40,7 @@ module Arcabouco
40
40
  mattr_accessor :asset_list
41
41
  mattr_accessor :application_name
42
42
 
43
- self.asset_list = %w(jquery.js app.css app.js vendor.js vendor.css *.png *.jpg *.gif *.mp3 *.wav)
43
+ self.asset_list = %w(app.css app.js vendor.js vendor.css *.png *.jpg *.gif *.mp3 *.wav)
44
44
  self.application_name = "Arcabouco Application"
45
45
 
46
46
  def self.setup
@@ -6,6 +6,7 @@ require 'compass'
6
6
  require 'sprockets-sass'
7
7
  require 'handlebars_assets'
8
8
  require 'pathname'
9
+ require 'uglifier'
9
10
 
10
11
  Encoding.default_external = Encoding::UTF_8
11
12
  Encoding.default_internal = Encoding::UTF_8
@@ -46,12 +47,17 @@ module Arcabouco
46
47
  end
47
48
 
48
49
  def content_for_index
50
+
49
51
  application_preload_html = ""
50
52
  application_preloader_filename = File.join Arcabouco.root, 'app', 'templates', 'application_preloader.html'
51
53
  if File.file?(application_preloader_filename)
52
54
  application_preload_html = File.read application_preloader_filename
53
55
  end
54
- erb :"#{relative_to}/index.html", locals: { :assets => $environment, :application_name => Arcabouco.application_name, :application_preload_html => application_preload_html}, layout: false, cache: false
56
+
57
+ main_js = Uglifier.compile(File.read(File.join(Arcabouco.gem_root,'templates','bootstrap_code.js')))
58
+
59
+
60
+ erb :"#{relative_to}/index.html", locals: { :assets => $environment, :application_name => Arcabouco.application_name, :application_preload_html => application_preload_html, :main_js => main_js }, layout: false, cache: false
55
61
  end
56
62
 
57
63
  get '/save_app.html' do
@@ -1,3 +1,3 @@
1
1
  module Arcabouco
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
data/lib/assets/js/app.js CHANGED
@@ -1,7 +1,7 @@
1
1
  //= require './core/capabilities'
2
2
  //= require './core/environment'
3
3
  //= require './core/debug'
4
+ //= require './core/sound'
4
5
  //= require 'config'
5
6
  //= require './core/boot'
6
- //= require 'usecode'
7
- //= require 'templates'
7
+ //= require 'main'
@@ -1,13 +1,13 @@
1
1
  @app = window.app
2
- @app._routers = []
3
- @app.routes = {}
4
- @app.activeView = null
5
- @app._features = {}
6
- @app.ui = {}
2
+ # @app._routers = []
3
+ # @app.routes = {}
4
+ # @app.activeView = null
5
+ # @app.ui = {}
6
+ # @app._features = {}
7
+ # @app.domain = ''
7
8
  @app.enable_debug = true
8
- @app.domain = ''
9
9
 
10
- @app.registerRouter = ( router ) ->
11
- this._routers.push router
10
+ # @app.registerRouter = ( router ) ->
11
+ # this._routers.push router
12
12
 
13
13
  # Backbone.old_sync = Backbone.sync
@@ -0,0 +1,67 @@
1
+ class _Sound
2
+ format: if $.browser.webkit then ".mp3" else ".wav"
3
+ soundPath: "/app.assets/"
4
+ sound: []
5
+ environmentSound: null
6
+ maxChannels: 8
7
+
8
+ constructor: () ->
9
+ @sound.size = 8
10
+ for i in [0..7]
11
+ @sound[i] = null
12
+
13
+ loadSoundChannel: (name) ->
14
+ snd = new Audio( @soundPath + name + @format )
15
+ snd.preload = false
16
+ snd.load()
17
+ snd
18
+
19
+ enableDesktopLoop: ( env ) ->
20
+ if typeof env.loop == 'boolean'
21
+ env.loop = true
22
+ else
23
+ env.addEventListener( 'ended',
24
+ () ->
25
+ this.currentTime = 0
26
+ this.play()
27
+ false
28
+ )
29
+
30
+ playDesktop: (name, options = {}) ->
31
+ if options.environmentSound
32
+ @environmentSound.stop() if @environmentSound
33
+ @environmentSound = @loadSoundChannel( name )
34
+ @enableDesktopLoop( @environmentSound ) if options.environmentSound
35
+ @environmentSound.play()
36
+ return
37
+
38
+ aChannel = false
39
+ for i in [0..8]
40
+ if @sound[i] == null
41
+ aChannel = i
42
+ break
43
+ else if @sound[i] and (@sound[i].currentTime == @sound[i].duration || @sound[i].currentTime == 0)
44
+ aChannel = i
45
+ break
46
+
47
+ @sound[ aChannel ] = @loadSoundChannel( name )
48
+ @enableDesktopLoop( @sound[ aChannel ] ) if options.environmentSound
49
+ @sound[ aChannel ].play()
50
+
51
+ stopDesktop: (channel) ->
52
+ @sound[channel].stop() if @sound[channel] and (@sound[channel].currentTime == @sound[channel].duration || @sound[channel].currentTime == 0)
53
+
54
+ stopEnvironmentDesktop: ->
55
+ @environmentSound.stop() if @environmentSound
56
+
57
+ # SUPPORT CORDOVA
58
+ play: (name, options = {}) ->
59
+ @playDesktop name, options unless IS_MOBILE
60
+
61
+ stop: (channel) ->
62
+ @stopDesktop channel unless IS_MOBILE
63
+
64
+ stopEnvironment: ->
65
+ @stopEnvironmentDesktop() unless IS_MOBILE
66
+
67
+ window.Sound = new _Sound()
@@ -1,4 +1,5 @@
1
1
  //= require handlebars.runtime
2
+ //= require ./vendor/jquery.js
2
3
  //= require ./vendor/underscore.js
3
4
  //= require ./vendor/backbone.js
4
5
  //= require ./vendor/async.js
@@ -0,0 +1,77 @@
1
+ function _getJSON(url,callback) {
2
+ var xobj = new XMLHttpRequest();
3
+ xobj.overrideMimeType("application/json");
4
+ xobj.open('GET', url, true);
5
+ xobj.onreadystatechange = function () { if (xobj.readyState == 4 && xobj.status == "200") { callback(JSON.parse(xobj.responseText)); } };
6
+ xobj.send(null);
7
+ }
8
+
9
+ function _loadJS(src,onload)
10
+ {
11
+ var js = document.createElement('script');
12
+ js.type = 'text/javascript';
13
+ js.src = '/app.assets/' + src;
14
+ js.onload = onload;
15
+ document.head.appendChild(js);
16
+ }
17
+
18
+ function _loadCSS(src)
19
+ {
20
+ var css = document.createElement('link');
21
+ css.rel = 'stylesheet';
22
+ css.type = 'text/css';
23
+ css.href = '/app.assets/' + src;
24
+ document.head.appendChild(css);
25
+ }
26
+
27
+ function bootstrapApplication()
28
+ {
29
+ if (app.bootstraped) return;
30
+ app.bootstraped = true;
31
+ if (app.enable_debug) console.log("DEBUG: Bootstrap Application. Manifest (" + app.assets_manifest + ")");
32
+ _getJSON( app.assets_manifest, function(data) {
33
+ _loadCSS( data.assets['vendor.css'] );
34
+ _loadCSS( data.assets['app.css'] );
35
+ _loadJS( data.assets['vendor.js'], function() {
36
+ _loadJS( data.assets['app.js'], function() {
37
+ $('#application_preload_layer').remove();
38
+ });
39
+ });
40
+ });
41
+ }
42
+
43
+ function updateApplicationDownloadProgress(progress)
44
+ {
45
+ if (app.bootstraped) return;
46
+ if (app.enable_debug) console.log("DEBUG: Detected new asset");
47
+ }
48
+
49
+ function refreshApplicationFiles()
50
+ {
51
+ app.applicationCache.swapCache();
52
+ if (app.bootstraped == false) {
53
+ bootstrapApplication();
54
+ }
55
+ else {
56
+ window.app.confirm('A new version of this application is available. Load it?', function() {
57
+ window.location.reload();
58
+ });
59
+ }
60
+ }
61
+
62
+ appcache_frame = document.createElement('iframe');
63
+ appcache_frame.src = '/save_app.html';
64
+ appcache_frame.onload = function() {
65
+ app.applicationCache = appcache_frame.contentWindow.applicationCache;
66
+
67
+ app.applicationCache.addEventListener('noupdate', bootstrapApplication, false);
68
+ app.applicationCache.addEventListener('cached', bootstrapApplication, false);
69
+ app.applicationCache.addEventListener('updateready', refreshApplicationFiles, false);
70
+ app.applicationCache.addEventListener('progress', function(e) { updateApplicationDownloadProgress(e); }, false);
71
+
72
+ setInterval(function() {
73
+ if (app.enable_debug) console.log("DEBUG: Checking for new assets");
74
+ app.applicationCache.update();
75
+ }, 10*60*1000);
76
+ }
77
+ document.head.appendChild( appcache_frame );
@@ -17,106 +17,13 @@
17
17
  <div id="application_preload_layer" style="position:absolute;top:0px;right:0px;left:0px;bottom:0px"><%= application_preload_html %></div>
18
18
  <div id='app'></div>
19
19
 
20
- <script type="text/javascript" src="/app.assets/<%= assets['jquery.js'].digest_path %>"></script>
21
20
  <script type="text/javascript">
22
21
  window.app = {}
23
- window.app.confirm = function(message, callback) {
24
- if (confirm(message)) {
25
- callback();
26
- }
27
- }
22
+ window.app.confirm = function(message, callback) { if (confirm(message)) { callback(); } }
28
23
  window.app.bootstraped = false;
24
+ window.app.enable_debug = true;
29
25
  window.app.assets_manifest = "/<%= ENV['RACK_ENV'] == 'production' ? 'app.assets/manifest.json' : 'manifest.json' %>";
30
-
31
- function currentCacheStatus() {
32
- appCache = app.applicationCache;
33
- switch (appCache.status) {
34
- case appCache.UNCACHED: // UNCACHED == 0
35
- return 'UNCACHED';
36
- break;
37
- case appCache.IDLE: // IDLE == 1
38
- return 'IDLE';
39
- break;
40
- case appCache.CHECKING: // CHECKING == 2
41
- return 'CHECKING';
42
- break;
43
- case appCache.DOWNLOADING: // DOWNLOADING == 3
44
- return 'DOWNLOADING';
45
- break;
46
- case appCache.UPDATEREADY: // UPDATEREADY == 4
47
- return 'UPDATEREADY';
48
- break;
49
- case appCache.OBSOLETE: // OBSOLETE == 5
50
- return 'OBSOLETE';
51
- break;
52
- default:
53
- return 'UKNOWN CACHE STATUS';
54
- break;
55
- }
56
- }
57
-
58
- function addScriptTag(src,onload)
59
- {
60
- var newScript = document.createElement('script');
61
- newScript.type = 'text/javascript';
62
- newScript.src = '/app.assets/' + src;
63
- newScript.onload = onload;
64
- document.head.appendChild(newScript);
65
- }
66
-
67
- function bootstrapApplication()
68
- {
69
- if (app.bootstraped) return;
70
- app.bootstraped = true;
71
- console.log("START UPDATED");
72
- console.log("FETCH " + app.assets_manifest );
73
- jQuery.getJSON( app.assets_manifest, function(data) {
74
- $('head').append('<link rel="stylesheet" href="/app.assets/' + data.assets["vendor.css"] + '" type="text/css" />');
75
- $('head').append('<link rel="stylesheet" href="/app.assets/' + data.assets["app.css"] + '" type="text/css" />');
76
- addScriptTag( data.assets['vendor.js'], function() {
77
- // After vendor is loaded. Start application
78
- addScriptTag( data.assets['app.js'], function() {
79
- $('#application_preload_layer').remove();
80
- });
81
- });
82
- });
83
- }
84
-
85
- function updateApplicationDownloadProgress(progress)
86
- {
87
- if (app.bootstraped) return;
88
- console.log("New asset downloaded");
89
- }
90
-
91
- function refreshApplicationFiles()
92
- {
93
- app.applicationCache.swapCache();
94
- if (app.bootstraped == false) {
95
- bootstrapApplication();
96
- }
97
- else {
98
- window.app.confirm('A new version of this application is available. Load it?', function() {
99
- window.location.reload();
100
- });
101
- }
102
- }
103
-
104
- $(document).ready( function() {
105
- appcache_frame = $('<iframe>').attr('src', '/save_app.html').load(function() {
106
- app.applicationCache = appcache_frame.contentWindow.applicationCache;
107
-
108
- app.applicationCache.addEventListener('noupdate', bootstrapApplication, false);
109
- app.applicationCache.addEventListener('cached', bootstrapApplication, false);
110
- app.applicationCache.addEventListener('updateready', refreshApplicationFiles, false);
111
- app.applicationCache.addEventListener('progress', function(e) { updateApplicationDownloadProgress(e); }, false);
112
-
113
- setInterval(function() {
114
- console.log("Checking for new versions");
115
- app.applicationCache.update();
116
- }, 10*60*1000);
117
-
118
- }).appendTo('head')[0]
119
- });
26
+ <%= main_js %>
120
27
  </script>
121
28
  </body>
122
29
  </html>
@@ -8,9 +8,6 @@ CACHE:
8
8
 
9
9
  <% if assets['vendor.js'] %>/app.assets/<%= assets['vendor.js'].digest_path %><% end %>
10
10
 
11
- <% if assets['jquery.js'] %>/app.assets/<%= assets['jquery.js'].digest_path %><% end %>
12
-
13
-
14
11
  NETWORK:
15
12
  *
16
13
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arcabouco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Negri
@@ -309,15 +309,16 @@ files:
309
309
  - lib/assets/js/core/capabilities.js
310
310
  - lib/assets/js/core/debug.js.coffee
311
311
  - lib/assets/js/core/environment.js.coffee
312
- - lib/assets/js/jquery.js
313
- - lib/assets/js/templates.js
314
- - lib/assets/js/usecode.js
312
+ - lib/assets/js/core/sound.coffee
313
+ - lib/assets/js/main.js
315
314
  - lib/assets/js/vendor.js
316
315
  - lib/assets/js/vendor/async.js
317
316
  - lib/assets/js/vendor/backbone.js
318
317
  - lib/assets/js/vendor/handlebars.js
318
+ - lib/assets/js/vendor/jquery.js
319
319
  - lib/assets/js/vendor/tasks.js.coffee
320
320
  - lib/assets/js/vendor/underscore.js
321
+ - lib/templates/bootstrap_code.js
321
322
  - lib/templates/index.html.erb
322
323
  - lib/templates/manifest.erb
323
324
  - lib/templates/save_app.html
File without changes
File without changes
File without changes