Commit a14a05ce

mo khan <mo@mokhan.ca>
2014-01-01 15:57:41
convert a href to link_to
1 parent 1f3f8e0
app/views/creation_tags/show.html.erb
@@ -23,12 +23,16 @@
     <% @creations.each do |creation| %>
       <div class="span4">
         <div class="thumbnail">
-          <a href="<%= url_for creation %>"><%= image_tag creation.primary_image.image.large.url %></a>
+          <%= link_to creation do %>
+            <%= image_tag creation.primary_image.image.large.url %>
+          <% end %>
           <div class="caption">
-            <h3><a href="<%= url_for creation %>"><%= creation.name %></a> <em><small>by <a href="<%= url_for profile_path(creation.user) %>"> <%= shrink(creation.user.name, 20) %></a></small></em></h3>
+            <h3><%= link_to creation.name, creation %> <em><small>by <%= link_to shrink(creation.user.name, 20), profile_path(creation.user) %></small></em></h3>
             <p>
             <% creation.tags.each do |tag| -%>
-              <a href="<%= url_for creation_tag_path(tag.name) %>"><span class="label"><%= tag.name %></span></a>
+              <%= link_to creation_tag_path(tag.name) do %>
+                <span class="label"><%= tag.name %></span>
+              <% end %>
             <% end -%>
             </p>
             <p><%= creation.story %></p>
app/views/creations/_form.html.erb
@@ -57,7 +57,7 @@
     </div>
     <div class="form-actions">
       <button type="submit" class="btn btn-primary">NEXT STEP</button>
-      <a href="<%= url_for @creation %>" class="btn">Cancel</a>
+      <%= link_to "Cancel", creation_path(@creation), class: 'btn' %>
     </div>
   </fieldset>
 <% end %>
app/views/creations/index.html.erb
@@ -29,7 +29,7 @@
       <strong>Make</strong> cakes, <strong>sell</strong> cakes, or just <strong>love</strong> eating them? You've come to the right place!
       <strong>CakeSide</strong> is a free site to <strong>share</strong> your cake <strong>creations</strong> and <strong>ideas</strong> with other cake fanatics like yourself!</p><br/>
       <p style="text-align: center;">
-      Get your cakes featured on this page <a href="<%= url_for new_user_session_path %>" class="btn btn-primary btn-large">Sign Up For Free!</a> or <%= link_to "sign in", new_user_session_path %>
+      Get your cakes featured on this page <%= link_to "Sign Up For Free!", new_user_session_path, class: "btn btn-primary btn-large" %> or <%= link_to "sign in", new_user_session_path %>
       </p>
     </div>
   </div>
@@ -62,9 +62,11 @@
         <% @creations.each do |creation| %>
           <div class="span4">
             <div class="thumbnail">
-              <a href="<%= url_for creation %>"><%= image_tag creation.primary_image.image.large.url %></a>
+              <%= link_to creation do %>
+                <%= image_tag creation.primary_image.image.large.url %>
+              <% end %>
               <div class="caption">
-                <h3><a href="<%= url_for creation %>"><%= creation.name %></a> <em><small>by <a href="<%= url_for profile_path(creation.user) %>"> <%= shrink(creation.user.name, 20) %></a></small></em></h3>
+                <h3><%= link_to creation.name, creation %> <em><small>by <%= link_to shrink(creation.user.name, 20), profile_path(creation.user) %></small></em></h3>
                 <p><%= creation.story %></p>
               </div>
             </div>
