limelight 0.3.0-java → 0.3.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/lib/init.rb +1 -1
  2. data/lib/limelight.jar +0 -0
  3. data/lib/limelight/builtin/players.rb +2 -1
  4. data/lib/limelight/builtin/players/combo_box.rb +2 -0
  5. data/lib/limelight/builtin/players/curtains.rb +1 -0
  6. data/lib/limelight/builtin/players/password_box.rb +34 -0
  7. data/lib/limelight/casting_director.rb +2 -1
  8. data/lib/limelight/client/playbills.rb +83 -0
  9. data/lib/limelight/commands/command.rb +14 -2
  10. data/lib/limelight/commands/help_command.rb +50 -0
  11. data/lib/limelight/commands/unpack_command.rb +44 -0
  12. data/lib/limelight/commands/version_command.rb +31 -0
  13. data/lib/limelight/data.rb +47 -0
  14. data/lib/limelight/java_couplings.rb +1 -0
  15. data/lib/limelight/limelight_exception.rb +13 -0
  16. data/lib/limelight/main.rb +22 -24
  17. data/lib/limelight/producer.rb +3 -2
  18. data/lib/limelight/prop.rb +2 -1
  19. data/lib/limelight/scene.rb +8 -1
  20. data/lib/limelight/util/downloader.rb +113 -0
  21. data/lib/limelight/version.rb +1 -1
  22. data/productions/examples/8thlight.com/styles.rb +147 -149
  23. data/productions/examples/calculator/styles.rb +2 -4
  24. data/productions/examples/langstons_ant/styles.rb +1 -2
  25. data/productions/examples/sandbox/click_me/players/chromaton.rb +2 -3
  26. data/productions/examples/sandbox/click_me/styles.rb +6 -7
  27. data/productions/examples/sandbox/floaters/players/floater.rb +2 -2
  28. data/productions/examples/sandbox/floaters/styles.rb +1 -2
  29. data/productions/examples/sandbox/frameing/players/sandbox.rb +14 -0
  30. data/productions/examples/sandbox/frameing/props.rb +32 -0
  31. data/productions/examples/sandbox/frameing/styles.rb +42 -0
  32. data/productions/examples/sandbox/header.rb +1 -0
  33. data/productions/examples/sandbox/homer/styles.rb +1 -2
  34. data/productions/examples/sandbox/images_scene/styles.rb +3 -2
  35. data/productions/examples/sandbox/inputs/styles.rb +0 -1
  36. data/productions/examples/sandbox/rounded_corners/styles.rb +1 -2
  37. data/productions/examples/sandbox/scrolling/styles.rb +1 -2
  38. data/productions/examples/sandbox/styles.rb +7 -9
  39. data/productions/examples/sandbox/teaser/styles.rb +1 -2
  40. data/productions/examples/tutorials/tutorial_1/styles.rb +2 -4
  41. data/productions/startup/stages.rb +6 -0
  42. data/productions/startup/{players → welcome/players}/browse_button.rb +0 -0
  43. data/productions/startup/{players → welcome/players}/download_button.rb +3 -3
  44. data/productions/startup/{players → welcome/players}/sandbox_button.rb +0 -0
  45. data/productions/startup/{props.rb → welcome/props.rb} +0 -0
  46. data/productions/startup/{styles.rb → welcome/styles.rb} +0 -0
  47. data/spec/builtin/players/password_box_spec.rb +27 -0
  48. data/spec/client/playbills_spec.rb +76 -0
  49. data/spec/commands/help_command_spec.rb +39 -0
  50. data/spec/commands/unpack_command_spec.rb +44 -0
  51. data/spec/data_spec.rb +47 -0
  52. data/spec/main_spec.rb +20 -0
  53. data/spec/prop_spec.rb +18 -0
  54. data/spec/scene_spec.rb +43 -0
  55. data/spec/spec_helper.rb +2 -1
  56. data/spec/util/downloader_spec.rb +89 -0
  57. metadata +33 -11
  58. data/productions/examples/sandbox.llp +0 -0
@@ -12,6 +12,7 @@ require 'limelight/dsl/build_exception'
12
12
  require 'limelight/theater'
13
13
  require 'limelight/production'
14
14
  require 'limelight/gems'
15
+ require 'limelight/util/downloader'
15
16
 
16
17
  module Limelight
17
18
 
@@ -38,7 +39,7 @@ module Limelight
38
39
  def initialize(root_path, theater=nil, production=nil)
39
40
  if (root_path[-4..-1] == ".lll")
40
41
  url = IO.read(root_path).strip
41
- root_path = Limelight::Context.instance.downloader.download(url).absolute_path
42
+ root_path = Util::Downloader.download(url)
42
43
  end
43
44
  if (root_path[-4..-1] == ".llp")
44
45
  root_path = unpack_production(root_path)
@@ -59,7 +60,7 @@ module Limelight
59
60
  #
60
61
  def load(options = {})
61
62
  establish_production
62
- Gems.install_gems_in_production(@production)
63
+ Gems.install_gems_in_production(@production)
63
64
  Kernel.load(@production.init_file) if ( !options[:ignore_init] && File.exists?(@production.init_file) )
64
65
  load_stages if File.exists?(@production.stages_file)
65
66
  end
@@ -80,9 +80,10 @@ module Limelight
80
80
  # child2
81
81
  # end
82
82
  #
83
- def build(&block)
83
+ def build(options = {}, &block)
84
84
  require 'limelight/dsl/prop_builder'
85
85
  builder = Limelight::DSL::PropBuilder.new(self)
86
+ builder.__install_instance_variables(options)
86
87
  builder.__loader__ = scene.loader
87
88
  builder.instance_eval(&block)
88
89
  end
@@ -111,7 +111,14 @@ module Limelight
111
111
 
112
112
  # Removed the Prop from the index.
113
113
  #
114
- def unindex_prop(prop)
114
+ def unindex_prop(prop)
115
+ prop.children.each do |child|
116
+ if child.children.empty?
117
+ @prop_index.delete(child.id)
118
+ else
119
+ unindex_prop(child)
120
+ end
121
+ end
115
122
  @prop_index.delete(prop.id) if prop.id
116
123
  end
117
124
 
@@ -0,0 +1,113 @@
1
+ require 'limelight/data'
2
+ require 'limelight/limelight_exception'
3
+ require 'uri'
4
+ require 'ftools'
5
+ require 'net/http'
6
+ require 'net/https'
7
+
8
+ module Limelight
9
+ module Util
10
+
11
+ class Downloader
12
+
13
+ def self.download(resource)
14
+ puts "resource: #{resource}"
15
+ new.download(resource)
16
+ end
17
+
18
+ def initialize
19
+ Data.establish_data_dirs
20
+ end
21
+
22
+ def download(resource)
23
+ uri = URI.parse(resource)
24
+ case uri.scheme
25
+ when nil, "file"
26
+ download_file(uri)
27
+ when 'http', 'https'
28
+ download_http(uri)
29
+ else
30
+ raise LimelightException.new("Download failed. Unhandled URI scheme: #{uri.scheme}")
31
+ end
32
+ end
33
+
34
+ def download_file(uri)
35
+ raise LimelightException.new("Download failed. Not found: #{uri.path}") if !File.exists?(uri.path)
36
+ filename = File.basename(uri.path)
37
+ destination = find_unused_downloads_filename(filename)
38
+ File.copy(uri.path, destination)
39
+ return destination
40
+ end
41
+
42
+ def download_http(uri)
43
+ saved_filename = nil
44
+
45
+ begin
46
+ saved_filename = attempt_http_download(uri)
47
+ rescue Exception => e
48
+ raise LimelightException.new(e)
49
+ end
50
+
51
+ return saved_filename
52
+ end
53
+
54
+
55
+ private #############################################
56
+
57
+ def find_unused_downloads_filename(filename)
58
+ default = File.join(Data.downloads_dir, filename)
59
+ extension = File.extname(default)
60
+ filename_without_extension = default[0...(-1 * extension.length)]
61
+ attempt = default
62
+ postfix = 2
63
+ while (File.exists?(attempt))
64
+ attempt = "#{filename_without_extension}_#{postfix}#{extension}"
65
+ postfix += 1
66
+ end
67
+ return attempt
68
+ end
69
+
70
+ def calculate_filename(uri, response)
71
+ content_disposition = response['content-disposition']
72
+ if content_disposition
73
+ match = /filename="(.*)"/.match(content_disposition)
74
+ return match[1] if match
75
+ end
76
+ return File.basename(uri.path)
77
+ end
78
+
79
+ def save_to_file(uri, response)
80
+ filename = calculate_filename(uri, response)
81
+ destination = find_unused_downloads_filename(filename)
82
+ file = File.open(destination, 'w')
83
+
84
+ begin
85
+ response.read_body do |segment|
86
+ file.write(segment)
87
+ end
88
+ ensure
89
+ file.close
90
+ end
91
+
92
+ return destination
93
+ end
94
+
95
+ def attempt_http_download(uri, attempts = 5)
96
+ http = Net::HTTP.new(uri.host, uri.port)
97
+ http.use_ssl = true if uri.port.to_s == "443"
98
+ http.request_get(uri.path) do |response|
99
+ case response
100
+ when Net::HTTPSuccess
101
+ return save_to_file(uri, response)
102
+ when Net::HTTPRedirection
103
+ return attempt_http_download(URI.parse(response['location']), attempts - 1)
104
+ else
105
+ raise LimelightException.new("Download failed. #{response.code}: #{response.message}")
106
+ end
107
+ end
108
+ end
109
+
110
+ end
111
+
112
+ end
113
+ end
@@ -6,7 +6,7 @@ module Limelight
6
6
  unless defined? MAJOR
