lolita-file-upload 0.8.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/app/assets/javascripts/lolita/file-upload/gallery.js.coffee +30 -35
- data/app/assets/javascripts/tinymce/plugins/lolita_gallery/plugin.js.coffee.erb +14 -0
- data/app/controllers/lolita/uploads_controller.rb +9 -1
- data/app/models/lolita/upload/file.rb +0 -1
- data/app/views/components/lolita/configuration/tab/files/_image.html.erb +2 -1
- data/app/views/components/lolita/configuration/tab/files/_row.html.erb +4 -2
- data/config/locales/en.yml +2 -0
- data/config/locales/lv.yml +5 -0
- data/config/locales/sv_SE.yml +49 -0
- data/lib/lolita-file-upload/rails/file_upload_routes.rb +1 -1
- data/lolita-file-upload.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2276e438635874a5b59609dca7cd7757a185f3b7
|
4
|
+
data.tar.gz: 9edaf5e5936f9273c0b2724084a046826dc917e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ee8f4e1050231abeffcd3c3a4bab5c0af454eaa8496c3195481f5ed3003d5f4610ce3f128fdf68e8f1416fcdcf9b8369bb31407fbd97040d3e5bf18d2df3e9a
|
7
|
+
data.tar.gz: 6b9d4be98d45f0652b99a605f93f67e526aacc14d4baa6a463bae106ee75fe4bee1f23c44b86e428d4b3443cb1af88a228ab3b271df8d5738ee21d44330a1456
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lolita-file-upload (0.
|
4
|
+
lolita-file-upload (1.0.0)
|
5
5
|
carrierwave (~> 0.6.0)
|
6
6
|
lolita (~> 3.2)
|
7
7
|
mini_magick (~> 3.6.0)
|
@@ -61,10 +61,10 @@ GEM
|
|
61
61
|
railties (>= 3.0, < 5.0)
|
62
62
|
thor (>= 0.14, < 2.0)
|
63
63
|
json (1.8.0)
|
64
|
-
kaminari (0.
|
64
|
+
kaminari (0.16.1)
|
65
65
|
actionpack (>= 3.0.0)
|
66
66
|
activesupport (>= 3.0.0)
|
67
|
-
lolita (3.4.
|
67
|
+
lolita (3.4.3)
|
68
68
|
abstract (~> 1)
|
69
69
|
actionpack (~> 3.2.0)
|
70
70
|
activesupport (~> 3.2.0)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class LolitaFileUploadGallery
|
1
|
+
class window.LolitaFileUploadGallery
|
2
2
|
@_instance: null
|
3
3
|
_initialized: false
|
4
4
|
_imageQueue: []
|
@@ -24,9 +24,17 @@ class LolitaFileUploadGallery
|
|
24
24
|
@_createSlider()
|
25
25
|
@_addImagesToDOM()
|
26
26
|
@_observeCloseButton()
|
27
|
-
@_addButtonToTinyMCE()
|
28
27
|
@._initialized = true
|
29
28
|
|
29
|
+
_observeImageDropping: ->
|
30
|
+
if typeof tinyMCE.onAddEditor == 'object' && typeof tinyMCE.onAddEditor.add == 'function'
|
31
|
+
tinyMCE.onAddEditor.add (e) =>
|
32
|
+
@_observeDropOnTinyMCEEditor(e.editor)
|
33
|
+
else
|
34
|
+
tinyMCE.on "AddEditor", (e) =>
|
35
|
+
@_observeDropOnTinyMCEEditor(e.editor)
|
36
|
+
|
37
|
+
|
30
38
|
toggle: ->
|
31
39
|
@_gallery().toggle()
|
32
40
|
@_slider().elastislide("refresh")
|
@@ -41,11 +49,6 @@ class LolitaFileUploadGallery
|
|
41
49
|
else
|
42
50
|
@_addToQueue($fileContainer)
|
43
51
|
|
44
|
-
_observeImageDropping: ->
|
45
|
-
tinyMCE.onAddEditor.add( (mgr, editor) =>
|
46
|
-
@_observeDropOnTinyMCEEditor(editor)
|
47
|
-
)
|
48
|
-
|
49
52
|
_createSlider: ->
|
50
53
|
@_slider().elastislide({
|
51
54
|
imageW: 100
|
@@ -71,7 +74,7 @@ class LolitaFileUploadGallery
|
|
71
74
|
_addImagesToDOM: ->
|
72
75
|
while image = @._imageQueue.shift()
|
73
76
|
@_addToDOM(image)
|
74
|
-
|
77
|
+
|
75
78
|
_observeCloseButton: ->
|
76
79
|
$(CLOSE_BUTTON_SELECTOR).mouseenter(->
|
77
80
|
$(this).addClass("ui-state-hover")
|
@@ -81,16 +84,12 @@ class LolitaFileUploadGallery
|
|
81
84
|
@_gallery().hide()
|
82
85
|
)
|
83
86
|
|
84
|
-
_addButtonToTinyMCE: ->
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
onclick: ->
|
91
|
-
LolitaFileUploadGallery.get().toggle()
|
92
|
-
})
|
93
|
-
)
|
87
|
+
_addButtonToTinyMCE: (editor) ->
|
88
|
+
editor.addButton "gallery",
|
89
|
+
title: LolitaFileUploadGallery.buttonTitle
|
90
|
+
image: LolitaFileUploadGallery.buttonImage
|
91
|
+
onclick: ->
|
92
|
+
LolitaFileUploadGallery.get().toggle()
|
94
93
|
|
95
94
|
_gallery: ->
|
96
95
|
$(GALLERY_SELECTOR)
|
@@ -99,7 +98,7 @@ class LolitaFileUploadGallery
|
|
99
98
|
$(SLIDER_SELECTOR)
|
100
99
|
|
101
100
|
_isImagePath: (filePath) ->
|
102
|
-
filePath.match(/\.(jpg|jpeg|gif|png|ico)$/)
|
101
|
+
filePath.match(/\.(jpg|jpeg|gif|png|ico)$/i)
|
103
102
|
|
104
103
|
_getFileExtension: (filePath) ->
|
105
104
|
filePath.substr(filePath.lastIndexOf('.') + 1)
|
@@ -112,7 +111,7 @@ class LolitaFileUploadGallery
|
|
112
111
|
LolitaFileUploadGallery.availableFileIcons['unknown']
|
113
112
|
|
114
113
|
_getFileBasename: (filePath) ->
|
115
|
-
filePath.replace(/\\/g, "/").replace( /.*\//, '' )
|
114
|
+
filePath.replace(/\\/g, "/").replace( /.*\//, '' )
|
116
115
|
|
117
116
|
_tape: ->
|
118
117
|
$(TAPE_SELECTOR)
|
@@ -125,13 +124,13 @@ class LolitaFileUploadGallery
|
|
125
124
|
)
|
126
125
|
|
127
126
|
_imageTag: (imagePath, originalImagePath) ->
|
128
|
-
$('<img>').attr({src: imagePath, alt: imagePath}).
|
127
|
+
$('<img>').attr({src: imagePath, alt: imagePath}).attr('data-original-url', originalImagePath)
|
129
128
|
|
130
129
|
_fileContainer: (filePath, originalFilePath) ->
|
131
|
-
$('<li>').html(
|
132
|
-
$('<a>').attr('href', '#').addClass('file').html(
|
130
|
+
$('<li>').html(
|
131
|
+
$('<a>').attr('href', '#').addClass('file').html(
|
133
132
|
$('<img>').attr({src: @_getFileIcon(originalFilePath), title: @_getFileBasename(originalFilePath)})
|
134
|
-
.
|
133
|
+
.attr('data-original-url', originalFilePath)
|
135
134
|
)
|
136
135
|
)
|
137
136
|
|
@@ -145,19 +144,17 @@ class LolitaFileUploadGallery
|
|
145
144
|
|
146
145
|
_observeDropOnTinyMCEEditor: (newEditor) ->
|
147
146
|
self = this
|
148
|
-
newEditor.
|
149
|
-
$(
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
})
|
154
|
-
)
|
147
|
+
newEditor.on "LoadContent", (e) ->
|
148
|
+
$(e.target.getContainer()).droppable({
|
149
|
+
drop: (event, ui) ->
|
150
|
+
e.target.selection.setContent(self._insertableTag(ui.draggable))
|
151
|
+
})
|
155
152
|
|
156
153
|
_editorContainer: (editor) ->
|
157
154
|
$("#" + editor.editorContainer).find(".mceIframeContainer")
|
158
155
|
|
159
156
|
_insertableTag: (draggable) ->
|
160
|
-
filePath = draggable.
|
157
|
+
filePath = draggable.attr("data-original-url")
|
161
158
|
if @_isImagePath(filePath)
|
162
159
|
@_insertableImageTag(filePath)
|
163
160
|
else
|
@@ -165,8 +162,6 @@ class LolitaFileUploadGallery
|
|
165
162
|
|
166
163
|
_insertableImageTag: (imagePath) ->
|
167
164
|
"<img src='" + imagePath + "' alt='" + imagePath + "' />"
|
168
|
-
|
165
|
+
|
169
166
|
_insertableFileTag: (filePath) ->
|
170
167
|
"<a class='file-icon' href='" + filePath + "'><img src='" + @_getFileIcon(filePath) + "' /><span>" + @_getFileBasename(filePath) + "</span></a>"
|
171
|
-
|
172
|
-
window.LolitaFileUploadGallery = LolitaFileUploadGallery
|
@@ -0,0 +1,14 @@
|
|
1
|
+
tinymce.PluginManager.add "lolita_gallery", (editor, url) ->
|
2
|
+
|
3
|
+
# Add a button that opens a window
|
4
|
+
editor.addButton "lolita_gallery",
|
5
|
+
text: "<%= I18n.t("lolita.upload.gallery.tinymce.button_text") %>"
|
6
|
+
icon: "image"
|
7
|
+
onclick: -> window.LolitaFileUploadGallery.get().toggle()
|
8
|
+
|
9
|
+
# Adds a menu item to the tools menu
|
10
|
+
editor.addMenuItem "lolita_gallery",
|
11
|
+
text: "<%= I18n.t("lolita.upload.gallery.tinymce.button_text") %>"
|
12
|
+
icon: "image"
|
13
|
+
context: "tools"
|
14
|
+
onclick: -> window.LolitaFileUploadGallery.get().toggle()
|
@@ -25,7 +25,7 @@ class Lolita::UploadsController < ApplicationController
|
|
25
25
|
|
26
26
|
def update
|
27
27
|
authorization_proxy.can?(:update,@file.class)
|
28
|
-
@file.update_attributes!(
|
28
|
+
@file.update_attributes!(resource_params(@file))
|
29
29
|
flash[:notice] = ::I18n.t("lolita.uploads_controller.update.notice")
|
30
30
|
render_component *@tab.build("",:update,:file=>@file)
|
31
31
|
end
|
@@ -67,4 +67,12 @@ class Lolita::UploadsController < ApplicationController
|
|
67
67
|
def resource_param_name
|
68
68
|
@file.class.to_s.underscore.gsub("/","_")
|
69
69
|
end
|
70
|
+
|
71
|
+
def resource_params(resource)
|
72
|
+
params.require(resource_param_name).permit(*get_resource_columns(resource))
|
73
|
+
end
|
74
|
+
|
75
|
+
def get_resource_columns(resource)
|
76
|
+
resource.class.column_names.map { |name| name.to_sym }
|
77
|
+
end
|
70
78
|
end
|
@@ -2,7 +2,6 @@ module Lolita
|
|
2
2
|
module Upload
|
3
3
|
class File < ActiveRecord::Base
|
4
4
|
self.table_name = 'lolita_files'
|
5
|
-
attr_accessible :asset, :name, :fileable_type, :asset_extension
|
6
5
|
mount_uploader :asset, FileUploader
|
7
6
|
belongs_to :fileable, polymorphic: true
|
8
7
|
before_save :set_metadata
|
@@ -16,6 +16,7 @@
|
|
16
16
|
<p><%= File.basename(file.send(tab.uploader).url) %></p>
|
17
17
|
</div>
|
18
18
|
<script>
|
19
|
+
$(function(){
|
19
20
|
LolitaFileUploadGallery.get().add('<%= file.send(tab.uploader).preview ? file.send(tab.uploader).preview.url : '' %>', '<%= file.send(tab.uploader).url %>')
|
20
21
|
<% if tab.association_type == :many
|
21
22
|
ids = "#{resource_name}[#{tab.association.name.to_s.singularize}_ids][]"
|
@@ -25,5 +26,5 @@
|
|
25
26
|
<% if resource && resource.new_record? && resource.errors.any? %>
|
26
27
|
$(".tabs form:first").append('<input type="hidden" class="<%=tab.association.name%>-ids" name="<%= ids %>" value="<%= file.id %>" />')
|
27
28
|
<% end %>
|
28
|
-
|
29
|
+
});
|
29
30
|
</script>
|
@@ -1,6 +1,8 @@
|
|
1
1
|
<tr id="upload_<%=tab.association.name%>_row_<%=file.id%>" data-<%=tab.association.name%>-id="<%=file.id%>">
|
2
2
|
<%= render_component *tab.build("",:cells,:file=>file) %>
|
3
3
|
<script>
|
4
|
-
|
4
|
+
$(function(){
|
5
|
+
LolitaFileUploadGallery.get().add('<%= file.send(tab.uploader).preview ? file.send(tab.uploader).preview.url : '' %>', '<%= file.send(tab.uploader).url %>)
|
6
|
+
});
|
5
7
|
</script>
|
6
|
-
</tr>
|
8
|
+
</tr>
|
data/config/locales/en.yml
CHANGED
data/config/locales/lv.yml
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
sv_SE:
|
2
|
+
components:
|
3
|
+
lolita:
|
4
|
+
configuration:
|
5
|
+
tab:
|
6
|
+
files:
|
7
|
+
fixed_gallery:
|
8
|
+
close: Close
|
9
|
+
field:
|
10
|
+
file:
|
11
|
+
remove_current_upload: "Remove current file?"
|
12
|
+
lolita:
|
13
|
+
uploads_controller:
|
14
|
+
update:
|
15
|
+
notice: "File information successfuly saved"
|
16
|
+
error: "File information not saved"
|
17
|
+
upload:
|
18
|
+
errors:
|
19
|
+
"file too big": "file too big (max %{value} %{unit})"
|
20
|
+
gallery:
|
21
|
+
tinymce:
|
22
|
+
button_text: "Gallery"
|
23
|
+
close: "Close"
|
24
|
+
tabs:
|
25
|
+
titles:
|
26
|
+
files: "Files"
|
27
|
+
images:
|
28
|
+
edit: "Edit"
|
29
|
+
delete: "Delete"
|
30
|
+
back: "Back"
|
31
|
+
previous: "Previous"
|
32
|
+
next: "Next"
|
33
|
+
save: "Save"
|
34
|
+
support:
|
35
|
+
bytes:
|
36
|
+
byte:
|
37
|
+
one: byte
|
38
|
+
other: bytes
|
39
|
+
kilobyte:
|
40
|
+
one: kilobyte
|
41
|
+
other: kilobytes
|
42
|
+
megabyte:
|
43
|
+
one: megabyte
|
44
|
+
other: megabytes
|
45
|
+
gigabyte:
|
46
|
+
one: gigabyte
|
47
|
+
other: gigabytes
|
48
|
+
tinymce:
|
49
|
+
gallery: Gallery
|
@@ -6,7 +6,7 @@ module ActionDispatch::Routing
|
|
6
6
|
# /lolita/articles/1/pictures/5
|
7
7
|
resources mapping.plural, :module=>mapping.module, :only=>:none do
|
8
8
|
collection do
|
9
|
-
match "/:association/create"
|
9
|
+
match "/:association/create" => "#{controllers[:uploads]}#create", :as => "create_upload", :via => :post
|
10
10
|
end
|
11
11
|
resources :uploads, :controller => controllers[:uploads], :path => "/:association"
|
12
12
|
end
|
data/lolita-file-upload.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "lolita-file-upload"
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "1.0.0"
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["ITHouse (Latvia)", "Arturs Meisters", "Gatis Tomsons"]
|
9
9
|
s.description = "File upload gem for Lolita with with fulll integration - models, controller, views"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lolita-file-upload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ITHouse (Latvia)
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-11-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: lolita
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- app/assets/images/lolita/tinymce_gallery.png
|
115
115
|
- app/assets/javascripts/lolita/file-upload/application.js
|
116
116
|
- app/assets/javascripts/lolita/file-upload/gallery.js.coffee
|
117
|
+
- app/assets/javascripts/tinymce/plugins/lolita_gallery/plugin.js.coffee.erb
|
117
118
|
- app/assets/stylesheets/lolita/file-upload/application.css
|
118
119
|
- app/assets/stylesheets/lolita/file-upload/gallery.css
|
119
120
|
- app/assets/stylesheets/lolita/file-upload/uploader.css.erb
|
@@ -140,6 +141,7 @@ files:
|
|
140
141
|
- app/views/components/lolita/configuration/tab/files/_upload_script.html.erb
|
141
142
|
- config/locales/en.yml
|
142
143
|
- config/locales/lv.yml
|
144
|
+
- config/locales/sv_SE.yml
|
143
145
|
- lib/generators/lolita/file_upload/install_generator.rb
|
144
146
|
- lib/generators/lolita/file_upload/templates/migration.rb
|
145
147
|
- lib/lolita-file-upload.rb
|
@@ -248,4 +250,3 @@ test_files:
|
|
248
250
|
- test_orm/support.rb
|
249
251
|
- test_orm/uploaders/list_image_uploader.rb
|
250
252
|
- test_orm/uploaders/main_image_uploader.rb
|
251
|
-
has_rdoc:
|