Oh, duh! Sorry I overlooked this problem.
You need to memoize the @stylesheets array. Change that method to look
like this:
def customize_admin_css
@stylesheets ||=[]
include_stylesheet 'radiant_custom'
end
Sean
Christopher Zimmermann wrote:
> Hi,
> Im trying to include a custom CSS file for radiant. Previously, I just
> replaced the main.css file in the radiant gem directory - but thats not
> "sustainable".
>
> I tried following Sean's instructions below but have run into trouble. The
> technique is to create an extension that runs a before filter that calls:
> include_stylesheet 'my_stylesheet'
>
> But it looks like the include_stylesheet is crashing because the @stylesheet
> array is empty.
>
> The line it is failing on is:
> controllers/application.rb line 22
> "@stylesheets << sheet"
>
> My extension looks like this:
>
> def activate
> require_dependency 'application'
> SiteController.class_eval do
>
> prepend_before_filter :customize_admin_css
>
> def customize_admin_css
> include_stylesheet ('radiant_custom')
> end
> end
> end
>
> Any ideas anyone - could be something silly as I am still a rubynuby.
>
> Thanks!
> Topher
>
>
> Following is the dev log trace:
>
> NoMethodError (You have a nil object when you didn't expect it!
> You might have expected an instance of Array.
> The error occurred while evaluating nil.<<):
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/app/controllers/application.rb:22:in `include_stylesheet'
>
> C:/a_Systems/InstantRails-1.7-win/rails_apps/henry_radiant2/vendor/extensions/custom_stylesheet/custom_stylesheet_extension.rb:18:in
> `customize_admin_css'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/actionpack/lib/action_controller/filters.rb:469:in `send'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/actionpack/lib/action_controller/filters.rb:469:in `call'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/actionpack/lib/action_controller/filters.rb:442:in `run'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/actionpack/lib/action_controller/filters.rb:714:in
> `run_before_filters'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/actionpack/lib/action_controller/filters.rb:694:in
> `call_filters'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/actionpack/lib/action_controller/filters.rb:688:in
> `perform_action_without_benchmark'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in
> `perform_action_without_rescue'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/1.8/benchmark.rb:293:in
> `measure'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in
> `perform_action_without_rescue'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/actionpack/lib/action_controller/rescue.rb:83:in
> `perform_action'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/actionpack/lib/action_controller/base.rb:435:in `send'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/actionpack/lib/action_controller/base.rb:435:in
> `process_without_filters'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/actionpack/lib/action_controller/filters.rb:684:in
> `process_without_session_management_support'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/actionpack/lib/action_controller/session_management.rb:114:in
> `process'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/actionpack/lib/action_controller/base.rb:334:in `process'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/railties/lib/dispatcher.rb:41:in `dispatch'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
> 1.0.1-mswin32/lib/mongrel/rails.rb:78:in `process'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
> 1.0.1-mswin32/lib/mongrel/rails.rb:76:in `synchronize'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
> 1.0.1-mswin32/lib/mongrel/rails.rb:76:in `process'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
> 1.0.1-mswin32/lib/mongrel.rb:618:in `process_client'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
> 1.0.1-mswin32/lib/mongrel.rb:617:in `each'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
> 1.0.1-mswin32/lib/mongrel.rb:617:in `process_client'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
> 1.0.1-mswin32/lib/mongrel.rb:736:in `run'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
> 1.0.1-mswin32/lib/mongrel.rb:736:in `initialize'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
> 1.0.1-mswin32/lib/mongrel.rb:736:in `new'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
> 1.0.1-mswin32/lib/mongrel.rb:736:in `run'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
> 1.0.1-mswin32/lib/mongrel.rb:720:in `initialize'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
> 1.0.1-mswin32/lib/mongrel.rb:720:in `new'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
> 1.0.1-mswin32/lib/mongrel.rb:720:in `run'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
> 1.0.1-mswin32/lib/mongrel/configurator.rb:271:in `run'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
> 1.0.1-mswin32/lib/mongrel/configurator.rb:270:in `each'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
> 1.0.1-mswin32/lib/mongrel/configurator.rb:270:in `run'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
> 1.0.1-mswin32/bin/mongrel_rails:127:in `run'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
> 1.0.1-mswin32/lib/mongrel/command.rb:211:in `run'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/mongrel-
> 1.0.1-mswin32/bin/mongrel_rails:243
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/activesupport/lib/active_support/dependencies.rb:488:in
> `load'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/activesupport/lib/active_support/dependencies.rb:488:in
> `load'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/activesupport/lib/active_support/dependencies.rb:342:in
> `new_constants_in'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/activesupport/lib/active_support/dependencies.rb:488:in
> `load'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/railties/lib/commands/servers/mongrel.rb:60
>
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
> `gem_original_require'
>
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
> `require'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/activesupport/lib/active_support/dependencies.rb:495:in
> `require'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/activesupport/lib/active_support/dependencies.rb:342:in
> `new_constants_in'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/activesupport/lib/active_support/dependencies.rb:495:in
> `require'
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/gems/1.8/gems/radiant-
> 0.6.4/vendor/rails/railties/lib/commands/server.rb:39
>
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
> `gem_original_require'
>
> C:/a_Systems/InstantRails-1.7-win/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
> `require'
> script/server:3
>
> On Dec 2, 2007 2:02 PM, Sean Cribbs <[EMAIL PROTECTED]> wrote:
>
>
>> Richard,
>>
>> This is rather trivial to do with an extension. Write your desired CSS,
>> put it in your extension public/stylesheets directory. Then put
>> something like this in your extension's activate method:
>>
>> SiteController.class_eval do
>>
>> before_filter :customize_admin_css
>>
>> def customize_admin_css
>>
>> include_stylesheet 'my_stylesheet'
>>
>> end
>>
>> end
>>
>> Obviously you'd want to name your stylesheet something else. Hope this
>> is helpful!
>>
>> Sean
>>
>> Richard Hurt wrote:
>>
>>> Putting the controls on a sidebar is OK with me. I would even be fine
>>>
>> with
>>
>>> a smaller text for the page title and various controls. I'm screen
>>>
>> height
>>
>>> challenged, not blind. :)
>>>
>>> Hmmm...what about a way to customize the CSS of the Admin pages for each
>>> install? Would that work? It wouldn't even have to be anything fancy
>>>
>> like
>>
>>> a table in the DB, just a static file on the server would work for me.
>>>
>> We
>>
>>> could then change the look & feel of the pages pretty easily and to fit
>>> within our own guidelines.
>>>
>>> Later...
>>> Richard
>>>
>>> On Dec 2, 2007 3:08 PM, Ryan Heneise <[EMAIL PROTECTED]> wrote:
>>>
>>>
>>>
>>>> I think I prefer having the buttons underneath the form, because it is
>>>> more standard and fits the open-edit-save workflow. Moving the buttons
>>>> to the top breaks with convention.
>>>>
>>>> What about a 2-column layout (similar to this:
>>>> http://www.madebyfrog.com/news/preview_layout_for_version_1)
>>>> , moving the meta-data form inputs to the second column? If some of
>>>> the metadata were moved out of the way horizontally, then the body of
>>>> the form could be shorter.
>>>>
>>>>
>>>>
>>>> On Dec 2, 2007, at 6:30 AM, Andrew Neil wrote:
>>>>
>>>>
>>>>
>>>>>> 5. Can we make the edit page a little more friendly for those of us
>>>>>> without 1700x2400 displays? :)
>>>>>>
>>>>>>
>>>>> I feel your pain. A couple of thoughts:
>>>>>
>>>>> * "Save Changes" and "Save and continue" buttons could go at the top,
>>>>> perhaps level with the "Edit Page" heading, but floated to the right.
>>>>> * The same two buttons could be given access keys, e.g. S and C, so
>>>>> that you can trigger them with a key command, rather than pushing
>>>>> them with your cursor.
>>>>>
>>>>> A
>>>>> _______________________________________________
>>>>> Radiant mailing list
>>>>> Post: [email protected]
>>>>> Search: http://radiantcms.org/mailing-list/search/
>>>>> Site: http://lists.radiantcms.org/mailman/listinfo/radiant
>>>>>
>>>>>
>>>>>
>>>> _______________________________________________
>>>> Radiant mailing list
>>>> Post: [email protected]
>>>> Search: http://radiantcms.org/mailing-list/search/
>>>> Site: http://lists.radiantcms.org/mailman/listinfo/radiant
>>>>
>>>>
>>>>
>>> _______________________________________________
>>> Radiant mailing list
>>> Post: [email protected]
>>> Search: http://radiantcms.org/mailing-list/search/
>>> Site: http://lists.radiantcms.org/mailman/listinfo/radiant
>>>
>>>
>>>
>> _______________________________________________
>> Radiant mailing list
>> Post: [email protected]
>> Search: http://radiantcms.org/mailing-list/search/
>> Site: http://lists.radiantcms.org/mailman/listinfo/radiant
>>
>>
>
>
>
>
_______________________________________________
Radiant mailing list
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant