Skip to content
Browse files

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

…ge""

This reverts commit c26bc19.
  • Loading branch information...
1 parent c26bc19 commit f9b8f69eae5aaa472d240cdfc2a146d1d4119d28 @edwardzhou committed Oct 9, 2011
View
20 app/admin/photos.rb
@@ -1,3 +1,5 @@
+#encoding: utf-8
+
ActiveAdmin.register Photo do
# New Link on all actions except :new and :show
@@ -7,6 +9,24 @@
end
end
+ show do
+ panel "照片详情" do
+ attributes_table_for photo do
+ row :id
+ row :album
+ row :display_order
+ row :show_in_index
+ row :description
+ row :created_at
+ row :updated_at
+ row(:image) do
+ image_tag photo.image_url(:thumb).to_s
+ end
+ end
+ end
+
+ active_admin_comments
+ end
form :partial => "form"
end
View
4 app/helpers/application_helper.rb
@@ -29,10 +29,6 @@ def is_dev?
Rails.env.development?
end
- def even_odd(index)
- index.even? ? "even" : "odd"
- end
-
end
View
4 app/helpers/home_helper.rb
@@ -1,2 +1,6 @@
module HomeHelper
+ def hot_photos
+ Photo.hot_photos
+ end
+
end
View
7 app/models/photo.rb
@@ -1,5 +1,12 @@
class Photo < ActiveRecord::Base
belongs_to :album
+ scope :show_in_index, where(:show_in_index => true)
+
mount_uploader :image, PhotoUploader
+
+ def self.hot_photos
+ show_in_index.order('created_at DESC').limit(6)
+ end
+
end
View
2 app/views/admin/photos/_form.html.haml
@@ -1,5 +1,5 @@
= semantic_form_for [:admin, @photo], :html => {:multipart => true} do |f|
- = f.inputs :album, :display_order, :description
+ = f.inputs :album, :display_order, :description, :show_in_index
= f.inputs do
= f.input :image, :as => :file
= f.input :image_cache, :as => :hidden
View
19 app/views/common/_hot_photos.html.haml
@@ -0,0 +1,19 @@
+
+#hot_photos
+ %h5 课间留影
+ %ul
+ - hot_photos().each do |photo|
+ %li
+ = link_to photo.image_url.to_s, :class => "hot_photos", :rel => "hot_photos", :title => "#{photo.description}" do
+ = image_tag photo.image_url(:thumb).to_s
+
+
+= stylesheet_link_tag '/fancybox/jquery.fancybox-1.3.4.css'
+= javascript_include_tag '/fancybox/jquery.fancybox-1.3.4.pack.js'
+= javascript_include_tag '/fancybox/jquery.mousewheel-3.0.4.pack.js'
+
+:javascript
+ $(document).ready(function(){
+ $("a.hot_photos").fancybox();
+ });
+
View
2 app/views/home/index.html.haml
@@ -6,6 +6,8 @@
-#= render 'common/ad_01'
+= render 'common/hot_photos'
+
%h1 讲师介绍
= render 'company/trainer_edwardzhou'
View
4 app/views/orders/index.html.haml
@@ -38,8 +38,8 @@
%th/
%tbody
- - @orders.each_with_index do |order, index|
- %tr(class="#{even_odd(index)}")
+ - @orders.each do |order|
+ %tr(class="#{cycle('even', 'odd')}")
%td
#order_code(id="#{order.id}")= order.order_code
%td= order.created_at
View
9 db/migrate/20111009032923_add_show_in_index_to_photo.rb
@@ -0,0 +1,9 @@
+class AddShowInIndexToPhoto < ActiveRecord::Migration
+ def self.up
+ add_column :photos, :show_in_index, :boolean
+ end
+
+ def self.down
+ remove_column :photos, :show_in_index
+ end
+end
View
3 db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20111006073559) do
+ActiveRecord::Schema.define(:version => 20111009032923) do
create_table "active_admin_comments", :force => true do |t|
t.integer "resource_id", :null => false
@@ -221,6 +221,7 @@
t.string "image"
t.datetime "created_at"
t.datetime "updated_at"
+ t.boolean "show_in_index"
end
create_table "roles", :force => true do |t|
View
11 public/stylesheets/active_admin.css
@@ -1582,10 +1582,7 @@ table.dashboard {
.columns .column {
float: left; }
-div.photo {
- float: left;
- padding: 5px; }
-
-div.panel_contents {
- float: none;
- min-height: 200px; }
+/*div.photo {*/
+/*float: left;*/
+/*padding: 5px;*/
+/*}*/
View
12 public/stylesheets/sass/active_admin.scss
@@ -3,12 +3,8 @@
@import "active_admin/base";
-div.photo {
- float: left;
- padding: 5px;
-}
+/*div.photo {*/
+ /*float: left;*/
+ /*padding: 5px;*/
+/*}*/
-div.panel_contents {
- float: none;
- min-height: 200px;
-}
View
25 public/stylesheets/sass/style.scss
@@ -237,6 +237,31 @@ div.inner_box{
}
+div#hot_photos{
+ //border: 1px solid #A8BACD;
+ margin-bottom: 10px;
+ overflow: hidden;
+ padding: 1px;
+ position: relative;
+ //width: 185px;
+ //height: 120px;
+
+ ul {
+ //margin: 0 0 1.5em;
+ padding: 0;
+ width: 1600px;
+
+ li {
+ display: inline;
+ //margin: 0 0 0.25em 30px;
+ padding: 5px;
+ }
+ }
+
+
+}
+
+
/**************************************/
/* FOOTER */
View
12 public/stylesheets/style.css
@@ -1148,6 +1148,18 @@ div.inner_box {
.li_star_blue {
list-style-image: url("/images/star_blue.gif"); }
+div#hot_photos {
+ margin-bottom: 10px;
+ overflow: hidden;
+ padding: 1px;
+ position: relative; }
+ div#hot_photos ul {
+ padding: 0;
+ width: 1600px; }
+ div#hot_photos ul li {
+ display: inline;
+ padding: 5px; }
+
/**************************************/
/* FOOTER */
/**************************************/

0 comments on commit f9b8f69

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