arcabouco 0.1.0 → 0.1.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
  SHA1:
3
- metadata.gz: c4df75f821808c5663d31e05c98aad88e02a6239
4
- data.tar.gz: 56dde7619e5ccfb22ef0569f20358e8bd7fe9f20
3
+ metadata.gz: 9a671d00d7f4680fc4270f6969b711b773d05a6d
4
+ data.tar.gz: a20ef1281de933e9aa34788b99cc7da1f6e7beef
5
5
  SHA512:
6
- metadata.gz: ed26a9f6523304eacd9bcdbbc91d9486a3f5c7d845043d8580f4b42fdb342cc722004fee669984a6b2cb34cde4adcc317371622fc8d0bbf4c652c04344e7d79c
7
- data.tar.gz: b049c7abb99db89e56bc8aa7fc9e900bd80b718b80c0007acadc3264aee74e2e7bead3a3decca7968945ac0e6686362026619a572eb6006f3910d92a1869e5b0
6
+ metadata.gz: f1322db098088a70aceafb2410c5d35990d50ea1ea2033a19faa0f2ebd2df323e0c39007e745909ec735bfe59d8a096271a1975a4ede42917eb130c2bcde3191
7
+ data.tar.gz: 447dd453f5d4897655d128d355bcf2634b024d530df9928b920b2ac6b910f84c59f4f8b7c7b0a7958911712bb0d644d6048b49bb334c5def753d8f435537430e
@@ -10,8 +10,8 @@ module Arcabouco
10
10
 
11
11
  def configure_root_directory
12
12
  Arcabouco.gem_root = File.expand_path("../..",__FILE__)
13
- Dir.chdir "."
14
- Arcabouco.root = File.expand_path Dir.getwd
13
+ Arcabouco.root = File.expand_path Bundler.root
14
+ Dir.chdir Arcabouco.root
15
15
  end
16
16
  end
17
17
  end
@@ -23,16 +23,43 @@ module Arcabouco
23
23
  super
24
24
  end
25
25
 
26
+ def assets_list
27
+ %w(jquery.js app.css app.js vendor.js vendor.css *.png)
28
+ end
29
+
26
30
  def relative_to
27
31
  "../" + Pathname.new(File.expand_path('../templates', File.dirname(__FILE__))).relative_path_from(Pathname.new(Arcabouco.root)).to_s
32
+ # Pathname.new(File.expand_path('../templates', File.dirname(__FILE__))).relative_path_from(Pathname.new(Arcabouco.root)).to_s
28
33
  end
29
34
 
30
35
  get '/manifest.appcache' do
31
- erb :"#{relative_to}/manifest", :locals => { :assets => $environment }
36
+ index_digest = Digest::MD5.new
37
+ index_digest.update content_for_index
38
+ erb :"#{relative_to}/manifest", :locals => { :assets => $environment, :index_digest => index_digest.hexdigest }
39
+ end
40
+
41
+ get '/manifest.json' do
42
+ content_type :json
43
+ obj = {}
44
+ obj['assets'] = {}
45
+ assets_list.each do |asset|
46
+ next if asset.to_s.index("*")
47
+ obj['assets'][asset] = "/app.assets/" + $environment[asset.to_s].digest_path
48
+ end
49
+ obj.to_json
50
+ end
51
+
52
+ def content_for_index
53
+ erb :"#{relative_to}/index.html", locals: { :assets => $environment }, layout: false, cache: false
54
+ end
55
+
56
+ get '/save_app.html' do
57
+ erb :"#{relative_to}/save_app.html"
32
58
  end
33
59
 
34
60
  get '/*' do
35
- haml :"#{relative_to}/index", locals: { :assets => $environment }, layout: false
61
+ expires 0, :public, :'no-cache', :must_revalidate # Expire in 1 minute, require Auth
62
+ content_for_index
36
63
  end
37
64
  end
38
65
 
@@ -40,6 +67,7 @@ module Arcabouco
40
67
  attr_accessor :root
41
68
  attr_accessor :rack
42
69
  attr_accessor :env
70
+ attr_accessor :web
43
71
 
44
72
  def initialize
45
73
  self.root = Arcabouco.root
@@ -66,7 +94,8 @@ module Arcabouco
66
94
  end
67
95
 
68
96
  def setup_rack
69
- app = Arcabouco::WebServer.new
97
+ self.web = Arcabouco::WebServer.new
98
+ web = self.web
70
99
 
71
100
  # app_css.write_to( Arcabouco.root + "/public/app-#{app_css.digest}.min.css" )
72
101
  $environment = self.get_env()
@@ -74,7 +103,7 @@ module Arcabouco
74
103
  map '/app.assets' do
75
104
  run $environment
76
105
  end
77
- run app
106
+ run web
78
107
  end
79
108
  self.rack
80
109
  end
@@ -92,6 +121,7 @@ module Arcabouco
92
121
  self.env.css_compressor = :sass
93
122
  end
94
123
 
124
+
95
125
  def build
