Commit 5ac8b5a

mo khan <mo@mokhan.ca>
2016-05-05 23:35:01
sprinkle some randome videoes.
1 parent 8c029c0
Changed files (3)
app
app/helpers/application_helper.rb
@@ -1,4 +1,8 @@
 module ApplicationHelper
+  VIDEOS=[
+    'ua8oObEPptQ',
+    'txuWGoZF3ew',
+  ]
   def gravatar_for(user, size: 260)
     secure_host = "https://secure.gravatar.com/avatar"
     options = "s=#{size}&d=mm"
@@ -16,4 +20,10 @@ module ApplicationHelper
       search_field_tag :q, params[:q], placeholder: t(:search)
     end
   end
+
+  def random_video
+    video = VIDEOS.sample
+    iframe = content_tag(:iframe, "", width: 560, height: 315, src: "https://www.youtube.com/embed/#{video}", frameborder: 0, allowfullscreen: true)
+    content_tag(:div, iframe, class: "flex-video")
+  end
 end
app/views/gyms/index.html.erb
@@ -3,10 +3,13 @@
 <% end %>
 
 <div class="row">
-  <div class="large-12 columns">
+  <div class="large-8 columns">
     <h1><%= t(".title") %></h1>
     <div id="results">
       <%= render partial: 'index' %>
     </div>
   </div>
+  <div class="large-4 columns">
+    <%= random_video %>
+  </div>
 </div>
app/views/training_sessions/index.html.erb
@@ -7,9 +7,7 @@
 <% else %>
   <div class="row">
     <div class="large-12 columns">
-      <div class="flex-video">
-        <iframe width="560" height="315" src="https://www.youtube.com/embed/txuWGoZF3ew" frameborder="0" allowfullscreen></iframe>
-      </div>
+      <%= random_video %>
     </div>
   </div>
 <% end %>