Package not found. Please check the package name and try again.

documentalist 0.1.0 → 0.1.1

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.
Files changed (48) hide show
  1. data/Manifest +48 -12
  2. data/README.rdoc +1 -1
  3. data/Rakefile +28 -12
  4. data/config/default.yml +17 -0
  5. data/documentalist.gemspec +40 -34
  6. data/lib/backends/net_pbm.rb +10 -0
  7. data/lib/backends/odf_merge.rb +64 -0
  8. data/lib/backends/open_office.rb +108 -0
  9. data/lib/backends/open_office/bridges/jodconverter-2.2.2/ChangeLog.txt +119 -0
  10. data/lib/backends/open_office/bridges/jodconverter-2.2.2/LICENSE.txt +504 -0
  11. data/lib/backends/open_office/bridges/jodconverter-2.2.2/README.txt +58 -0
  12. data/lib/backends/open_office/bridges/jodconverter-2.2.2/docs/jodconverter-2.2.2-javadoc.jar +0 -0
  13. data/lib/backends/open_office/bridges/jodconverter-2.2.2/docs/third-party-licenses/license-commons-io.txt +203 -0
  14. data/lib/backends/open_office/bridges/jodconverter-2.2.2/docs/third-party-licenses/license-openoffice.org.txt +8 -0
  15. data/lib/backends/open_office/bridges/jodconverter-2.2.2/docs/third-party-licenses/license-slf4j.txt +24 -0
  16. data/lib/backends/open_office/bridges/jodconverter-2.2.2/docs/third-party-licenses/license-xstream.txt +27 -0
  17. data/lib/backends/open_office/bridges/jodconverter-2.2.2/document-formats.xml +513 -0
  18. data/lib/backends/open_office/bridges/jodconverter-2.2.2/lib/DEPENDENCIES.txt +17 -0
  19. data/lib/backends/open_office/bridges/jodconverter-2.2.2/lib/commons-cli-1.2.jar +0 -0
  20. data/lib/backends/open_office/bridges/jodconverter-2.2.2/lib/commons-io-1.4.jar +0 -0
  21. data/lib/backends/open_office/bridges/jodconverter-2.2.2/lib/jodconverter-2.2.2.jar +0 -0
  22. data/lib/backends/open_office/bridges/jodconverter-2.2.2/lib/jodconverter-cli-2.2.2.jar +0 -0
  23. data/lib/backends/open_office/bridges/jodconverter-2.2.2/lib/juh-3.0.1.jar +0 -0
  24. data/lib/backends/open_office/bridges/jodconverter-2.2.2/lib/jurt-3.0.1.jar +0 -0
  25. data/lib/backends/open_office/bridges/jodconverter-2.2.2/lib/ridl-3.0.1.jar +0 -0
  26. data/lib/backends/open_office/bridges/jodconverter-2.2.2/lib/slf4j-api-1.5.6.jar +0 -0
  27. data/lib/backends/open_office/bridges/jodconverter-2.2.2/lib/slf4j-jdk14-1.5.6.jar +0 -0
  28. data/lib/backends/open_office/bridges/jodconverter-2.2.2/lib/unoil-3.0.1.jar +0 -0
  29. data/lib/backends/open_office/bridges/jodconverter-2.2.2/lib/xstream-1.3.1.jar +0 -0
  30. data/lib/backends/open_office/bridges/jodconverter-2.2.2/src/jodconverter-2.2.2-sources.jar +0 -0
  31. data/lib/backends/open_office/bridges/jodconverter-2.2.2/src/jodconverter-cli-2.2.2-sources.jar +0 -0
  32. data/lib/{DocumentConverter.py → backends/open_office/bridges/pyodconverter.py} +0 -0
  33. data/lib/{open_office → backends/open_office}/server.rb +8 -5
  34. data/lib/backends/pdf_tools.rb +14 -0
  35. data/lib/documentalist.rb +130 -42
  36. data/lib/tasks/tasks.rb +6 -0
  37. data/rails/config/documentalist.yml.tpl +67 -0
  38. data/rails/init.rb +12 -1
  39. data/rails/initialize_configuration.rb +6 -0
  40. data/test/documentalist_test.rb +48 -25
  41. data/test/fixtures/{fixture.odt → fixture_001.odt} +0 -0
  42. data/test/net_pbm_test.rb +7 -0
  43. data/test/odf_merge_test.rb +56 -0
  44. data/test/open_office_test.rb +70 -13
  45. data/test/pdf_tools_test.rb +8 -0
  46. data/test/rails_integration_test.rb +39 -0
  47. data/test/test_helper.rb +29 -0
  48. metadata +112 -12