96
126
  FileUtils.mkpath Arcabouco.root + "/public"
97
127
  FileUtils.mkpath Arcabouco.root + "/public/app.assets"
@@ -99,9 +129,10 @@ module Arcabouco
99
129
  prepare_env_for_build
100
130
 
101
131
  manifest = Sprockets::Manifest.new(env, Arcabouco.root + "/public/app.assets/manifest.json")
102
- manifest.compile(%w(app.css app.js vendor.js vendor.css *.png))
132
+ manifest.compile self.web.assets_list
103
133
 
104
134
  compile_view "/", "index.html"
135
+ compile_view "/save_app.html", "save_app.html"
105
136
  compile_view "/manifest.appcache", "manifest.appcache"
106
137
  end
107
138
 
@@ -1,3 +1,3 @@
1
1
  module Arcabouco
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
File without changes
@@ -1,4 +1,3 @@
1
- window.app = {}
2
1
  @app = window.app
3
2
  @app._routers = []
4
3
  @app.routes = {}
@@ -1,5 +1,4 @@
1
1
  //= require handlebars.runtime
2
- //= require ./vendor/jquery.js
3
2
  //= require ./vendor/underscore.js
4
3
  //= require ./vendor/backbone.js
5
4
  //= require ./vendor/async.js
@@ -3,13 +3,9 @@
3
3
  -# Set a base Title (From Partial maybe?)
4
4
  %link{:href => "//iugu.com/imgs/favicon.ico", :rel => "icon"}/
5
5
  %link{:href => "//iugu.com/imgs/favicon.ico", :rel => "shortcut icon"}/
6
- %title ...
6
+ %title ......
7
7
  %meta{ :charset => "utf-8" }
8
8
 
