Sha256: 016c0bc4773f9215648204042dd8e6324305c860dc4fda08947044df1ba2c82b

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

class Marty::ComponentsController < Marty::ApplicationController
  # This is useful for individual component testing.  Note that the
  # appropriate route needs to be defined.
  # <base_url>/components/<ComponentCamelCaseName>
  def index
    component = params[:component]

    return redirect_to root_path unless component

    format, req_disposition, title =
      params[:format], params[:disposition], params[:reptitle]

    if format && Marty::ContentHandler::GEN_FORMATS.member?(format)
      klass = component.constantize

      raise "bad component" unless klass < Netzke::Base

      inst = klass.new
      return unless inst.respond_to?(:export_content)

      title ||= component

      res, type, disposition, filename =
        inst.export_content(format, title, params)

      return send_data(res,
                       type:        type,
                       filename:    filename,
                       disposition: req_disposition || disposition,
                       )
    end

    cname = component.gsub("::", "_").underscore
    render layout: true,
    inline: "<%= netzke :#{cname}, class_name: '#{component}', height: 650 %>"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
marty-0.5.15 app/controllers/marty/components_controller.rb~
marty-0.5.14 app/controllers/marty/components_controller.rb~
marty-0.5.13 app/controllers/marty/components_controller.rb~
marty-0.5.12 app/controllers/marty/components_controller.rb~