rtex 2.0.5 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,11 +1,20 @@
1
+ v2.1.0
2
+
3
+ Merge in rails-2.2.2 branch, modify to make sure Prawn isn't trampled and
4
+ 2.3.0 is supported.
5
+ Simplify tagging of templates for later processing (+ ensure it works
6
+ with compiled templates).
7
+ Update README_RAILS
8
+
1
9
  v2.0.5
2
10
 
3
- Fix issue with Echoe being ultra-sensitive on RubyGems versions (v2.0.4 was RubyGems 1.2 only,
4
- and 1.3 just came out)
11
+ Fix issue with Echoe being ultra-sensitive on RubyGems versions (v2.0.4
12
+ was RubyGems 1.2 only, and 1.3 just came out)
5
13
 
6
14
  v2.0.4
7
15
 
8
- Support for TeX escaping (via l()) calling to_s on the argument. This should handle nils.
16
+ Support for TeX escaping (via l()) calling to_s on the argument.
17
+ This should handle nils.
9
18
 
10
19
  v2.0.3
11
20
 
@@ -26,15 +26,22 @@ Create files +pdf.rtex+ extensions (eg, +index.pdf.rtex+) using standard LaTeX m
26
26
 
27
27
  With the following:
28
28
 
29
+ # In config/initializers/mime_types.rb (or environment.rb in older Rails)
30
+ Mime::Type.register "application/pdf", :pdf
31
+
29
32
  # app/controllers/items_controller.rb
30
33
  def index
31
34
  @items = Item.find(:all)
35
+ respond_to do |format|
36
+ format.html # We support the normal HTML view as well
37
+ format.pdf
38
+ end
32
39
  end
33
40
 
34
41
  # app/views/items/index.pdf.rtex
35
42
  \section*{Items}
36
43
  \begin{itemize}
37
- <%= render :partial => @items %>
44
+ <%= render :partial => @items %>
38
45
  \end{itemize}
39
46
 
40
47
  # app/views/items/_item.pdf.rtex
@@ -43,7 +50,7 @@ With the following:
43
50
  # app/layouts/application.pdf.rtex
44
51
  \documentclass[12pt]{article}
45
52
  \begin{document}
46
- <%= yield %>
53
+ <%= yield %>
47
54
  \end{document}
48
55
 
49
56
  If you hit +http://the.server.url/items.pdf+, you end up with a nice PDF listing of items.
@@ -7,30 +7,21 @@ module RTeX
7
7
  def self.setup
8
8
  RTeX::Document.options[:tempdir] = File.expand_path(File.join(RAILS_ROOT, 'tmp'))
9
9
  if ActionView::Base.respond_to?(:register_template_handler)
10
- ActionView::Base.register_template_handler(:rtex, Template)
10
+ ActionView::Base.register_template_handler(:rtex, TemplateHandler)
11
11
  else
12
- # Rails 2.1
13
- ActionView::Template.register_template_handler(:rtex, Template)
12
+ ActionView::Template.register_template_handler(:rtex, TemplateHandler)
14
13
  end
15
14
  ActionController::Base.send(:include, ControllerMethods)
16
15
  ActionView::Base.send(:include, HelperMethods)
17
16
  end
18
17
 
