Skip to content

Commit 346dac7

Browse files
author
gamma
committed
Initial
0 parents  commit 346dac7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1596
-0
lines changed

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
#
3+
# If you find yourself ignoring temporary files generated by your text editor
4+
# or operating system, you probably want to add a global ignore instead:
5+
# git config --global core.excludesfile ~/.gitignore_global
6+
7+
# Ignore bundler config
8+
/.bundle
9+
10+
# Ignore the default SQLite database.
11+
/db/*.sqlite3
12+
13+
# Ignore all logfiles and tempfiles.
14+
/log/*.log
15+
/tmp
16+
17+
18+
/public/uploads/

Gemfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
source 'https://rubygems.org'
2+
3+
gem 'rails', '3.2.17'
4+
5+
# Bundle edge Rails instead:
6+
# gem 'rails', :git => 'git://github.com/rails/rails.git'
7+
8+
gem 'sqlite3'
9+
10+
gem 'rmagick'
11+
gem 'paperclip'
12+
13+
# Gems used only for assets and not required
14+
# in production environments by default.
15+
group :assets do
16+
gem 'sass-rails'
17+
gem 'coffee-rails'
18+
19+
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
20+
gem 'therubyracer'
21+
22+
gem 'uglifier', '>= 1.0.3'
23+
24+
gem 'twitter-bootstrap-rails'
25+
gem "less-rails"
26+
27+
end
28+
29+
gem 'jquery-rails'

Gemfile.lock

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
actionmailer (3.2.17)
5+
actionpack (= 3.2.17)
6+
mail (~> 2.5.4)
7+
actionpack (3.2.17)
8+
activemodel (= 3.2.17)
9+
activesupport (= 3.2.17)
10+
builder (~> 3.0.0)
11+
erubis (~> 2.7.0)
12+
journey (~> 1.0.4)
13+
rack (~> 1.4.5)
14+
rack-cache (~> 1.2)
15+
rack-test (~> 0.6.1)
16+
sprockets (~> 2.2.1)
17+
activemodel (3.2.17)
18+
activesupport (= 3.2.17)
19+
builder (~> 3.0.0)
20+
activerecord (3.2.17)
21+
activemodel (= 3.2.17)
22+
activesupport (= 3.2.17)
23+
arel (~> 3.0.2)
24+
tzinfo (~> 0.3.29)
25+
activeresource (3.2.17)
26+
activemodel (= 3.2.17)
27+
activesupport (= 3.2.17)
28+
activesupport (3.2.17)
29+
i18n (~> 0.6, >= 0.6.4)
30+
multi_json (~> 1.0)
31+
arel (3.0.3)
32+
builder (3.0.4)
33+
climate_control (0.0.3)
34+
activesupport (>= 3.0)
35+
cocaine (0.5.3)
36+
climate_control (>= 0.0.3, < 1.0)
37+
coffee-rails (3.2.2)
38+
coffee-script (>= 2.2.0)
39+
railties (~> 3.2.0)
40+
coffee-script (2.2.0)
41+
coffee-script-source
42+
execjs
43+
coffee-script-source (1.7.0)
44+
commonjs (0.2.7)
45+
erubis (2.7.0)
46+
execjs (2.0.2)
47+
hike (1.2.3)
48+
i18n (0.6.9)
49+
journey (1.0.4)
50+
jquery-rails (3.1.0)
51+
railties (>= 3.0, < 5.0)
52+
thor (>= 0.14, < 2.0)
53+
json (1.8.1)
54+
less (2.4.0)
55+
commonjs (~> 0.2.7)
56+
less-rails (2.4.2)
57+
actionpack (>= 3.1)
58+
less (~> 2.4.0)
59+
libv8 (3.16.14.3)
60+
mail (2.5.4)
61+
mime-types (~> 1.16)
62+
treetop (~> 1.4.8)
63+
mime-types (1.25.1)
64+
multi_json (1.9.2)
65+
paperclip (4.1.1)
66+
activemodel (>= 3.0.0)
67+
activesupport (>= 3.0.0)
68+
cocaine (~> 0.5.3)
69+
mime-types
70+
polyglot (0.3.4)
71+
rack (1.4.5)
72+
rack-cache (1.2)
73+
rack (>= 0.4)
74+
rack-ssl (1.3.3)
75+
rack
76+
rack-test (0.6.2)
77+
rack (>= 1.0)
78+
rails (3.2.17)
79+
actionmailer (= 3.2.17)
80+
actionpack (= 3.2.17)
81+
activerecord (= 3.2.17)
82+
activeresource (= 3.2.17)
83+
activesupport (= 3.2.17)
84+
bundler (~> 1.0)
85+
railties (= 3.2.17)
86+
railties (3.2.17)
87+
actionpack (= 3.2.17)
88+
activesupport (= 3.2.17)
89+
rack-ssl (~> 1.3.2)
90+
rake (>= 0.8.7)
91+
rdoc (~> 3.4)
92+
thor (>= 0.14.6, < 2.0)
93+
rake (10.1.1)
94+
rdoc (3.12.2)
95+
json (~> 1.4)
96+
ref (1.0.5)
97+
rmagick (2.13.2)
98+
sass (3.3.3)
99+
sass-rails (3.2.6)
100+
railties (~> 3.2.0)
101+
sass (>= 3.1.10)
102+
tilt (~> 1.3)
103+
sprockets (2.2.2)
104+
hike (~> 1.2)
105+
multi_json (~> 1.0)
106+
rack (~> 1.0)
107+
tilt (~> 1.1, != 1.3.0)
108+
sqlite3 (1.3.9)
109+
therubyracer (0.12.1)
110+
libv8 (~> 3.16.14.0)
111+
ref
112+
thor (0.18.1)
113+
tilt (1.4.1)
114+
treetop (1.4.15)
115+
polyglot
116+
polyglot (>= 0.3.1)
117+
twitter-bootstrap-rails (2.2.8)
118+
actionpack (>= 3.1)
119+
execjs
120+
rails (>= 3.1)
121+
railties (>= 3.1)
122+
tzinfo (0.3.39)
123+
uglifier (2.5.0)
124+
execjs (>= 0.3.0)
125+
json (>= 1.8.0)
126+
127+
PLATFORMS
128+
ruby
129+
130+
DEPENDENCIES
131+
coffee-rails
132+
jquery-rails
133+
less-rails
134+
paperclip
135+
rails (= 3.2.17)
136+
rmagick
137+
sass-rails
138+
sqlite3
139+
therubyracer
140+
twitter-bootstrap-rails
141+
uglifier (>= 1.0.3)

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Rails 3.2.17 + Paperclip + multiple file upload with nested resource
2+
3+
http://www.railscook.com/recipes/multiple-files-upload-with-nested-resource-using-paperclip-in-rails/
4+
5+
## Getting Started
6+
7+
* Clone
8+
9+
git clone https://github.com/hackhowtofaq/multiple_files_upload_with_nested_resource_rails.git
10+
11+
* Change folder
12+
13+
cd multiple_files_upload_with_nested_resource_rails
14+
15+
* Install gems
16+
17+
bundle install
18+
19+
* Make database
20+
21+
bundle exec rake db:schema:load
22+
23+
* Start server
24+
25+
bundle exec rails s
26+
27+
* Open browser
28+
29+
http://localhost:3000/galleries
30+

Rakefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env rake
2+
# Add your own tasks in files placed in lib/tasks ending in .rake,
3+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4+
5+
require File.expand_path('../config/application', __FILE__)
6+
7+
GalleryJqueryFileUpload::Application.load_tasks

app/assets/javascripts/application.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// This is a manifest file that'll be compiled into application.js, which will include all the files
2+
// listed below.
3+
//
4+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6+
//
7+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8+
// the compiled file.
9+
//
10+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11+
// GO AFTER THE REQUIRES BELOW.
12+
//
13+
14+
//= require jquery
15+
//= require jquery_ujs
16+
17+
18+
//= require pictures
19+
20+
21+
//= require twitter/bootstrap
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
jQuery ->
2+
$("a[rel~=popover], .has-popover").popover()
3+
$("a[rel~=tooltip], .has-tooltip").tooltip()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

app/assets/javascripts/main.js

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*
2+
* jQuery File Upload Plugin JS Example 6.5.1
3+
* https://github.com/blueimp/jQuery-File-Upload
4+
*
5+
* Copyright 2010, Sebastian Tschan
6+
* https://blueimp.net
7+
*
8+
* Licensed under the MIT license:
9+
* http://www.opensource.org/licenses/MIT
10+
*/
11+
12+
/*jslint nomen: true, unparam: true, regexp: true */
13+
/*global $, window, document */
14+
15+
$(function () {
16+
17+
function update(coords)
18+
{
19+
$('#picture_crop_x').val(coords.x)
20+
$('#picture_crop_y').val(coords.y)
21+
$('#picture_crop_w').val(coords.w)
22+
$('#picture_crop_h').val(coords.h)
23+
};
24+
25+
$('#cropbox').Jcrop({
26+
boxWidth: 770,
27+
boxHeight: 433,
28+
onSelect: update,
29+
onChange: update
30+
});
31+
32+
33+
'use strict';
34+
35+
// Initialize the jQuery File Upload widget:
36+
$('#fileupload').fileupload({
37+
autoUpload: true,
38+
uploadTemplate: function (o) {
39+
var rows = $();
40+
$.each(o.files, function (index, file) {
41+
console.log(file);
42+
var row = $('<li class="span3">' +
43+
'<div class="thumbnail">' +
44+
'<div class="preview" style="text-align: center;"></div>' +
45+
'<div class="progress progress-success progress-striped active">' +
46+
'<div class="bar" style="width:0%;"></div>' +
47+
'</div>' +
48+
'</div>');
49+
rows = rows.add(row);
50+
});
51+
return rows;
52+
},
53+
54+
completed: function(e, data) {
55+
console.log(data.result[0].url);
56+
$('a[href^="' + data.result[0].url + '"]').slimbox();
57+
},
58+
downloadTemplate: function (o) {
59+
var rows = $();
60+
$.each(o.files, function (index, file) {
61+
var row = $('<li class="span3" id="picture_' + file.picture_id + '">' +
62+
(file.error ? '<div class="name"></div>' +
63+
'<div class="size"></div><div class="error" ></div>' :
64+
'<div class="thumbnail">' +
65+
'<a href="' + file.url +'" rel="lightbox-pictures" class="picture_' + file.id + '" title="<%= pic.description %>">' +
66+
'<img src="" alt="">') +
67+
'</a>' +
68+
'<div class="caption">' +
69+
'<p style="text-align: center;">' +
70+
'<a href="" class="btn btn-mini btn-show" style="margin-right: 4px;">' +
71+
'<i class="icon-edit "></i>' +
72+
'Edit' +
73+
'</a>' +
74+
'<a class="btn btn-mini btn-delete" confirm="Вы уверены?" data-remote=true data-method="delete" href="" >' +
75+
'<i class="icon-trash"></i>' +
76+
'Delete' +
77+
'</a>' +
78+
'</p>' +
79+
'</div>' +
80+
'</div>');
81+
82+
83+
if (file.error) {
84+
row.find('.name').text(file.name);
85+
row.find('.error').text(
86+
locale.fileupload.errors[file.error] || file.error
87+
);
88+
} else {
89+
if (file.thumbnail_url) {
90+
row.find('img').prop('src', file.thumbnail_url);
91+
}
92+
row.find('.btn-delete')
93+
.attr('href', '/galleries/' + $("#galleryID").val() + '/pictures/' + file.picture_id);
94+
row.find('.btn-show')
95+
.attr('href', '/galleries/' + $("#galleryID").val() + '/pictures/' + file.picture_id + '/edit');
96+
}
97+
rows = rows.add(row);
98+
});
99+
return rows;
100+
}
101+
102+
});
103+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* This is a manifest file that'll be compiled into application.css, which will include all the files
3+
* listed below.
4+
*
5+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7+
*
8+
* You're free to add application-wide styles to this file and they'll appear at the top of the
9+
* compiled file, but it's generally better to create a new file per style scope.
10+
*
11+
*= require_self
12+
*= require_tree .
13+
*/

0 commit comments

Comments
 (0)