lolita-file-upload 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bad60752c9c5a77fb9c8c76754eb40ceb9931f3a
4
+ data.tar.gz: b10230f5aa0f7d896bb436e02324dd6ecfe7ca37
5
+ SHA512:
6
+ metadata.gz: b63032f1b0340729378973cd2c41b1939437c8a50a6823655bbce7daee3efb23658206cc8f8f4300ee513ac85ee75d93fb1356360cc394b6c751c7f083e80ee4
7
+ data.tar.gz: e813324dab6176db4b9e847095a016c4b1fb808ad5e35462e4f950b8a19995034a7007282f639df4c829e88e52c75b79fb99559402def279929d8df2e3fa0490
data/.gitignore ADDED
@@ -0,0 +1,49 @@
1
+ uploads
2
+ .project
3
+ .settings
4
+ .rvmrc
5
+ coverage.data
6
+ test_orm/log
7
+ # rcov generated
8
+ coverage
9
+ /upload/
10
+
11
+ # rdoc generated
12
+ rdoc
13
+
14
+ # yard generated
15
+ doc
16
+ .yardoc
17
+
18
+ # bundler
19
+ .bundle
20
+
21
+ # jeweler generated
22
+ pkg
23
+
24
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
25
+ #
26
+ # * Create a file at ~/.gitignore
27
+ # * Include files you want ignored
28
+ # * Run: git config --global core.excludesfile ~/.gitignore
29
+ #
30
+ # After doing this, these files will be ignored in all your git projects,
31
+ # saving you from having to 'pollute' every project you touch with them
32
+ #
33
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
34
+ #
35
+ # For MacOS:
36
+ #
37
+ #.DS_Store
38
+ #
39
+ # For TextMate
40
+ #*.tmproj
41
+ #tmtags
42
+ #
43
+ # For emacs:
44
+ #*~
45
+ #\#*
46
+ #.\#*
47
+ #
48
+ # For vim:
49
+ *.swp
data/Gemfile CHANGED
@@ -1,23 +1,13 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
 
3
- gem "lolita", "~>3.2.0.rc.6"
4
- gem "carrierwave", "~> 0.6.0"
5
- gem "mini_magick"
6
- gem 'jquery-rails', '>= 1.0.12'
7
- group :test do
8
- gem "rspec-rails", "~> 2.6"
9
- gem "ffaker"
10
- gem "factory_girl"
11
- gem "sqlite3"
12
- gem "rspec", "~> 2.6"
13
- gem 'cover_me', '>= 1.0.0.rc6'
14
- gem 'rails', "~> 3.2.0"
15
- end
16
-
17
- group :development do
18
- gem "cucumber", "~> 1.0"
19
- gem "cucumber-rails", "~> 1.0"
20
- gem "bundler", "~> 1.0"
21
- gem "jeweler", "~> 1.6"
22
- end
3
+ gemspec
23
4
 