19
- class Template < ::ActionView::TemplateHandlers::ERB
20
- def initialize(*args)
21
- super
22
- # Support Rails render API before:
23
- # commit d2ccb852d4e1f6f1b01e43f32213053ae3bef408
24
- # Date: Fri Jul 18 16:00:20 2008 -0500
25
- if defined?(@view)
26
- @view.template_format = :pdf
27
- end
28
- # Tag for RTeX
29
- # TODO: Move options into TemplateHandler from Controller
30
- # (need to handle send_file)
31
- def @view.rendered_with_rtex
32
- true
33
- end
18
+ class TemplateHandler < ::ActionView::TemplateHandlers::ERB
19
+ # Due to significant changes in ActionView over the lifespan of Rails,
20
+ # tagging compiled templates to set a thread local variable flag seems
21
+ # to be the least brittle approach.
22
+ def compile(template)
23
+ # Insert assignment, but not before the #coding: line, if present
24
+ super.sub(/^(?!#)/m, "Thread.current[:_rendering_rtex] = true;\n")
34
25
  end
35
26
  end
36
27
 
@@ -41,7 +32,7 @@ module RTeX
41
32
 
42
33
  def render_with_rtex(options=nil, *args, &block)
43
34
  result = render_without_rtex(options, *args, &block)
44
- if result.is_a?(String) && @template.respond_to?(:rendered_with_rtex)
35
+ if result.is_a?(String) && Thread.current[:_rendering_rtex]
45
36
  options ||= {}
46
37
  ::RTeX::Document.new(result, options.merge(:processed => true)).to_pdf do |filename|
47
38
  serve_file = Tempfile.new('rtex-pdf')
@@ -54,13 +45,13 @@ module RTeX
54
45
  :length => File.size(serve_file.path)
55
46
  serve_file.close
56
47
  end
57
- else
58
- result
59
48
  end
49
+
60
50
  end
61
51
  end
62
52
 
63
53
  module HelperMethods
54
+ # Similar to h()
64
55
  def latex_escape(s)
65
56
  RTeX::Document.escape(s)
66
57
  end
@@ -69,4 +60,4 @@ module RTeX
69
60
 
70
61
  end
71
62
  end
72
- end
63
+ end
@@ -64,8 +64,8 @@ module RTeX
64
64
  end
65
65
 
66
66
  MAJOR = 2
67
- MINOR = 0
68
- TINY = 5
67
+ MINOR = 1
68
+ TINY = 0
69
69
 
70
70
  # The current version as a Version instance
71
71
  CURRENT = new(MAJOR, MINOR, TINY)
@@ -1,117 +1,40 @@
1
+ # -*- encoding: utf-8 -*-
1
2
 
2
- # Gem::Specification for Rtex-2.0.5
3
- # Originally generated by Echoe
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{rtex}
5
+ s.version = "2.1.0"
4
6
 
5
- --- !ruby/object:Gem::Specification
6
- name: rtex
7
- version: !ruby/object:Gem::Version
8
- version: 2.0.5
9
- platform: ruby
10
- authors:
11
- - Bruce Williams, Wiebe Cazemier
12
- autorequire:
13
- bindir: bin
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Bruce Williams, Wiebe Cazemier"]
9
+ s.date = %q{2009-02-26}
10
+ s.default_executable = %q{rtex}
11
+ s.description = %q{LaTeX preprocessor for PDF generation; Rails plugin}
12
+ s.email = %q{bruce@codefluency.com}
13
+ s.executables = ["rtex"]
14
+ s.extra_rdoc_files = ["bin/rtex", "CHANGELOG", "lib/rtex/document.rb", "lib/rtex/escaping.rb", "lib/rtex/framework/merb.rb", "lib/rtex/framework/rails.rb", "lib/rtex/tempdir.rb", "lib/rtex/version.rb", "lib/rtex.rb", "README.rdoc", "README_RAILS.rdoc"]
15
+ s.files = ["bin/rtex", "CHANGELOG", "init.rb", "lib/rtex/document.rb", "lib/rtex/escaping.rb", "lib/rtex/framework/merb.rb", "lib/rtex/framework/rails.rb", "lib/rtex/tempdir.rb", "lib/rtex/version.rb", "lib/rtex.rb", "Manifest", "rails/init.rb", "Rakefile", "README.rdoc", "README_RAILS.rdoc", "test/document_test.rb", "test/filter_test.rb", "test/fixtures/first.tex", "test/fixtures/first.tex.erb", "test/fixtures/fragment.tex.erb", "test/fixtures/text.textile", "test/tempdir_test.rb", "test/test_helper.rb", "vendor/instiki/LICENSE", "vendor/instiki/redcloth_for_tex.rb", "rtex.gemspec"]
16
+ s.has_rdoc = true
17
+ s.homepage = %q{http://rtex.rubyforge.org}
18
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Rtex", "--main", "README.rdoc"]
19
+ s.require_paths = ["lib"]
20
+ s.rubyforge_project = %q{rtex}
21
+ s.rubygems_version = %q{1.3.1}
22
+ s.summary = %q{LaTeX preprocessor for PDF generation; Rails plugin}
23
+ s.test_files = ["test/document_test.rb", "test/filter_test.rb", "test/tempdir_test.rb", "test/test_helper.rb"]
14
24
 
15
- date: 2008-10-08 00:00:00 -05:00
16
- default_executable:
17
- dependencies:
18
- - !ruby/object:Gem::Dependency
19
- name: Shoulda
20
- type: :development
21
- version_requirement:
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: "0"
27
- version:
28
- - !ruby/object:Gem::Dependency
29
- name: echoe
30
- type: :development
31
- version_requirement:
32
- version_requirements: !ruby/object:Gem::Requirement
33
- requirements:
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: "0"
37
- version:
38
- description: LaTeX preprocessor for PDF generation; Rails plugin
39
- email: bruce@codefluency.com
40
- executables:
41
- - rtex
42
- extensions: []
25
+ if s.respond_to? :specification_version then
26
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
27
+ s.specification_version = 2
43
28
 
44
- extra_rdoc_files:
45
- - bin/rtex
46
- - CHANGELOG
47
- - lib/rtex/document.rb
48
- - lib/rtex/escaping.rb
49
- - lib/rtex/framework/merb.rb
50
- - lib/rtex/framework/rails.rb
51
- - lib/rtex/tempdir.rb
52
- - lib/rtex/version.rb
53
- - lib/rtex.rb
54
- - README.rdoc
55
- - README_RAILS.rdoc
56
- files:
57
- - bin/rtex
58
- - CHANGELOG
59
- - init.rb
60
- - lib/rtex/document.rb
61
- - lib/rtex/escaping.rb
62
- - lib/rtex/framework/merb.rb
63
- - lib/rtex/framework/rails.rb
64
- - lib/rtex/tempdir.rb
65
- - lib/rtex/version.rb
66
- - lib/rtex.rb
67
- - Manifest
68
- - rails/init.rb
69
- - Rakefile
70
- - README.rdoc
71
- - README_RAILS.rdoc
72
- - test/document_test.rb
73
- - test/filter_test.rb
74
- - test/fixtures/first.tex
75
- - test/fixtures/first.tex.erb
76
- - test/fixtures/fragment.tex.erb
77
- - test/fixtures/text.textile
78
- - test/tempdir_test.rb
79
- - test/test_helper.rb
80
- - vendor/instiki/LICENSE
81
- - vendor/instiki/redcloth_for_tex.rb
82
- - rtex.gemspec
83
- has_rdoc: true
84
- homepage: http://rtex.rubyforge.org
85
- post_install_message:
86
- rdoc_options:
87
- - --line-numbers
88
- - --inline-source
89
- - --title
90
- - Rtex
91
- - --main
92
- - README.rdoc
93
- require_paths:
94
- - lib
95
- required_ruby_version: !ruby/object:Gem::Requirement
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: "0"
100
- version:
101
- required_rubygems_version: !ruby/object:Gem::Requirement
102
- requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- version: "0"
106
- version:
107
- requirements: []
108
-
109
- rubyforge_project: rtex
110
- rubygems_version: 1.3.0
111
- specification_version: 2
112
- summary: LaTeX preprocessor for PDF generation; Rails plugin
113
- test_files:
114
- - test/document_test.rb
115
- - test/filter_test.rb
116
- - test/tempdir_test.rb
117
- - test/test_helper.rb
29
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
30
+ s.add_development_dependency(%q<Shoulda>, [">= 0"])
31
+ s.add_development_dependency(%q<echoe>, [">= 0"])
32
+ else
33
+ s.add_dependency(%q<Shoulda>, [">= 0"])
34
+ s.add_dependency(%q<echoe>, [">= 0"])
35
+ end
36
+ else
37
+ s.add_dependency(%q<Shoulda>, [">= 0"])
38
+ s.add_dependency(%q<echoe>, [">= 0"])
39
+ end
40
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rtex
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruce Williams, Wiebe Cazemier
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-08 00:00:00 -05:00
12
+ date: 2009-02-26 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  requirements: []
105
105
 
106
106
  rubyforge_project: rtex
107
- rubygems_version: 1.3.0
107
+ rubygems_version: 1.3.1
108
108
  signing_key:
109
109
  specification_version: 2
110
110
  summary: LaTeX preprocessor for PDF generation; Rails plugin