goat 0.3.41 → 0.3.42

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'goat'
3
- s.version = '0.3.41'
3
+ s.version = '0.3.42'
4
4
  s.summary = 'Pre-release beta version of Goat'
5
5
  s.author = 'Patrick Collison'
6
6
  s.email = 'patrick@collison.ie'
@@ -771,7 +771,7 @@ module Goat
771
771
 
772
772
  def self.handle_request(app)
773
773
  pg = self.new(app)
774
-
774
+
775
775
  raise "Page #{pg} has no id: did you forget to call super()?" unless pg.id
776
776
 
777
777
  pg.response
@@ -822,6 +822,8 @@ module Goat
822
822
  canvas.style << distiller.style
823
823
  canvas.script << distiller.script
824
824
 
825
+ distiller.all_component_classes.each {|c| canvas.script_files += c.script_files}
826
+
825
827
  EM.next_tick { register_page(distiller) }
826
828
  end
827
829
 
@@ -868,15 +870,20 @@ module Goat
868
870
  end
869
871
 
870
872
  class PageCanvas
871
- attr_accessor :title, :script, :style, :html
873
+ attr_accessor :title, :script, :style, :html, :script_files
872
874
 
873
875
  def initialize
874
876
  @script = []
875
877
  @style = []
878
+ @script_files = []
876
879
  end
877
880
 
878
881
  def flattened_style; @style.join; end
879
882
  def flattened_script; @script.join; end
883
+
884
+ def additional_script_tags
885
+ @script_files.map {|file| "<script for=\"goat\" src=\"#{file}\"></script>"}
886
+ end
880
887
  end
881
888
 
882
889
  class JustRerenderError < RuntimeError; end
@@ -1276,9 +1283,14 @@ module Goat
1276
1283
 
1277
1284
  def self.script(script); @script = AutoBind.process(script); end
1278
1285
  def script(script); @script = AutoBind.process(script); end
1286
+
1287
+ # the above are actually *setters*; these are the (internal-use-only) getters
1279
1288
  def self.__script; @script; end
1280
1289
  def __script; @script; end
1281
1290
 
1291
+ def self.script_files; @script_files ||= []; end
1292
+ def self.script_file(f); script_files << f; end
1293
+
1282
1294
  def wire_script
1283
1295
  "Goat.wireComponent('#{id}', #{clientside_instance})"
1284
1296
  end
@@ -6,6 +6,7 @@
6
6
  <%= yield %>
7
7
  <script src="/static/jquery.js"></script>
8
8
  <script src="/static/goat.js"></script>
9
+ <%= canvas.additional_script_tags %>
9
10
  <script><%= canvas.script %></script>
10
11
  <% if page.class.live_updates_enabled? %><script>Goat.page_id = '<%= page.id %>'</script><% end %>
11
12
  </body></html>
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goat
3
3
  version: !ruby/object:Gem::Version
4
- hash: 65
4
+ hash: 71
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 41
10
- version: 0.3.41
9
+ - 42
10
+ version: 0.3.42
11
11
  platform: ruby
12
12
  authors:
13
13
  - Patrick Collison
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-09 00:00:00 +00:00
18
+ date: 2011-02-15 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency