the_storages 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +19 -0
- data/Rakefile +1 -0
- data/app/helpers/the_storages_helper.rb +25 -0
- data/app/models/concerns/act_as_storage.rb +36 -0
- data/app/models/uploaded_file.rb +113 -0
- data/app/views/the_storages/_form.haml +18 -0
- data/app/views/the_storages/_lightbox_init.haml +17 -0
- data/app/views/the_storages/_list.haml +41 -0
- data/app/views/the_storages/_new.haml +36 -0
- data/db/migrate/20130101010101_uploaded_files.rb +25 -0
- data/db/migrate/20130101010102_change_storages.rb +15 -0
- data/lib/generators/the_storages/USAGE +33 -0
- data/lib/generators/the_storages/the_storages_generator.rb +40 -0
- data/lib/generators/the_storages/views_generator.rb +43 -0
- data/lib/the_storages.rb +5 -0
- data/lib/the_storages/version.rb +3 -0
- data/the_storages.gemspec +27 -0
- metadata +110 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Ilya N. Zykin
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module TheStoragesHelper
|
2
|
+
def file_type_icon file
|
3
|
+
case
|
4
|
+
when file.is_doc? then
|
5
|
+
image_tag('doctype/100x100/doc.jpg', :alt=>t('file_types.text_document'), :title=>t('file_types.text_document'))
|
6
|
+
when file.is_txt? then
|
7
|
+
image_tag('doctype/100x100/txt.jpg', :alt=>t('file_types.text_file'), :title=>t('file_types.text_file'))
|
8
|
+
when file.is_ppt? then
|
9
|
+
image_tag('doctype/100x100/ppt.jpg', :alt=>t('file_types.presentation'), :title=>t('file_types.presentation'))
|
10
|
+
when file.is_xls? then
|
11
|
+
image_tag('doctype/100x100/xls.jpg', :alt=>t('file_types.e_table'), :title=>t('file_types.e_table'))
|
12
|
+
when file.is_pdf? then
|
13
|
+
image_tag('doctype/100x100/pdf.jpg', :alt=>t('file_types.pdf'), :title=>t('file_types.pdf'))
|
14
|
+
when file.is_psd? then
|
15
|
+
image_tag('doctype/100x100/psd.jpg', :alt=>t('file_types.psd'), :title=>t('file_types.psd'))
|
16
|
+
when file.is_media? then
|
17
|
+
image_tag('doctype/100x100/media.jpg', :alt=>t('file_types.media'), :title=>t('file_types.media'))
|
18
|
+
when file.is_arch? then
|
19
|
+
image_tag('doctype/100x100/zip.jpg', :alt=>t('file_types.archive'), :title=>t('file_types.archive'))
|
20
|
+
else
|
21
|
+
image_tag 'doctype/100x100/default.jpg', :alt=>t('file_types.file'), :title=>t('file_types.file')
|
22
|
+
end
|
23
|
+
end#fn
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module ActAsStorage
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
has_many :uploaded_files, as: :storage
|
6
|
+
|
7
|
+
before_update :recalculate_files_data
|
8
|
+
after_update :recalculate_files_data_for_user
|
9
|
+
after_destroy :recalculate_files_data_for_user
|
10
|
+
end
|
11
|
+
|
12
|
+
def recalculate_files_data
|
13
|
+
sum = 0
|
14
|
+
files = self.uploaded_files.active
|
15
|
+
|
16
|
+
files.each{ |f| sum += f.file_file_size }
|
17
|
+
self.files_size = sum
|
18
|
+
self.files_count = files.size
|
19
|
+
end
|
20
|
+
|
21
|
+
def recalculate_files_data_for_user
|
22
|
+
user = self.user
|
23
|
+
storages = user.storages.active | user.recipes.active | user.pages.active | user.articles.active
|
24
|
+
files_size = 0
|
25
|
+
files_count = 0
|
26
|
+
|
27
|
+
storages.each do |s|
|
28
|
+
files_size += s.files_size
|
29
|
+
files_count += s.files_count
|
30
|
+
end
|
31
|
+
|
32
|
+
user.files_size = files_size
|
33
|
+
user.files_count = files_count
|
34
|
+
user.save(:validation => false)
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
class UploadedFile < ActiveRecord::Base
|
2
|
+
include PublishedObject::InitMethod
|
3
|
+
include PublishedObject::BasicStates
|
4
|
+
|
5
|
+
belongs_to :user
|
6
|
+
belongs_to :storage, :polymorphic => true
|
7
|
+
acts_as_nested_set :scope => [:user_id, :storage_id, :storage_type]
|
8
|
+
|
9
|
+
def to_param
|
10
|
+
self.zip
|
11
|
+
end
|
12
|
+
|
13
|
+
has_attached_file :file,
|
14
|
+
:url => Project::FILE_URL,
|
15
|
+
:default_url=>Project::FILE_DEFAULT,
|
16
|
+
:styles => { :normal => '600x400#', :std => '270x180#', :small => '100x100#', :mini => '50x50#', :micro => '25x25#' },
|
17
|
+
:convert_options => { :all => "-strip" }
|
18
|
+
|
19
|
+
validates :file_file_name, :uniqueness => {:message => I18n.translate('uploaded_files.uniqueness.file_name'), :scope=>[:user_id, :storage_type, :storage_id]}
|
20
|
+
validates_attachment_size :file, :in => 10.bytes..2.megabytes, :message=>I18n.translate('uploaded_files.attachment_size')
|
21
|
+
|
22
|
+
# FILTERS
|
23
|
+
before_validation :generate_file_name
|
24
|
+
before_destroy :update_storage
|
25
|
+
after_create :update_storage
|
26
|
+
after_update :update_storage
|
27
|
+
|
28
|
+
def update_storage
|
29
|
+
self.storage.save
|
30
|
+
end
|
31
|
+
|
32
|
+
def generate_file_name
|
33
|
+
#file_name= self.title
|
34
|
+
#self.title= self.file_title_filter(self.title)
|
35
|
+
extension= File.extname(self.base_file_name).downcase
|
36
|
+
file_name= File.basename(self.base_file_name, extension)
|
37
|
+
file_name= self.file_name_filter(file_name)
|
38
|
+
self.file.instance_write(:file_name, "#{file_name}#{extension}")
|
39
|
+
end
|
40
|
+
|
41
|
+
# functions for FILTERS
|
42
|
+
# Russian.translit(' _ Иван _ Иванов ^@#$&№%*«»!?.,:;{}()<>_+|/~ Test ----').text_symbols2dash.underscore2dash.spaces2dash.strip_dashes.downcase
|
43
|
+
# => "ivan-ivanov-test"
|
44
|
+
def file_name_filter file_name
|
45
|
+
return Russian.translit(file_name).text_symbols2dash.remove_quotes.underscore2dash.spaces2dash.strip_dashes.downcase
|
46
|
+
end
|
47
|
+
|
48
|
+
# '«Олимпиада для школьников» и новый год + снегурочка & Dead Moро$O;ff!!!'.text_symbols2dash.spaces2dash.strip_dashes.dashes2space
|
49
|
+
# => "Олимпиада для школьников и новый год снегурочка Dead Moро O ff"
|
50
|
+
def file_title_filter title
|
51
|
+
return title.text_symbols2dash.remove_quotes.spaces2dash.strip_dashes.dashes2space
|
52
|
+
end
|
53
|
+
|
54
|
+
# HELPERS
|
55
|
+
def full_filepath
|
56
|
+
Project::ADDRESS + self.file.url.split('?').first
|
57
|
+
end
|
58
|
+
|
59
|
+
def to_textile_link
|
60
|
+
"\"#{self.file_file_name}\":#{self.full_filepath}"
|
61
|
+
end
|
62
|
+
|
63
|
+
# FILE INFO METHODS
|
64
|
+
def base_file_name
|
65
|
+
self.file_file_name.to_s
|
66
|
+
end
|
67
|
+
|
68
|
+
def base_file_type
|
69
|
+
self.file.content_type
|
70
|
+
end
|
71
|
+
|
72
|
+
# FILE TYPES METHODS
|
73
|
+
def is_image?
|
74
|
+
['.gif','.jpeg','.jpg','.pjpeg','.png','.bmp'].include?(File.extname(base_file_name))
|
75
|
+
end
|
76
|
+
|
77
|
+
def need_thumb?
|
78
|
+
is_image?
|
79
|
+
end
|
80
|
+
|
81
|
+
def is_doc?
|
82
|
+
['.doc', '.docx'].include?(File.extname(base_file_name))
|
83
|
+
end
|
84
|
+
|
85
|
+
def is_txt?
|
86
|
+
['text/plain'].include?(base_file_type)
|
87
|
+
end
|
88
|
+
|
89
|
+
def is_ppt?
|
90
|
+
['application/vnd.ms-powerpoint', 'application/x-ppt'].include?(base_file_type)
|
91
|
+
end
|
92
|
+
|
93
|
+
def is_xls?
|
94
|
+
['application/vnd.ms-excel'].include?(base_file_type)
|
95
|
+
end
|
96
|
+
|
97
|
+
def is_pdf?
|
98
|
+
['application/pdf'].include?(base_file_type)
|
99
|
+
end
|
100
|
+
|
101
|
+
def is_psd?
|
102
|
+
['.psd'].include?(File.extname(base_file_name))
|
103
|
+
end
|
104
|
+
|
105
|
+
def is_media?
|
106
|
+
['video/x-msvideo','audio/wav','application/x-wmf','video/mpeg','audio/mpeg','audio/mp3'].include?(base_file_type)
|
107
|
+
end
|
108
|
+
|
109
|
+
def is_arch?
|
110
|
+
['.zip','.rar','.gz','.tar'].include?(File.extname(base_file_name))
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
= hidden_field_tag 'storage_type', storage.class
|
2
|
+
= hidden_field_tag 'storage_id', storage.to_param
|
3
|
+
|
4
|
+
%p
|
5
|
+
= f.label :file, t('uploaded_files.form.file')
|
6
|
+
= file_field_tag 'files[]', :class => :multi
|
7
|
+
|
8
|
+
.file_notice
|
9
|
+
%ul
|
10
|
+
%li= t('uploaded_files.file_size_for_uploading_notice')
|
11
|
+
%li= t('uploaded_files.file_foto_for_uploading_notice')
|
12
|
+
|
13
|
+
= form_buttons_for(uploaded_file)
|
14
|
+
|
15
|
+
.submit_button
|
16
|
+
= submit_tag button, :class => :submit
|
17
|
+
|
18
|
+
= moderation_buttons_for(uploaded_file)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
- content_for :gallery_lightbox do
|
2
|
+
-# lightbox gallery 0.5
|
3
|
+
=javascript_include_tag "/javascripts/gallery/gallery.pack.js"
|
4
|
+
:javascript
|
5
|
+
$(function(){
|
6
|
+
$('a.gallery').lightBox({
|
7
|
+
overlayBgColor: '#000',
|
8
|
+
overlayOpacity: 0.6,
|
9
|
+
imageLoading: '/javascripts/gallery/loading.gif',
|
10
|
+
imageBtnClose: '/javascripts/gallery/close.gif',
|
11
|
+
imageBtnPrev: '/javascripts/gallery/prev.gif',
|
12
|
+
imageBtnNext: '/javascripts/gallery/next.gif',
|
13
|
+
containerResizeSpeed: 350,
|
14
|
+
txtImage: 'Изображения: ',
|
15
|
+
txtOf: 'из'
|
16
|
+
});//$('a.gallery')
|
17
|
+
});//$(function())
|
@@ -0,0 +1,41 @@
|
|
1
|
+
- uploaded_files = storage.uploaded_files.reversed_nested_set.active.all.paginate(:page=>params[:page], :per_page=>25)
|
2
|
+
|
3
|
+
- unless uploaded_files.blank?
|
4
|
+
= will_paginate uploaded_files
|
5
|
+
|
6
|
+
%ul.uploaded_files_list
|
7
|
+
- uploaded_files.each do |uploaded_file|
|
8
|
+
%li
|
9
|
+
.form.overblock
|
10
|
+
.upload_file_header
|
11
|
+
.icon
|
12
|
+
- img = uploaded_file.is_image? ? |
|
13
|
+
image_tag(uploaded_file.file.url(:small), :alt=>uploaded_file.file_file_name) : |
|
14
|
+
file_type_icon(uploaded_file) |
|
15
|
+
= link_to img, uploaded_file.full_filepath, :title=>uploaded_file.title, :class=>(uploaded_file.is_image? ? :gallery : nil )
|
16
|
+
.title
|
17
|
+
= link_to uploaded_file.file_file_name, uploaded_file.full_filepath, :title=>uploaded_file.title
|
18
|
+
.file_size
|
19
|
+
= sprintf("%.3f", (uploaded_file.file.size.to_f/1.megabyte.to_f))
|
20
|
+
= t('shared.megabytes')
|
21
|
+
%p
|
22
|
+
%label{:name=>:url}= t('shared.url_address')
|
23
|
+
%input{:value=>uploaded_file.full_filepath, :class=>:input}
|
24
|
+
|
25
|
+
= link_to t('uploaded_files.delete'), uploaded_file_url(uploaded_file, :subdomain=>@user.subdomain), :method=>:delete, :class=>'button delete', :confirm=>t('uploaded_files.delete_confirm')
|
26
|
+
|
27
|
+
- id = object_id(uploaded_file, 'other_codes_link')
|
28
|
+
- fn = "show_other_codes('#{object_id(uploaded_file)}')"
|
29
|
+
= link_to_function t('uploaded_files.other_codes'), fn, :class=>:button, :id=>id
|
30
|
+
|
31
|
+
%div{:id=>object_id(uploaded_file, 'other_codes'), :style=>'display:none;'}
|
32
|
+
%p
|
33
|
+
%label{:name=>:textile_link}= t('uploaded_files.textile_link')
|
34
|
+
%input{:value=>uploaded_file.to_textile_link, :class=>:input}
|
35
|
+
%p
|
36
|
+
%label{:name=>:center_textile_link}= t('uploaded_files.center_code')
|
37
|
+
%input{:value=>'p=. '+uploaded_file.to_textile_link, :class=>:input}
|
38
|
+
- fn = "hide_other_codes('#{object_id(uploaded_file)}')"
|
39
|
+
= link_to_function t('uploaded_files.hide_other_codes'), fn, :class=>:button
|
40
|
+
|
41
|
+
= will_paginate uploaded_files
|
@@ -0,0 +1,36 @@
|
|
1
|
+
- uploaded_file = storage.uploaded_files.new
|
2
|
+
|
3
|
+
:css
|
4
|
+
.file_notice ul{
|
5
|
+
margin-bottom:10px;
|
6
|
+
padding:5px;
|
7
|
+
border:1px dashed red;
|
8
|
+
background-color: PeachPuff;
|
9
|
+
}
|
10
|
+
.file_notice ul li{
|
11
|
+
font-weight:bold;
|
12
|
+
list-style: disc outside none;
|
13
|
+
margin-left: 20px;
|
14
|
+
}
|
15
|
+
#add_file_link a{
|
16
|
+
background-color: PowderBlue;
|
17
|
+
font-size: 16pt;
|
18
|
+
padding:5px 15px;
|
19
|
+
-moz-border-radius:5px;
|
20
|
+
border: 1px solid Blue;
|
21
|
+
}
|
22
|
+
#add_file_link{
|
23
|
+
margin-bottom:15px;
|
24
|
+
}
|
25
|
+
|
26
|
+
-#
|
27
|
+
#add_file_link
|
28
|
+
=link_to_function t('uploaded_files.show_upload_new_file_form'), "$('#upload_file_form').show();$('#add_file_link').hide()"
|
29
|
+
|
30
|
+
- content_for :js do
|
31
|
+
= javascript_include_tag "jqMultiUploads"
|
32
|
+
|
33
|
+
#upload_file_form.form.overblock{:style => "background: #CCFFCC"}
|
34
|
+
= form_for :uploaded_file, :url => uploaded_files_url(:subdomain=>@user.subdomain), :html => { :style => "background: #CCFFCC", :multipart => true, :method=>:post } do |f|
|
35
|
+
= render :partial => 'uploaded_files/form', :locals => {:f => f, :uploaded_file=>uploaded_file, :button=>t('uploaded_files.create'), :storage=>storage}
|
36
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class UploadedFiles < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :uploaded_files do |t|
|
4
|
+
t.integer :user_id
|
5
|
+
t.references :storage, polymorphic: true
|
6
|
+
|
7
|
+
t.string :title, null: false
|
8
|
+
t.string :state, default: :active
|
9
|
+
|
10
|
+
# paperclip
|
11
|
+
t.string :file_file_name
|
12
|
+
t.string :file_content_type
|
13
|
+
t.integer :file_file_size, default: 0
|
14
|
+
t.datetime :file_updated_at
|
15
|
+
|
16
|
+
# nested set
|
17
|
+
t.integer :parent_id
|
18
|
+
t.integer :lft
|
19
|
+
t.integer :rgt
|
20
|
+
t.integer :depth, default: 0
|
21
|
+
|
22
|
+
t.timestamps
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class ChangeStorages < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
change_table :users do |t|
|
4
|
+
t.integer :storages_files_count, default: 0
|
5
|
+
t.integer :storages_files_size, default: 0
|
6
|
+
end
|
7
|
+
|
8
|
+
# [:users, :pages, :posts, :articles, :recipes, :blogs, :notes, :hubs].each do |table_name|
|
9
|
+
# change_table table_name do |t|
|
10
|
+
# t.integer :storage_files_count, default: 0
|
11
|
+
# t.integer :storage_files_size, default: 0
|
12
|
+
# end
|
13
|
+
# end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Description:
|
2
|
+
TheStorages generator will copy files for organize comment's tree in your web project
|
3
|
+
|
4
|
+
This text:
|
5
|
+
bundle exec rails g the_storages --help
|
6
|
+
|
7
|
+
Generators:
|
8
|
+
bundle exec rails g the_storages install
|
9
|
+
|
10
|
+
This will create:
|
11
|
+
config/initializers/the_storages.rb
|
12
|
+
|
13
|
+
app/models/ip_black_list.rb
|
14
|
+
app/models/user_agent_black_list.rb
|
15
|
+
|
16
|
+
app/controllers/comments_controller.rb
|
17
|
+
app/controllers/ip_black_lists_controller.rb
|
18
|
+
app/controllers/user_agent_black_lists_controller.rb
|
19
|
+
|
20
|
+
bundle exec rails g the_storages controllers
|
21
|
+
|
22
|
+
This will create:
|
23
|
+
app/controllers/comments_controller.rb
|
24
|
+
app/controllers/ip_black_lists_controller.rb
|
25
|
+
app/controllers/user_agent_black_lists_controller.rb
|
26
|
+
|
27
|
+
View Generators:
|
28
|
+
bundle exec rails g the_storages:views assets
|
29
|
+
bundle exec rails g the_storages:views helper
|
30
|
+
bundle exec rails g the_storages:views views
|
31
|
+
|
32
|
+
Migrations:
|
33
|
+
bundle exec rake the_storages_engine:install:migrations
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class TheStoragesGenerator < Rails::Generators::NamedBase
|
2
|
+
source_root File.expand_path('../templates', __FILE__)
|
3
|
+
# argument :xname, type: :string, default: :xname
|
4
|
+
|
5
|
+
def generate_controllers
|
6
|
+
if gen_name == 'install'
|
7
|
+
cp_setup
|
8
|
+
cp_models
|
9
|
+
cp_controllers
|
10
|
+
elsif gen_name == 'controllers'
|
11
|
+
cp_controllers
|
12
|
+
elsif gen_name == 'models'
|
13
|
+
cp_models
|
14
|
+
else
|
15
|
+
puts 'TheStorages Generator - wrong Name'
|
16
|
+
puts 'Try to use [install|controllers]'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def gen_name
|
23
|
+
name.to_s.downcase
|
24
|
+
end
|
25
|
+
|
26
|
+
def cp_setup
|
27
|
+
copy_file 'the_comments.rb', 'config/initializers/the_comments.rb'
|
28
|
+
end
|
29
|
+
|
30
|
+
def cp_models
|
31
|
+
copy_file 'ip_black_list.rb', 'app/models/ip_black_list.rb'
|
32
|
+
copy_file 'user_agent_black_list.rb', 'app/models/user_agent_black_list.rb'
|
33
|
+
end
|
34
|
+
|
35
|
+
def cp_controllers
|
36
|
+
copy_file 'comments_controller.rb', 'app/controllers/comments_controller.rb'
|
37
|
+
copy_file 'ip_black_lists_controller.rb', 'app/controllers/ip_black_lists_controller.rb'
|
38
|
+
copy_file 'user_agent_black_lists_controller.rb', 'app/controllers/user_agent_black_lists_controller.rb'
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module TheStorages
|
2
|
+
module Generators
|
3
|
+
class ViewsGenerator < Rails::Generators::NamedBase
|
4
|
+
source_root File.expand_path('../../../../app/views', __FILE__)
|
5
|
+
|
6
|
+
def self.banner
|
7
|
+
<<-BANNER.chomp
|
8
|
+
|
9
|
+
bundle exec rails g the_storages:views assets
|
10
|
+
bundle exec rails g the_storages:views views
|
11
|
+
bundle exec rails g the_storages:views helper
|
12
|
+
|
13
|
+
BANNER
|
14
|
+
end
|
15
|
+
|
16
|
+
def copy_sortable_tree_files
|
17
|
+
copy_gem_files
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def param_name
|
23
|
+
name.downcase
|
24
|
+
end
|
25
|
+
|
26
|
+
def copy_gem_files
|
27
|
+
# if param_name == 'assets'
|
28
|
+
# copy_file "../assets/javascripts/the_storages", "app/assets/javascripts/the_storages"
|
29
|
+
# copy_file "../assets/stylesheets/the_storages", "app/assets/stylesheets/the_storages"
|
30
|
+
# elsif param_name == 'views'
|
31
|
+
# directory "../views/the_storages", "app/views/the_storages"
|
32
|
+
# directory "../views/ip_black_lists", "app/views/ip_black_lists"
|
33
|
+
# directory "../views/user_agent_black_lists", "app/views/user_agent_black_lists"
|
34
|
+
# elsif param_name == 'helper'
|
35
|
+
# copy_file "../helpers/render_comments_tree_helper.rb", "app/helpers/render_comments_tree_helper.rb"
|
36
|
+
# else
|
37
|
+
# puts "Wrong params - use only [assets | views | helper] values"
|
38
|
+
# end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/the_storages.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'the_storages/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "the_storages"
|
8
|
+
spec.version = TheStorages::VERSION
|
9
|
+
spec.authors = ["Ilya N. Zykin"]
|
10
|
+
spec.email = ["zykin-ilya@ya.ru"]
|
11
|
+
spec.description = %q{TheStorages - act as file storage }
|
12
|
+
spec.summary = %q{easy file attaching to any AR Model}
|
13
|
+
spec.homepage = "https://github.com/the-teacher"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# spec.add_dependency 'paperclip'
|
22
|
+
spec.add_dependency 'state_machine'
|
23
|
+
spec.add_dependency 'the_sortable_tree'
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: the_storages
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ilya N. Zykin
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: state_machine
|
16
|
+
requirement: &76205340 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *76205340
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: the_sortable_tree
|
27
|
+
requirement: &76205130 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *76205130
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: bundler
|
38
|
+
requirement: &76204870 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1.3'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *76204870
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: &76204660 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *76204660
|
58
|
+
description: ! 'TheStorages - act as file storage '
|
59
|
+
email:
|
60
|
+
- zykin-ilya@ya.ru
|
61
|
+
executables: []
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- .gitignore
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- app/helpers/the_storages_helper.rb
|
71
|
+
- app/models/concerns/act_as_storage.rb
|
72
|
+
- app/models/uploaded_file.rb
|
73
|
+
- app/views/the_storages/_form.haml
|
74
|
+
- app/views/the_storages/_lightbox_init.haml
|
75
|
+
- app/views/the_storages/_list.haml
|
76
|
+
- app/views/the_storages/_new.haml
|
77
|
+
- db/migrate/20130101010101_uploaded_files.rb
|
78
|
+
- db/migrate/20130101010102_change_storages.rb
|
79
|
+
- lib/generators/the_storages/USAGE
|
80
|
+
- lib/generators/the_storages/the_storages_generator.rb
|
81
|
+
- lib/generators/the_storages/views_generator.rb
|
82
|
+
- lib/the_storages.rb
|
83
|
+
- lib/the_storages/version.rb
|
84
|
+
- the_storages.gemspec
|
85
|
+
homepage: https://github.com/the-teacher
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 1.8.15
|
107
|
+
signing_key:
|
108
|
+
specification_version: 3
|
109
|
+
summary: easy file attaching to any AR Model
|
110
|
+
test_files: []
|