ruby_gallery 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", "~> 1.3.4"
12
+ gem "jeweler", "~> 1.8.4"
13
+ gem "paperclip", "~> 3.0"
14
+ #gem "rcov", ">= 0"
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,62 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activemodel (3.2.13)
5
+ activesupport (= 3.2.13)
6
+ builder (~> 3.0.0)
7
+ activerecord (3.2.13)
8
+ activemodel (= 3.2.13)
9
+ activesupport (= 3.2.13)
10
+ arel (~> 3.0.2)
11
+ tzinfo (~> 0.3.29)
12
+ activesupport (3.2.13)
13
+ i18n (= 0.6.1)
14
+ multi_json (~> 1.0)
15
+ arel (3.0.2)
16
+ bourne (1.4.0)
17
+ mocha (~> 0.13.2)
18
+ builder (3.0.4)
19
+ climate_control (0.0.3)
20
+ activesupport (>= 3.0)
21
+ cocaine (0.5.1)
22
+ climate_control (>= 0.0.3, < 1.0)
23
+ git (1.2.5)
24
+ i18n (0.6.1)
25
+ jeweler (1.8.4)
26
+ bundler (~> 1.0)
27
+ git (>= 1.2.5)
28
+ rake
29
+ rdoc
30
+ json (1.7.7)
31
+ metaclass (0.0.1)
32
+ mime-types (1.21)
33
+ mocha (0.13.3)
34
+ metaclass (~> 0.0.1)
35
+ multi_json (1.7.1)
36
+ paperclip (3.4.1)
37
+ activemodel (>= 3.0.0)
38
+ activerecord (>= 3.0.0)
39
+ activesupport (>= 3.0.0)
40
+ cocaine (~> 0.5.0)
41
+ mime-types
42
+ rake (10.0.3)
43
+ rdoc (3.12.2)
44
+ json (~> 1.4)
45
+ shoulda (3.4.0)
46
+ shoulda-context (~> 1.0, >= 1.0.1)
47
+ shoulda-matchers (~> 1.0, >= 1.4.1)
48
+ shoulda-context (1.0.2)
49
+ shoulda-matchers (1.5.2)
50
+ activesupport (>= 3.0.0)
51
+ bourne (~> 1.3)
52
+ tzinfo (0.3.37)
53
+
54
+ PLATFORMS
55
+ ruby
56
+
57
+ DEPENDENCIES
58
+ bundler (~> 1.3.4)
59
+ jeweler (~> 1.8.4)
60
+ paperclip (~> 3.0)
61
+ rdoc (~> 3.12)
62
+ shoulda
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Peter Dang
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1 @@
1
+ Beginning .....................
data/Rakefile ADDED
@@ -0,0 +1,45 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "ruby_gallery"
18
+ gem.homepage = "http://github.com/dangluan/ruby_gallery"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Help to create gallery}
21
+ gem.description = %Q{Upload image use gallery}
22
+ gem.email = "peter@rubify.com"
23
+ gem.authors = ["Peter Dang"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ task :default => :test
36
+
37
+ require 'rdoc/task'
38
+ Rake::RDocTask.new do |rdoc|
39
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
+
41
+ rdoc.rdoc_dir = 'rdoc'
42
+ rdoc.title = "ruby_gallery #{version}"
43
+ rdoc.rdoc_files.include('README*')
44
+ rdoc.rdoc_files.include('lib/**/*.rb')
45
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
@@ -0,0 +1,49 @@
1
+
2
+ clearInterval(window.refeshWork);
3
+ window.refeshWork = null;
4
+
5
+ $('#fileupload').fileupload({
6
+ dropZone: $('#fileupload'),
7
+ progressInterval: 20,
8
+ add: function(e,data){
9
+ if ($('span#upload_button').attr('status') == 'process'){
10
+ return false;
11
+ } else {
12
+ var types = /(\.|\/)(png|jpg|gif|jpeg)$/i;
13
+ var file = data.files[0];
14
+ if (types.test(file.type) || types.test(file.name) ){
15
+ $('span.upload-button span').html("<%= t('details.processing') %>");
16
+ $("span#no-file").remove();
17
+ $('#file_box ul#photos_album').append("<li class='photo-cat new-photo' ><div id='progress' class='pic-icon' ></div></li>");
18
+ data.submit();
19
+ } else {
20
+ alert("<%= t('details.please_upload_image_file')%>");
21
+ }
22
+ }
23
+ },
24
+ progressall: function(e, data){
25
+ // var progress = parseInt(data.loaded / data.total * 100, 10);
26
+ // $('#file_box ul#photos_album li.new-photo').find('#progress div.bar').css('width',progress + '%' );
27
+ },
28
+ done: function(e, data){
29
+ var report = '';
30
+ if(data.result != 'failed'){
31
+ var res = data.result;
32
+ $('span#upload_button span').html("<%= t('details.upload_picture') %>");
33
+ $('#file_box ul#photos_album li.new-photo').fadeOut('slow', function() {
34
+
35
+ $('#file_box ul#photos_album li.new-photo').remove();
36
+ $('#file_box ul#photos_album').append(res);
37
+
38
+ });
39
+
40
+ // var t=setTimeout(function(){
41
+ // }, 2000);
42
+ } else {
43
+ $('#file_box ul#photos_album li.new-photo').html("<%= t('details.upload_failed') %>");
44
+ var t = setTimeout(function(){
45
+ $('#file_box ul#photos_album li.new-photo').remove();
46
+ }, 2000);
47
+ }
48
+ }
49
+ });
File without changes
@@ -0,0 +1,3 @@
1
+ class AttachmentsController < ApplicationController
2
+
3
+ end
@@ -0,0 +1,13 @@
1
+ module RubyGallery::RubyGalleryHelper
2
+ def show_gallery_images(model_name, opts={})
3
+ object = model_name.to_s.singularize.classify.constantize.find(params[:id])
4
+ content_tag(:div, class: "upload-box") do
5
+ content_tag(:div, class: "legend", "#{t('details.upload_album')}"),
6
+ content_tag(:div, class: "form-box") do
7
+ content_tag(:form, id: "fileupload", class: "fileupload", method: "POST", enctype: "multipart/form-data") do
8
+
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ class AlbumAttachment < ActiveRecord::Base
2
+ has_many :album_photos, dependent: :destroy
3
+ end
@@ -0,0 +1,6 @@
1
+ class AlbumPhoto < ActiveRecord::Base
2
+ attr_accessible :photo
3
+
4
+ belongs_to :album_attachment
5
+ has_attached_file :photo, :styles => { :medium => "300x300>", :thumb => "100x100>" }
6
+ end
@@ -0,0 +1,16 @@
1
+ require 'rails/generators/active_record'
2
+
3
+ module ActiveRecord
4
+ module Generators
5
+ class RubyGalleryGenerator < ActiveRecord::Generators::Base
6
+ argument :attributes, :type => :array, :default => [], :banner => "filed:type field:type"
7
+
8
+ source_root File.expand_path("../templates", __FILE__)
9
+
10
+ def copy_ruby_gallery_migration
11
+ migration_template "album_photo_migration.rb", "db/migrate/create_ablum_photo_table"
12
+ migration_template "migration.rb", "db/migrate/ruby_gallery_add_columns_to_#{table_name}"
13
+ migration_template "album_attachment_migration.rb", "db/migrate/create_album_attachment_table"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ class CreateAlbumAttachment < ActiveRecord::Migration
2
+ def up
3
+ create_table :album_attachments do |a|
4
+ a.string :parent_type
5
+ a.integer :parent_id
6
+ a.timestamps
7
+ end
8
+ end
9
+
10
+ def down
11
+ drop_table :album_attachments
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ class CreateAlbumPhoto < ActiveRecord::Migration
2
+ def up
3
+ create_table :album_photos do |a|
4
+ a.integer :album_attachment_id
5
+ a.timestamps
6
+ end
7
+ end
8
+
9
+ def down
10
+ drop_table :album_photos
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ class RubyGalleryAddColumnTo<%= table_name.camelize %> < ActiveRecord::Migration
2
+ def self.up
3
+ add_attachment :<%= table_name %>, :photo
4
+ end
5
+
6
+ def self.down
7
+ remove_attachment :<%= table_name %>, :photo
8
+ end
9
+ end
@@ -0,0 +1,21 @@
1
+ require 'securerandom'
2
+ require 'rails/generators'
3
+ require 'rails/generators/migration'
4
+
5
+ module RubyGallery
6
+ module Generators
7
+ class InstallGenerator < Rails::Generators::Base
8
+ include Rails::Generators::Migration
9
+
10
+ source_root File.expand_path("../../templates", __FILE__)
11
+
12
+ desc "Creates a Congig file and copy locate files to your application."
13
+
14
+ class_option :orm
15
+
16
+ def copy_jsfile
17
+ copy_file "../../../app/assets/javascripts/ruby_gallery.js", "app/assets/javascripts/ruby_gallery.js"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,15 @@
1
+ module RubyGallery
2
+ module Generators
3
+ class RubyGalleryGenerator < Rails::Generators::NamedBase
4
+ include Rails::Generators::ResourceHelpers
5
+
6
+ namespace "ruby_gallery"
7
+
8
+ source_root File.expand_path("../templates", __FILE__)
9
+
10
+ desc "Generates RubyGallery attributes for a model given its NAME."
11
+
12
+ hook_for :orm
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,4 @@
1
+ module RubyGallery
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,74 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "ruby_gallery"
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Peter Dang"]
12
+ s.date = "2013-03-21"
13
+ s.description = "Upload image use gallery"
14
+ s.email = "peter@rubify.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.markdown"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.markdown",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "app/assets/javascripts/ruby_gallery.js",
28
+ "app/assets/stylesheets/ruby_gallery.css",
29
+ "app/controllers/attachments_controller.rb",
30
+ "app/helpers/ruby_gallery/ruby_gallery_helper.rb",
31
+ "app/models/album_attachment.rb",
32
+ "app/models/album_photo.rb",
33
+ "lib/generators/active_record/ruby_gallery_generator.rb",
34
+ "lib/generators/active_record/templates/album_attachment_migration.rb",
35
+ "lib/generators/active_record/templates/album_photo_migration.rb",
36
+ "lib/generators/active_record/templates/migration.rb",
37
+ "lib/generators/ruby_gallery/install_generator.rb",
38
+ "lib/generators/ruby_gallery/ruby_gallery_generator.rb",
39
+ "lib/ruby_gallery.rb",
40
+ "ruby_gallery.gemspec",
41
+ "test/helper.rb",
42
+ "test/test_ruby_gallery.rb"
43
+ ]
44
+ s.homepage = "http://github.com/dangluan/ruby_gallery"
45
+ s.licenses = ["MIT"]
46
+ s.require_paths = ["lib"]
47
+ s.rubygems_version = "1.8.24"
48
+ s.summary = "Help to create gallery"
49
+
50
+ if s.respond_to? :specification_version then
51
+ s.specification_version = 3
52
+
53
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
54
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
55
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
56
+ s.add_development_dependency(%q<bundler>, ["~> 1.3.4"])
57
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
58
+ s.add_development_dependency(%q<paperclip>, ["~> 3.0"])
59
+ else
60
+ s.add_dependency(%q<shoulda>, [">= 0"])
61
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
62
+ s.add_dependency(%q<bundler>, ["~> 1.3.4"])
63
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
64
+ s.add_dependency(%q<paperclip>, ["~> 3.0"])
65
+ end
66
+ else
67
+ s.add_dependency(%q<shoulda>, [">= 0"])
68
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
69
+ s.add_dependency(%q<bundler>, ["~> 1.3.4"])
70
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
71
+ s.add_dependency(%q<paperclip>, ["~> 3.0"])
72
+ end
73
+ end
74
+
data/test/helper.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'ruby_gallery'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestRubyGallery < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,153 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_gallery
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Peter Dang
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: shoulda
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rdoc
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '3.12'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.12'
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.3.4
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.4
62
+ - !ruby/object:Gem::Dependency
63
+ name: jeweler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.8.4
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.8.4
78
+ - !ruby/object:Gem::Dependency
79
+ name: paperclip
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '3.0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '3.0'
94
+ description: Upload image use gallery
95
+ email: peter@rubify.com
96
+ executables: []
97
+ extensions: []
98
+ extra_rdoc_files:
99
+ - LICENSE.txt
100
+ - README.markdown
101
+ files:
102
+ - .document
103
+ - Gemfile
104
+ - Gemfile.lock
105
+ - LICENSE.txt
106
+ - README.markdown
107
+ - Rakefile
108
+ - VERSION
109
+ - app/assets/javascripts/ruby_gallery.js
110
+ - app/assets/stylesheets/ruby_gallery.css
111
+ - app/controllers/attachments_controller.rb
112
+ - app/helpers/ruby_gallery/ruby_gallery_helper.rb
113
+ - app/models/album_attachment.rb
114
+ - app/models/album_photo.rb
115
+ - lib/generators/active_record/ruby_gallery_generator.rb
116
+ - lib/generators/active_record/templates/album_attachment_migration.rb
117
+ - lib/generators/active_record/templates/album_photo_migration.rb
118
+ - lib/generators/active_record/templates/migration.rb
119
+ - lib/generators/ruby_gallery/install_generator.rb
120
+ - lib/generators/ruby_gallery/ruby_gallery_generator.rb
121
+ - lib/ruby_gallery.rb
122
+ - ruby_gallery.gemspec
123
+ - test/helper.rb
124
+ - test/test_ruby_gallery.rb
125
+ homepage: http://github.com/dangluan/ruby_gallery
126
+ licenses:
127
+ - MIT
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ! '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ segments:
139
+ - 0
140
+ hash: -3522156934352762017
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ! '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubyforge_project:
149
+ rubygems_version: 1.8.24
150
+ signing_key:
151
+ specification_version: 3
152
+ summary: Help to create gallery
153
+ test_files: []