Sha256: bdbb0564f9293d40d88bd900b020fd4992d86d6bebd7103a334e54531fb76d86

Contents?: true

Size: 1.69 KB

Versions: 6

Compression:

Stored size: 1.69 KB

Contents

# Application template recipe for the rails_apps_composer. Check for a newer version here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/navigation.rb

after_bundler do

  say_wizard "Navigation recipe running 'after bundler'"

    # Create navigation links
    if recipes.include? 'haml'
      # There is Haml code in this script. Changing the indentation is perilous between HAMLs.
      # We have to use single-quote-style-heredoc to avoid interpolation.
      create_file "app/views/shared/_navigation.html.haml" do <<-'HAML'
- if user_signed_in?
  %li
    Logged in as #{current_user.name}
  %li
    = link_to('Logout', signout_path)
- else
  %li
    = link_to('Login', signin_path)
HAML
      end
    else
      create_file "app/views/shared/_navigation.html.erb" do <<-ERB
<% if user_signed_in? %>
  <li>
  Logged in as <%= current_user.name %>
  </li>
  <li>
  <%= link_to('Logout', signout_path) %>        
  </li>
<% else %>
  <li>
  <%= link_to('Login', signin_path)  %>  
  </li>
<% end %>
ERB
      end
    end

    # Add navigation links to the default application layout
    if recipes.include? 'haml'
      # There is Haml code in this script. Changing the indentation is perilous between HAMLs.
      inject_into_file 'app/views/layouts/application.html.haml', :after => "%body\n" do <<-HAML
  %ul.hmenu
    = render 'shared/navigation'
HAML
      end
    else
      inject_into_file 'app/views/layouts/application.html.erb', :after => "<body>\n" do
  <<-ERB
  <ul class="hmenu">
    <%= render 'shared/navigation' %>
  </ul>
ERB
      end
    end

end

__END__

name: Navigation
description: "Add navigation links."
author: RailsApps

category: other
tags: [utilities, configuration]

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rails_apps_composer-1.0.10 recipes/navigation.rb
rails_apps_composer-1.0.7 recipes/navigation.rb
rails_apps_composer-1.0.6 recipes/navigation.rb
rails_apps_composer-1.0.5 recipes/navigation.rb
rails_apps_composer-1.0.4 recipes/navigation.rb
rails_apps_composer-1.0.3 recipes/navigation.rb