app/views/creations/show.html.erb
@@ -11,11 +11,19 @@ $(function() {
   <div class="row">
   <div class="span12">
     <% if @creation.user == current_user %>
-      <p>
-    <%= link_to '<i class="icon-edit"></i> <strong>EDIT</strong>'.html_safe, edit_creation_path(@creation), :class => 'btn' %> 
-    <a class="btn" href="<%= url_for new_creation_photo_path(@creation) %>"><i class="icon-plus"></i><strong>ADD IMAGES</strong></a>
-    <a class="btn" href="<%= url_for creation_favorites_path(:creation_id => @creation.id) %>"><i class="icon-heart"></i> <strong>FANCLUB (<%=  pluralize(@creation.favorites.length, 'fan') %>)</strong></a>
-    <%= link_to '<i class="icon-white icon-remove"></i> <strong>DELETE</strong>'.html_safe, creation_path(@creation),:confirm => "Are you sure you want to permanently remove this creation?", :method => :delete, :class => 'btn btn-danger pull-right' %>
+    <p>
+    <%= link_to edit_creation_path(@creation), class: 'btn' do %>
+      <i class="icon-edit"></i> <strong>EDIT</strong>
+    <% end %>
+    <%= link_to new_creation_photo_path(@creation), class: 'btn' do %>
+      <i class="icon-plus"></i><strong>ADD IMAGES</strong>
+    <% end %>
+    <%= link_to creation_favorites_path(:creation_id => @creation.id), class: 'btn' do %>
+      <i class="icon-heart"></i> <strong>FANCLUB (<%=  pluralize(@creation.favorites.length, 'fan') %>)</strong>
+    <% end %>
+    <%= link_to creation_path(@creation), confirm: "Are you sure you want to permanently remove this creation?", method: :delete, class: 'btn btn-danger pull-right' do %>
+      <i class="icon-white icon-remove"></i> <strong>DELETE</strong>
+    <% end %>
     </p>
   <% end %>
   </div>
@@ -32,7 +40,9 @@ $(function() {
     <% if @creation.tags.any? %>
       <span> <i class="icon-tags"></i> </span>
       <% @creation.tags.each do |tag| -%>
-        <a href="<%= url_for creation_tag_path(tag.name) %>" class="mix-link" data-event="click-on-tag"><span class="label"><%= tag.name %></span></a>
+        <%= link_to creation_tag_path(tag.name), class: 'mix-link', data: { event: "click-on-tag" } do %>
+          <span class="label"><%= tag.name %></span>
+        <% end %>
       <% end -%>
     <% end -%>
     <hr />
app/views/favorites/index.html.erb
@@ -6,7 +6,9 @@
       <% @creation.favorites.each do |favorite| %>
         <li class="span3">
         <div class="thumbnail">
-          <a href="<%= url_for profile_path(favorite.user) %>" class="thumbnail"><%= avatar_for(favorite.user) %></a>
+          <%= link_to url_for profile_path(favorite.user), class: 'thumbnail' do %>
+            <%= avatar_for(favorite.user) %>
+          <% end %>
           <div class="caption">
             <h5><%= favorite.user.name %></h5>
             <p><%= favorite.user.city %></p>
app/views/layouts/_footer.html.erb
@@ -5,9 +5,9 @@
     <div class="span4">
       <h3>CakeSide</h3>
       <ul class="unstyled">
-        <li> <a href="/">Home</a> </li>
-        <li> <a href="<%= url_for about_us_path %>">About Us</a> </li>
-        <li> <a href="<%= url_for why_cakeside_path %>">Why CakeSide?</a> </li>
+        <li> <%= link_to "Home", root_path %> </li>
+        <li> <%= link_to "About Us", about_us_path %> </li>
+        <li> <%= link_to "Why CakeSide?", why_cakeside_path %> </li>
       </ul>
     </div>
     <div class="span4">
app/views/layouts/_header.html.erb
@@ -2,7 +2,9 @@
   <div class="navbar-inner">
     <div class="container">
       <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></a>
-      <a class="brand" style="color:hotpink;" href="/">Cake<em>Side</em></a>
+      <%= link_to root_path, class: 'brand', style: 'color:hotpink;' do %>
+        Cake<em>Side</em>
+      <% end %>
       <div class="nav-collapse">
         <ul class="nav">
           <li class="dropdown">
app/views/profiles/favorites.html.erb
@@ -4,7 +4,11 @@
   <div class="span12">
     <ul class="thumbnails">
       <% @creations.each do |creation| %>
-        <li><a href="<%= url_for creation %>"><img class="thumbnail" src="<%= creation.primary_image.image.thumb.url %>" alt="<%= creation.name %>"></a></li>
+        <li>
+        <%= link_to creation do %>
+          <img class="thumbnail" src="<%= creation.primary_image.image.thumb.url %>" alt="<%= creation.name %>">
+        <% end %>
+        </li>
       <% end %>
     </ul>
   </div>
app/views/profiles/index.html.erb
@@ -5,9 +5,12 @@
       <% @profiles.each do |profile| %>
         <li class="span3">
         <div class="thumbnail">
-          <a href="<%= url_for profile_path(profile) %>"><%= avatar_for(profile) %></a>
+          <%= link_to profile_path(profile) do %>
+            <%= avatar_for(profile) %>
+          <% end %>
           <div class="caption">
-            <h5><a href="<%= url_for profile_path(profile) %>"><%= shrink(profile.name, 20) %></a> <small>(<%= profile.creations_count %>)</small></h5>
+            <h5><%= link_to shrink(profile.name, 20), profile_path(profile) %> <small>(<%= profile.creations_count %>)</small></h5>
+
             <% if(profile.city.blank?) -%>
             <h6>somewhere in sugarland</h6>
             <% else -%>
app/views/search/index.html.erb
@@ -20,7 +20,11 @@
             <tbody>
             <% @creations.each_with_index do |creation, index| %>
               <tr>
-                <td><a href="<%= url_for creation_path(creation) %>"><%= image_tag creation.primary_image.image.thumb.url, :class=> 'thumbnail', :style => "width:65px" %></a></td>
+                <td>
+                  <%= link_to creation_path(creation) do %>
+                    <%= image_tag creation.primary_image.image.thumb.url, class: 'thumbnail', style: "width:65px;" %>
+                  <% end %>
+                </td>
                 <td><%= link_to creation.user.name, profile_path(creation.user) %></td>
                 <td><%= creation.name %></td>
                 <td><%= creation.story %></td>
@@ -62,7 +66,11 @@
             <tbody>
             <% @members.each_with_index do |artist, index| %>
               <tr>
-                <td><a href="<%= url_for profile_path(artist) %>"><%= avatar_for(artist, :size => 65) %></a></td>
+                <td>
+                  <%= link_to profile_path(artist) do %>
+                    <%= avatar_for(artist, size: 65) %>
+                  <% end %>
+                </td>
                 <td><%= link_to artist.name, profile_path(artist) %></td>
                 <td><%= link_to artist.website if artist.website %></td>
                 <td><%= link_to artist.twitter, "https://twitter.com/#{artist.twitter}" if artist.twitter.present? %></td>
app/views/shared/_creation_image_gallery.html.erb
@@ -2,11 +2,15 @@
   <% @creations.each do |creation| %>
     <li class="span3">
     <div class="thumbnail">
-      <a href="<%= url_for creation %>" class="mix-link" data-event="click-on-thumbnail"><img src="<%= creation.primary_image.image.thumb.url %>" alt="<%= creation.name %>" style="width:260px;height:180px;" /></a>
-      <h3><a href="<%= url_for creation %>" class="mix-link" data-event="click-on-title"><%= short_name(creation, 15) %></a></h3>
-      <h4><small>By <a href="<%= url_for profile_path(creation.user) %>"><%= shrink(creation.user.name, 20) %></a></small></h4>
+      <%= link_to creation, class: 'mix-link', data: { event: 'click-on-thumbnail' } do %>
+        <img src="<%= creation.primary_image.image.thumb.url %>" alt="<%= creation.name %>" style="width:260px;height:180px;" />
+      <% end %>
+      <h3><%= link_to short_name(creation, 15), creation, class: 'mix-link', data: { event: 'click-on-title' } %></h3>
+      <h4><small>By <%= link_to shrink(creation.user.name, 20), profile_path(creation.user) %></small></h4>
       <p>
-      <a href="<%= url_for creation_favorites_path(:creation_id => creation.id) %>"><span class="badge"><%= creation.favorites.size %> <i class="icon-heart-empty"></i></span></a>
+      <%= link_to creation_favorites_path(:creation_id => creation.id) do %>
+        <span class="badge"><%= creation.favorites.size %> <i class="icon-heart-empty"></i></span>
+      <% end %>
       <span class="badge badge-warning"><i class="icon-comments"> <a href="<%= url_for creation %>#disqus_thread" data-disqus-identifier="c-<%= creation.id %>"></a></i></span>
       </p>
     </div>
app/views/tutorial_tags/show.html.erb
@@ -25,14 +25,16 @@
         <div class="thumbnail">
           <img src="<%= tutorial.image_url %>" />
           <div class="caption">
-            <h3><a href="<%= tutorial.url %>" target="_blank"><%= tutorial.heading %></a> <small><%= tutorial.created_at.to_s :foomat %></small></h3>
+            <h3><%= link_to tutorial.heading, tutorial.url, target: "_blank" %> <small><%= tutorial.created_at.to_s :foomat %></small></h3>
             <p>
             <% tutorial.tags.each do |tag| -%>
-              <a href="<%= url_for tutorial_tag_path(tag.name) %>"><span class="label"><%= tag.name %></span></a>
+              <%= link_to tutorial_tag_path(tag.name) do %>
+                <span class="label"><%= tag.name %></span>
+              <% end %>
             <% end -%>
             </p>
             <p><%= tutorial.description %></p>
-            <p><a class="btn" href="<%= url_for tutorial %>">View</a></p>
+            <p><%= link_to "View", tutorial %>View</a></p>
           </div>
         </div>
       </div>
app/views/tutorials/_form.html.erb
@@ -32,7 +32,7 @@ $(function(){
         <%= f.hidden_field :description, :class => "input-xlarge, tutorial-description" %>
         <%= f.hidden_field :image_url %>
         <button type="submit" class="btn btn-primary">Save</button>
-        <a href="<%= url_for tutorials_url %>" class="btn">Cancel</a>
+        <%= link_to "Cancel", tutorials_path, class: 'btn' %>
       </div>
     </fieldset>
   <% end %>
app/views/tutorials/index.html.erb
@@ -20,14 +20,16 @@
         <div class="thumbnail">
           <img src="<%= tutorial.image_url %>" />
           <div class="caption">
-            <h3><a href="<%= tutorial.url %>" target="_blank"><%= tutorial.heading %></a> <small><%= tutorial.created_at.to_s :foomat %></small></h3>
+            <h3><%= link_to tutorial.heading, tutorial.url, target: '_blank' %> <small><%= tutorial.created_at.to_s :foomat %></small></h3>
             <p>
             <% tutorial.tags.each do |tag| -%>
-              <a href="<%= url_for tutorial_tag_path(tag.name) %>"><span class="label"><%= tag.name %></span></a>
+              <%= link_to tutorial_tag_path(tag.name) do %>
+                <span class="label"><%= tag.name %></span>
+              <% end %>
             <% end -%>
             </p>
             <p><%= tutorial.description %></p>
-            <p><a class="btn" href="<%= url_for tutorial %>">View</a></p>
+            <p><%= link_to "View", tutorial, class: 'btn' %></p>
           </div>
         </div>
       </div>