Merge branch 'rails3' of https://github.com/vanicat/balder into vanicat-rails3
This commit is contained in:
commit
3d97e3e3fe
16 changed files with 91 additions and 81 deletions
2
Gemfile
2
Gemfile
|
@ -1,6 +1,6 @@
|
||||||
source 'http://rubygems.org'
|
source 'http://rubygems.org'
|
||||||
|
|
||||||
gem 'rails', '3.0.0'
|
gem 'rails', '3.0.1'
|
||||||
|
|
||||||
gem "authlogic"
|
gem "authlogic"
|
||||||
gem 'mime-types', :require => 'mime/types'
|
gem 'mime-types', :require => 'mime/types'
|
||||||
|
|
80
Gemfile.lock
80
Gemfile.lock
|
@ -1,20 +1,20 @@
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/jnicklas/carrierwave.git
|
remote: git://github.com/jnicklas/carrierwave.git
|
||||||
revision: 3372a078a0ea4d6e4e2ee1990610db9186f43b41
|
revision: 272c9aac1f2f30c4bd2990e28a3b1403c9820f37
|
||||||
specs:
|
specs:
|
||||||
carrierwave (0.5.0.beta2)
|
carrierwave (0.5.0)
|
||||||
activesupport (~> 3.0.0)
|
activesupport (~> 3.0)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
abstract (1.0.0)
|
abstract (1.0.0)
|
||||||
actionmailer (3.0.0)
|
actionmailer (3.0.1)
|
||||||
actionpack (= 3.0.0)
|
actionpack (= 3.0.1)
|
||||||
mail (~> 2.2.5)
|
mail (~> 2.2.5)
|
||||||
actionpack (3.0.0)
|
actionpack (3.0.1)
|
||||||
activemodel (= 3.0.0)
|
activemodel (= 3.0.1)
|
||||||
activesupport (= 3.0.0)
|
activesupport (= 3.0.1)
|
||||||
builder (~> 2.1.2)
|
builder (~> 2.1.2)
|
||||||
erubis (~> 2.6.6)
|
erubis (~> 2.6.6)
|
||||||
i18n (~> 0.4.1)
|
i18n (~> 0.4.1)
|
||||||
|
@ -22,19 +22,19 @@ GEM
|
||||||
rack-mount (~> 0.6.12)
|
rack-mount (~> 0.6.12)
|
||||||
rack-test (~> 0.5.4)
|
rack-test (~> 0.5.4)
|
||||||
tzinfo (~> 0.3.23)
|
tzinfo (~> 0.3.23)
|
||||||
activemodel (3.0.0)
|
activemodel (3.0.1)
|
||||||
activesupport (= 3.0.0)
|
activesupport (= 3.0.1)
|
||||||
builder (~> 2.1.2)
|
builder (~> 2.1.2)
|
||||||
i18n (~> 0.4.1)
|
i18n (~> 0.4.1)
|
||||||
activerecord (3.0.0)
|
activerecord (3.0.1)
|
||||||
activemodel (= 3.0.0)
|
activemodel (= 3.0.1)
|
||||||
activesupport (= 3.0.0)
|
activesupport (= 3.0.1)
|
||||||
arel (~> 1.0.0)
|
arel (~> 1.0.0)
|
||||||
tzinfo (~> 0.3.23)
|
tzinfo (~> 0.3.23)
|
||||||
activeresource (3.0.0)
|
activeresource (3.0.1)
|
||||||
activemodel (= 3.0.0)
|
activemodel (= 3.0.1)
|
||||||
activesupport (= 3.0.0)
|
activesupport (= 3.0.1)
|
||||||
activesupport (3.0.0)
|
activesupport (3.0.1)
|
||||||
arel (1.0.1)
|
arel (1.0.1)
|
||||||
activesupport (~> 3.0.0)
|
activesupport (~> 3.0.0)
|
||||||
authlogic (2.1.6)
|
authlogic (2.1.6)
|
||||||
|
@ -42,10 +42,10 @@ 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)
|
excon (0.2.4)
|
||||||
fog (0.3.7)
|
fog (0.3.19)
|
||||||
builder
|
builder
|
||||||
excon (>= 0.2.3)
|
excon (>= 0.2.4)
|
||||||
formatador (>= 0.0.15)
|
formatador (>= 0.0.15)
|
||||||
json
|
json
|
||||||
mime-types
|
mime-types
|
||||||
|
@ -53,12 +53,13 @@ GEM
|
||||||
nokogiri (~> 1.4.3.1)
|
nokogiri (~> 1.4.3.1)
|
||||||
ruby-hmac
|
ruby-hmac
|
||||||
formatador (0.0.15)
|
formatador (0.0.15)
|
||||||
i18n (0.4.1)
|
i18n (0.4.2)
|
||||||
json (1.4.6)
|
json (1.4.6)
|
||||||
mail (2.2.6.1)
|
mail (2.2.10)
|
||||||
activesupport (>= 2.3.6)
|
activesupport (>= 2.3.6)
|
||||||
mime-types
|
i18n (~> 0.4.1)
|
||||||
treetop (>= 1.4.5)
|
mime-types (~> 1.16)
|
||||||
|
treetop (~> 1.4.8)
|
||||||
mime-types (1.16)
|
mime-types (1.16)
|
||||||
net-ssh (2.0.23)
|
net-ssh (2.0.23)
|
||||||
nokogiri (1.4.3.1)
|
nokogiri (1.4.3.1)
|
||||||
|
@ -67,26 +68,26 @@ GEM
|
||||||
rack (1.2.1)
|
rack (1.2.1)
|
||||||
rack-mount (0.6.13)
|
rack-mount (0.6.13)
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
rack-test (0.5.4)
|
rack-test (0.5.6)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
rails (3.0.0)
|
rails (3.0.1)
|
||||||
actionmailer (= 3.0.0)
|
actionmailer (= 3.0.1)
|
||||||
actionpack (= 3.0.0)
|
actionpack (= 3.0.1)
|
||||||
activerecord (= 3.0.0)
|
activerecord (= 3.0.1)
|
||||||
activeresource (= 3.0.0)
|
activeresource (= 3.0.1)
|
||||||
activesupport (= 3.0.0)
|
activesupport (= 3.0.1)
|
||||||
bundler (~> 1.0.0)
|
bundler (~> 1.0.0)
|
||||||
railties (= 3.0.0)
|
railties (= 3.0.1)
|
||||||
railties (3.0.0)
|
railties (3.0.1)
|
||||||
actionpack (= 3.0.0)
|
actionpack (= 3.0.1)
|
||||||
activesupport (= 3.0.0)
|
activesupport (= 3.0.1)
|
||||||
rake (>= 0.8.4)
|
rake (>= 0.8.4)
|
||||||
thor (~> 0.14.0)
|
thor (~> 0.14.0)
|
||||||
rake (0.8.7)
|
rake (0.8.7)
|
||||||
rmagick (2.13.1)
|
rmagick (2.13.1)
|
||||||
ruby-hmac (0.4.0)
|
ruby-hmac (0.4.0)
|
||||||
thor (0.14.1)
|
thor (0.14.4)
|
||||||
treetop (1.4.8)
|
treetop (1.4.9)
|
||||||
polyglot (>= 0.3.1)
|
polyglot (>= 0.3.1)
|
||||||
tzinfo (0.3.23)
|
tzinfo (0.3.23)
|
||||||
|
|
||||||
|
@ -99,5 +100,8 @@ DEPENDENCIES
|
||||||
fog
|
fog
|
||||||
mime-types
|
mime-types
|
||||||
pg
|
pg
|
||||||
rails (= 3.0.0)
|
rails (= 3.0.1)
|
||||||
rmagick
|
rmagick
|
||||||
|
|
||||||
|
METADATA
|
||||||
|
version: 1.0.6
|
||||||
|
|
|
@ -6,7 +6,7 @@ module ApplicationHelper
|
||||||
levels.delete_at(0)
|
levels.delete_at(0)
|
||||||
|
|
||||||
#links = "You are here: "
|
#links = "You are here: "
|
||||||
links = content_tag('a', "HOME", :href => "/") if include_home
|
links = content_tag('a', "HOME", :href => root_path ) if include_home
|
||||||
|
|
||||||
nocrumb = ["collections", "albums", "photos", "tags", "new", "edit", "tags"]
|
nocrumb = ["collections", "albums", "photos", "tags", "new", "edit", "tags"]
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,10 @@ class FlashSessionCookieMiddleware
|
||||||
if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
|
if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
|
||||||
req = Rack::Request.new(env)
|
req = Rack::Request.new(env)
|
||||||
env['HTTP_COOKIE'] = [ @session_key,
|
env['HTTP_COOKIE'] = [ @session_key,
|
||||||
req.params[@session_key] ]
|
req.params[@session_key] ].join('=').freeze unless req.params[@session_key].nil?
|
||||||
.join('=').freeze unless req.params[@session_key].nil?
|
env['HTTP_ACCEPT'] = "#{req.params['_http_accept']}".freeze unless req.params['_http_accept'].nil?
|
||||||
env['HTTP_ACCEPT'] = "#{req.params['_http_accept']}"
|
|
||||||
.freeze unless req.params['_http_accept'].nil?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@app.call(env)
|
@app.call(env)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,8 +3,8 @@ class Album < ActiveRecord::Base
|
||||||
has_many :collection_albums
|
has_many :collection_albums
|
||||||
has_many :collections, :through => :collection_albums
|
has_many :collections, :through => :collection_albums
|
||||||
|
|
||||||
validates_uniqueness_of :path, :message => "Album already exsists on disc"
|
validates :path, :presence => true, :uniqueness => true #, :message => "Album already exsists on disc"
|
||||||
validates_presence_of :title, :message => "can't be blank"
|
validates :title, :presence => true #, :message => "can't be blank"
|
||||||
|
|
||||||
before_validation :ensure_path, :set_title
|
before_validation :ensure_path, :set_title
|
||||||
after_create :create_folders
|
after_create :create_folders
|
||||||
|
@ -13,22 +13,20 @@ class Album < ActiveRecord::Base
|
||||||
attr_accessor :tags
|
attr_accessor :tags
|
||||||
#attr_protected :path
|
#attr_protected :path
|
||||||
|
|
||||||
scope :untouched, :conditions => "albums.id IN ( SELECT DISTINCT photos.album_id FROM photos WHERE photos.description IS NULL AND photos.id NOT IN ( SELECT photo_id FROM photo_tags) )", :order => 'title'
|
scope :untouched, where("albums.id IN ( SELECT DISTINCT photos.album_id FROM photos WHERE photos.description IS NULL AND photos.id NOT IN ( SELECT photo_id FROM photo_tags) )").order('title')
|
||||||
scope :unused, :conditions => "albums.id NOT IN (SELECT album_id FROM collection_albums)"
|
scope :unused, where("albums.id NOT IN (SELECT album_id FROM collection_albums)")
|
||||||
scope :used, :conditions => "albums.id IN (SELECT album_id FROM collection_albums)"
|
scope :used, where("albums.id IN (SELECT album_id FROM collection_albums)")
|
||||||
|
|
||||||
def to_param
|
def to_param
|
||||||
"#{id}-#{title.parameterize}"
|
"#{id}-#{title.parameterize}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def ensure_path
|
def ensure_path
|
||||||
self.path = self.title.parameterize unless self.path
|
self.path = self.title.parameterize unless self.path
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_title
|
def set_title
|
||||||
self.title = File.basename( self.path).titleize unless self.title || !self.path
|
self.title = File.basename(self.path).titleize unless self.title || !self.path
|
||||||
end
|
end
|
||||||
|
|
||||||
def tags
|
def tags
|
||||||
|
|
|
@ -3,6 +3,8 @@ class Collection < ActiveRecord::Base
|
||||||
has_many :albums, :through => :collection_albums
|
has_many :albums, :through => :collection_albums
|
||||||
attr_accessor :album_list
|
attr_accessor :album_list
|
||||||
|
|
||||||
|
validates :title, :presence => true
|
||||||
|
|
||||||
def to_param
|
def to_param
|
||||||
"#{id}-#{title.parameterize}"
|
"#{id}-#{title.parameterize}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
class Photo < ActiveRecord::Base
|
class Photo < ActiveRecord::Base
|
||||||
|
# TODO: path not used? it should be removed from the DB
|
||||||
|
|
||||||
belongs_to :album
|
belongs_to :album
|
||||||
has_many :photo_tags, :dependent => :destroy
|
has_many :photo_tags, :dependent => :destroy
|
||||||
has_many :tags, :through => :photo_tags
|
has_many :tags, :through => :photo_tags
|
||||||
|
|
||||||
mount_uploader :file, FileUploader
|
mount_uploader :file, FileUploader
|
||||||
|
|
||||||
#validates_uniqueness_of :path, :message => "Photo already exsists on disc"
|
validates :title, :presence => true
|
||||||
validates_presence_of :title
|
|
||||||
|
|
||||||
before_validation :set_title
|
before_validation :set_title
|
||||||
#before_create :exif_read
|
#before_create :exif_read
|
||||||
|
@ -49,6 +50,10 @@ class Photo < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
self.tags = ts
|
self.tags = ts
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def _delete
|
||||||
|
0
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
@ -82,6 +87,5 @@ class Photo < ActiveRecord::Base
|
||||||
photo.Keywords = self.tags
|
photo.Keywords = self.tags
|
||||||
photo.save
|
photo.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ class Role < ActiveRecord::Base
|
||||||
has_many :subroles, :through => :roleables, :source => :roleable, :source_type => 'Role'
|
has_many :subroles, :through => :roleables, :source => :roleable, :source_type => 'Role'
|
||||||
has_many :users, :through => :roleables, :source => :roleable, :source_type => 'User'
|
has_many :users, :through => :roleables, :source => :roleable, :source_type => 'User'
|
||||||
|
|
||||||
validates_uniqueness_of :name
|
validates :name, :presence => true, :uniqueness => true
|
||||||
|
|
||||||
acts_as_permissible
|
acts_as_permissible
|
||||||
end
|
end
|
|
@ -1,3 +1,6 @@
|
||||||
class UserSession < Authlogic::Session::Base
|
class UserSession < Authlogic::Session::Base
|
||||||
# configuration here, see documentation for sub modules of Authlogic::Session
|
# configuration here, see documentation for sub modules of Authlogic::Session
|
||||||
end
|
def to_key
|
||||||
|
new_record? ? nil : [ self.send(self.class.primary_key) ]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -3,4 +3,10 @@
|
||||||
<br />
|
<br />
|
||||||
<%= form.label :email %><br />
|
<%= form.label :email %><br />
|
||||||
<%= form.text_field :email %><br />
|
<%= form.text_field :email %><br />
|
||||||
<br/>
|
<br/>
|
||||||
|
<%= form.label :password %><br />
|
||||||
|
<%= form.password_field :password %><br />
|
||||||
|
<br/>
|
||||||
|
<%= form.label :password_confirmation %><br />
|
||||||
|
<%= form.password_field :password_confirmation %><br />
|
||||||
|
<br/>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<% content_for :javascript do %>
|
<% content_for :javascript do %>
|
||||||
<script src="http://maps.google.com/maps/api/js?sensor=true" type="text/javascript"></script>
|
<%= javascript_include_tag "http://maps.google.com/maps/api/js?sensor=true" -%>
|
||||||
<script src="/javascripts/tag/tag.js" type="text/javascript" charset="utf-8"></script>
|
<%= javascript_include_tag "tag/tag" -%>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div id="map_canvas"></div>
|
<div id="map_canvas"></div>
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
<% for album in @collection.albums %>
|
<% for album in @collection.albums %>
|
||||||
<%= form.fields_for :album_list do |album_fields| %>
|
<%= form.fields_for :album_list do |album_fields| %>
|
||||||
<span>
|
<span>
|
||||||
<img src="/images/delete-24x24.png" border="" class="delete" />
|
<%= image_tag "delete-24x24.png", :class => "delete", :alt => "Delete" -%>
|
||||||
|
|
||||||
<% if album.photos.empty? %>
|
<% if album.photos.empty? %>
|
||||||
<%= album.title %>
|
<%= album.title %>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|
|
@ -19,18 +19,12 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<h1>
|
<h1>
|
||||||
<a href="/">
|
<%= link_to(if ENV['LOGO'] then image_tag(ENV['LOGO']) else (ENV['TITLE'] || "Photos") end, root_path) %>
|
||||||
<% if ENV['LOGO'] %>
|
</h1>
|
||||||
<%= image_tag ENV['LOGO'] %>
|
<% form_tag albums_path, { :id => :search } do -%>
|
||||||
<% else %>
|
|
||||||
<%= ENV['TITLE'] || "Photos" %>
|
|
||||||
<% end %>
|
|
||||||
</a>
|
|
||||||
</h1>
|
|
||||||
<form action="/albums" method="get" id="search">
|
|
||||||
<input type="text" name="q" class="textfield"/>
|
<input type="text" name="q" class="textfield"/>
|
||||||
<input type="submit" value="Search" class="button" />
|
<input type="submit" value="Search" class="button" />
|
||||||
</form>
|
<% end -%>
|
||||||
<hr class="seperator" />
|
<hr class="seperator" />
|
||||||
<%= breadcrumbs %>
|
<%= breadcrumbs %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -50,4 +44,4 @@
|
||||||
<%= javascript_include_tag 'jquery-1.4.2.js', 'rails', 'balder' %>
|
<%= javascript_include_tag 'jquery-1.4.2.js', 'rails', 'balder' %>
|
||||||
<%= yield :javascript %>
|
<%= yield :javascript %>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<% content_for :javascript do %>
|
<% content_for :javascript do %>
|
||||||
<script src="/javascripts/tag/tag.js" type="text/javascript" charset="utf-8"></script>
|
<%= javascript_include_tag "tag/tag" -%>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= hidden_field_tag :all_tags, @tags %>
|
<%= hidden_field_tag :all_tags, @tags %>
|
||||||
<%= form.label :title %><br />
|
<%= form.label :title %><br />
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<% content_for :javascript do %>
|
<% content_for :javascript do %>
|
||||||
<script type="text/javascript" src="/javascripts/uploadify-2.1/jquery.uploadify.v2.1.0.min.js"></script>
|
<%= javascript_include_tag "uploadify-2.1/jquery.uploadify.v2.1.0.min.js" -%>
|
||||||
<script type="text/javascript" src="/javascripts/uploadify-2.1/swfobject.js"></script>
|
<%= javascript_include_tag "uploadify-2.1/swfobject.js" -%>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('#photo_file').uploadify({
|
$('#photo_file').uploadify({
|
||||||
uploader:'/javascripts/uploadify-2.1/uploadify.swf',
|
uploader:'<%= javascript_path "uploadify-2.1/uploadify.swf" -%>',
|
||||||
script:'<%= photos_path %>',
|
script:'<%= photos_path %>',
|
||||||
fileDataName : 'photo[file]',
|
fileDataName : 'photo[file]',
|
||||||
scriptData: {
|
scriptData: {
|
||||||
|
@ -13,7 +13,7 @@ $(document).ready(function() {
|
||||||
'authenticity_token' : encodeURIComponent('<%= u form_authenticity_token if protect_against_forgery?%>'),
|
'authenticity_token' : encodeURIComponent('<%= u form_authenticity_token if protect_against_forgery?%>'),
|
||||||
'photo[album_id]' : "<%= @album.id %>"
|
'photo[album_id]' : "<%= @album.id %>"
|
||||||
},
|
},
|
||||||
cancelImg:'/javascripts/jquery.uploadify-v1.6.2.mit/cancel.png',
|
cancelImg:'<%= javascript_path "jquery.uploadify-v1.6.2.mit/cancel.png" -%>',
|
||||||
multi:true,
|
multi:true,
|
||||||
auto:true,
|
auto:true,
|
||||||
onComplete : function (e,queueId,fileObj,res,data) {
|
onComplete : function (e,queueId,fileObj,res,data) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
ActionController::Routing::Routes.draw do
|
ActionController::Routing::Routes.draw do
|
||||||
resources :account, :as => "users"
|
resource :account, :controller => :users
|
||||||
match "login", :to => "user_sessions#new", :as => :login
|
match "login", :to => "user_sessions#new", :as => :login
|
||||||
match "authenticate", :to => "user_sessions#create", :as => :authenticate
|
match "authenticate", :to => "user_sessions#create", :as => :authenticate
|
||||||
match "logout", :to => "user_sessions#destroy", :as => :logout
|
match "logout", :to => "user_sessions#destroy", :as => :logout
|
||||||
|
@ -51,8 +51,8 @@ ActionController::Routing::Routes.draw do
|
||||||
resources :albums
|
resources :albums
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :users, :to => "admin/users#index"
|
resources :users, :controller => "admin/users"
|
||||||
|
|
||||||
root :to => "collections#index"
|
root :to => "collections#index"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue