ziya 2.1.9 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,4 +31,6 @@
31
31
  2.1.6 - Fix issue with nil value in series being ignored where using the { :value => nil } form.
32
32
  2.1.7 - Fix possible naming conflict with String extension class
33
33
  2.1.8 - Added support for ruby 1.9 and bundler ( Thanks Roland Venesz and Todd Sedano for the contributions! )
34
+ 2.1.9 - Various bug fixes and clean ups
35
+ 2.3.0 - Moving to Rails3
34
36
 
@@ -30,6 +30,7 @@ like applications. Your manager will love you for it !!
30
30
 
31
31
  * logging
32
32
  * color
33
+ * builder
33
34
 
34
35
  ZiYa comes pre-bundled with the following packages:
35
36
  * XML/SWF charts Version 5.07 (http://www.maani.us/xml_charts/index.php)
@@ -66,10 +67,74 @@ like applications. Your manager will love you for it !!
66
67
 
67
68
  == SYNOPSIS:
68
69
 
69
- This gem version requires a client update to flash 9.0 and possibly you will
70
+ This gem version requires a client update to flash 10.0 and possibly you will
70
71
  need to get a new license from XML/SWF >= 5.0, if you want to use
71
72
  advanced features suck as links and live updates.
72
73
 
74
+ == Creating a ZiYa chart in a Rails 3.0 application
75
+
76
+ 1 - Edit your Gemfile and add the followings:
77
+ gem 'ziya', '2.3.0'
78
+ gem 'color'
79
+ gem 'logging'
80
+ gem 'builder'
81
+
82
+ 2 - Create a ziya.rb file under config/initializers
83
+
84
+ ziya.rb:
85
+
86
+ require 'ziya'
87
+
88
+ # Initializes the ZiYa Framework
89
+ Ziya.initialize(
90
+ :logger => RAILS_DEFAULT_LOGGER,
91
+ :themes_dir => File.join( File.dirname(__FILE__), %w[.. .. public charts themes])
92
+ )
93
+
94
+ This will initialize the gem. You can log the output to stdout using the ZiYa bundled logger
95
+ or specify a file ie File.join( File.dirname(__FILE__), %w[.. log ziya.log]. If you choose to use the
96
+ ZiYa logger, you can specify the :log_level option to either :warn :info :debug or :error.
97
+ You will need to specify your themes directory typically located under public/charts/themes or any location
98
+ you'll like to choose.
99
+
100
+ 3 - Create a chart controller
101
+
102
+ blee_controller.rb:
103
+
104
+ class BleeController < ApplicationController
105
+ helper Ziya::HtmlHelpers::Charts, Ziya::YamlHelpers::Charts
106
+
107
+ # Callback from the flash movie to get the chart's data
108
+ def load_chart
109
+ # Create a bar chart with 2 series composed of 3 data points each.
110
+ # Chart will be rendered using the default look and feel
111
+ chart = Ziya::Charts::Bar.new
112
+ chart.add( :axis_category_text, %w[2006 2007 2008] )
113
+ chart.add( :series, "Dogs", [10,20,30] )
114
+ chart.add( :series, "Cats", [5,15,25] )
115
+ respond_to do |fmt|
116
+ fmt.xml { render :xml => chart.to_xml }
117
+ end
118
+ end
119
+ end
120
+
121
+ 4 - Create a view
122
+
123
+ blee/index.html.erb:
124
+
125
+ # Defines the necessary tag to embed a flash movie in your html page.
126
+ # This will callback to your controller to fetch the necessary xml.
127
+ <%= ziya_chart load_chart_url(:xml) -%>
128
+
129
+ NOTE: You must now specify the xml format for correct rendering!
130
+
131
+ 5 - Create a named route
132
+
133
+ config/routes.rb:
134
+
135
+ match 'blee' => "blee#index"
136
+ match 'load_chart' => "blee#load_chart"
137
+
73
138
  == Creating a ZiYa chart in a Rails 2.3 application
74
139
 
75
140
  1 - Create a ziya.rb file under config/initializers
@@ -110,7 +175,8 @@ like applications. Your manager will love you for it !!
110
175
  respond_to do |fmt|
111
176
  fmt.xml { render :xml => chart.to_xml }
112
177
  end
113
- end
178
+ end
179
+ end
114
180
 
115
181
  4 - Create a view
116
182
 
@@ -32,8 +32,8 @@ module Ziya
32
32
  url ? CGI.escape( url.gsub( /&amp;/, '&' ) ) : url
33
33
  end
34
34
 
35
- # # All this stolen form rails to make Ziya work with other fmks....
36
- def tag(name, options = nil, open = false, escape = true)
35
+ # All this stolen form rails to make Ziya work with other fmks....
36
+ def ziya_tag(name, options = nil, open = false, escape = true)
37
37
  "<#{name}#{tag_options(options, escape) if options}" + (open ? ">" : " />")
38
38
  end
39
39
 
@@ -57,32 +57,7 @@ module Ziya
57
57
  " #{attrs.sort * ' '}" unless attrs.empty?
58
58
  end
59
59
  end
60
- #
61
- # def content_tag(name, content_or_options_with_block = nil, options = nil, escape = true, &block)
62
- # if block_given?
63
- # options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash)
64
- # content = capture_block(&block)
65
- # content_tag = content_tag_string(name, content, options, escape)
66
- # block_is_within_action_view?(block) ? concat(content_tag, block.binding) : content_tag
67
- # else
68
- # content = content_or_options_with_block
69
- # content_tag_string(name, content, options, escape)
70
- # end
71
- # end
72
- #
73
- # def capture_block( *args, &block )
74
- # block.call(*args)
75
- # end
76
- #
77
- # def content_tag_string(name, content, options, escape = true)
78
- # tag_options = tag_options(options, escape) if options
79
- # "<#{name}#{tag_options}>#{content}</#{name}>"
80
- # end
81
- #
82
- # def block_is_within_action_view?(block)
83
- # eval("defined? _erbout", block.binding)
84
- # end
85
- #
60
+
86
61
  def escape_chars
87
62
  { '&' => '&amp;', '"' => '&quot;', '>' => '&gt;', '<' => '&lt;' }
88
63
  end
@@ -77,7 +77,7 @@ module Ziya::HtmlHelpers::Charts
77
77
  var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
78
78
  if( hasRightVersion ) {
79
79
  AC_FL_RunContent(
80
- 'codebase' , 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0',
80
+ 'codebase' , 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,45,2',
81
81
  'width' , '#{options[:width]}',
82
82
  'height' , '#{options[:height]}',
83
83
  'scale' , '#{options[:scale]}',
@@ -114,7 +114,9 @@ module Ziya::HtmlHelpers::Charts
114
114
  options = default_chart_options.merge( chart_options )
115
115
 
116
116
  flash_vars = url ? charts_swf : charts_swf_base
117
- _ziya_chart( url, flash_vars, "charts.swf", options )
117
+ buff = _ziya_chart( url, flash_vars, "charts.swf", options )
118
+
119
+ (respond_to? :raw) ? raw( buff ) : buff
118
120
  end
119
121
 
120
122
  # genereates composite chart urls
@@ -139,7 +141,7 @@ module Ziya::HtmlHelpers::Charts
139
141
  def charts_swf() "#{charts_swf_base}&xml_source=%s"; end
140
142
  def chart_path() "/charts"; end
141
143
  def class_id() "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" end
142
- def codebase() "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0"; end
144
+ def codebase() "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,45,2"; end
143
145
 
144
146
  # generates swf path
145
147
  def gen_swf_path( path_directive, swf_dir, url )
@@ -154,8 +156,8 @@ module Ziya::HtmlHelpers::Charts
154
156
  # setup width and height
155
157
  setup_movie_size( options )
156
158
 
157
- color_param = tag( 'param', {:name => 'bgcolor', :value => options[:bgcolor]}, true )
158
- color_param += tag( 'param', {:name => "wmode", :value => options[:wmode]}, true )
159
+ color_param = ziya_tag( 'param', {:name => 'bgcolor', :value => options[:bgcolor]}, true )
160
+ color_param += ziya_tag( 'param', {:name => "wmode", :value => options[:wmode]}, true )
159
161
 
160
162
  xml_swf_path = gen_swf_path( swf_path, options[:swf_path], url )
161
163
  xml_swf_path << "&amp;timestamp=#{Time.now.to_i}" if options[:cache] == false
@@ -46,8 +46,8 @@ module Ziya::HtmlHelpers::Gauges
46
46
  # setup width and height
47
47
  setup_movie_size( options )
48
48
 
49
- color_param = tag( 'param', {:name => 'bgcolor', :value => options[:bgcolor]}, true )
50
- color_param += tag( 'param', {:name => "wmode", :value => options[:wmode]}, true )
49
+ color_param = ziya_tag( 'param', {:name => 'bgcolor', :value => options[:bgcolor]}, true )
50
+ color_param += ziya_tag( 'param', {:name => "wmode", :value => options[:wmode]}, true )
51
51
 
52
52
  xml_swf_path = swf_path % [options[:swf_path], url]
53
53
  xml_swf_path << "&amp;timestamp=#{Time.now.to_i}" if options[:use_cache] == true
@@ -41,8 +41,8 @@ module Ziya::HtmlHelpers::Maps
41
41
  # setup width and height
42
42
  setup_movie_size( options )
43
43
 
44
- color_param = tag( 'param', {:name => 'bgcolor', :value => options[:bgcolor]}, true )
45
- color_param += tag( 'param', {:name => "wmode", :value => options[:wmode]}, true )
44
+ color_param = ziya_tag( 'param', {:name => 'bgcolor', :value => options[:bgcolor]}, true )
45
+ color_param += ziya_tag( 'param', {:name => "wmode", :value => options[:wmode]}, true )
46
46
 
47
47
  xml_swf_path = gen_sw_path( options[:swf_path], swf_file, url )
48
48
  xml_swf_path << "&amp;timestamp=#{Time.now.to_i}" if options[:cache]
@@ -13,11 +13,11 @@ describe Ziya::HtmlHelpers::Charts do
13
13
  end
14
14
 
15
15
  it "should generate the correct flash embed tag using js" do
16
- ziya_chart_js( "/test/test_me", :swf_path => "/test_me", :asset_url => "/test" ).should == " <script language=\"javascript\" type=\"text/javascript\">\n if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {\n alert( \"This page requires AC_RunActiveContent.js.\" );\n } \n else {\n var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);\n if( hasRightVersion ) { \n AC_FL_RunContent(\n 'codebase' , 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0',\n 'width' , '400',\n 'height' , '300',\n 'scale' , 'noscale',\n 'salign' , 'tl',\n 'bgcolor' , 'ffffff',\n 'wmode' , 'opaque',\n 'movie' , '/test_me/charts',\n 'src' , '/test_me/charts',\n 'FlashVars' , 'library_path=/test_me/charts_library&xml_source=%2Ftest%2Ftest_me&chart_id=ziya_chart', \n 'id' , 'ziya_chart',\n 'name' , 'ziya_chart',\n 'menu' , 'true',\n 'allowFullScreen' , 'true',\n 'allowScriptAccess','sameDomain',\n 'quality' , 'high',\n 'align' , 'l',\n 'pluginspage' , 'http://www.macromedia.com/go/getflashplayer',\n 'play' , 'true',\n 'devicefont' , 'false'\n ); \n } \n else { \n var alternateContent = 'This content requires the Adobe Flash Player. '\n + '<u><a href=http://www.macromedia.com/go/getflash/>Get Flash</a></u>.';\n document.write(alternateContent); \n }\n }\n </script>\n"
16
+ ziya_chart_js( "/test/test_me", :swf_path => "/test_me", :asset_url => "/test" ).should == " <script language=\"javascript\" type=\"text/javascript\">\n if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {\n alert( \"This page requires AC_RunActiveContent.js.\" );\n } \n else {\n var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);\n if( hasRightVersion ) { \n AC_FL_RunContent(\n 'codebase' , 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,45,2',\n 'width' , '400',\n 'height' , '300',\n 'scale' , 'noscale',\n 'salign' , 'tl',\n 'bgcolor' , 'ffffff',\n 'wmode' , 'opaque',\n 'movie' , '/test_me/charts',\n 'src' , '/test_me/charts',\n 'FlashVars' , 'library_path=/test_me/charts_library&xml_source=%2Ftest%2Ftest_me&chart_id=ziya_chart', \n 'id' , 'ziya_chart',\n 'name' , 'ziya_chart',\n 'menu' , 'true',\n 'allowFullScreen' , 'true',\n 'allowScriptAccess','sameDomain',\n 'quality' , 'high',\n 'align' , 'l',\n 'pluginspage' , 'http://www.macromedia.com/go/getflashplayer',\n 'play' , 'true',\n 'devicefont' , 'false'\n ); \n } \n else { \n var alternateContent = 'This content requires the Adobe Flash Player. '\n + '<u><a href=http://www.macromedia.com/go/getflash/>Get Flash</a></u>.';\n document.write(alternateContent); \n }\n }\n </script>\n"
17
17
  end
18
18
 
19
19
  it "should generate the correct flash embed tag" do
20
- ziya_chart( "/test/test_me", :swf_path => '/blee' ).should == " <object codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" id=\"ziya_chart\" height=\"300\" width=\"400\">\n <param name=\"scale\" value=\"noscale\"/>\n <param name=\"salign\" value=\"tl\"/> \n <param name=\"bgcolor\" value=\"ffffff\"/>\n <param name=\"wmode\" value=\"opaque\"/> \n <param name=\"movie\" value=\"/charts/charts.swf\"/>\n <param name=\"Flashvars\" value=\"library_path=/blee/charts_library&xml_source=%2Ftest%2Ftest_me&amp;chart_id=ziya_chart\"/>\n <param name=\"menu\" value=\"true\"/>\n <param name=\"allowFullScreen\" value=\"true\"/>\n <param name=\"allowScriptAccess\" value=\"\"/> \n <param name=\"quality\" value=\"high\"/>\n <param name=\"play\" value=\"true\"/> \n <param name=\"devicefont\" value=\"false\"/>\n <embed scale=\"noscale\" \n allowfullscreen = \"true\" \n allowscriptaccess = \"\" \n bgcolor = \"ffffff\" \n devicefont = \"false\" \n flashvars = \"library_path=/blee/charts_library&xml_source=%2Ftest%2Ftest_me&amp;chart_id=ziya_chart\" \n menu = \"true\" \n name = \"ziya_chart\" \n play = \"true\" \n pluginspage = \"http://www.macromedia.com/go/getflashplayer\" \n quality = \"high\" \n salign = \"tl\" \n src = \"/charts/charts.swf\" \n type = \"application/x-shockwave-flash\" \n wmode = \"opaque\" \n align = \"l\" \n height = \"300\" \n width = \"400\"/> \n </object> \n"
20
+ ziya_chart( "/test/test_me", :swf_path => '/blee' ).should == " <object codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,45,2\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" id=\"ziya_chart\" height=\"300\" width=\"400\">\n <param name=\"scale\" value=\"noscale\"/>\n <param name=\"salign\" value=\"tl\"/> \n <param name=\"bgcolor\" value=\"ffffff\"/>\n <param name=\"wmode\" value=\"opaque\"/> \n <param name=\"movie\" value=\"/charts/charts.swf\"/>\n <param name=\"Flashvars\" value=\"library_path=/blee/charts_library&xml_source=%2Ftest%2Ftest_me&amp;chart_id=ziya_chart\"/>\n <param name=\"menu\" value=\"true\"/>\n <param name=\"allowFullScreen\" value=\"true\"/>\n <param name=\"allowScriptAccess\" value=\"\"/> \n <param name=\"quality\" value=\"high\"/>\n <param name=\"play\" value=\"true\"/> \n <param name=\"devicefont\" value=\"false\"/>\n <embed scale=\"noscale\" \n allowfullscreen = \"true\" \n allowscriptaccess = \"\" \n bgcolor = \"ffffff\" \n devicefont = \"false\" \n flashvars = \"library_path=/blee/charts_library&xml_source=%2Ftest%2Ftest_me&amp;chart_id=ziya_chart\" \n menu = \"true\" \n name = \"ziya_chart\" \n play = \"true\" \n pluginspage = \"http://www.macromedia.com/go/getflashplayer\" \n quality = \"high\" \n salign = \"tl\" \n src = \"/charts/charts.swf\" \n type = \"application/x-shockwave-flash\" \n wmode = \"opaque\" \n align = \"l\" \n height = \"300\" \n width = \"400\"/> \n </object> \n"
21
21
  end
22
22
  end
23
23
 
@@ -1 +1 @@
1
- 2.1.9
1
+ 2.3.0
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 2
7
- - 1
8
- - 9
9
- version: 2.1.9
7
+ - 3
8
+ - 0
9
+ version: 2.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Fernand Galiana
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-20 00:00:00 -06:00
17
+ date: 2010-10-13 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency