/merb_usercss

Merb slice that enables user-specific custom CSS

Primary LanguageRubyMIT LicenseMIT

MerbUsercss
===========

A slice for the Merb framework that enables user-specific CSS.

Instructions for installation:

 - file: config/init.rb
  # add the slice as a regular dependency
  dependency 'merb_usercss'


  # optionally change the way we find a user's custom css

  Merb::BootLoader.before_app_loads do
    Merb::Slices::config[:merb_usercss][:user_block] = lambda do |id|
      u = User.find(id); u ? u.custom_css : ".user {}" }
    end  
  end

 - file: config/router.rb

  # example: /merb_usercss/usercss/:id
  add_slice(:MerbUsercss)

  # example: /foo/usercss/:id
  add_slice(:MerbUsercss, 'foo') # same as :path => 'foo'

  # example: /usercss/:id
  slice(:MerbUsercss)

 - file: app/views/layout/application.html.erb (or other layout)
  <%= stylesheet_include_tag(slice_url(:merb_usercss, :show, current_user)) if current_user %>


Normally you should also run the following rake task:

rake slices:merb_usercss:install