data/Manifest CHANGED
@@ -1,12 +1,48 @@
1
- README.rdoc
2
- Rakefile
3
- documentalist.gemspec
4
- init.rb
5
- lib/DocumentConverter.py
6
- lib/documentalist.rb
7
- lib/open_office/server.rb
8
- rails/init.rb
9
- test/documentalist_test.rb
10
- test/fixtures/fixture.odt
11
- test/open_office_test.rb
12
- Manifest
1
+ README.rdoc
2
+ Rakefile
3
+ config/default.yml
4
+ documentalist.gemspec
5
+ init.rb
6
+ lib/backends/net_pbm.rb
7
+ lib/backends/odf_merge.rb
8
+ lib/backends/open_office.rb
9
+ lib/backends/open_office/bridges/jodconverter-2.2.2/ChangeLog.txt
10
+ lib/backends/open_office/bridges/jodconverter-2.2.2/LICENSE.txt
11
+ lib/backends/open_office/bridges/jodconverter-2.2.2/README.txt
12
+ lib/backends/open_office/bridges/jodconverter-2.2.2/docs/jodconverter-2.2.2-javadoc.jar
13
+ lib/backends/open_office/bridges/jodconverter-2.2.2/docs/third-party-licenses/license-commons-io.txt
14
+ lib/backends/open_office/bridges/jodconverter-2.2.2/docs/third-party-licenses/license-openoffice.org.txt
15
+ lib/backends/open_office/bridges/jodconverter-2.2.2/docs/third-party-licenses/license-slf4j.txt
16
+ lib/backends/open_office/bridges/jodconverter-2.2.2/docs/third-party-licenses/license-xstream.txt
17
+ lib/backends/open_office/bridges/jodconverter-2.2.2/document-formats.xml
18
+ lib/backends/open_office/bridges/jodconverter-2.2.2/lib/DEPENDENCIES.txt
19
+ lib/backends/open_office/bridges/jodconverter-2.2.2/lib/commons-cli-1.2.jar
20
+ lib/backends/open_office/bridges/jodconverter-2.2.2/lib/commons-io-1.4.jar
21
+ lib/backends/open_office/bridges/jodconverter-2.2.2/lib/jodconverter-2.2.2.jar
22
+ lib/backends/open_office/bridges/jodconverter-2.2.2/lib/jodconverter-cli-2.2.2.jar
23
+ lib/backends/open_office/bridges/jodconverter-2.2.2/lib/juh-3.0.1.jar
24
+ lib/backends/open_office/bridges/jodconverter-2.2.2/lib/jurt-3.0.1.jar
25
+ lib/backends/open_office/bridges/jodconverter-2.2.2/lib/ridl-3.0.1.jar
26
+ lib/backends/open_office/bridges/jodconverter-2.2.2/lib/slf4j-api-1.5.6.jar
27
+ lib/backends/open_office/bridges/jodconverter-2.2.2/lib/slf4j-jdk14-1.5.6.jar
28
+ lib/backends/open_office/bridges/jodconverter-2.2.2/lib/unoil-3.0.1.jar
29
+ lib/backends/open_office/bridges/jodconverter-2.2.2/lib/xstream-1.3.1.jar
30
+ lib/backends/open_office/bridges/jodconverter-2.2.2/src/jodconverter-2.2.2-sources.jar
31
+ lib/backends/open_office/bridges/jodconverter-2.2.2/src/jodconverter-cli-2.2.2-sources.jar
32
+ lib/backends/open_office/bridges/pyodconverter.py
33
+ lib/backends/open_office/server.rb
34
+ lib/backends/pdf_tools.rb
35
+ lib/documentalist.rb
36
+ lib/tasks/tasks.rb
37
+ rails/config/documentalist.yml.tpl
38
+ rails/init.rb
39
+ rails/initialize_configuration.rb
40
+ test/documentalist_test.rb
41
+ test/fixtures/fixture_001.odt
42
+ test/net_pbm_test.rb
43
+ test/odf_merge_test.rb
44
+ test/open_office_test.rb
45
+ test/pdf_tools_test.rb
46
+ test/rails_integration_test.rb
47
+ test/test_helper.rb
48
+ Manifest
@@ -1,3 +1,3 @@
1
1
  = Documentalist
