From 698e4fd780e33c1bb8478f92d1543bdc48191360 Mon Sep 17 00:00:00 2001 From: Matt Moriarity Date: Sat, 28 Jul 2007 18:37:00 -0400 Subject: [PATCH] Cleanup of layout and application helper Simplified the class_for_* helpers to DRYer one-liners Also cleaned up the javascript includes --- app/helpers/application_helper.rb | 16 ++-------------- app/views/layouts/application.haml | 15 ++++++--------- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 93e5f74..20b4d67 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,23 +1,11 @@ # Methods added to this helper will be available to all templates in the application. module ApplicationHelper def class_for_song(song) - if @song.nil? - 'song' - elsif @song.id == song.id - 'current song' - else - 'song' - end + (!@song.nil? and @song.id == song.id) ? 'current song' : 'song' end def class_for_show(show) - if @show.nil? - 'show' - elsif @show.id == show.id - 'current show' - else - 'show' - end + (!@show.nil? and @show.id == show.id) ? 'current show' : 'show' end def all_songs diff --git a/app/views/layouts/application.haml b/app/views/layouts/application.haml index dda8531..de30a2f 100644 --- a/app/views/layouts/application.haml +++ b/app/views/layouts/application.haml @@ -2,10 +2,7 @@ %html %head %title Lyrix - = javascript_include_tag *%w(prototype effects dragdrop controls) - - %w(lowpro remote).each do |js| - = javascript_include_tag "lowpro/#{js}" - = javascript_include_tag 'application' + = javascript_include_tag *%w(prototype effects dragdrop controls lowpro/lowpro application) = stylesheet_link_tag 'application' %body #sidebar @@ -13,22 +10,22 @@ %ul#side_songs_list - all_songs.each do |s| %li{:class => class_for_song(s), :id => dom_id(s)} - = image_tag('cd.png', :align => 'top', :border => 0, :class => 'draggable') + = image_tag 'cd.png', :align => 'top', :class => 'draggable' = link_to s.title, edit_song_path(s) %li#new_song - = image_tag('cd_add.png', :align => 'top') + = image_tag 'cd_add.png', :align => 'top' = link_to 'Add a new song...', new_song_path %h1 Shows %ul#side_shows_list - all_shows.each do |s| %li{:class => class_for_show(s), :id => dom_id(s)} - = image_tag('film.png', :align => 'top', :border => 0) + = image_tag 'film.png', :align => 'top' = link_to s.title, edit_show_path(s) %li#new_show - = image_tag('film_add.png', :align => 'top') + = image_tag 'film_add.png', :align => 'top' = link_to 'Add a new show...', new_show_path #content %p#success_box{:style => 'display:none'} - = image_tag('information.png') + = image_tag 'information.png' %span#success = yield \ No newline at end of file -- 2.11.4.GIT