lipsiadmin 5.0.1 → 5.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ 2009-07-28
2
+ * Added cattr_accessor for set view_path, jars_path see doc of Lipsiadmin::Utils::PdfBuilder
3
+
1
4
  2009-07-18
2
5
  * Fixed a big problem that occours in Rails 2.3.2 with timezone active and caching class!
3
6
 
@@ -27,7 +27,8 @@ module Lipsiadmin
27
27
  # go here: http://pd4ml.com/buy.htm and then put your licensed jar in a directory in your
28
28
  # project then simply calling this:
29
29
  #
30
- # Lipsiadmin::Utils::PdfBuilder::JARS_PATH = "here/is/my/licensed/pd4ml"
30
+ # Lipsiadmin::Utils::PdfBuilder.jars_path = "here/is/my/licensed/pd4ml"
31
+ # Lipsiadmin::Utils::PdfBuilder.view_path = "keep/template/in/other/path"
31
32
  #
32
33
  # you can use your version without any problem.
33
34
  #
@@ -45,20 +46,22 @@ module Lipsiadmin
45
46
  def render_pdf(template, filename=nil, options={})
46
47
 
47
48
  # path to the pd4ml jarfile
48
- jars_path = Lipsiadmin::Utils::PdfBuilder::JARS_PATH
49
+ jars_path = Lipsiadmin::Utils::PdfBuilder.jars_path
50
+ # path to our templates
51
+ view_path = Lipsiadmin::Utils::PdfBuilder.view_path
49
52
 
50
53
  options[:landescape] = options[:landescape] ? "LANDESCAPE" : "PORTRAIT"
51
54
  options[:send_data] ||= !filename.blank?
52
55
 
53
56
  # try to find erb extension
54
- ext = File.exist?("#{RAILS_ROOT}/app/views/pdf/#{template}.html.erb") ? "erb" : "haml"
57
+ ext = File.exist?("#{view_path}/#{template}.html.erb") ? "erb" : "haml"
55
58
 
56
59
  # encode the template
57
- input = encode_entities(render(:template => "/pdf/#{template}.html.#{ext}"))
60
+ input = encode_entities(render(:template => "#{view_path}/#{template}.html.#{ext}"))
58
61
 
59
62
  # search for stylesheet links and make their paths absolute.
60
- input.gsub!('<link href="/javascripts', '<link href="' + RAILS_ROOT + '/public/javascripts')
61
- input.gsub!('<link href="/stylesheets', '<link href="' + RAILS_ROOT + '/public/stylesheets')
63
+ input.gsub!('<link href="/javascripts', '<link href="' + view_path + '/../../../public/javascripts')
64
+ input.gsub!('<link href="/stylesheets', '<link href="' + view_path + '/../../../public/stylesheets')
62
65
 
63
66
  # search for images src, append full-path.
64
67
  input.gsub!('src="/', 'src="' + RAILS_ROOT + '/public/')
@@ -73,7 +76,7 @@ module Lipsiadmin
73
76
  # build the command
74
77
  class_path = "#{jars_path}/pd4ml.jar:.:#{jars_path}"
75
78
  class_path = "\"#{jars_path}/pd4ml.jar\";\"#{jars_path}\"" if RUBY_PLATFORM =~ /mswin/
76
- cmd = "cd #{Lipsiadmin::Utils::PdfBuilder::PD4RUBY_PATH} && java -Xmx512m -Djava.awt.headless=true -cp #{class_path} Pd4Ruby --file \"#{t.path}\" --width 950 --orientation #{options[:landescape]} 2>&1"
79
+ cmd = "cd #{Lipsiadmin::Utils::PdfBuilder.pd4ruby_path} && java -Xmx512m -Djava.awt.headless=true -cp #{class_path} Pd4Ruby --file \"#{t.path}\" --width 950 --orientation #{options[:landescape]} 2>&1"
77
80
 
78
81
  # grep the output
79
82
  output = IO.popen(cmd) { |s| s.read }
@@ -90,8 +93,6 @@ module Lipsiadmin
90
93
  erase_results
91
94
  output
92
95
  end
93
- # ensure
94
- # t.close
95
96
  end
96
97
 
97
98
  # Errors For PDF
@@ -32,7 +32,8 @@ module Lipsiadmin
32
32
  # go here: http://pd4ml.com/buy.htm and then put your licensed jar in a directory in your
33
33
  # project then simply calling this:
34
34
  #
35
- # Lipsiadmin::Utils::PdfBuilder::JARS_PATH = "here/is/my/licensed/pd4ml"
35
+ # Lipsiadmin::Utils::PdfBuilder.jars_path = "here/is/my/licensed/pd4ml"
36
+ # Lipsiadmin::Utils::PdfBuilder.view_path = "keep/template/in/other/path"
36
37
  #
37
38
  # you can use your version without any problem.
38
39
  #
@@ -50,19 +51,21 @@ module Lipsiadmin
50
51
  def render_pdf(template, body)
51
52
 
52
53
  # path to the pd4ml jarfile
53
- jars_path = Lipsiadmin::Utils::PdfBuilder::JARS_PATH
54
+ jars_path = Lipsiadmin::Utils::PdfBuilder.jars_path
55
+ # path to our templates
56
+ view_path = Lipsiadmin::Utils::PdfBuilder.view_path
54
57
 
55
58
  body[:landescape] = body[:landescape] ? "LANDESCAPE" : "PORTRAIT"
56
59
 
57
60
  # try to find erb extension
