Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

выводить на главной баннеры

  • Loading branch information...
commit e3e7fbe5d26cade9f8c275846060b07f420e042b 1 parent 94dc7b9
@lda lda authored
View
2  app/assets/javascripts/public/main_page_banner/init_main_page_banner.js.coffee
@@ -13,7 +13,7 @@
previews.children().last().prependTo previews
$myclone = previews.children().last().clone()
image_manipulation = $myclone.html()
- $big_image = image_manipulation.replace(/files\/(\d+)\/\d+-\d+(\!|%21)/,'files/$1/653-363!')
+ $big_image = image_manipulation.replace(/files\/(\d+)\/\d+-\d+(\!|%21)/,'files/$1/680-363!')
poster.html $big_image
poster.find('img').removeClass("min").addClass "max"
poster.find('img').css(opacity: 0).animate
View
8 app/assets/stylesheets/public/main_page.sass
@@ -134,11 +134,11 @@
+clearfix
float: left
height: 363px
- margin-left: -255px
+ margin-left: -228px
position: absolute
right: 0
top: 0
- width: 255px
+ width: 228px
.previews
border-left: 1px solid #fafafa
@@ -148,7 +148,7 @@
margin: 0
position: absolute
right: 0
- width: 254px
+ width: 227px
li
border-bottom: 1px solid #fafafa
@@ -156,7 +156,7 @@
a
display: block
- width: 254px
+ width: 227px
img
display: block
View
2  app/controllers/affiches_controller.rb
@@ -2,7 +2,7 @@ class AffichesController < InheritedResourcesController
actions :index, :show
has_scope :page, :default => 1
- has_scope :with_showings, :default => 1
+ has_scope :with_showings, :default => true, :type => :boolean
layout 'public'
View
7 app/controllers/application_controller.rb
@@ -1,5 +1,10 @@
class ApplicationController < ActionController::Base
protect_from_forgery
-
layout 'public'
+ helper_method :banners
+
+ private
+ def banners
+ Affiche.with_images.with_showings.latest(4)
+ end
end
View
4 app/helpers/application_helper.rb
@@ -12,8 +12,8 @@ def poster_image_tag_for(affiche, width, height, crop = true)
image_tag resized_image_url(affiche.poster_url, width, height, crop)
end
- def image_image_tag_for(affiche, width, height)
- image_tag resized_image_url(affiche.image_url, width, height, true)
+ def image_image_tag_for(affiche, width, height, options={})
+ image_tag resized_image_url(affiche.image_url, width, height, true), :alt => affiche.title, :title => affiche.title
end
private
View
7 app/models/affiches/affiche.rb
@@ -9,8 +9,11 @@ class Affiche < ActiveRecord::Base
default_scope order('affiches.id DESC')
- # NOTE: using with has_scope in AffichesController
- scope :with_showings, ->(fake) { includes(:showings).where('showings.starts_at > ?', Date.today) }
+ scope :with_showings, -> { includes(:showings).where('showings.starts_at > ?', Date.today) }
+
+ scope :with_images, -> { where('image_url IS NOT NULL') }
+
+ scope :latest, ->(count) { limit(count) }
def showings_grouped_by_day(search_params = nil)
search_params ||= { :starts_on_gt => Date.today, :starts_on_lt => Date.today + 4.weeks }
View
15 app/views/application/main_page.html.erb
@@ -18,18 +18,9 @@
</div>
<div class="previews_wrapper">
<ul class='previews'>
- <li>
- <a href="#"><img src="http://storage.esp.tomsk.gov.ru/files/1940/254-121!/2011-11-30_LTE-02_600.jpg" alt="Мстители" title='Мстители' /></a>
- </li>
- <li>
- <a href="#"><img src="http://storage.esp.tomsk.gov.ru/files/1374/254-121!/photo_48617.jpg" alt="1+1" title='1+1' /></a>
- </li>
- <li>
- <a href="#"><img src="http://storage.esp.tomsk.gov.ru/files/1948/254-121!/IMG_4831.jpg" alt="Мрачные тени" title='Мрачные тени' /></a>
- </li>
- <li class='last'>
- <a href="#"><img src="http://storage.esp.tomsk.gov.ru/files/2335/254-121!/sib_326_023-1_jpg_625x625_q70.jpg" alt="Deep purple" title='Deep purple' /></a>
- </li>
+ <% banners.each do |affiche| %>
+ <li><%= link_to image_image_tag_for(affiche, 227, 121), affiche_path(affiche) %></li>
+ <% end %>
</ul>
</div>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.