Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Revert "Revert "add 'show_in_index' to photo; show photos in index pa…

…ge""

This reverts commit c26bc19.
  • Loading branch information...
commit f9b8f69eae5aaa472d240cdfc2a146d1d4119d28 1 parent c26bc19
Edward Zhou authored
20 app/admin/photos.rb
... ... @@ -1,3 +1,5 @@
  1 +#encoding: utf-8
  2 +
1 3 ActiveAdmin.register Photo do
2 4
3 5 # New Link on all actions except :new and :show
@@ -7,6 +9,24 @@
7 9 end
8 10 end
9 11
  12 + show do
  13 + panel "照片详情" do
  14 + attributes_table_for photo do
  15 + row :id
  16 + row :album
  17 + row :display_order
  18 + row :show_in_index
  19 + row :description
  20 + row :created_at
  21 + row :updated_at
  22 + row(:image) do
  23 + image_tag photo.image_url(:thumb).to_s
  24 + end
  25 + end
  26 + end
  27 +
  28 + active_admin_comments
  29 + end
10 30
11 31 form :partial => "form"
12 32 end
4 app/helpers/application_helper.rb
@@ -29,10 +29,6 @@ def is_dev?
29 29 Rails.env.development?
30 30 end
31 31
32   - def even_odd(index)
33   - index.even? ? "even" : "odd"
34   - end
35   -
36 32
37 33
38 34 end
4 app/helpers/home_helper.rb
... ... @@ -1,2 +1,6 @@
1 1 module HomeHelper
  2 + def hot_photos
  3 + Photo.hot_photos
  4 + end
  5 +
2 6 end
7 app/models/photo.rb
... ... @@ -1,5 +1,12 @@
1 1 class Photo < ActiveRecord::Base
2 2 belongs_to :album
3 3
  4 + scope :show_in_index, where(:show_in_index => true)
  5 +
4 6 mount_uploader :image, PhotoUploader
  7 +
  8 + def self.hot_photos
  9 + show_in_index.order('created_at DESC').limit(6)
  10 + end
  11 +
5 12 end
2  app/views/admin/photos/_form.html.haml
... ... @@ -1,5 +1,5 @@
1 1 = semantic_form_for [:admin, @photo], :html => {:multipart => true} do |f|
2   - = f.inputs :album, :display_order, :description
  2 + = f.inputs :album, :display_order, :description, :show_in_index
3 3 = f.inputs do
4 4 = f.input :image, :as => :file
5 5 = f.input :image_cache, :as => :hidden
19 app/views/common/_hot_photos.html.haml
... ... @@ -0,0 +1,19 @@
  1 +
  2 +#hot_photos
  3 + %h5 课间留影
  4 + %ul
  5 + - hot_photos().each do |photo|
  6 + %li
  7 + = link_to photo.image_url.to_s, :class => "hot_photos", :rel => "hot_photos", :title => "#{photo.description}" do
  8 + = image_tag photo.image_url(:thumb).to_s
  9 +
  10 +
  11 += stylesheet_link_tag '/fancybox/jquery.fancybox-1.3.4.css'
  12 += javascript_include_tag '/fancybox/jquery.fancybox-1.3.4.pack.js'
  13 += javascript_include_tag '/fancybox/jquery.mousewheel-3.0.4.pack.js'
  14 +
  15 +:javascript
  16 + $(document).ready(function(){
  17 + $("a.hot_photos").fancybox();
  18 + });
  19 +
2  app/views/home/index.html.haml
@@ -6,6 +6,8 @@
6 6
7 7 -#= render 'common/ad_01'
8 8
  9 += render 'common/hot_photos'
  10 +
9 11 %h1 讲师介绍
10 12 = render 'company/trainer_edwardzhou'
11 13
4 app/views/orders/index.html.haml
@@ -38,8 +38,8 @@
38 38 %th/
39 39
40 40 %tbody
41   - - @orders.each_with_index do |order, index|
42   - %tr(class="#{even_odd(index)}")
  41 + - @orders.each do |order|
  42 + %tr(class="#{cycle('even', 'odd')}")
