Sha256: a5d220396795cf6a5dc948551c1853c52bff0d994d7b663032eab9640a1124b3

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

class Presentation::AssetsController < ActionController::Base
  # TODO: consider packaging a minifier so we get the perfect solution: a cached, minified bundle of assets
  caches_page :stylesheet, :javascript

  def stylesheet
    dir = asset_path(:stylesheets)
    sheet = params[:id].split(',').collect{ |id| File.read("#{dir}/#{id}.css") }.join("\n")
    
    respond_to do |type|
      type.css {render :text => sheet}
    end
  end
  
  # TODO: bundle unobtrusive javascripts that can add behavior.
  # - jquery vs prototype (i'll develop jquery, and wait for prototype contributions)
  # - ajax links with html response
  # - - inline
  # - - modal dialog
  # - ajax links with js response
  # - ajax links with no response
  # - inline editing
  # - "dirty" form awareness
  # - tabbed forms
  # - tooltips for extended information (e.g. column description or truncated field text)
  # - basic form validation
  # - - required fields
  # TODO: tests for ujs
  def javascript
    dir = asset_path(:javascripts)
    script = params[:id].split(',').collect{ |id| File.read("#{dir}/#{id}.js") }.join("\n")
    
    respond_to do |type|
      type.js {render :text => script}
    end
  end
  
  protected
  
  def asset_path(type)
    File.join(File.dirname(__FILE__), '..', '..', 'assets', type.to_s)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
presenting-2.0.0 app/controllers/presentation/assets_controller.rb