58
- ext = File.exist?("#{RAILS_ROOT}/app/views/pdf/#{template}.html.erb") ? "erb" : "haml"
61
+ ext = File.exist?("#{view_path}/#{template}.html.erb") ? "erb" : "haml"
59
62
 
60
63
  # encode the template
61
- input = encode_entities(render_message("/pdf/#{template}.html.#{ext}", body))
64
+ input = encode_entities(render_message("#{view_path}/#{template}.html.#{ext}", body))
62
65
 
63
66
  # search for stylesheet links and make their paths absolute.
64
- input.gsub!('<link href="/javascripts', '<link href="' + RAILS_ROOT + '/public/javascripts')
65
- input.gsub!('<link href="/stylesheets', '<link href="' + RAILS_ROOT + '/public/stylesheets')
67
+ input.gsub!('<link href="/javascripts', '<link href="' + view_path + '/../../../public/javascripts')
68
+ input.gsub!('<link href="/stylesheets', '<link href="' + view_path + '/../../../public/stylesheets')
66
69
 
67
70
  # search for images src, append full-path.
68
71
  input.gsub!('src="/', 'src="' + RAILS_ROOT + '/public/')
@@ -77,7 +80,7 @@ module Lipsiadmin
77
80
  # build the command
78
81
  class_path = "#{jars_path}/pd4ml.jar:.:#{jars_path}"
79
82
  class_path = "\"#{jars_path}/pd4ml.jar\";\"#{jars_path}\"" if RUBY_PLATFORM =~ /mswin/
80
- cmd = "cd #{Lipsiadmin::Utils::PdfBuilder::PD4RUBY_PATH} && java -Xmx512m -Djava.awt.headless=true -cp #{class_path} Pd4Ruby --file \"#{t.path}\" --width 950 --orientation #{body[:landescape]} 2>&1"
83
+ cmd = "cd #{Lipsiadmin::Utils::PdfBuilder.pd4ruby_path} && java -Xmx512m -Djava.awt.headless=true -cp #{class_path} Pd4Ruby --file \"#{t.path}\" --width 950 --orientation #{body[:landescape]} 2>&1"
81
84
 
82
85
  # grep the output
83
86
  output = IO.popen(cmd) { |s| s.read }
@@ -88,7 +91,7 @@ module Lipsiadmin
88
91
  # return raw pdf binary-stream
89
92
  output
90
93
  ensure
91
- t.close
94
+ t.close if t
92
95
  end
93
96
  end
94
97
 
@@ -6,7 +6,8 @@ module Lipsiadmin
6
6
  # go here: http://pd4ml.com/buy.htm and then put your licensed jar in a directory in your
7
7
  # project then simply calling this:
8
8
  #
9
- # Lipsiadmin::Utils::PdfBuilder::JARS_PATH = "here/is/my/licensed/pd4ml"
9
+ # Lipsiadmin::Utils::PdfBuilder.jars_path = "here/is/my/licensed/pd4ml"
10
+ # Lipsiadmin::Utils::PdfBuilder.view_path = "keep/template/in/other/path"
10
11
  #
11
12
  # you can use your version without any problem.
12
13
  #
@@ -17,16 +18,21 @@ module Lipsiadmin
17
18
  #
18
19
  # are present will use it
19
20
  #
20
- module PdfBuilder
21
+ class PdfBuilder
21
22
  if File.exist?("#{Rails.root}/vendor/pd4ml/pd4ml.jar") &&
22
23
  File.exist?("#{Rails.root}/vendor/pd4ml/ss_css2.jar")
23
24
 
24
- JARS_PATH = "#{Rails.root}/vendor/pd4ml"
25
+ @@jars_path = "#{Rails.root}/vendor/pd4ml"
25
26
  else
26
- JARS_PATH = "#{File.dirname(__FILE__)}/../../resources/pd4ml"
27
+ @@jars_path = "#{File.dirname(__FILE__)}/../../resources/pd4ml"
27
28
  end
28
29
 
29
- PD4RUBY_PATH = "#{File.dirname(__FILE__)}/../../resources/pd4ml/ruby"
30
+ @@pd4ruby_path = "#{File.dirname(__FILE__)}/../../resources/pd4ml/ruby"
31
+ @@view_path = "#{RAILS_ROOT}/app/views/pdf"
32
+
33
+ cattr_accessor :jars_path
34
+ cattr_accessor :pd4ruby_path
35
+ cattr_accessor :view_path
30
36
  end
31
37
  end
32
38
  end
data/lib/version.rb CHANGED
@@ -2,7 +2,7 @@ module Lipsiadmin
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 5
4
4
  MINOR = 0
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lipsiadmin
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.1
4
+ version: 5.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Davide D'Agostino
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-18 00:00:00 +02:00
12
+ date: 2009-07-28 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -468,7 +468,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
468
468
  requirements:
469
469
  - ImageMagick
470
470
  rubyforge_project: lipsiadmin
471
- rubygems_version: 1.3.4
471
+ rubygems_version: 1.3.5
472
472
  signing_key:
473
473
  specification_version: 3
474
474
  summary: Lipsiadmin is a new revolutionary admin for your projects.Lipsiadmin is based on Ext Js 2.0. framework (with prototype adapter) and is ready for Rails 2.0. This admin is for newbie developper but also for experts, is not entirely written in javascript because the aim of developper wose build in a agile way web/site apps so we use extjs in a new intelligent way a mixin of 'old' html and new ajax functions, for example ext manage the layout of page, grids, tree and errors, but form are in html code.