avatars_for_rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +138 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +91 -0
- data/Rakefile +29 -0
- data/app/controllers/avatars_controller.rb +109 -0
- data/app/models/avatar.rb +138 -0
- data/app/views/avatars/_errors.html.erb +6 -0
- data/app/views/avatars/_form.html.erb +128 -0
- data/app/views/avatars/_includes.html.erb +14 -0
- data/app/views/avatars/_list.html.erb +39 -0
- data/app/views/avatars/_new.html.erb +15 -0
- data/app/views/avatars/_precrop.html.erb +38 -0
- data/app/views/avatars/destroy.js.erb +2 -0
- data/app/views/avatars/edit.html.erb +8 -0
- data/app/views/avatars/index.html.erb +4 -0
- data/app/views/avatars/new.html.erb +1 -0
- data/app/views/avatars/show.html.erb +8 -0
- data/app/views/avatars/update.js.erb +6 -0
- data/avatars_for_rails.gemspec +40 -0
- data/config/locales/en.yml +28 -0
- data/config/routes.rb +6 -0
- data/lib/avatars_for_rails/avatars_controller_config.rb +4 -0
- data/lib/avatars_for_rails.rb +27 -0
- data/lib/generators/avatars_for_rails/install_generator.rb +28 -0
- data/lib/generators/avatars_for_rails/templates/initializer.rb +11 -0
- data/lib/generators/avatars_for_rails/templates/migration.rb +20 -0
- data/lib/generators/avatars_for_rails/templates/public/images/Jcrop.gif +0 -0
- data/lib/generators/avatars_for_rails/templates/public/images/cancel.png +0 -0
- data/lib/generators/avatars_for_rails/templates/public/images/pbar-ani.gif +0 -0
- data/lib/generators/avatars_for_rails/templates/public/images/rails.png +0 -0
- data/lib/generators/avatars_for_rails/templates/public/javascripts/application.js +2 -0
- data/lib/generators/avatars_for_rails/templates/public/javascripts/avatars.js +8 -0
- data/lib/generators/avatars_for_rails/templates/public/javascripts/controls.js +965 -0
- data/lib/generators/avatars_for_rails/templates/public/javascripts/dragdrop.js +974 -0
- data/lib/generators/avatars_for_rails/templates/public/javascripts/effects.js +1123 -0
- data/lib/generators/avatars_for_rails/templates/public/javascripts/jquery-ui.min.js +401 -0
- data/lib/generators/avatars_for_rails/templates/public/javascripts/jquery.Jcrop.min.js +163 -0
- data/lib/generators/avatars_for_rails/templates/public/javascripts/jquery.fileupload-ui.js +259 -0
- data/lib/generators/avatars_for_rails/templates/public/javascripts/jquery.fileupload.js +475 -0
- data/lib/generators/avatars_for_rails/templates/public/javascripts/jquery.form.js +815 -0
- data/lib/generators/avatars_for_rails/templates/public/javascripts/jquery.js +7179 -0
- data/lib/generators/avatars_for_rails/templates/public/javascripts/prototype.js +6001 -0
- data/lib/generators/avatars_for_rails/templates/public/javascripts/rails.js +158 -0
- data/lib/generators/avatars_for_rails/templates/public/stylesheets/.gitkeep +0 -0
- data/lib/generators/avatars_for_rails/templates/public/stylesheets/avatars.css +115 -0
- data/lib/generators/avatars_for_rails/templates/public/stylesheets/jquery.Jcrop.css +35 -0
- data/lib/generators/avatars_for_rails/templates/public/stylesheets/jquery.fileupload-ui.css +70 -0
- data/spec/avatars_for_rails_spec.rb +7 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/actor.rb +7 -0
- data/spec/dummy/app/views/layouts/application.html.erb +20 -0
- data/spec/dummy/config/application.rb +46 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +26 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +35 -0
- data/spec/dummy/config/initializers/avatars_for_rails.rb +6 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +60 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20110411073237_create_actors.rb +13 -0
- data/spec/dummy/db/migrate/20110411073238_create_avatars.rb +21 -0
- data/spec/dummy/db/schema.rb +32 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/images/Jcrop.gif +0 -0
- data/spec/dummy/public/images/cancel.png +0 -0
- data/spec/dummy/public/images/pbar-ani.gif +0 -0
- data/spec/dummy/public/images/rails.png +0 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/avatars.js +8 -0
- data/spec/dummy/public/javascripts/controls.js +965 -0
- data/spec/dummy/public/javascripts/dragdrop.js +974 -0
- data/spec/dummy/public/javascripts/effects.js +1123 -0
- data/spec/dummy/public/javascripts/jquery-ui.min.js +401 -0
- data/spec/dummy/public/javascripts/jquery.Jcrop.min.js +163 -0
- data/spec/dummy/public/javascripts/jquery.fileupload-ui.js +259 -0
- data/spec/dummy/public/javascripts/jquery.fileupload.js +475 -0
- data/spec/dummy/public/javascripts/jquery.form.js +815 -0
- data/spec/dummy/public/javascripts/jquery.js +7179 -0
- data/spec/dummy/public/javascripts/prototype.js +6001 -0
- data/spec/dummy/public/javascripts/rails.js +158 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/public/stylesheets/avatars.css +115 -0
- data/spec/dummy/public/stylesheets/jquery.Jcrop.css +35 -0
- data/spec/dummy/public/stylesheets/jquery.fileupload-ui.css +70 -0
- data/spec/dummy/public/system/logos/1/actor/stream20110411-3539-1e9l1hn-0.jpg +0 -0
- data/spec/dummy/public/system/logos/1/original/stream20110411-3539-1e9l1hn-0.jpg +0 -0
- data/spec/dummy/public/system/logos/1/profile/stream20110411-3539-1e9l1hn-0.jpg +0 -0
- data/spec/dummy/public/system/logos/1/representation/stream20110411-3539-1e9l1hn-0.jpg +0 -0
- data/spec/dummy/public/system/logos/1/tie/stream20110411-3539-1e9l1hn-0.jpg +0 -0
- data/spec/dummy/public/system/logos/2/actor/stream20110411-3539-1hlzauh-0.jpeg +0 -0
- data/spec/dummy/public/system/logos/2/original/stream20110411-3539-1hlzauh-0.jpeg +0 -0
- data/spec/dummy/public/system/logos/2/profile/stream20110411-3539-1hlzauh-0.jpeg +0 -0
- data/spec/dummy/public/system/logos/2/representation/stream20110411-3539-1hlzauh-0.jpeg +0 -0
- data/spec/dummy/public/system/logos/2/tie/stream20110411-3539-1hlzauh-0.jpeg +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/integration/navigation_spec.rb +9 -0
- data/spec/spec_helper.rb +33 -0
- metadata +333 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
<br class="clearfloat" />
|
2
|
+
<div class="space_center"></div>
|
3
|
+
<div class="space_center"></div>
|
4
|
+
<% unless(@avatars.empty? || (@avatars.first.present? && @avatars.first.id.blank?)) %>
|
5
|
+
<h2><%=t('avatar.text.use') %></h2>
|
6
|
+
<div class="space_center"></div>
|
7
|
+
<div class="space_center"></div>
|
8
|
+
<div class="avatars" id="all_avatars">
|
9
|
+
<% @avatars.each do |avatar| %>
|
10
|
+
<% unless avatar.id.blank? %>
|
11
|
+
<%= div_for(avatar) do %>
|
12
|
+
<div class="boxgrid captionfull">
|
13
|
+
<%= image_tag(avatar.logo.url(:profile), :class => avatar.active ? 'default' : 'non_default', :size => '94x94', :id => "avatar_img_#{avatar.id}") %>
|
14
|
+
<% if avatar.active %>
|
15
|
+
<div class="cover boxcaption">
|
16
|
+
<%= link_to "Delete avatar", avatar, :confirm => t('avatar.destroy_sure'), :method => :delete, :remote => true %>
|
17
|
+
</div>
|
18
|
+
<% else %>
|
19
|
+
<div class="cover boxcaption">
|
20
|
+
<%= link_to "Set as default", avatar, :confirm => t('avatar.set_default_sure'), :method => :put, :remote => true %>
|
21
|
+
<%= link_to "Delete avatar", avatar, :confirm => t('avatar.destroy_sure'), :method => :delete, :remote => true %>
|
22
|
+
</div>
|
23
|
+
<% end %>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
26
|
+
<% end %>
|
27
|
+
<% end %>
|
28
|
+
</div>
|
29
|
+
<br />
|
30
|
+
<br class="clearfloat" />
|
31
|
+
<div class="space_center"></div>
|
32
|
+
<div class="space_center"></div>
|
33
|
+
<h2><%=t('avatar.text.new') %></h2>
|
34
|
+
<% else %>
|
35
|
+
<h2><%= t('avatar.new') %></h2>
|
36
|
+
<% end %>
|
37
|
+
|
38
|
+
|
39
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<% if !@avatar.logo.errors['precrop'].blank? %>
|
2
|
+
<h2><%= t('avatar.crop_image') %></h2>
|
3
|
+
<br class="clearfloat" />
|
4
|
+
<div class="space_center"></div>
|
5
|
+
<%= render :partial => 'precrop' %>
|
6
|
+
<% elsif !@avatar.errors.blank? %>
|
7
|
+
<%= render :partial => 'errors' %>
|
8
|
+
<% else %>
|
9
|
+
<br class="clearfloat" />
|
10
|
+
<div class="space_center"></div>
|
11
|
+
<div class="space_center"></div>
|
12
|
+
<div id="content_logo">
|
13
|
+
<%= render :partial => 'form' %>
|
14
|
+
<% end %>
|
15
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<% if params[:drag_name].blank? %>
|
2
|
+
<% my_file_name = File.basename(@avatar.logo.queued_for_write[:original].path.to_s) %>
|
3
|
+
<% else %>
|
4
|
+
<% my_file_name = params[:drag_name].to_s %>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<% if Avatar.check_image_tmp_valid(my_file_name) %>
|
8
|
+
<div class = "block">
|
9
|
+
<div id="precropPrev" >
|
10
|
+
<div class="form_row">
|
11
|
+
<%= t('avatar.preview') %>
|
12
|
+
</div>
|
13
|
+
<div id="precropPrevImg" class="logo">
|
14
|
+
<%= image_tag "tmp/#{my_file_name}",:id=>"preview" %>
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
|
18
|
+
<div class="form_row">
|
19
|
+
<%= t('avatar.original') %>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<div id="precropDiv" class = "block title content">
|
23
|
+
<%= image_tag "tmp/#{my_file_name}",:id=>"cropImage" %>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<%= form_for @avatar, :html => { :multipart => true } do |f| %>
|
28
|
+
<div class= "block">
|
29
|
+
<% for attribute in [:crop_x, :crop_y, :crop_w, :crop_h] %>
|
30
|
+
<%= f.hidden_field attribute, :id => attribute %>
|
31
|
+
<% end %>
|
32
|
+
<%= f.hidden_field :name, :value => my_file_name %>
|
33
|
+
<div class="form_row center">
|
34
|
+
<%= f.submit t('avatar.crop_submit'), :class => "button" %>
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
<% end %>
|
38
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render :partial => 'new' %>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Provide a simple gemspec so you can easily use your enginex
|
2
|
+
# project in your rails apps through git.
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "avatars_for_rails"
|
5
|
+
s.version = "0.0.1"
|
6
|
+
s.authors = ["Jaime Castro Montero"]
|
7
|
+
s.summary = "Avatar manager for rails apps."
|
8
|
+
s.description = "A Rails engine that allows any model to act as avatarable, permitting it to have a complete avatar manager with a few options."
|
9
|
+
s.email = "jaime1988@gmail.com"
|
10
|
+
s.homepage = "http://github.com/ging/avatars_for_rails"
|
11
|
+
s.files = `git ls-files`.split("\n")
|
12
|
+
#s.files = Dir["{app,lib,config}/**/*"] + ["MIT-LICENSE", "Rakefile", "Gemfile", "README.rdoc"]
|
13
|
+
# Gem dependencies
|
14
|
+
#
|
15
|
+
# SQL foreign keys
|
16
|
+
s.add_runtime_dependency('foreigner', '~> 0.9.1')
|
17
|
+
s.add_runtime_dependency('paperclip', '~> 2.3.4')
|
18
|
+
s.add_runtime_dependency('rmagick','~> 2.13.1')
|
19
|
+
|
20
|
+
|
21
|
+
# Development Gem dependencies
|
22
|
+
#
|
23
|
+
s.add_development_dependency('rails', '~> 3.0.5')
|
24
|
+
# Testing database
|
25
|
+
s.add_development_dependency('sqlite3-ruby')
|
26
|
+
# Debugging
|
27
|
+
if RUBY_VERSION < '1.9'
|
28
|
+
s.add_development_dependency('ruby-debug', '~> 0.10.3')
|
29
|
+
end
|
30
|
+
# Specs
|
31
|
+
s.add_development_dependency('rspec-rails', '~> 2.5.0')
|
32
|
+
# Fixtures
|
33
|
+
s.add_development_dependency('factory_girl', '~> 1.3.2')
|
34
|
+
# Population
|
35
|
+
s.add_development_dependency('forgery', '~> 0.3.6')
|
36
|
+
# Integration testing
|
37
|
+
s.add_development_dependency('capybara', '~> 0.3.9')
|
38
|
+
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
en:
|
2
|
+
actor:
|
3
|
+
name: "Name"
|
4
|
+
avatar:
|
5
|
+
crop_image: "Crop the uploaded image"
|
6
|
+
crop_submit: "Crop image"
|
7
|
+
destroy: "Delete"
|
8
|
+
destroy_sure: "Are you sure you wan't to delete the selected avatar?"
|
9
|
+
error:
|
10
|
+
no_file: "You have to select a file"
|
11
|
+
no_image_file: "The file you uploaded isn't valid, it must be an image file"
|
12
|
+
list: "You have these avatars"
|
13
|
+
new: "Create a new avatar"
|
14
|
+
new_short: "New avatar"
|
15
|
+
no_avatars: "You haven't any avatar, plesase create a new one."
|
16
|
+
one: "Avatar"
|
17
|
+
other: "Avatars"
|
18
|
+
original: "Original image"
|
19
|
+
preview: "Preview"
|
20
|
+
profile_change: "Change your avatar"
|
21
|
+
set_default: "Set as default"
|
22
|
+
set_default_sure: "Are you sure you wan't to set this avatar as default?"
|
23
|
+
text:
|
24
|
+
new: "... or upload a new one"
|
25
|
+
use: "Use your saved avatars ..."
|
26
|
+
upload: "Upload"
|
27
|
+
|
28
|
+
|
data/config/routes.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
require 'paperclip'
|
3
|
+
#require 'ruby-debug'
|
4
|
+
|
5
|
+
module AvatarsForRails
|
6
|
+
|
7
|
+
autoload :AvatarsControllerConfig, 'avatars_for_rails/avatars_controller_config'
|
8
|
+
|
9
|
+
mattr_accessor :avatarable_model
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def setup
|
13
|
+
yield self
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Engine < Rails::Engine
|
18
|
+
|
19
|
+
config.to_prepare do
|
20
|
+
AvatarsController.class_eval do
|
21
|
+
include AvatarsForRails::AvatarsControllerConfig
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#class AvatarsForRails::InstallGenerator < Rails::Generators::Base #:nodoc:
|
2
|
+
class AvatarsForRails::InstallGenerator < Rails::Generators::NamedBase #:nodoc:
|
3
|
+
include Rails::Generators::Migration
|
4
|
+
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
require 'rails/generators/active_record'
|
11
|
+
|
12
|
+
def create_initializer_file
|
13
|
+
template 'initializer.rb', 'config/initializers/avatars_for_rails.rb'
|
14
|
+
end
|
15
|
+
|
16
|
+
def copy_public
|
17
|
+
directory "public"
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def self.next_migration_number(dirname)
|
22
|
+
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_migration_file
|
26
|
+
migration_template 'migration.rb', 'db/migrate/create_avatars_for_rails_' + file_name + '.rb'
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class CreateAvatarsForRails<%= file_name.camelize %> < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
#Tables
|
4
|
+
create_table "avatars", :force => true do |t|
|
5
|
+
t.integer "<%= file_name %>_id"
|
6
|
+
t.string "logo_file_name"
|
7
|
+
t.string "logo_content_type"
|
8
|
+
t.integer "logo_file_size"
|
9
|
+
t.datetime "logo_updated_at"
|
10
|
+
t.boolean "active", :default => true
|
11
|
+
end
|
12
|
+
|
13
|
+
add_index "avatars", "<%= file_name %>_id"
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.down
|
18
|
+
drop_table :avatars
|
19
|
+
end
|
20
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,8 @@
|
|
1
|
+
$(document).ready( function() {
|
2
|
+
//Full Caption Sliding (Hidden to Visible)
|
3
|
+
$('.boxgrid.captionfull').hover( function() {
|
4
|
+
$(".cover", this).stop().animate({top:'61px'},{queue:false,duration:160});
|
5
|
+
}, function() {
|
6
|
+
$(".cover", this).stop().animate({top:'104px'},{queue:false,duration:160});
|
7
|
+
});
|
8
|
+
});
|