7
7
  MAJOR = 0
8
8
  MINOR = 3
9
- TINY = 0
9
+ TINY = 1
10
10
 
11
11
  STRING = [MAJOR, MINOR, TINY].join('.')
12
12
  TAG = "REL_" + [MAJOR, MINOR, TINY].join('_')
@@ -2,211 +2,209 @@
2
2
  #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
3
 
4
4
  page {
5
- width "100%"
6
- height "100%"
7
- horizontal_alignment "center"
8
- background_image "images/bg.jpg"
5
+ width "100%"
6
+ height "100%"
7
+ horizontal_alignment "center"
8
+ background_image "images/bg.jpg"
9
9
  vertical_scrollbar :on
10
10
  }
11
-
11
+
12
12
  main_column {
13
- border_width 0
14
- background_image "images/canvas_bg.jpg"
15
- width 823
16
- height :auto
17
- horizontal_alignment "center"
13
+ border_width 0
14
+ background_image "images/canvas_bg.jpg"
15
+ width 823
16
+ height :auto
17
+ horizontal_alignment "center"
18
18
  }
19
-
19
+
20
20
  header {
21
- height 200
22
- background_image "images/header.jpg"
23
- width 823
24
- horizontal_alignment "center"
21
+ height 200
22
+ background_image "images/header.jpg"
23
+ width 823
24
+ horizontal_alignment "center"
25
25
  }
26
26
 
27
27
  menu {
28
- height 67
29
- top_border_width 1
30
- bottom_border_width 1
31
- border_color "#333333"
32
- width 823
33
- horizontal_alignment :right
34
- right_margin 25
35
- left_margin 25
36
- bottom_margin 15
28
+ height 67
29
+ top_border_width 1
30
+ bottom_border_width 1
31
+ border_color "#333333"
32
+ width 823
33
+ horizontal_alignment :right
34
+ right_margin 25
35
+ left_margin 25
36
+ bottom_margin 15
37
37
  }
38
38
 
39
39
  link {
40
- width 80
41
- height 50
42
- text_color "#0049F4"
43
- font_face "Arial"
44
- font_size 13
45
- vertical_alignment :center
46
- horizontal_alignment :center
47
- hover {
48
- text_color "#ffffff"
49
- background_image "images/button_bg.jpg"
50
- }
40
+ width 80
41
+ height 50
42
+ text_color "#0049F4"
43
+ font_face "Arial"
44
+ font_size 13
45
+ alignment :center
46
+ hover {
47
+ text_color "#ffffff"
48
+ background_image "images/button_bg.jpg"
49
+ }
51
50
  }
52
51
 
53
52
  tag_line {
54
- width 823
55
- height 70
56
- background_image "images/anvil.jpg"
57
- right_margin 25
58
- left_margin 25
59
- horizontal_alignment :left
60
- font_style "italics"
61
- text_color "white"
62
- font_size 18
63
- top_padding 10
64
- left_padding 10
65
- right_padding 375
66
- }
67
-
53
+ width 823
54
+ height 70
55
+ background_image "images/anvil.jpg"
56
+ right_margin 25
57
+ left_margin 25
58
+ horizontal_alignment :left
59
+ font_style "italic"
60
+ text_color "white"
61
+ font_size 18
62
+ top_padding 10
63
+ left_padding 10
64
+ right_padding 375
65
+ }
66
+
68
67
  services_tagline {
69
68
  extends :tag_line
70
69
  background_image "images/botticelli.jpg"
71
- horizontal_alignment "right"
70
+ horizontal_alignment "right"
72
71
  }
73
-
72
+
74
73
  about_tagline {
75
74
  extends :tag_line
76
- background_image "images/moses.jpg"
77
- horizontal_alignment "right"
75
+ background_image "images/moses.jpg"
76
+ horizontal_alignment "right"
78
77
  }
79
-
78
+
80
79
  section_title {
81
- width 823
82
- height 50
83
- top_margin 20
84
- left_margin 50
85
- right_margin 50
86
- bottom_border_width 1
87
- border_color "#0049F4"
88
- text_color "white"
89
- font_size 20
90
- font_style "bold"
80
+ width 823
81
+ height 50
82
+ top_margin 20
83
+ left_margin 50
84
+ right_margin 50
85
+ bottom_border_width 1
86
+ border_color "#0049F4"
87
+ text_color "white"
88
+ font_size 20
89
+ font_style "bold"
91
90
  }
92
91
 
93
92
  sub_title {
94
- text_color "#0049F4"
95
- font_size 32
96
- font_face "Courier"
93
+ text_color "#0049F4"
94
+ font_size 32
95
+ font_face "Courier"
97
96
  }
