marley 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,38 +0,0 @@
1
- module Marley
2
- class Client
3
- # Here we define the Jamaica client class for Marley. This client
4
- # is a simple HTML page that is intended to be run in a browser.
5
- # It will have its actual UI metadata in the global variable '_jamaica_json'
6
- # and onDocumentReady, this will be turned into the client UI.
7
- def initialize(opts={})
8
- @opts={:app_name => 'Application',:css => '', :js => ''}.merge(opts)
9
- @client_dir="#{File.dirname(__FILE__)}/client/"
10
- @libs = Dir.glob("#{@client_dir}*.js").sort
11
- @styles = [ 'jamaica.css' ]
12
- end
13
- def joint(joint_d,joint_name)
14
- [:css,:js].each do |ext|
15
- fn="#{joint_d}#{joint_name}.#{ext.to_s}"
16
- File.exists?(fn) && send(ext,File.new(fn,"r").read)
17
- end
18
- end
19
- def css(add_css=nil)
20
- @opts[:css]+=add_css if add_css
21
- @opts[:css]
22
- end
23
- def js(add_js=nil)
24
- @opts[:js]+=add_js if add_js
25
- @opts[:js]
26
- end
27
- def to_s(json='')
28
- <<-EOHTML
29
- <head>
30
- <title>#{@opts[:app_name]}</title>
31
- <script type='text/javascript'>var _jamaica_json=#{json}; #{ @libs.map{ |l| File.new(l).read }.push(@opts[:js]).join("\n") }</script>
32
- <style>#{ @styles.map{ |s| File.new("#{@client_dir}#{s}").read }.push(@opts[:css]).join("\n") }
33
- </head>
34
- <body></body>
35
- EOHTML
36
- end
37
- end
38
- end