Skip to content

Instantly share code, notes, and snippets.

View markbates's full-sized avatar

Mark Bates markbates

View GitHub Profile
class MyController < Mack::Controller::Base
# action code omitted...
end
class MyController
include Mack::Controller
# action code omitted...
end
module Mack
module ViewHelpers
module MyHelpers
# methods here
end
end
end
class MyController
include Mack::Controller
end
module Mack
module ControllerHelpers
module MyController
# methods here
end
end
end
class Admin::UsersController
include Mack::Controller
end
module Mack
module ControllerHelpers
module Admin
module UsersController
# methods here
end
end
module Mack
module Rendering
module Engine
class Pdf < Mack::Rendering::Engine::Base
def render(io, binding)
@_pdf = ::PDF::Writer.new
self.view_template.instance_variable_set("@_pdf", @_pdf)
eval(io, binding)
@_pdf.render
pdf.select_font "Times-Roman"
pdf.fill_color(Color::RGB::Red)
pdf.text @post.title, :font_size => 24, :justification => :center
pdf.fill_color(Color::RGB::Black)
pdf.text "by #{@post.email}", :font_size => 12, :justification => :center
pdf.with_options(:font_size => 10, :justification => :left) do |p|
p.text "\n"
p.text @post.body
p.text "\n"
p.text "Created at: #{@post.created_at}"
require_gems do |gem|
gem.add "pdf-writer", :version => "1.1.8", :libs => "pdf/writer"
end
# config/initializers/gems.rb
require_gems do |gem|
gem.add "mack-data_mapper", :libs => "mack-data_mapper"
gem.add "mack-distributed", :libs => "mack-distributed"
end
# config/app_config/default.yml or your <environment>.yml file of choice
# Share your routes? true/false
mack::share_routes: true
# Share your objects? true/false
mack::share_objects: true
# Share your views/layouts? true/false
mack::share_views: true
# What is the UNIQUE name for this application?
# This is used to be able to register the services