various rails3 migrations
This commit is contained in:
parent
b273696999
commit
d6ced88bcb
13
Gemfile
13
Gemfile
|
@ -6,16 +6,19 @@ gem "authlogic"
|
||||||
gem 'mime-types', :require => 'mime/types'
|
gem 'mime-types', :require => 'mime/types'
|
||||||
gem "carrierwave", :git => 'git://github.com/jnicklas/carrierwave.git'
|
gem "carrierwave", :git => 'git://github.com/jnicklas/carrierwave.git'
|
||||||
# MySQL:
|
# MySQL:
|
||||||
gem "mysql2"
|
#gem "mysql2"
|
||||||
# PostgreSQL:
|
# PostgreSQL:
|
||||||
#gem 'pg'
|
gem 'pg'
|
||||||
|
|
||||||
|
# S3 support
|
||||||
|
gem 'fog'
|
||||||
|
|
||||||
# ImageMagick:
|
# ImageMagick:
|
||||||
#gem "rmagick", :require => 'RMagick'
|
gem "rmagick", :require => 'RMagick'
|
||||||
|
|
||||||
# FreeImage:
|
# FreeImage:
|
||||||
#gem "image_science", :git => 'git://github.com/perezd/image_science.git'
|
|
||||||
#gem "RubyInline"
|
#gem "RubyInline"
|
||||||
|
#gem "image_science", :git => 'git://github.com/perezd/image_science.git'
|
||||||
|
|
||||||
# MiniMagick
|
# MiniMagick
|
||||||
gem "mini_magick"
|
#gem "mini_magick"
|
22
Gemfile.lock
22
Gemfile.lock
|
@ -42,14 +42,26 @@ GEM
|
||||||
builder (2.1.2)
|
builder (2.1.2)
|
||||||
erubis (2.6.6)
|
erubis (2.6.6)
|
||||||
abstract (>= 1.0.0)
|
abstract (>= 1.0.0)
|
||||||
|
excon (0.2.3)
|
||||||
|
fog (0.3.7)
|
||||||
|
builder
|
||||||
|
excon (>= 0.2.3)
|
||||||
|
formatador (>= 0.0.15)
|
||||||
|
json
|
||||||
|
mime-types
|
||||||
|
net-ssh (~> 2.0.23)
|
||||||
|
nokogiri (~> 1.4.3.1)
|
||||||
|
ruby-hmac
|
||||||
|
formatador (0.0.15)
|
||||||
i18n (0.4.1)
|
i18n (0.4.1)
|
||||||
|
json (1.4.6)
|
||||||
mail (2.2.6.1)
|
mail (2.2.6.1)
|
||||||
activesupport (>= 2.3.6)
|
activesupport (>= 2.3.6)
|
||||||
mime-types
|
mime-types
|
||||||
treetop (>= 1.4.5)
|
treetop (>= 1.4.5)
|
||||||
mime-types (1.16)
|
mime-types (1.16)
|
||||||
mini_magick (2.1)
|
net-ssh (2.0.23)
|
||||||
subexec (~> 0.0.4)
|
nokogiri (1.4.3.1)
|
||||||
pg (0.9.0)
|
pg (0.9.0)
|
||||||
polyglot (0.3.1)
|
polyglot (0.3.1)
|
||||||
rack (1.2.1)
|
rack (1.2.1)
|
||||||
|
@ -71,7 +83,8 @@ GEM
|
||||||
rake (>= 0.8.4)
|
rake (>= 0.8.4)
|
||||||
thor (~> 0.14.0)
|
thor (~> 0.14.0)
|
||||||
rake (0.8.7)
|
rake (0.8.7)
|
||||||
subexec (0.0.4)
|
rmagick (2.13.1)
|
||||||
|
ruby-hmac (0.4.0)
|
||||||
thor (0.14.1)
|
thor (0.14.1)
|
||||||
treetop (1.4.8)
|
treetop (1.4.8)
|
||||||
polyglot (>= 0.3.1)
|
polyglot (>= 0.3.1)
|
||||||
|
@ -83,7 +96,8 @@ PLATFORMS
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
authlogic
|
authlogic
|
||||||
carrierwave!
|
carrierwave!
|
||||||
|
fog
|
||||||
mime-types
|
mime-types
|
||||||
mini_magick
|
|
||||||
pg
|
pg
|
||||||
rails (= 3.0.0)
|
rails (= 3.0.0)
|
||||||
|
rmagick
|
||||||
|
|
|
@ -59,8 +59,8 @@ class AlbumsController < ApplicationController
|
||||||
unless params[:collection_id].empty?
|
unless params[:collection_id].empty?
|
||||||
@album.collections << Collection.find( params[:collection_id] )
|
@album.collections << Collection.find( params[:collection_id] )
|
||||||
end
|
end
|
||||||
flash[:notice] = "Album created!"
|
flash[:notice] = "Album created! Now add some nice photos."
|
||||||
redirect_to @album
|
redirect_to upload_album_photos_path( @album )
|
||||||
else
|
else
|
||||||
render :action => :new
|
render :action => :new
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,8 +29,8 @@ class CollectionsController < ApplicationController
|
||||||
def create
|
def create
|
||||||
@collection = Collection.new(params[:collection])
|
@collection = Collection.new(params[:collection])
|
||||||
if @collection.save
|
if @collection.save
|
||||||
flash[:notice] = "Collection created!"
|
flash[:notice] = "Collection created! Now lets add a new album."
|
||||||
redirect_to @collection
|
redirect_to new_collection_album_path(@collection)
|
||||||
else
|
else
|
||||||
render :action => :new
|
render :action => :new
|
||||||
end
|
end
|
||||||
|
|
|
@ -74,7 +74,9 @@ class PhotosController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
puts "create"
|
||||||
@photo = Photo.new(params[:photo])
|
@photo = Photo.new(params[:photo])
|
||||||
|
puts @photo.inspect
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @photo.save
|
if @photo.save
|
||||||
format.html { render :text => "FILEID:" + @photo.file.album.url }
|
format.html { render :text => "FILEID:" + @photo.file.album.url }
|
||||||
|
|
|
@ -3,11 +3,10 @@
|
||||||
class FileUploader < CarrierWave::Uploader::Base
|
class FileUploader < CarrierWave::Uploader::Base
|
||||||
|
|
||||||
# Include RMagick or ImageScience support
|
# Include RMagick or ImageScience support
|
||||||
# include CarrierWave::RMagick
|
include CarrierWave::RMagick
|
||||||
# include CarrierWave::ImageScience
|
# include CarrierWave::ImageScience
|
||||||
include CarrierWave::MiniMagick
|
# include CarrierWave::MiniMagick
|
||||||
# Choose what kind of storage to use for this uploader
|
# Choose what kind of storage to use for this uploader
|
||||||
#storage :file
|
|
||||||
if ENV['S3_KEY']
|
if ENV['S3_KEY']
|
||||||
storage :s3
|
storage :s3
|
||||||
|
|
||||||
|
@ -22,7 +21,7 @@ class FileUploader < CarrierWave::Uploader::Base
|
||||||
# This is a sensible default for uploaders that are meant to be mounted:
|
# This is a sensible default for uploaders that are meant to be mounted:
|
||||||
def store_dir
|
def store_dir
|
||||||
#{}"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
#{}"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||||
"uploads/files/#{model.album.path}"
|
ENV['STORAGE_PATH'] + "/files/#{model.album.path}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Provide a default URL as a default if there hasn't been a file uploaded
|
# Provide a default URL as a default if there hasn't been a file uploaded
|
||||||
|
@ -41,25 +40,25 @@ class FileUploader < CarrierWave::Uploader::Base
|
||||||
version :collection do
|
version :collection do
|
||||||
process :resize_to_fill => [200, 200]
|
process :resize_to_fill => [200, 200]
|
||||||
def store_dir
|
def store_dir
|
||||||
"uploads/thumbs/#{model.album.path}"
|
ENV['STORAGE_PATH'] + "/files/thumbs/#{model.album.path}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
version :album do
|
version :album do
|
||||||
process :resize_to_fill => [100, 100]
|
process :resize_to_fill => [100, 100]
|
||||||
def store_dir
|
def store_dir
|
||||||
"uploads/thumbs/#{model.album.path}"
|
ENV['STORAGE_PATH'] + "/files/thumbs/#{model.album.path}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
version :preview do
|
version :preview do
|
||||||
process :resize_to_fit => [210, 210]
|
process :resize_to_fit => [210, 210]
|
||||||
def store_dir
|
def store_dir
|
||||||
"uploads/thumbs/#{model.album.path}"
|
ENV['STORAGE_PATH'] + "/files/thumbs/#{model.album.path}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
version :single do
|
version :single do
|
||||||
process :resize_to_limit => [950, 950]
|
process :resize_to_limit => [950, 950]
|
||||||
def store_dir
|
def store_dir
|
||||||
"uploads/thumbs/#{model.album.path}"
|
ENV['STORAGE_PATH'] + "/files/thumbs/#{model.album.path}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,6 @@
|
||||||
<%= link_to "Edit album", edit_album_path(@album) %> |
|
<%= link_to "Edit album", edit_album_path(@album) %> |
|
||||||
<%= link_to "Edit all photos", edit_multiple_album_photos_path(@album) %> |
|
<%= link_to "Edit all photos", edit_multiple_album_photos_path(@album) %> |
|
||||||
<%= link_to "Edit untouched photos", untouched_album_photos_path(@album) %> |
|
<%= link_to "Edit untouched photos", untouched_album_photos_path(@album) %> |
|
||||||
<%= link_to "Add photos", upload_album_photos_path(@album) %>
|
<%= link_to "Add photos", upload_collection_album_photos_path(params[:collection_id], @album) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
|
@ -3,7 +3,7 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
<title><%= ENV['TITLE'] %></title>
|
<title><%= ENV['TITLE'] || "Photos" %></title>
|
||||||
<%= yield :head %>
|
<%= yield :head %>
|
||||||
<%= stylesheet_link_tag 'application' %>
|
<%= stylesheet_link_tag 'application' %>
|
||||||
</head>
|
</head>
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
<% if ENV['LOGO'] %>
|
<% if ENV['LOGO'] %>
|
||||||
<%= image_tag ENV['LOGO'] %>
|
<%= image_tag ENV['LOGO'] %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= ENV['TITLE'] %>
|
<%= ENV['TITLE'] || "Photos" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</a>
|
</a>
|
||||||
</h1>
|
</h1>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
<meta name = "viewport" content = "width = device-width">
|
<meta name = "viewport" content = "width = device-width">
|
||||||
<meta name = "viewport" content = "initial-scale = 1.0, user-scalable=no">
|
<meta name = "viewport" content = "initial-scale = 1.0, user-scalable=no">
|
||||||
<title><%= ENV['TITLE'] %></title>
|
<title><%= ENV['TITLE'] || "Photos" %></title>
|
||||||
<%= yield :head %>
|
<%= yield :head %>
|
||||||
<%= stylesheet_link_tag 'application', 'iphone' %>
|
<%= stylesheet_link_tag 'application', 'iphone' %>
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
ENV['PUBLIC'] = 'true'
|
ENV['STORAGE_PATH'] = "uploads" if ENV['STORAGE_PATH'].nil?
|
||||||
ENV['TITLE'] = 'photo'
|
#ENV['PRIVATE'] = 'true'
|
||||||
|
#ENV['TITLE'] = 'photo'
|
||||||
#ENV['HEROKU'] = 'true'
|
#ENV['HEROKU'] = 'true'
|
||||||
#ENV['S3_KEY'] = ''
|
#ENV['S3_KEY'] = ''
|
||||||
#ENV['S3_SECRET'] = ''
|
#ENV['S3_SECRET'] = ''
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
development:
|
development:
|
||||||
adapter: postgresql
|
adapter: postgresql
|
||||||
database: gallery_development
|
database: balder_development
|
||||||
username: gallery
|
username: balder
|
||||||
password: changeme
|
password: changeme
|
||||||
production:
|
production:
|
||||||
adapter: mysql
|
adapter: mysql
|
||||||
encoding: utf8
|
encoding: utf8
|
||||||
username: photogallery
|
username: balder
|
||||||
password: changeme
|
password: changeme
|
||||||
database: gallery_production
|
database: balder_production
|
||||||
socket: /var/run/mysqld/mysqld.sock
|
socket: /var/run/mysqld/mysqld.sock
|
||||||
test: &TEST
|
test: &TEST
|
||||||
adapter: postgresql
|
adapter: postgresql
|
||||||
database: gallery_test
|
database: gallery_test
|
||||||
username: gallery
|
username: balder
|
||||||
password: changeme
|
password: changeme
|
||||||
|
|
||||||
cucumber:
|
cucumber:
|
||||||
|
|
|
@ -1,27 +1,58 @@
|
||||||
ActionController::Routing::Routes.draw do |map|
|
ActionController::Routing::Routes.draw do
|
||||||
map.resource :account, :controller => "users"
|
resources :account, :as => "users"
|
||||||
map.login "login", :controller => "user_sessions", :action => "new"
|
match "login", :to => "user_sessions#new", :as => :login
|
||||||
map.authenticate "authenticate", :controller => "user_sessions", :action => "create"
|
match "authenticate", :to => "user_sessions#create", :as => :authenticate
|
||||||
map.logout "logout", :controller => "user_sessions", :action => "destroy"
|
match "logout", :to => "user_sessions#destroy", :as => :logout
|
||||||
|
|
||||||
map.resources :photos, :collection => { :untouched => :get, :edit_multiple => :post, :update_multiple => :put, :upload => :get, :scan => :get }
|
resources :photos do
|
||||||
map.resources :albums, :collection => { :untouched => :get, } do |album|
|
collection do
|
||||||
album.resources :tags do |tag|
|
get :untouched
|
||||||
tag.resources :photos, :collection => { :untouched => :get, :upload => :get, :edit_multiple => :get }
|
post :edit_multiple
|
||||||
|
put :update_multiple
|
||||||
|
get :upload
|
||||||
|
get :scan
|
||||||
|
end
|
||||||
|
end
|
||||||
|
resources :albums do
|
||||||
|
collection do
|
||||||
|
get :untouched
|
||||||
|
end
|
||||||
|
resources :tags do
|
||||||
|
resources :photos do
|
||||||
|
collection do
|
||||||
|
get :untouched
|
||||||
|
get :upload
|
||||||
|
get :edit_multiple
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
resources :photos do
|
||||||
|
collection do
|
||||||
|
get :untouched
|
||||||
|
get :upload
|
||||||
|
get :edit_multiple
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
resources :collections do
|
||||||
|
resources :albums do
|
||||||
|
resources :photos do
|
||||||
|
collection do
|
||||||
|
get :untouched
|
||||||
|
get :upload
|
||||||
|
get :edit_multiple
|
||||||
end
|
end
|
||||||
album.resources :photos, :collection => { :untouched => :get, :upload => :get, :edit_multiple => :get }
|
|
||||||
end
|
end
|
||||||
map.resources :collections do |collection|
|
|
||||||
collection.resources :albums do |album|
|
|
||||||
album.resources :photos, :collection => { :untouched => :get }
|
|
||||||
#album.resources :photos, :collection => { :untouched => :get, :upload => :get, :edit_multiple => :get }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
map.resources :tags, :has_many => [ :photos, :albums ], :shallow => true
|
resources :tags, :shallow => true do
|
||||||
|
resources :photos
|
||||||
|
resources :albums
|
||||||
|
end
|
||||||
|
|
||||||
map.resources :users, :controller => "admin/users"
|
resources :users, :to => "admin/users#index"
|
||||||
|
|
||||||
map.root :controller => "collections"
|
root :to => "collections#index"
|
||||||
|
|
||||||
end
|
end
|
13
db/schema.rb
13
db/schema.rb
|
@ -1,10 +1,11 @@
|
||||||
# This file is auto-generated from the current state of the database. Instead of editing this file,
|
# This file is auto-generated from the current state of the database. Instead
|
||||||
# please use the migrations feature of Active Record to incrementally modify your database, and
|
# of editing this file, please use the migrations feature of Active Record to
|
||||||
# then regenerate this schema definition.
|
# incrementally modify your database, and then regenerate this schema definition.
|
||||||
#
|
#
|
||||||
# Note that this schema.rb definition is the authoritative source for your database schema. If you need
|
# Note that this schema.rb definition is the authoritative source for your
|
||||||
# to create the application database on another system, you should be using db:schema:load, not running
|
# database schema. If you need to create the application database on another
|
||||||
# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
# system, you should be using db:schema:load, not running all the migrations
|
||||||
|
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
||||||
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
||||||
#
|
#
|
||||||
# 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.
|
||||||
|
|
Loading…
Reference in a new issue