5
+ group :test do
6
+ gem 'rspec-rails', '~> 2.14'
7
+ gem 'ffaker', '~> 1.16.2'
8
+ gem 'factory_girl', '~> 3.6.2'
9
+ gem 'sqlite3', '~> 1.3.7'
10
+ gem 'rspec', '~> 2.14'
11
+ gem 'rails', '~> 3.2.12'
12
+ gem 'byebug'
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,151 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lolita-file-upload (0.8.0)
5
+ carrierwave (~> 0.6.0)
6
+ lolita (~> 3.2)
7
+ mini_magick (~> 3.6.0)
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ abstract (1.0.0)
13
+ actionmailer (3.2.13)
14
+ actionpack (= 3.2.13)
15
+ mail (~> 2.5.3)
16
+ actionpack (3.2.13)
17
+ activemodel (= 3.2.13)
18
+ activesupport (= 3.2.13)
19
+ builder (~> 3.0.0)
20
+ erubis (~> 2.7.0)
21
+ journey (~> 1.0.4)
22
+ rack (~> 1.4.5)
23
+ rack-cache (~> 1.2)
24
+ rack-test (~> 0.6.1)
25
+ sprockets (~> 2.2.1)
26
+ activemodel (3.2.13)
27
+ activesupport (= 3.2.13)
28
+ builder (~> 3.0.0)
29
+ activerecord (3.2.13)
30
+ activemodel (= 3.2.13)
31
+ activesupport (= 3.2.13)
32
+ arel (~> 3.0.2)
33
+ tzinfo (~> 0.3.29)
34
+ activeresource (3.2.13)
35
+ activemodel (= 3.2.13)
36
+ activesupport (= 3.2.13)
37
+ activesupport (3.2.13)
38
+ i18n (= 0.6.1)
39
+ multi_json (~> 1.0)
40
+ arel (3.0.2)
41
+ builder (3.0.4)
42
+ byebug (1.5.0)
43
+ columnize (~> 0.3.6)
44
+ debugger-linecache (~> 1.2.0)
45
+ carrierwave (0.6.2)
46
+ activemodel (>= 3.2.0)
47
+ activesupport (>= 3.2.0)
48
+ columnize (0.3.6)
49
+ debugger-linecache (1.2.0)
50
+ diff-lcs (1.2.4)
51
+ erubis (2.7.0)
52
+ factory_girl (3.6.2)
53
+ activesupport (>= 3.0.0)
54
+ ffaker (1.16.2)
55
+ haml (3.1.8)
56
+ hike (1.2.3)
57
+ i18n (0.6.1)
58
+ journey (1.0.4)
59
+ jquery-rails (2.2.2)
60
+ railties (>= 3.0, < 5.0)
61
+ thor (>= 0.14, < 2.0)
62
+ json (1.8.0)
63
+ kaminari (0.14.1)
64
+ actionpack (>= 3.0.0)
65
+ activesupport (>= 3.0.0)
66
+ lolita (3.3.0)
67
+ abstract (~> 1)
68
+ activesupport (~> 3.2.0)
69
+ haml (~> 3.0)
70
+ jquery-rails (~> 2.2.1)
71
+ kaminari (~> 0.13)
72
+ tinymce-rails (~> 3.5.8)
73
+ tinymce-rails-config-manager
74
+ mail (2.5.4)
75
+ mime-types (~> 1.16)
76
+ treetop (~> 1.4.8)
77
+ mime-types (1.23)
78
+ mini_magick (3.6.0)
79
+ subexec (~> 0.2.1)
80
+ multi_json (1.7.7)
81
+ polyglot (0.3.3)
82
+ rack (1.4.5)
83
+ rack-cache (1.2)
84
+ rack (>= 0.4)
85
+ rack-ssl (1.3.3)
86
+ rack
87
+ rack-test (0.6.2)
88
+ rack (>= 1.0)
89
+ rails (3.2.13)
90
+ actionmailer (= 3.2.13)
91
+ actionpack (= 3.2.13)
92
+ activerecord (= 3.2.13)
93
+ activeresource (= 3.2.13)
94
+ activesupport (= 3.2.13)
95
+ bundler (~> 1.0)
96
+ railties (= 3.2.13)
97
+ railties (3.2.13)
98
+ actionpack (= 3.2.13)
99
+ activesupport (= 3.2.13)
100
+ rack-ssl (~> 1.3.2)
101
+ rake (>= 0.8.7)
102
+ rdoc (~> 3.4)
103
+ thor (>= 0.14.6, < 2.0)
104
+ rake (10.1.0)
105
+ rdoc (3.12.2)
106
+ json (~> 1.4)
107
+ rspec (2.14.0)
108
+ rspec-core (~> 2.14.0)
109
+ rspec-expectations (~> 2.14.0)
110
+ rspec-mocks (~> 2.14.0)
111
+ rspec-core (2.14.1)
112
+ rspec-expectations (2.14.0)
113
+ diff-lcs (>= 1.1.3, < 2.0)
114
+ rspec-mocks (2.14.1)
115
+ rspec-rails (2.14.0)
116
+ actionpack (>= 3.0)
117
+ activesupport (>= 3.0)
118
+ railties (>= 3.0)
119
+ rspec-core (~> 2.14.0)
120
+ rspec-expectations (~> 2.14.0)
121
+ rspec-mocks (~> 2.14.0)
122
+ sprockets (2.2.2)
123
+ hike (~> 1.2)
124
+ multi_json (~> 1.0)
125
+ rack (~> 1.0)
126
+ tilt (~> 1.1, != 1.3.0)
127
+ sqlite3 (1.3.7)
128
+ subexec (0.2.3)
129
+ thor (0.18.1)
130
+ tilt (1.4.1)
131
+ tinymce-rails (3.5.8.3)
132
+ railties (>= 3.1.1)
133
+ tinymce-rails-config-manager (0.0.7)
134
+ railties (~> 3.2.8)
135
+ treetop (1.4.14)
136
+ polyglot
137
+ polyglot (>= 0.3.1)
138
+ tzinfo (0.3.37)
139
+
140
+ PLATFORMS
141
+ ruby
142
+
143
+ DEPENDENCIES
144
+ byebug
145
+ factory_girl (~> 3.6.2)
146
+ ffaker (~> 1.16.2)
147
+ lolita-file-upload!
148
+ rails (~> 3.2.12)
149
+ rspec (~> 2.14)
150
+ rspec-rails (~> 2.14)
151
+ sqlite3 (~> 1.3.7)
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Lolita file upload
2
+
3
+ File upload gem for Lolita.
4
+
5
+ ## Instalation
6
+
7
+ * gem install lolita-file-upload
8
+ * include in gemfile like this: `gem "lolita-file-upload"`
9
+ * cd your_project_path
10
+ * rails g lolita_file_upload:install
11
+
12
+ Install will copy migration to your project.
13
+ If you update to newest version of gem, than run `rails g lolita_file_upload:assets`
14
+
15
+ ##Configuration
16
+
17
+ Gem will not used until any of lolita configuration blocks define tab with type :files. Like this
18
+ ```ruby
19
+ class Post
20
+ include Lolita::Configuration
21
+ has_many :files, :as=>:fileable, :class_name=>"Lolita::Upload::File"
22
+
23
+ lolita do
24
+ tab(:content)
25
+ tab(:files)
26
+ end
27
+ end
28
+ ```
data/Rakefile CHANGED
@@ -1,39 +1,7 @@
1
1
  require 'rubygems'
