mirror of
https://github.com/danbee/danbarberphoto
synced 2025-03-04 08:49:07 +00:00
Added taken_at to photos and sorted on it.
This commit is contained in:
parent
c194138d16
commit
57418726ca
@ -7,9 +7,9 @@ class PhotosController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
if params[:category_id]
|
if params[:category_id]
|
||||||
@category = Category.find_by_id(params[:category_id])
|
@category = Category.find_by_id(params[:category_id])
|
||||||
@photos = @category.photos.enabled.paginate(:page => params[:page], :per_page => 11)
|
@photos = @category.photos.enabled.order(:taken_at.desc).paginate(:page => params[:page], :per_page => 11)
|
||||||
else
|
else
|
||||||
@photos = Photo.enabled.paginate :all, :page => params[:page], :per_page => 11
|
@photos = Photo.enabled.order(:taken_at.desc).paginate :all, :page => params[:page], :per_page => 11
|
||||||
end
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
|
|||||||
@ -34,6 +34,7 @@ private
|
|||||||
exif = MiniExiftool.new photo.queued_for_write[:original].path
|
exif = MiniExiftool.new photo.queued_for_write[:original].path
|
||||||
self.title = exif.title if self.title.empty?
|
self.title = exif.title if self.title.empty?
|
||||||
self.description = exif.description if self.description.empty?
|
self.description = exif.description if self.description.empty?
|
||||||
|
self.taken_at = exif.date_time_original
|
||||||
self.save
|
self.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
9
db/migrate/20101215172105_add_taken_date_to_photo.rb
Normal file
9
db/migrate/20101215172105_add_taken_date_to_photo.rb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
class AddTakenDateToPhoto < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_column :photos, :taken_at, :datetime
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_column :photos, :taken_at
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20101202155552) do
|
ActiveRecord::Schema.define(:version => 20101215172105) do
|
||||||
|
|
||||||
create_table "admin_users", :force => true do |t|
|
create_table "admin_users", :force => true do |t|
|
||||||
t.string "first_name", :default => "", :null => false
|
t.string "first_name", :default => "", :null => false
|
||||||
@ -62,6 +62,7 @@ ActiveRecord::Schema.define(:version => 20101202155552) do
|
|||||||
t.integer "sort"
|
t.integer "sort"
|
||||||
t.boolean "featured", :default => false
|
t.boolean "featured", :default => false
|
||||||
t.boolean "enabled", :default => true
|
t.boolean "enabled", :default => true
|
||||||
|
t.datetime "taken_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
25
vendor/plugins/jrails/tasks/jrails.rake
vendored
25
vendor/plugins/jrails/tasks/jrails.rake
vendored
@ -1,25 +0,0 @@
|
|||||||
namespace :jrails do
|
|
||||||
|
|
||||||
namespace :js do
|
|
||||||
desc "Copies the jQuery and jRails javascripts to public/javascripts"
|
|
||||||
task :install do
|
|
||||||
puts "Copying files..."
|
|
||||||
project_dir = RAILS_ROOT + '/public/javascripts/'
|
|
||||||
scripts = Dir[File.join(File.dirname(__FILE__), '..', '/javascripts/', '*.js')]
|
|
||||||
FileUtils.cp(scripts, project_dir)
|
|
||||||
puts "files copied successfully."
|
|
||||||
end
|
|
||||||
|
|
||||||
desc 'Remove the prototype / script.aculo.us javascript files'
|
|
||||||
task :scrub do
|
|
||||||
puts "Removing files..."
|
|
||||||
files = %W[controls.js dragdrop.js effects.js prototype.js]
|
|
||||||
project_dir = File.join(RAILS_ROOT, 'public', 'javascripts')
|
|
||||||
files.each do |fname|
|
|
||||||
FileUtils.rm(File.join(project_dir, fname)) if File.exists?(File.join(project_dir, fname))
|
|
||||||
end
|
|
||||||
puts "files removed successfully."
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
Loading…
Reference in New Issue
Block a user