forked from smecsia/prawnto
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexander Bondarev
committed
Nov 10, 2010
1 parent
bee0f69
commit 24b0f8a
Showing
4 changed files
with
42 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
**/*.swp | ||
pkg/* | ||
reference_pdfs | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
$:.unshift(File.dirname(__FILE__)) unless | ||
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) | ||
|
||
module Prawnto | ||
VERSION='0.0.3' | ||
autoload :ActionControllerMixin, 'prawnto/action_controller_mixin' | ||
autoload :ActionViewMixin, 'prawnto/action_view_mixin' | ||
module TemplateHandlers | ||
autoload :Base, 'prawnto/template_handlers/base' | ||
autoload :Dsl, 'prawnto/template_handlers/dsl' | ||
autoload :Raw, 'prawnto/template_handlers/raw' | ||
end | ||
|
||
module TemplateHandler | ||
autoload :CompileSupport, 'prawnto/template_handler/compile_support' | ||
end | ||
|
||
class << self | ||
def enable | ||
ActionController::Base.send :include, Prawnto::ActionControllerMixin | ||
ActionView::Base.send :include, Prawnto::ActionViewMixin | ||
Mime::Type.register "application/pdf", :pdf | ||
ActionView::Template.register_template_handler 'prawn', Prawnto::TemplateHandlers::Base | ||
ActionView::Template.register_template_handler 'prawn_dsl', Prawnto::TemplateHandlers::Dsl | ||
ActionView::Template.register_template_handler 'prawn_xxx', Prawnto::TemplateHandlers::Raw | ||
end | ||
end | ||
end | ||
|
||
$:.unshift(File.dirname(__FILE__)) unless | ||
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) | ||
|
||
module Prawnto | ||
VERSION='0.0.4' | ||
autoload :ActionControllerMixin, 'prawnto/action_controller_mixin' | ||
autoload :ActionViewMixin, 'prawnto/action_view_mixin' | ||
module TemplateHandlers | ||
autoload :Base, 'prawnto/template_handlers/base' | ||
autoload :Dsl, 'prawnto/template_handlers/dsl' | ||
autoload :Raw, 'prawnto/template_handlers/raw' | ||
end | ||
|
||
module TemplateHandler | ||
autoload :CompileSupport, 'prawnto/template_handler/compile_support' | ||
end | ||
|
||
class << self | ||
def enable | ||
ActionController::Base.send :include, Prawnto::ActionControllerMixin | ||
ActionView::Base.send :include, Prawnto::ActionViewMixin | ||
Mime::Type.register "application/pdf", :pdf | ||
ActionView::Template.register_template_handler 'prawn', Prawnto::TemplateHandlers::Base | ||
ActionView::Template.register_template_handler 'prawn_dsl', Prawnto::TemplateHandlers::Dsl | ||
ActionView::Template.register_template_handler 'prawn_xxx', Prawnto::TemplateHandlers::Raw | ||
end | ||
end | ||
|
||
require "prawnto/railtie" | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
if defined?(Rails) && defined?(Rails::Railtie) | ||
module Prawnto | ||
class Railtie < Rails::Railtie | ||
initializer 'prawnto.init_config' do | ||
Prawnto.enable | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
require 'prawnto' | ||
if defined? Rails && defined? RAILS_ROOT && defined? Prawn | ||
if defined?(Rails) && defined?(Rails.root) && defined?(Prawn) | ||
Prawnto.enable | ||
else | ||
throw "Should be enabled only if Rails && Prawn are both defined" | ||
end |