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