2
2
 
3
- Rails gem for talking to OpenOffice.
3
+ Rails gem for talking to OpenOffice and merging data into OpenDocument templates using an ERB-like syntax.
data/Rakefile CHANGED
@@ -1,16 +1,32 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
- require 'echoe'
4
3
 
5
- Echoe.new('documentalist', '0.1.0') do |p|
6
- p.description = "Ruby interface that talks to OpenOffice"
7
- p.url = "http://github.com/davout/documentalist"
8
- p.author = "David FRANCOIS"
9
- p.email = "david.francois@webflows.fr"
10
- p.ignore_pattern = ["tmp/*", "script/*"]
11
- p.test_pattern = "test/**/*.rb"
12
- p.development_dependencies = []
13
- p.runtime_dependencies = ['zip >=2.0.2']
14
- end
4
+ # We want developers to be able to include rake tasks even without echoe gem available
5
+ require 'echoe' rescue nil
15
6
 
16
- Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
7
+ if Object.const_defined? :Echoe
8
+ Echoe.new('documentalist', '0.1.1') do |p|
9
+ p.description = "The smooth document management experience, usable as a Rails gem plugin or standalone in any ruby application"
10
+ p.url = "http://github.com/davout/documentalist"
11
+ p.author = "David FRANCOIS"
12
+ p.email = "david.francois@webflows.fr"
13
+ p.ignore_pattern = ["tmp/*", "script/*"]
14
+ p.test_pattern = "test/**/*.rb"
15
+ p.development_dependencies = ['flexmock >=0.8.6']
16
+ p.runtime_dependencies = ['zip >=2.0.2', 'SystemTimer >=1.2']
17
+
18
+ # TODO : Enforce some dependencies and don't make backend available if
19
+ # the dependency is not met
20
+ #
21
+ # wkhtmltopdf
22
+ # iconv
23
+ # pgrep
24
+ # ps
25
+ # pkill
26
+ # grep
27
+ # file
28
+ # which
29
+ # jod converter
30
+ # open office 3
31
+ end
32
+ end
@@ -0,0 +1,17 @@
1
+ # Default configuration in case none is provided
2
+ log_path: ~/documentalist.log
3
+
4
+ python:
5
+ path: /usr/bin/python
6
+
7
+ java:
8
+ path: /usr/bin/java
9
+
10
+ open_office:
11
+ path: /usr/bin/soffice
12
+ bridge: JOD
13
+ max_cpu: 80
14
+ max_startup_time: 3
15
+ wakeup_time: 3
16
+ max_conversion_attempts: 3
17
+ max_conversion_time: 5
@@ -1,34 +1,40 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{documentalist}
5
- s.version = "0.1.0"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["David FRANCOIS"]
9
- s.date = %q{2010-06-08}
10
- s.description = %q{Ruby interface that talks to OpenOffice}
11
- s.email = %q{david.francois@webflows.fr}
12
- s.extra_rdoc_files = ["README.rdoc", "lib/DocumentConverter.py", "lib/documentalist.rb", "lib/open_office/server.rb"]
13
- s.files = ["README.rdoc", "Rakefile", "documentalist.gemspec", "init.rb", "lib/DocumentConverter.py", "lib/documentalist.rb", "lib/open_office/server.rb", "rails/init.rb", "test/documentalist_test.rb", "test/fixtures/fixture.odt", "test/open_office_test.rb", "Manifest"]
14
- s.homepage = %q{http://github.com/davout/documentalist}
15
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Documentalist", "--main", "README.rdoc"]
16
- s.require_paths = ["lib"]
17
- s.rubyforge_project = %q{documentalist}
18
- s.rubygems_version = %q{1.3.7}
19
- s.summary = %q{Ruby interface that talks to OpenOffice}
20
- s.test_files = ["test/documentalist_test.rb", "test/open_office_test.rb"]
21
-
22
- if s.respond_to? :specification_version then
23
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
- s.specification_version = 3
25
-
26
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
- s.add_runtime_dependency(%q<zip>, [">= 2.0.2"])
28
- else
29
- s.add_dependency(%q<zip>, [">= 2.0.2"])
30
- end
31
- else
32
- s.add_dependency(%q<zip>, [">= 2.0.2"])
33
- end
34
- end
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{documentalist}
5
+ s.version = "0.1.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["David FRANCOIS"]
9
+ s.date = %q{2010-06-30}
10
+ s.description = %q{The smooth document management experience, usable as a Rails gem plugin or standalone in any ruby application}
11
+ s.email = %q{david.francois@webflows.fr}
12
+ s.extra_rdoc_files = ["README.rdoc", "lib/backends/net_pbm.rb", "lib/backends/odf_merge.rb", "lib/backends/open_office.rb", "lib/backends/open_office/bridges/jodconverter-2.2.2/ChangeLog.txt", "lib/backends/open_office/bridges/jodconverter-2.2.2/LICENSE.txt", "lib/backends/open_office/bridges/jodconverter-2.2.2/README.txt", "lib/backends/open_office/bridges/jodconverter-2.2.2/docs/jodconverter-2.2.2-javadoc.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/docs/third-party-licenses/license-commons-io.txt", "lib/backends/open_office/bridges/jodconverter-2.2.2/docs/third-party-licenses/license-openoffice.org.txt", "lib/backends/open_office/bridges/jodconverter-2.2.2/docs/third-party-licenses/license-slf4j.txt", "lib/backends/open_office/bridges/jodconverter-2.2.2/docs/third-party-licenses/license-xstream.txt", "lib/backends/open_office/bridges/jodconverter-2.2.2/document-formats.xml", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/DEPENDENCIES.txt", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/commons-cli-1.2.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/commons-io-1.4.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/jodconverter-2.2.2.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/jodconverter-cli-2.2.2.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/juh-3.0.1.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/jurt-3.0.1.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/ridl-3.0.1.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/slf4j-api-1.5.6.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/slf4j-jdk14-1.5.6.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/unoil-3.0.1.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/xstream-1.3.1.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/src/jodconverter-2.2.2-sources.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/src/jodconverter-cli-2.2.2-sources.jar", "lib/backends/open_office/bridges/pyodconverter.py", "lib/backends/open_office/server.rb", "lib/backends/pdf_tools.rb", "lib/documentalist.rb", "lib/tasks/tasks.rb"]
13
+ s.files = ["README.rdoc", "Rakefile", "config/default.yml", "documentalist.gemspec", "init.rb", "lib/backends/net_pbm.rb", "lib/backends/odf_merge.rb", "lib/backends/open_office.rb", "lib/backends/open_office/bridges/jodconverter-2.2.2/ChangeLog.txt", "lib/backends/open_office/bridges/jodconverter-2.2.2/LICENSE.txt", "lib/backends/open_office/bridges/jodconverter-2.2.2/README.txt", "lib/backends/open_office/bridges/jodconverter-2.2.2/docs/jodconverter-2.2.2-javadoc.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/docs/third-party-licenses/license-commons-io.txt", "lib/backends/open_office/bridges/jodconverter-2.2.2/docs/third-party-licenses/license-openoffice.org.txt", "lib/backends/open_office/bridges/jodconverter-2.2.2/docs/third-party-licenses/license-slf4j.txt", "lib/backends/open_office/bridges/jodconverter-2.2.2/docs/third-party-licenses/license-xstream.txt", "lib/backends/open_office/bridges/jodconverter-2.2.2/document-formats.xml", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/DEPENDENCIES.txt", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/commons-cli-1.2.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/commons-io-1.4.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/jodconverter-2.2.2.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/jodconverter-cli-2.2.2.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/juh-3.0.1.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/jurt-3.0.1.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/ridl-3.0.1.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/slf4j-api-1.5.6.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/slf4j-jdk14-1.5.6.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/unoil-3.0.1.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/lib/xstream-1.3.1.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/src/jodconverter-2.2.2-sources.jar", "lib/backends/open_office/bridges/jodconverter-2.2.2/src/jodconverter-cli-2.2.2-sources.jar", "lib/backends/open_office/bridges/pyodconverter.py", "lib/backends/open_office/server.rb", "lib/backends/pdf_tools.rb", "lib/documentalist.rb", "lib/tasks/tasks.rb", "rails/config/documentalist.yml.tpl", "rails/init.rb", "rails/initialize_configuration.rb", "test/documentalist_test.rb", "test/fixtures/fixture_001.odt", "test/net_pbm_test.rb", "test/odf_merge_test.rb", "test/open_office_test.rb", "test/pdf_tools_test.rb", "test/rails_integration_test.rb", "test/test_helper.rb", "Manifest"]
14
+ s.homepage = %q{http://github.com/davout/documentalist}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Documentalist", "--main", "README.rdoc"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{documentalist}
18
+ s.rubygems_version = %q{1.3.7}
19
+ s.summary = %q{The smooth document management experience, usable as a Rails gem plugin or standalone in any ruby application}
20
+ s.test_files = ["test/open_office_test.rb", "test/odf_merge_test.rb", "test/documentalist_test.rb", "test/rails_integration_test.rb", "test/test_helper.rb", "test/pdf_tools_test.rb", "test/net_pbm_test.rb"]
21
+
22
+ if s.respond_to? :specification_version then
23
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
+ s.specification_version = 3
25
+
26
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
+ s.add_runtime_dependency(%q<zip>, [">= 2.0.2"])
28
+ s.add_runtime_dependency(%q<SystemTimer>, [">= 1.2"])
29
+ s.add_development_dependency(%q<flexmock>, [">= 0.8.6"])
30
+ else
31
+ s.add_dependency(%q<zip>, [">= 2.0.2"])
32
+ s.add_dependency(%q<SystemTimer>, [">= 1.2"])
33
+ s.add_dependency(%q<flexmock>, [">= 0.8.6"])
34
+ end
35
+ else
36
+ s.add_dependency(%q<zip>, [">= 2.0.2"])
37
+ s.add_dependency(%q<SystemTimer>, [">= 1.2"])
38
+ s.add_dependency(%q<flexmock>, [">= 0.8.6"])
39
+ end
40
+ end
@@ -0,0 +1,10 @@
1
+ # To change this template, choose Tools | Templates
2
+ # and open the template in the editor.
3
+
4
+ module Documentalist
5
+ module NetPBM
6
+ def convert
7
+ system("cd #{temp_dir} && ppmtojpeg #{ppm_image} > #{ppm_image.gsub(/ppm$/, "jpg")}")
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,64 @@
1
+ require 'erb'
2
+ require 'tmpdir'
3
+ require 'zip/zip'
4
+
5
+ module Documentalist
6
+ # Merge an ODF document with an arbitrary hash of data
7
+ def self.odf_merge(template, options = {})
8
+ ODFMerge.merge_template(template, options)
9
+ end
10
+
11
+ # This module provides open document merge functionality
12
+ module ODFMerge
13
+ def self.merge_string(string, options = {})
14
+ locals = options[:locals]
15
+
16
+ if locals and locals.is_a? Hash
17
+ locals.each do |k,v|
18
+ instance_variable_set("@#{k.to_s}".to_sym, v)
19
+ end
20
+ end
21
+
22
+ ERB.new(string).result(binding)
23
+ end
24
+
25
+ def self.get_contents(odt_file)
26
+ contents = String.new
27
+ Zip::ZipFile.open(odt_file) { |zip| contents = zip.read("content.xml") }
28
+ contents.gsub("&lt;%", "<%").gsub("%&gt;", "%>")
29
+ end
30
+
31
+ def self.merge_template(template, options = {})
32
+ # Get template contents
33
+ tmp_contents= Tempfile.new("officer-contents")
34
+ tmp_contents.write(merge_string(get_contents(template), :locals => options[:locals]))
35
+ tmp_contents.close
36
+
37
+ # Copy the template so we can merge the data into the copy
38
+ tmp_merged_template = File.join(Dir.tmpdir, "merged-template-#{rand(10**9)}#{File.extname(template)}")
39
+ FileUtils.cp(template, tmp_merged_template)
40
+
41
+ # Stuff the merged contents.xml into the OpenDocument zip
42
+ Zip::ZipFile.open(tmp_merged_template) do |zip|
43
+ zip.replace("content.xml", tmp_contents.path)
44
+ zip.commit
45
+ end
46
+
47
+ # Remove the merged contents.xml
48
+ tmp_contents.unlink
49
+
50
+ # Manages the converted file depending on the context
51
+ if options[:to]
52
+ if File.extname(options[:to]) == File.extname(template)
53
+ FileUtils.mv(tmp_merged_template, options[:to])
54
+ else
55
+ Documentalist.convert(tmp_merged_template, :to => options[:to])
56
+ FileUtils.rm(tmp_merged_template)
57
+ end
58
+ else
59
+ FileUtils.rm(template)
60
+ FileUtils.mv(tmp_merged_template, template)
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,108 @@
1
+ module Documentalist
2
+ module OpenOffice
3
+ # Converts documents
4
+ def self.convert(origin, options)
5
+ # See how to make OpenOffice startup as smooth as possible and not on first conversion
6
+ # OO auto-start option if in Rails app ?
7
+ Server.ensure_available
8
+
9
+ Documentalist.timeout(Documentalist.config[:open_office][:max_conversion_time], :attempts => Documentalist.config[:open_office][:max_conversion_attempts]) do
10
+ if Documentalist.config[:open_office][:bridge] == 'JOD'
11
+ # TODO : manage multi ooo instances : http://code.google.com/p/jodconverter/wiki/GettingStarted
12
+
13
+ system("#{Documentalist.config[:java][:path]} -jar #{File.join(File.dirname(__FILE__), %w{open_office bridges jodconverter-2.2.2 lib jodconverter-cli-2.2.2.jar})} #{origin} #{options[:to]}")
14
+ elsif Documentalist.config[:open_office][:bridge] == 'PYOD'
15
+ system("#{Documentalist.config[:python][:path]} #{File.join(File.dirname(__FILE__), %w{open_office bridges pyodconverter.py})} #{origin} #{options[:to]}")
16
+ end
17
+
18
+ self.convert_txt_to_utf8(options[:to]) if options[:to_format] == :txt
19
+
20
+ options[:to]
21
+ end
22
+ end
23
+
24
+ # HACK : convert ISO-8859-1 files back to UTF-8 when OpenOffice messes up and
25
+ # outputs the wrong encoding
26
+ def self.convert_txt_to_utf8(file_path)
27
+ if `file #{file_path}` =~ /ISO/
28
+ system("iconv --from-code ISO-8859-1 --to-code UTF-8 #{file_path} > tmp_iconv.txt && mv tmp_iconv.txt #{file_path}")
29
+ end
30
+ end
31
+
32
+ module Server
33
+ # Is OpenOffice server running?
34
+ def self.running?
35
+ !`pgrep soffice`.empty?
36
+ end
37
+
38
+ # Restart if running or start new instance
39
+ def self.restart!
40
+ (kill! if running?) and start!
41
+ end
42
+
43
+ # Start new instance
44
+ def self.start!
45
+ raise "Already running!" if running?
46
+
47
+ log_path = Documentalist.config[:log_file] || "/dev/null"
48
+
49
+ command_line = "#{Documentalist.config[:open_office][:path]} -headless -accept=\"socket,host=127.0.0.1,port=8100\;urp\;\" -nofirststartwizard -nologo -nocrashreport -norestore -nolockcheck -nodefault"
50
+ command_line << " >> #{log_path} 2>&1"
51
+ command_line << " &"
52
+
53
+ system(command_line)
54
+
55
+ begin
56
+ Documentalist.timeout(Documentalist.config[:open_office][:max_startup_time]) do
57
+ while !running?
58
+ # Do nothing
59
+ end
60
+ end
61
+ rescue Timeout::Error
62
+ raise "OpenOffice didn't start fast enough, you might want to increase the max_startup_time value or check your OpenOffice configuration"
63
+ end
64
+
65
+ # OpenOffice needs some time to fully wake up
66
+ sleep(Documentalist.config[:open_office][:wakeup_time])
67
+ nil
68
+ end
69
+
70
+ # Kill running instance
71
+ def self.kill!
72
+ raise "Not running!" unless running?
73
+
74
+ begin
75
+ Documentalist.timeout(3) do
76
+ while(running?)
77
+ system("pkill -9 office")
78
+ end
79
+ end
80
+ rescue Timeout::Error
81
+ raise "Mayday, mayday ! Could not kill OpenOffice !!"
82
+ ensure
83
+ # Remove user profile
84
+ system("rm -rf ~/openoffice.org*")
85
+ end
86
+ end
87
+
88
+ # Is the current instance stuck ?
89
+ def self.stalled?
90
+ if running?
91
+ cpu_usage = `ps -Ao pcpu,pid,comm | grep soffice | grep [#{pids.collect{|pid| '\('+pid.to_s+'\)'}}]`.split(/\n/)
92
+ cpu_usage.any? { |usage| /^\s*\d+/.match(usage)[0].strip.to_i > Documentalist.config[:open_office][:max_cpu] }
93
+ end
94
+ end
95
+
96
+ # Make sure there will be an available instance
97
+ def self.ensure_available
98
+ start! unless running?
99
+ restart! if stalled?
100
+ end
101
+
102
+ # Get OO processes pids
103
+ def self.pids
104
+ `pgrep soffice`.split.map(&:to_i) unless `pgrep soffice`.empty?
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,119 @@
1
+ JODConverter 2.2.2
2
+ ------------------
3
+
4
+ * added docx, xlsx, and pptx (supported by OOo since v3.0) to default formats
5
+
6
+ * updated plain text format to use UTF8,CRLF as default options
7
+
8
+ * added switch to pass a custom xml document format registry file to the command line tool
9
+
10
+ JODConverter 2.2.1
11
+ ------------------
12
+
13
+ ** Improvement
14
+ * [JODC-12] - Provide more detailed 'conversion failed' error messages
15
+ * [JODC-24] - Add MediaWiki wikitext format
16
+ * [JODC-25] - Add configurable outputDir to Maven plugin
17
+ * [JODC-26] - Expose low level OOo services as public in OOoConnection
18
+
19
+ ** New Feature
20
+ * [JODC-6] - Maven plugin
21
+ * [JODC-27] - Add utility methods to retrieve OOo version and locale at runtime
22
+
23
+ JODConverter 2.2.0
24
+ ------------------
25
+
26
+ ** Bug
27
+ * [JODC-14] - Incorrect Excel mime-type
28
+ * [JODC-16] - Failure when converting from .txt files with different line endings
29
+ * [JODC-18] - File extension should be treated as case insensitive
30
+
31
+ ** Improvement
32
+ * [JODC-5] - Add macro execution options
33
+ * [JODC-10] - Make XStream dependency optional
34
+ * [JODC-11] - Replace commons-logging with slf4j
35
+ * [JODC-17] - Add CSV to default formats
36
+ * [JODC-19] - Revise DocumentFormat exportOptions API
37
+ * [JODC-20] - Make document formats easily customisable in webapp
38
+ * [JODC-22] - Add DocumentFamily.DRAWING
39
+
40
+ ** New Feature
41
+ * [JODC-9] - IKVM compatibility to build as a .NET DLL
42
+ * [JODC-13] - Add support for converting multiple files at once in ConvertDocument command line tool
43
+
44
+ ** Task
45
+ * [JODC-21] - Split CLI into separate module
46
+
47
+ JODConverter 2.1.1
48
+ -------------------
49
+
50
+ * renamed project to JODConverter
51
+
52
+ * renamed packages from net.sf.jooreports to com.artofsolving.jodconverter
53
+
54
+ * updated OpenOffice.org JARs to 2.1.0
55
+
56
+ JOOConverter 2.1.0
57
+ -------------------
58
+
59
+ * added support for custom export options (e.g. Image Quality for PDFs)
60
+
61
+ * HTML as an input format is now enabled by default
62
+
63
+ * fixed a rare pagination bug when exporting to PDF a document with fields
64
+
65
+ * many internal code improvements: switched to Maven2-based build process
66
+ and directory layout, improved unit test coverage, refactorings
67
+
68
+ JOOConverter 2.1rc2
69
+ -------------------
70
+
71
+ * file-based conversions are the default again; stream-based conversions
72
+ introduced in 2.1rc1 proved to be frequently slower so they are still
73
+ available but as an option (using StreamOpenOfficeDocumentConverter)
74
+
75
+ * made the webapp settings configurable using Spring and XML
76
+
77
+ * added a sample C#.net web service client to the online guide
78
+
79
+ JOOConverter 2.1rc1
80
+ -------------------
81
+
82
+ * now all conversions pass UNO streams instead of files to OpenOffice.org
83
+ - no need to use temporary files anymore
84
+ - works with an OOo service running as a different user
85
+ - works with an OOo service running on a different machine
86
+
87
+ * added servlet that can be invoked as a simple "web service" by remote clients
88
+
89
+ * added WordPerfect as a supported input format (thanks to Derek Hulley of Alfresco)
90
+
91
+ * added isConnected() method to OpenOfficeConnection
92
+
93
+ JOOConverter 2.0.0
94
+ ------------------
95
+
96
+ * added default constructor to DocumentFormat to prevent error with XStream on some JVMs
97
+
98
+ * compiled and tested with Java 1.3 (was 1.4)
99
+
100
+ * replaced custom IO code with Jakarta Commons IO
101
+
102
+ * updated third-party libraries to their latest available versions
103
+
104
+
105
+ JOOConverter 2.0rc2
106
+ -------------------
107
+
108
+ Due to popular demand JOOConverter, while still being part of JOOReports, is now
109
+ released as a standalone project (as it was already the case with the 1.0 series).
110
+
111
+ Changes compared to the version included in JOOReports 2.0rc1
112
+
113
+ * added the converter web application
114
+
115
+ * made jar file executable with ConvertDocument as main class
116
+
117
+ * added (but unsupported) HTML and XHTML export formats
118
+
119
+ * minor bug fixes