9
- %link{:rel => :stylesheet, :type => :"text/css", :href => "/app.assets/#{assets['app.css'].digest_path}" }
10
- %script{:type => :"text/javascript", :src => "/app.assets/#{assets['vendor.js'].digest_path}"}
11
- %script{:type => :"text/javascript", :src => "/app.assets/#{assets['app.js'].digest_path}"}
12
-
13
9
  %meta{ :name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1" }
14
10
  %meta{ :name => "apple-mobile-web-app-capable", :content => "yes" }
15
11
  %meta{ :name => "apple-mobile-web-status-bar-style", :content => "black" }
@@ -22,17 +18,3 @@
22
18
  .js-warning
23
19
 
24
20
  #app
25
- %h1
26
- Application Place Holder
27
-
28
- -# Need to render additional footer
29
- -# Google Tag Manager and footer additional scripts
30
- -# Best to have a base_footer
31
-
32
- %script
33
- (function() { $(function() {
34
- if (typeof(run_webapp) == 'function')
35
- return run_webapp(true);
36
- });
37
- }).call(this);
38
-
@@ -0,0 +1,110 @@
1
+ <!DOCTYPE html>
2
+ <html class='no-js not-ready'>
3
+ <head>
4
+ <title>...</title>
5
+ <meta charset='utf-8'>
6
+ <meta content='width=device-width, initial-scale=1, maximum-scale=1' name='viewport'>
7
+ <meta content='yes' name='apple-mobile-web-app-capable'>
8
+ <meta content='black' name='apple-mobile-web-status-bar-style'>
9
+ <meta content='on' http-equiv='cleartype'>
10
+ <meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible'>
11
+ <meta content='320' name='MobileOptimized'>
12
+ <script type="text/javascript" src="/app.assets/<%= assets['jquery.js'].digest_path %>"></script>
13
+ </head>
14
+ <body>
15
+ <noscript>
16
+ <div class='js-warning'></div>
17
+ </noscript>
18
+ <div id='app'></div>
19
+
20
+ <script type="text/javascript">
21
+ window.app = {}
22
+ window.app.bootstraped = false;
23
+ window.app.assets_manifest = "/<%= ENV['RACK_ENV'] == 'production' ? 'app.assets/manifest.json' : 'manifest.json' %>";
24
+
25
+ function currentCacheStatus() {
26
+ appCache = app.applicationCache;
27
+ switch (appCache.status) {
28
+ case appCache.UNCACHED: // UNCACHED == 0
29
+ return 'UNCACHED';
30
+ break;
31
+ case appCache.IDLE: // IDLE == 1
32
+ return 'IDLE';
33
+ break;
34
+ case appCache.CHECKING: // CHECKING == 2
35
+ return 'CHECKING';
36
+ break;
37
+ case appCache.DOWNLOADING: // DOWNLOADING == 3
38
+ return 'DOWNLOADING';
39
+ break;
40
+ case appCache.UPDATEREADY: // UPDATEREADY == 4
41
+ return 'UPDATEREADY';
42
+ break;
43
+ case appCache.OBSOLETE: // OBSOLETE == 5
44
+ return 'OBSOLETE';
45
+ break;
46
+ default:
47
+ return 'UKNOWN CACHE STATUS';
48
+ break;
49
+ }
50
+ }
51
+
52
+ function addScriptTag(src)
53
+ {
54
+ var newScript = document.createElement('script');
55
+ newScript.type = 'text/javascript';
56
+ newScript.src = src;
57
+ document.head.appendChild(newScript);
58
+ }
59
+
60
+ function bootstrapApplication()
61
+ {
62
+ if (app.bootstraped) return;
63
+ app.bootstraped = true;
64
+ console.log("START");
65
+ console.log("FETCH " + app.assets_manifest );
66
+ jQuery.getJSON( app.assets_manifest, function(data) {
67
+ $('head').append('<link rel="stylesheet" href="' + data.assets["vendor.css"] + '" type="text/css" />');
68
+ $('head').append('<link rel="stylesheet" href="' + data.assets["app.css"] + '" type="text/css" />');
69
+ addScriptTag( data.assets['vendor.js'] );
70
+ addScriptTag( data.assets['app.js'] );
71
+ });
72
+ }
73
+
74
+ function updateApplicationDownloadProgress(progress)
75
+ {
76
+ if (app.bootstraped) return;
77
+ console.log("New asset downloaded");
78
+ }
79
+
80
+ function refreshApplicationFiles()
81
+ {
82
+ if (app.bootstraped == false) {
83
+ app.applicationCache.swapCache();
84
+ bootstrapApplication();
85
+ }
86
+ else {
87
+ if (confirm('A new version of this application is available. Load it?')) {
88
+ window.location.reload();
89
+ }
90
+ }
91
+ }
92
+
93
+ $(document).ready( function() {
94
+ appcache_frame = $('<iframe>').attr('src', '/save_app.html').load(function() {
95
+ app.applicationCache = appcache_frame.contentWindow.applicationCache;
96
+
97
+ app.applicationCache.addEventListener('noupdate', bootstrapApplication, false);
98
+ app.applicationCache.addEventListener('updateready', refreshApplicationFiles, false);
99
+ app.applicationCache.addEventListener('progress', function(e) { updateApplicationDownloadProgress(e); }, false);
100
+
101
+ setInterval(function() {
102
+ console.log("Checking for new versions");
103
+ app.applicationCache.update();
104
+ }, 10*1000);
105
+
106
+ }).appendTo('head')[0]
107
+ });
108
+ </script>
109
+ </body>
110
+ </html>
@@ -1,4 +1,5 @@
1
1
  CACHE MANIFEST
2
+ # <%= index_digest %>
2
3
 
3
4
  CACHE:
4
5
  <% if assets['app.css'] %>/app.assets/<%= assets['app.css'].digest_path %><% end %>
@@ -7,7 +8,10 @@ CACHE:
7
8
 
8
9
  <% if assets['vendor.js'] %>/app.assets/<%= assets['vendor.js'].digest_path %><% end %>
9
10
 
11
+ <% if assets['jquery.js'] %>/app.assets/<%= assets['jquery.js'].digest_path %><% end %>
12
+
10
13
  NETWORK:
14
+ *
11
15
 
12
16
  FALLBACK:
13
17
 
@@ -0,0 +1,7 @@
1
+ <!DOCTYPE html>
2
+ <html manifest='/manifest.appcache'>
3
+ <head></head>
4
+ <body>
5
+ </body>
6
+ </html>
7
+
@@ -0,0 +1,7 @@
1
+ <!DOCTYPE html>
2
+ <html manifest='/manifest.appcache'>
3
+ <head></head>
4
+ <body>
5
+ </body>
6
+ </html>
7
+
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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Negri
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: therubyracer
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: eco
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -288,23 +302,27 @@ files:
288
302
  - lib/assets/css/mixins.sass
289
303
  - lib/assets/css/no-js.sass
290
304
  - lib/assets/css/reset.sass
305
+ - lib/assets/css/vendor.css
291
306
  - lib/assets/js/app.js
292
307
  - lib/assets/js/config.js.coffee
293
308
  - lib/assets/js/core/boot.js.coffee
294
309
  - lib/assets/js/core/capabilities.js
295
310
  - lib/assets/js/core/debug.js.coffee
296
311
  - lib/assets/js/core/environment.js.coffee
312
+ - lib/assets/js/jquery.js
297
313
  - lib/assets/js/templates.js
298
314
  - lib/assets/js/usecode.js
299
315
  - lib/assets/js/vendor.js
300
316
  - lib/assets/js/vendor/async.js
301
317
  - lib/assets/js/vendor/backbone.js
302
318
  - lib/assets/js/vendor/handlebars.js
303
- - lib/assets/js/vendor/jquery.js
304
319
  - lib/assets/js/vendor/tasks.js.coffee
305
320
  - lib/assets/js/vendor/underscore.js
306
321
  - lib/templates/index.haml
322
+ - lib/templates/index.html.erb
307
323
  - lib/templates/manifest.erb
324
+ - lib/templates/save_app.html
325
+ - lib/templates/save_app.html.erb
308
326
  homepage: ''
309
327
  licenses: []
310
328
  metadata: {}
File without changes