Permalink
Browse files

Initial commit.

  • Loading branch information...
stephskardal committed Jan 31, 2012
0 parents commit 06aa8c06de8d08ca4958f23a04e8e4c1fcf78f7b
Showing with 141 additions and 0 deletions.
  1. +6 −0 .gitignore
  2. +1 −0 Gemfile
  3. +20 −0 MIT-LICENSE
  4. +20 −0 README.md
  5. +26 −0 Rakefile
  6. +11 −0 config/locales/pdf.en.yml
  7. +28 −0 lib/rails_admin_pdf.rb
  8. +4 −0 lib/rails_admin_pdf/engine.rb
  9. +3 −0 lib/rails_admin_pdf/version.rb
  10. +22 −0 rails_admin_pdf.gemspec
@@ -0,0 +1,6 @@
+.bundle/
+log/*.log
+pkg/
+test/dummy/db/*.sqlite3
+test/dummy/log/*.log
+test/dummy/tmp/
@@ -0,0 +1 @@
+gem "prawn"
@@ -0,0 +1,20 @@
+Copyright 2012 YOURNAME
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,20 @@
+RailsAdminPdf Gem (Engine)
+========
+
+PDF Builder for RailsAdmin.
+
+Installation
+========
+
+* Add to Gemfile and bundle install:
+
+ gem "rails_admin_pdf", :git => "git://github.com/stephskardal/rails_admin_pdf.git"
+
+* Add prawn to your main application, and create "#{class}Report" for every class that you would like to export.
+
+* If applicable, add right to :pdf action in CanCan ability class
+
+Copyright
+========
+
+Copyright (c) 2012 End Point & Steph Skardal.
@@ -0,0 +1,26 @@
+#!/usr/bin/env rake
+begin
+ require 'bundler/setup'
+rescue LoadError
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
+end
+begin
+ require 'rdoc/task'
+rescue LoadError
+ require 'rdoc/rdoc'
+ require 'rake/rdoctask'
+ RDoc::Task = Rake::RDocTask
+end
+
+RDoc::Task.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'RailsAdminPdf'
+ rdoc.options << '--line-numbers'
+ rdoc.rdoc_files.include('README.rdoc')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+
+
+Bundler::GemHelper.install_tasks
+
@@ -0,0 +1,11 @@
+
+en:
+ admin:
+ actions:
+ pdf:
+ title: "Pdf"
+ menu: "Download (PDF)"
+ breadcrumb: "Pdf"
+ link: "Pdf"
+ bulk_link: "Download (PDF)"
+ done: "Pdfed"
@@ -0,0 +1,28 @@
+require "rails_admin_pdf/engine"
+
+module RailsAdminPdf
+end
+
+require 'rails_admin/config/actions'
+
+module RailsAdmin
+ module Config
+ module Actions
+ class Pdf < Base
+ RailsAdmin::Config::Actions.register(self)
+
+ register_instance_option :member do
+ true
+ end
+
+ register_instance_option :controller do
+ Proc.new do
+ report = "#{@object.class.to_s.demodulize}Report".constantize.new
+ send_data report.to_pdf(@object), :filename => "#{@object.class.to_s.demodulize}_#{@object.id}.pdf", :type => "application/pdf"
+ end
+ end
+ end
+ end
+ end
+end
+
@@ -0,0 +1,4 @@
+module RailsAdminPdf
+ class Engine < Rails::Engine
+ end
+end
@@ -0,0 +1,3 @@
+module RailsAdminPdf
+ VERSION = "0.0.1"
+end
@@ -0,0 +1,22 @@
+$:.push File.expand_path("../lib", __FILE__)
+
+# Maintain your gem's version:
+require "rails_admin_pdf/version"
+
+# Describe your gem and declare its dependencies:
+Gem::Specification.new do |s|
+ s.name = "rails_admin_pdf"
+ s.version = RailsAdminPdf::VERSION
+ s.authors = ["TODO: Your name"]
+ s.email = ["TODO: Your email"]
+ s.homepage = "TODO"
+ s.summary = "TODO: Summary of RailsAdminPdf."
+ s.description = "TODO: Description of RailsAdminPdf."
+
+ s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
+
+ s.add_dependency "rails", "~> 3.1.3"
+ s.add_dependency "prawn"
+
+ # s.add_development_dependency "sqlite3"
+end

0 comments on commit 06aa8c0

Please sign in to comment.