2
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 'rake'
3
+ require 'rspec/core/rake_task'
11
4
 
12
- require 'jeweler'
13
- Jeweler::Tasks.new do |gem|
14
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
- gem.name = "lolita-file-upload"
16
- gem.homepage = "http://github.com/ithouse/lolita-file-upload"
17
- gem.license = "MIT"
18
- gem.summary = %Q{File upload gem for Lolita CMS}
19
- gem.description = %Q{File upload gem for Lolita with with fulll integration - models, controller, views}
20
- gem.email = "support@ithouse.lv"
21
- gem.authors = ["ITHouse","Arturs Meisters"]
22
- # Include your dependencies below. Runtime dependencies are required when using your gem,
23
- # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
- # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
- # gem.add_development_dependency 'rspec', '> 1.2.3'
26
- end
27
- Jeweler::RubygemsDotOrgTasks.new
28
-
29
- task :default => :test
30
-
31
- require 'rake/rdoctask'
32
- Rake::RDocTask.new do |rdoc|
33
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
34
-
35
- rdoc.rdoc_dir = 'rdoc'
36
- rdoc.title = "lolita-file-upload #{version}"
37
- rdoc.rdoc_files.include('README*')
38
- rdoc.rdoc_files.include('lib/**/*.rb')
39
- end
5
+ Bundler::GemHelper.install_tasks
6
+ RSpec::Core::RakeTask.new(:spec)
7
+ task :default => :spec
@@ -53,9 +53,15 @@ class LolitaFileUploadGallery
53
53
  margin: 5
54
54
  })
55
55
 
56
+ _image_and_icon: ->
57
+ $(IMAGE_SELECTOR + ',' + FILE_ICON_SELECTOR)
58
+
56
59
  _makeImagesDraggable: ->
