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 +3 -0
- data/lib/controller/pdf_builder.rb +10 -9
- data/lib/mailer/pdf_builder.rb +11 -8
- data/lib/utils/pdf_builder.rb +11 -5
- data/lib/version.rb +1 -1
- metadata +3 -3
data/CHANGELOG
CHANGED
@@ -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
|
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
|
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?("#{
|
57
|
+
ext = File.exist?("#{view_path}/#{template}.html.erb") ? "erb" : "haml"
|
55
58
|
|
56
59
|
# encode the template
|
57
|
-
input = encode_entities(render(:template => "
|
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="' +
|
61
|
-
input.gsub!('<link href="/stylesheets', '<link href="' +
|
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
|
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
|
data/lib/mailer/pdf_builder.rb
CHANGED
@@ -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
|
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
|
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?("#{
|
61
|
+
ext = File.exist?("#{view_path}/#{template}.html.erb") ? "erb" : "haml"
|
59
62
|
|
60
63
|
# encode the template
|
61
|
-
input = encode_entities(render_message("
|
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="' +
|
65
|
-
input.gsub!('<link href="/stylesheets', '<link href="' +
|
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
|
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
|
|
data/lib/utils/pdf_builder.rb
CHANGED
@@ -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
|
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
|
-
|
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
|
-
|
25
|
+
@@jars_path = "#{Rails.root}/vendor/pd4ml"
|
25
26
|
else
|
26
|
-
|
27
|
+
@@jars_path = "#{File.dirname(__FILE__)}/../../resources/pd4ml"
|
27
28
|
end
|
28
29
|
|
29
|
-
|
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
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.
|
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-
|
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.
|
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.
|