98
-
97
+
99
98
  section_body {
100
- width 823
101
- height :auto
102
- left_margin 50
103
- right_margin 50
104
- text_color "white"
105
- font_size 14
99
+ width 823
100
+ height :auto
101
+ left_margin 50
102
+ right_margin 50
103
+ text_color "white"
104
+ font_size 14
106
105
  }
107
106
 
108
107
  spot_light {
109
- width 412
110
- height 300
111
- top_margin 20
112
- left_margin 50
113
- right_margin 50
108
+ width 412
109
+ height 300
110
+ top_margin 20
111
+ left_margin 50
112
+ right_margin 50
114
113
  }
115
-
114
+
116
115
  spot_light_title {
117
- width 312
118
- height 45
119
- bottom_border_width 1
120
- border_color "#0049F4"
121
- font_size 20
122
- text_color "white"
116
+ width 312
117
+ height 45
118
+ bottom_border_width 1
119
+ border_color "#0049F4"
120
+ font_size 20
121
+ text_color "white"
123
122
  }
124
123
 
125
124
  book_news {
126
- height 75
127
- width "100%"
128
- bottom_border_width 1
129
- border_color "#333333"
130
- top_margin 10
125
+ height 75
126
+ width "100%"
127
+ bottom_border_width 1
128
+ border_color "#333333"
129
+ top_margin 10
131
130
  }
132
-
131
+
133
132
  book_news_img {
134
- background_image "images/thumbnail_book.jpg"
135
- width 59
136
- height 58
133
+ background_image "images/thumbnail_book.jpg"
134
+ width 59
135
+ height 58
137
136
  }
138
-
137
+
139
138
  book_news_text {
140
- width 253
141
- height 58
142
- left_margin 10
143
- font_size 15
144
- font_face "Helvetica"
145
- text_color "#919191"
139
+ width 253
140
+ height 58
141
+ left_margin 10
142
+ font_size 15
143
+ font_face "Helvetica"
144
+ text_color "#919191"
146
145
  }
147
146
 
148
147
  sm_news {
149
- height 75
150
- width "100%"
151
- bottom_border_width 1
152
- border_color "#333333"
153
- top_margin 10
148
+ height 75
149
+ width "100%"
150
+ bottom_border_width 1
151
+ border_color "#333333"
152
+ top_margin 10
154
153
  }
155
-
154
+
156
155
  sm_news_img {
157
- background_image "images/statemachine_thumbnail.png"
158
- width 59
159
- height 58
156
+ background_image "images/statemachine_thumbnail.png"
157
+ width 59
158
+ height 58
160
159
  }
161
-
160
+
162
161
  sm_news_text {
163
162
  extends :book_news_text
164
163
  }
165
164
 
166
165
  news {
167
- width 411
168
- height 320
169
- top_margin 20
170
- left_margin 30
171
- right_margin 50
166
+ width 411
167
+ height 320
168
+ top_margin 20
169
+ left_margin 30
170
+ right_margin 50
172
171
  }
173
-
172
+
174
173
  news_title {
175
- width 311
176
- height 45
177
- bottom_border_width 1
178
- border_color "#0049F4"
179
- font_size 20
180
- text_color "white"
174
+ width 311
175
+ height 45
176
+ bottom_border_width 1
177
+ border_color "#0049F4"
178
+ font_size 20
179
+ text_color "white"
181
180
  }
182
181
 
183
182
  new_item {
184
- text_color "#919191"
185
- font_size 12
186
- font_face "Helvetica"
187
- height 50
188
- width "100%"
189
- bottom_border_width 1
190
- border_color "#333333"
191
- top_margin 10
192
- background_color "black"
193
- hover {
194
- text_color "white"
195
- background_color "black"
196
- }
197
- }
198
-
183
+ text_color "#919191"
184
+ font_size 12
185
+ font_face "Helvetica"
186
+ height 50
187
+ width "100%"
188
+ bottom_border_width 1
189
+ border_color "#333333"
190
+ top_margin 10
191
+ background_color "black"
192
+ hover {
193
+ text_color "white"
194
+ background_color "black"
195
+ }
196
+ }
197
+
199
198
  footer {
200
- background_image "images/footer_bg.jpg"
201
- height 80
202
- width 823
199
+ background_image "images/footer_bg.jpg"
200
+ height 80
201
+ width 823
203
202
  }
204
-
203
+
205
204
  copyright {
206
- top_margin 40
207
- vertical_alignment :center
208
- horizontal_alignment :center
209
- text_color "#666"
210
- width 823
211
- height 80
205
+ top_margin 40
206
+ alignment :center
207
+ text_color "#666"
208
+ width 823
209
+ height 80
212
210
  }