57
- $(IMAGE_SELECTOR + ',' + FILE_ICON_SELECTOR).draggable("destroy")
58
- $(IMAGE_SELECTOR + ',' + FILE_ICON_SELECTOR).draggable({
60
+ @_image_and_icon().each(->
61
+ if $(this).is('.ui-draggable')
62
+ $(this).draggable("destroy")
63
+ )
64
+ @_image_and_icon().draggable({
59
65
  appendTo: "body"
60
66
  zIndex: 20000
61
67
  helper: "clone"
@@ -1,5 +1,15 @@
1
1
  #main #content .box .lolita-file-upload-form {padding: 20px 0 0 0;}
2
-
2
+ #main .box form .field_file { margin-top: 17px;}
3
+ #main .box form .field_file .field-value {}
4
+ #main .box form .field_file .field-value img { float: left; padding-right: 10px; }
5
+ #main .box form .field_file .field-value .actions { float: left; }
6
+ #main .box form .field_file .field-value .actions input {
7
+ border: 0;
8
+ padding: 0 0 3px;
9
+ width: auto;
10
+ }
11
+ #main .box form .field_file .field-value .actions .remove_checkbox { padding: 3px 0; }
12
+ #main .box form .field_file .field-value .actions .remove_checkbox label{ color: rgb(73, 73, 73); }
3
13
  .filelist {padding: 6% 1% 6% 6%; overflow: hidden;}
4
14
  .filelist .filelist-container {overflow: hidden;}
5
15
  .filelist .file-item {
@@ -1,42 +1,19 @@
1
1
  module Lolita
2
2
  module Upload
3
3
  class File < ActiveRecord::Base
4
- self.table_name = 'lolita_files'
4
+ self.table_name = 'lolita_files'
5
5
  attr_accessible :asset, :name, :fileable_type, :asset_extension
6
6
  mount_uploader :asset, FileUploader
7
- belongs_to :fileable, :polymorphic=>true
8
-
9
- #validate :size_limit FIXME to work with more than one tab
7
+ belongs_to :fileable, polymorphic: true
10
8
  before_save :set_metadata
11
- #before_create :singularize_files
12
-
13
9
 
14
10
  private
15
11
 
16
- def singularize_files
17
-
18
- if self.fileable && lolita = self.fileable.class.lolita
19
- if lolita.tabs.by_type(:files).association_type == :one
20
- self.class.destroy_all(["fileable_type = :type AND fileable_id = :id AND fileable_id > 0",:type => fileable_type,:id => fileable_id])
21
- end
22
- end
23
- end
24
-
25
- def size_limit
26
- if self.fileable && lolita=self.fileable.class.lolita
27
- maxsize=lolita.tabs.by_type(:files).maxfilesize
28
- if maxsize.to_i>0 && self.asset.file.size>maxsize
29
- bytes=Lolita::Support::Bytes.new(maxsize)
30
- self.errors.add(:asset,I18n.t("lolita.upload.errors.file too big",:value=>bytes.value,:unit=>bytes.unit))
31
- end
32
- end
33
- end
34
-
35
12
  def set_metadata
36
13
  unless self.asset.blank?
37
- self.name||=::File.basename(self.asset.store_path)
38
- self.asset_size=self.asset.file.size
39
- self.asset_extension=::File.extname(self.asset.store_path).gsub(".","")
14
+ self.name ||= ::File.basename(self.asset.store_path)
15
+ self.asset_size = self.asset.file.size
16
+ self.asset_extension = ::File.extname(self.asset.store_path).gsub(".", "")
40
17
  end
41
18
  end
42
19
 
@@ -1,3 +1,9 @@
1
- = image_tag(field.preview_image(current_form.object)) if field.has_image?(current_form.object)
2
- = current_form.file_field field.name
3
- = current_form.hidden_field field.cache_name
1
+ = image_tag(field.preview_image(current_form.object)) if field.has_image?(current_form.object)
2
+ = content_tag(:span, { class: 'actions'}) do
3
+ = current_form.file_field field.name
4
+ = current_form.hidden_field field.cache_name
5
+ - if current_form.object.send(field.name).present?
6
+ = content_tag(:div, class: 'remove_checkbox') do
7
+ = current_form.check_box "remove_#{field.name}"
8
+ = current_form.label "remove_#{field.name}", I18n.t("components.lolita.configuration.field.file.remove_current_upload")
9
+ = tag(:div, class: 'clear')
@@ -6,6 +6,9 @@ en:
6
6
  files:
7
7
  fixed_gallery:
8
8
  close: Close
9
+ field:
10
+ file:
11
+ remove_current_upload: "Remove current file?"
9
12
  lolita:
10
13
  uploads_controller:
11
14
  update:
@@ -6,6 +6,9 @@ lv:
6
6
  files:
7
7
  fixed_gallery:
8
8
  close: Aizvērt
9
+ field:
10
+ file:
11
+ remove_current_upload: "Nodzēst failu?"
9
12
  lolita:
10
13
  uploads_controller:
11
14
  update:
@@ -12,13 +12,13 @@ module Lolita
12
12
  # As any other Lolita::Configuration::Tab this should receive _dbi_ object.
13
13
  # Additional _args_ that may represent methods, for details see Lolita::Configuration::Tab.
14
14
  # And block.
15
- def initialize(dbi,*args,&block)
15
+ def initialize(dbi, *args, &block)
16
16
  @type=:files
17
17
  @dissociate = true
18
18
  @filters=[]
19
19
  @dbi=dbi
20
20
  set_default_association
21
- super
21
+ super(dbi, @type, *args, &block)
22
22
  end
23
23
 
24
24
  # NOTE: Filters only limit frontend, backend limit is set in Uploader