43 43 %td
44 44 #order_code(id="#{order.id}")= order.order_code
45 45 %td= order.created_at
9 db/migrate/20111009032923_add_show_in_index_to_photo.rb
... ... @@ -0,0 +1,9 @@
  1 +class AddShowInIndexToPhoto < ActiveRecord::Migration
  2 + def self.up
  3 + add_column :photos, :show_in_index, :boolean
  4 + end
  5 +
  6 + def self.down
  7 + remove_column :photos, :show_in_index
  8 + end
  9 +end
3  db/schema.rb
@@ -10,7 +10,7 @@
10 10 #
11 11 # It's strongly recommended to check this file into your version control system.
12 12
13   -ActiveRecord::Schema.define(:version => 20111006073559) do
  13 +ActiveRecord::Schema.define(:version => 20111009032923) do
14 14
15 15 create_table "active_admin_comments", :force => true do |t|
16 16 t.integer "resource_id", :null => false
@@ -221,6 +221,7 @@
221 221 t.string "image"
222 222 t.datetime "created_at"
223 223 t.datetime "updated_at"
  224 + t.boolean "show_in_index"
224 225 end
225 226
226 227 create_table "roles", :force => true do |t|
11 public/stylesheets/active_admin.css
@@ -1582,10 +1582,7 @@ table.dashboard {
1582 1582 .columns .column {
1583 1583 float: left; }
1584 1584
1585   -div.photo {
1586   - float: left;
1587   - padding: 5px; }
1588   -
1589   -div.panel_contents {
1590   - float: none;
1591   - min-height: 200px; }
  1585 +/*div.photo {*/
  1586 +/*float: left;*/
  1587 +/*padding: 5px;*/
  1588 +/*}*/
12 public/stylesheets/sass/active_admin.scss
@@ -3,12 +3,8 @@
3 3
4 4 @import "active_admin/base";
5 5
6   -div.photo {
7   - float: left;
8   - padding: 5px;
9   -}
  6 +/*div.photo {*/
  7 + /*float: left;*/
  8 + /*padding: 5px;*/
  9 +/*}*/
10 10
11   -div.panel_contents {
12   - float: none;
13   - min-height: 200px;
14   -}
25 public/stylesheets/sass/style.scss
@@ -237,6 +237,31 @@ div.inner_box{
237 237 }
238 238
239 239
  240 +div#hot_photos{
  241 + //border: 1px solid #A8BACD;
  242 + margin-bottom: 10px;
  243 + overflow: hidden;
  244 + padding: 1px;
  245 + position: relative;
  246 + //width: 185px;
  247 + //height: 120px;
  248 +
  249 + ul {
  250 + //margin: 0 0 1.5em;
  251 + padding: 0;
  252 + width: 1600px;
  253 +
  254 + li {
  255 + display: inline;
  256 + //margin: 0 0 0.25em 30px;
  257 + padding: 5px;
  258 + }
  259 + }
  260 +
  261 +
  262 +}
  263 +
  264 +
240 265
241 266 /**************************************/
242 267 /* FOOTER */
12 public/stylesheets/style.css
@@ -1148,6 +1148,18 @@ div.inner_box {
1148 1148 .li_star_blue {
1149 1149 list-style-image: url("/images/star_blue.gif"); }
1150 1150
  1151 +div#hot_photos {
  1152 + margin-bottom: 10px;
  1153 + overflow: hidden;
  1154 + padding: 1px;
  1155 + position: relative; }
  1156 + div#hot_photos ul {
  1157 + padding: 0;
  1158 + width: 1600px; }
  1159 + div#hot_photos ul li {
  1160 + display: inline;
  1161 + padding: 5px; }
  1162 +
1151 1163 /**************************************/
1152 1164 /* FOOTER */
1153 1165 /**************************************/

0 comments on commit f9b8f69

Please sign in to comment.
Something went wrong with that request. Please try again.