Sha256: f23d2a125290a8f4143b1083fb74755b0a3439eb132851036cb601bac656551b

Contents?: true

Size: 922 Bytes

Versions: 2

Compression:

Stored size: 922 Bytes

Contents

require 'rubygems'
require 'capcode'
require 'capcode/render/markaby'
require 'graphviz'
$:.unshift( "../lib" )
require 'capcode/render/binary'

module Capcode
  class Index < Route '/'
    def get
      render :markaby => :index
    end
  end
  
  class Image < Route '/image'
    def get
      render :binary => :image, :content_type => "image/png"
    end
  end

  class Dwl < Route '/download'
    def get
      render :binary => :image, :content_type => "image/png", :content_disposition => "attachment; filename=my_image.png"
    end
  end
end

module Capcode::Views
  def glop
    html do
      body do
        yield
      end
    end
  end
  
  def index
    h1 "Hello !"
    img :src => URL(Capcode::Image)
  end
  
  def image
    GraphViz::new( "G" ) { |g|
      g.hello << g.world
      g.bonjour - g.monde
      g.hola > g.mundo
      g.holla >> g.welt
    }.output( :png => String )
  end
end

Capcode.run( )

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capcode-render-binary-0.3.0 examples/render-binary.rb
capcode-render-binary-0.2.0 examples/render-binary.rb