mirror of
https://github.com/danbee/danbarberphoto
synced 2025-03-04 08:49:07 +00:00
Migrate to dragonfly step one.
This commit is contained in:
parent
5afc38189c
commit
54a17bea7b
4
Gemfile
4
Gemfile
@ -13,6 +13,8 @@ group :assets do
|
||||
gem 'coffee-rails', "~> 4.0.0"
|
||||
gem 'uglifier'
|
||||
|
||||
gem 'sprockets_better_errors'
|
||||
|
||||
gem 'bourbon'
|
||||
end
|
||||
|
||||
@ -75,6 +77,8 @@ gem 'squeel'
|
||||
gem 'will_paginate'
|
||||
gem 'redcarpet'
|
||||
gem 'paperclip'
|
||||
gem 'dragonfly'
|
||||
gem 'dragonfly-s3_data_store'
|
||||
gem 'haml'
|
||||
|
||||
gem 'slugtastic'
|
||||
|
||||
25
Gemfile.lock
25
Gemfile.lock
@ -88,8 +88,15 @@ GEM
|
||||
thread_safe (~> 0.1)
|
||||
warden (~> 1.2.3)
|
||||
diff-lcs (1.2.5)
|
||||
dragonfly (1.0.3)
|
||||
multi_json (~> 1.0)
|
||||
rack
|
||||
dragonfly-s3_data_store (1.0.3)
|
||||
dragonfly (~> 1.0)
|
||||
fog
|
||||
erubis (2.7.0)
|
||||
eventmachine (1.0.3)
|
||||
excon (0.31.0)
|
||||
execjs (2.0.2)
|
||||
factory_girl (4.4.0)
|
||||
activesupport (>= 3.0.0)
|
||||
@ -97,6 +104,16 @@ GEM
|
||||
factory_girl (~> 4.4.0)
|
||||
railties (>= 3.0.0)
|
||||
fivemat (1.2.1)
|
||||
fog (1.20.0)
|
||||
builder
|
||||
excon (~> 0.31.0)
|
||||
formatador (~> 0.2.0)
|
||||
mime-types
|
||||
multi_json (~> 1.0)
|
||||
net-scp (~> 1.1)
|
||||
net-ssh (>= 2.1.3)
|
||||
nokogiri (>= 1.5.11)
|
||||
formatador (0.2.4)
|
||||
haml (4.0.5)
|
||||
tilt
|
||||
hike (1.2.3)
|
||||
@ -118,6 +135,9 @@ GEM
|
||||
mini_portile (0.5.2)
|
||||
minitest (4.7.5)
|
||||
multi_json (1.9.0)
|
||||
net-scp (1.1.2)
|
||||
net-ssh (>= 2.6.5)
|
||||
net-ssh (2.8.0)
|
||||
newrelic_rpm (3.7.2.195)
|
||||
nokogiri (1.6.1)
|
||||
mini_portile (~> 0.5.0)
|
||||
@ -196,6 +216,8 @@ GEM
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
sprockets (~> 2.8)
|
||||
sprockets_better_errors (0.0.4)
|
||||
sprockets-rails (>= 1.0.0)
|
||||
sqlite3 (1.3.9)
|
||||
squeel (1.1.1)
|
||||
activerecord (>= 3.0)
|
||||
@ -235,6 +257,8 @@ DEPENDENCIES
|
||||
capybara-screenshot
|
||||
coffee-rails (~> 4.0.0)
|
||||
devise
|
||||
dragonfly
|
||||
dragonfly-s3_data_store
|
||||
exception_notification!
|
||||
factory_girl_rails
|
||||
fivemat
|
||||
@ -256,6 +280,7 @@ DEPENDENCIES
|
||||
shoulda-matchers
|
||||
simple_form
|
||||
slugtastic
|
||||
sprockets_better_errors
|
||||
sqlite3
|
||||
squeel
|
||||
thin
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
module PhotosHelper
|
||||
def link_to_photo(photo)
|
||||
link_to '', photo.photo.url, rel: 'photos', class: 'fancy', id: photo.id
|
||||
link_to '', photo.image.url, rel: 'photos', class: 'fancy', id: photo.id
|
||||
end
|
||||
end
|
||||
|
||||
@ -22,6 +22,8 @@ class Photo < ActiveRecord::Base
|
||||
bucket: ENV['AWS_BUCKET_NAME'],
|
||||
url: ':s3_domain_url'
|
||||
|
||||
dragonfly_accessor :image
|
||||
|
||||
@@per_page = 11
|
||||
|
||||
scope :enabled, lambda {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
.photo
|
||||
= link_to image_tag(photo.photo.url(:size5), :title => photo.title), photo.photo.url
|
||||
= link_to image_tag(photo.image.admin.url, :title => photo.title), photo.image.url
|
||||
.actions
|
||||
= link_to 'Edit', edit_admin_photo_path(photo)
|
||||
= link_to 'Destroy', [:admin, photo], confirm: 'Are you sure?', method: :delete
|
||||
|
||||
@ -6,6 +6,6 @@
|
||||
= render :partial => "photo", :collection => @photos
|
||||
|
||||
= will_paginate @products, :remote => true
|
||||
|
||||
|
||||
%br/
|
||||
= link_to 'New Photo', new_admin_photo_path, :class => [:button, :new]
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<style type="text/css">
|
||||
<% photos.each do |photo| %>
|
||||
#<%= photo.name.parameterize %>.sg-<%= size %> {
|
||||
background: url(<%= photo.photo.url(:"size#{size}") %>);
|
||||
background: url(<%= photo.image.send(:"size#{size}").url %>);
|
||||
}
|
||||
<% end %>
|
||||
@media
|
||||
@ -10,7 +10,7 @@
|
||||
only screen and (min-device-pixel-ratio: 1.5) {
|
||||
<% photos.each do |photo| %>
|
||||
#<%= photo.name.parameterize %>.sg-<%= size %> {
|
||||
background: url(<%= photo.photo.url(:"size#{size}x2") %>);
|
||||
background: url(<%= photo.image.send(:"size#{size}x2").url %>);
|
||||
background-size: 100%;
|
||||
}
|
||||
<% end %>
|
||||
|
||||
@ -25,6 +25,9 @@ DanBarberPhoto::Application.configure do
|
||||
# Do not compress assets
|
||||
config.assets.compress = false
|
||||
|
||||
# Enable errors for Sprockets
|
||||
config.assets.raise_production_errors = true
|
||||
|
||||
# Expands the lines which load the assets
|
||||
config.assets.debug = true
|
||||
|
||||
|
||||
47
config/initializers/dragonfly.rb
Normal file
47
config/initializers/dragonfly.rb
Normal file
@ -0,0 +1,47 @@
|
||||
require 'dragonfly'
|
||||
|
||||
# Configure
|
||||
Dragonfly.app.configure do
|
||||
plugin :imagemagick
|
||||
|
||||
protect_from_dos_attacks true
|
||||
secret "02f4922399e3faca75b1faaa0a05bd46b524419459628110e733041af6df183b"
|
||||
|
||||
url_format "/media/:job/:name"
|
||||
|
||||
datastore :s3,
|
||||
bucket_name: ENV['AWS_BUCKET'],
|
||||
access_key_id: ENV['AWS_KEY'],
|
||||
secret_access_key: ENV['AWS_SECRET'],
|
||||
region: 'eu-west-1'
|
||||
|
||||
processor :preview do |content| content.process! :thumb, '600x600' end
|
||||
|
||||
processor :admin do |content| content.process! :thumb, '140x140#' end
|
||||
|
||||
processor :size17 do |content| content.process! :thumb, '476x476#' end
|
||||
processor :size11 do |content| content.process! :thumb, '308x308#' end
|
||||
processor :size8 do |content| content.process! :thumb, '224x224#' end
|
||||
processor :size5 do |content| content.process! :thumb, '140x140#' end
|
||||
processor :size3 do |content| content.process! :thumb, '84x84#' end
|
||||
processor :size2 do |content| content.process! :thumb, '56x56#' end
|
||||
|
||||
processor :size17x2 do |content| content.process! :thumb, '952x952#' end
|
||||
processor :size11x2 do |content| content.process! :thumb, '616x616#' end
|
||||
processor :size8x2 do |content| content.process! :thumb, '448x448#' end
|
||||
processor :size5x2 do |content| content.process! :thumb, '280x280#' end
|
||||
processor :size3x2 do |content| content.process! :thumb, '168x168#' end
|
||||
processor :size2x2 do |content| content.process! :thumb, '112x112#' end
|
||||
end
|
||||
|
||||
# Logger
|
||||
Dragonfly.logger = Rails.logger
|
||||
|
||||
# Mount as middleware
|
||||
Rails.application.middleware.use Dragonfly::Middleware
|
||||
|
||||
# Add model functionality
|
||||
if defined?(ActiveRecord::Base)
|
||||
ActiveRecord::Base.extend Dragonfly::Model
|
||||
ActiveRecord::Base.extend Dragonfly::Model::Validations
|
||||
end
|
||||
@ -0,0 +1,6 @@
|
||||
class AddDragonflyImageToPhotos < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :photos, :image_uid, :string
|
||||
add_column :photos, :image_name, :string
|
||||
end
|
||||
end
|
||||
@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20130522071132) do
|
||||
ActiveRecord::Schema.define(version: 20140307120615) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@ -81,6 +81,8 @@ ActiveRecord::Schema.define(version: 20130522071132) do
|
||||
t.boolean "enabled", default: true
|
||||
t.datetime "taken_at"
|
||||
t.integer "views", default: 0
|
||||
t.string "image_uid"
|
||||
t.string "image_name"
|
||||
end
|
||||
|
||||
create_table "sessions", force: true do |t|
|
||||
|
||||
Loading…
Reference in New Issue
Block a user