tinymce-rails-documentupload 3.5.8.7 → 4.0.16.beta

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 734cfb9dfdbb63383e34a9a50c9f735352b35402
4
- data.tar.gz: 0605bca2cd2b2c83c48c11cf04d3a42b3ff3cd58
3
+ metadata.gz: aa2ddd69a749f10677a83d01337c92f5c4e07f3b
4
+ data.tar.gz: 513673d81d8d184d0e6de58b29cb0900a45dbdd2
5
5
  SHA512:
6
- metadata.gz: 1500025dd731c6ef34e393e465d1e737362fb5742bc56c139465a1f00e88fc7da3d0c52eb095a578d474c8a5b1ed54a2d24048d8b69fb8d56456db0770d0b19f
7
- data.tar.gz: febfcdca5bcfbf30bc6e9b5ac1c0b6b1e5ecd50e89a96e4e0eb2c7f9679c904a4f33302d245f2e4bf541b23cd9157f463bd3a065796171a64faf312be1745f91
6
+ metadata.gz: 79d0b7b20d4929644946ba2aee30a3c7844a125c5ea526a65072d41594cf4f86ac490bf54d3ed1bdc6a025c82db8b54cf65c60c51fe02835b98a1aef70661b98
7
+ data.tar.gz: a399a39d59ea20f0bef77ad1f76eb92213f1d0d0764d960d717757e77599bd4cd3d6f020c54a7cb30448ee57a64cd936faf13c6eeefcc75b1853effa996d4b9a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 4.0.0 / unreleased
2
+
3
+ * Rewrite the plugin to work with TinyMCE 4. TinyMCE 3.x is supported in the
4
+ tinymce3-branch.
5
+
1
6
  # 3.5.8.5 / 2013-05-09
2
7
 
3
8
  * Initial release
data/README.md CHANGED
@@ -1,3 +1,6 @@
1
+ # IMPORTANT NOTE:
2
+ This version is being rewritten to work with TinyMCE 4.x, and is currently not very tested. Use at your own risk, feedback welcome. For the stable version targetting TinyMCE 3, see the [tinymce3 branch](https://github.com/florentmorin/tinymce-rails-documentupload/tree/tinymce3)
3
+
1
4
  # tinymce-rails-documentupload
2
5
 
3
6
  Simple plugin for TinyMCE that allows uploading documents and inserting.
@@ -6,22 +9,28 @@
6
9
  This plugin is adapted from work done by [Christian Bechström Viken for TinyMCE Rails Image Upload plugin](https://github.com/PerfectlyNormal/tinymce-rails-imageupload).
7
10
 
8
11
  The icon used for the button comes from the icon set [Silk by famfamfam](http://www.famfamfam.com/lab/icons/silk/) and the spinner image from [ajaxload.info](http://ajaxload.info/).
12
+
13
+ Support for TinyMCE 3 is currently available in the [tinymce3 branch](https://github.com/florentmorin/tinymce-rails-documentupload/tree/tinymce3). The master branch is targetting TinyMCE 4.x.
9
14
 
10
15
  ## Requirements
11
16
 
12
17
  * Rails >= 3.1
13
- * TinyMCE using the advanced theme
18
+ * TinyMCE4 using the advanced theme
14
19
 
15
20
  ## Setup
16
21
 
17
22
  ### Add the gem to your Gemfile
18
23
 
19
- gem 'tinymce-rails-documentupload', '~> 3.5.8.7'
24
+ gem 'tinymce-rails-documentupload', '~> 4.0.0.beta'
25
+
26
+ # or use git
27
+
28
+ gem 'tinymce-rails-documentupload', github: 'florentmorin/tinymce-rails-documentupload'
20
29
 
21
30
  ### Set up TinyMCE as you would normally, but in the call to `.tinymce()`, add
22
31
 
23
32
  plugins: "uploaddocument"
24
- # theme_advanced_buttonsX must include "uploaddocument" somewhere to have the button appear
33
+ # toolbar option must include "uploaddocument" somewhere to have the button appear
25
34
 
26
35
  and the rest should happen automatically.
27
36
 
@@ -50,7 +59,7 @@
50
59
  document: {
51
60
  url: view_context.document_url(image)
52
61
  }
53
- }, content_type: "text/html"
62
+ }, layout: false, content_type: "text/html"
54
63
  end
55
64
  end
56
65
 
@@ -73,37 +82,23 @@ Example response:
73
82
 
74
83
  ## Internationalization
75
84
 
76
- I18n is taken care of by `tinymce-rails`. This gem includes strings for english and french.
77
- To add your own language, create the files `<code>.js` and `<code>_dlg.js` in `vendor/assets/javascripts/tinymce/plugins/uploaddocument/langs` in your application,
78
- or fork the gem and add your own translations there.
79
-
80
- To get your custom language precompiled, you have to add it to the list of files manually.
81
- If you have a fork, just add it to the list in `lib/tinymce-rails-documentupload/rails.rb`, but if you have the translations in the application,
82
- you can add it like this in `config/application.rb`:
83
-
84
- config.assets.precompile += %w(tinymce/plugins/uploaddocument/langs/fr.js tinymce/plugins/uploaddocument/langs/fr_dlg.js)
85
-
86
- The available strings are listed below:
87
-
88
- ### en.js
89
-
90
- tinyMCE.addI18n('en.uploaddocument', {
91
- desc: 'Insert a document from your computer'
92
- });
93
-
94
- ### en_dlg.js
95
-
96
- tinyMCE.addI18n('en.uploaddocument_dlg', {
97
- title: 'Insert document',
98
- header: "Insert document",
99
- input: "Choose a document",
100
- uploading: "Uploading…",
101
- blank_input: "Must choose a file",
102
- bad_response: "Got a bad response from the server",
103
- blank_response: "Didn't get a response from the server",
104
- insert: "Insert",
105
- cancel: "Cancel",
106
- alt_text: "Document description"
85
+ I18n is taken care of by `tinymce-rails`. This gem includes strings for `en` and `fr`. To add your own language, create the files `<code>.js` in `app/assets/javascripts/tinymce/plugins/uploaddocument/langs` in your application, or fork the gem and add your own translations there.
86
+
87
+ The format and available strings are listed below:
88
+
89
+ ### fr.js
90
+
91
+ tinyMCE.addI18n('fr', {
92
+ 'Insert a document from your computer': 'Insérer un document depuis votre ordinateur',
93
+ 'Insert document': "Insérer un document",
94
+ 'Choose a document': "Choisir un document",
95
+ 'You must choose a file': "Vous devez choisir un fichier",
96
+ 'Got a bad response from the server': "Mauvaise réponse du serveur",
97
+ "Didn't get a response from the server": "Aucune réponse du serveur",
98
+ 'Insert': "Insérer",
99
+ 'Cancel': "Annuler",
100
+ 'Document description': "Description du document",
101
+ 'Click to download' : "Cliquer pour télécharger",
107
102
  });
108
103
 
109
104
  ## Versioning
@@ -0,0 +1,12 @@
1
+ tinyMCE.addI18n('en', {
2
+ 'Insert a document from your computer': 'Insert a document from your computer',
3
+ 'Insert document': "Insert document",
4
+ 'Choose a document': "Choose a document",
5
+ 'You must choose a file': "You must choose a file",
6
+ 'Got a bad response from the server': "Got a bad response from the server",
7
+ "Didn't get a response from the server": "Didn't get a response from the server",
8
+ 'Insert': "Insert",
9
+ 'Cancel': "Cancel",
10
+ 'Document description': "Document description",
11
+ 'Click to download': "Click to download",
12
+ });
@@ -0,0 +1,12 @@
1
+ tinyMCE.addI18n('fr', {
2
+ 'Insert a document from your computer': "Envoyer un document depuis votre ordinateur",
3
+ 'Insert document': "Insérer un document",
4
+ 'Choose a document': "Choisir un document",
5
+ 'You must choose a file': "Vous devez sélectionner un fichier",
6
+ 'Got a bad response from the server': "Le serveur a envoyé une réponse erronée",
7
+ "Didn't get a response from the server": "Le serveur n'a pas renvoyé de réponse",
8
+ 'Insert': "Insérer",
9
+ 'Cancel': "Annuler",
10
+ 'Document description': "Description du document",
11
+ 'Click to download': "Cliquer pour télécharger",
12
+ });
@@ -0,0 +1,12 @@
1
+ tinyMCE.addI18n('fr_FR', {
2
+ 'Insert a document from your computer': "Envoyer un document depuis votre ordinateur",
3
+ 'Insert document': "Insérer un document",
4
+ 'Choose a document': "Choisir un document",
5
+ 'You must choose a file': "Vous devez sélectionner un fichier",
6
+ 'Got a bad response from the server': "Le serveur a envoyé une réponse erronée",
7
+ "Didn't get a response from the server": "Le serveur n'a pas renvoyé de réponse",
8
+ 'Insert': "Insérer",
9
+ 'Cancel': "Annuler",
10
+ 'Document description': "Description du document",
11
+ 'Click to download': "Cliquer pour télécharger",
12
+ });
@@ -0,0 +1,259 @@
1
+ (function() {
2
+ tinymce.PluginManager.requireLangPack('uploaddocument');
3
+
4
+ tinymce.create('tinymce.plugins.UploadDocument', {
5
+ UploadDocument: function(ed, url) {
6
+ var form,
7
+ iframe,
8
+ win,
9
+ throbber,
10
+ editor = ed;
11
+
12
+ function showDialog() {
13
+ win = editor.windowManager.open({
14
+ title: ed.translate('Insert a document from your computer'),
15
+ width: 500 + parseInt(editor.getLang('uploaddocument.delta_width', 0), 10),
16
+ height: 180 + parseInt(editor.getLang('uploaddocument.delta_height', 0), 10),
17
+ body: [
18
+ {type: 'iframe', url: 'javascript:void(0)'},
19
+ {type: 'textbox', name: 'file', label: ed.translate('Choose a document'), subtype: 'file'},
20
+ {type: 'textbox', name: 'alt', label: ed.translate('Document description')},
21
+ {type: 'container', classes: 'error', html: "<p style='color: #b94a48;'>&nbsp;</p>"},
22
+
23
+ // Trick TinyMCE to add a empty div that "preloads" the throbber image
24
+ {type: 'container', classes: 'throbber'},
25
+ ],
26
+ buttons: [
27
+ {
28
+ text: ed.translate('Insert'),
29
+ onclick: insertImage,
30
+ subtype: 'primary'
31
+ },
32
+ {
33
+ text: ed.translate('Cancel'),
34
+ onclick: ed.windowManager.close
35
+ }
36
+ ],
37
+ }, {
38
+ plugin_url: url
39
+ });
40
+
41
+ // TinyMCE likes pointless submit handlers
42
+ win.off('submit');
43
+ win.on('submit', insertImage);
44
+
45
+ /* WHY DO YOU HATE <form>, TINYMCE!? */
46
+ iframe = win.find("iframe")[0];
47
+ form = createElement('form', {
48
+ action: ed.getParam("uploaddocument_form_url", "/tinymce_documents"),
49
+ target: iframe._id,
50
+ method: "POST",
51
+ enctype: 'multipart/form-data',
52
+ accept_charset: "UTF-8",
53
+ });
54
+
55
+ // Might have several instances on the same page,
56
+ // so we TinyMCE create unique IDs and use those.
57
+ iframe.getEl().name = iframe._id;
58
+
59
+ // Create some needed hidden inputs
60
+ form.appendChild(createElement('input', {type: "hidden", name: "utf8", value: "✓"}));
61
+ form.appendChild(createElement('input', {type: 'hidden', name: 'authenticity_token', value: getMetaContents('csrf-token')}));
62
+ form.appendChild(createElement('input', {type: 'hidden', name: 'hint', value: ed.getParam("uploaddocument_hint", "")}));
63
+
64
+ var el = win.getEl();
65
+ var body = document.getElementById(el.id + "-body");
66
+
67
+ // Copy everything TinyMCE made into our form
68
+ var containers = body.getElementsByClassName('mce-container');
69
+ for(var i = 0; i < containers.length; i++) {
70
+ form.appendChild(containers[i]);
71
+ }
72
+
73
+ // Fix inputs, since TinyMCE hates HTML and forms
74
+ var inputs = form.getElementsByTagName('input');
75
+ for(var i = 0; i < inputs.length; i++) {
76
+ var ctrl = inputs[i];
77
+
78
+ if(ctrl.tagName.toLowerCase() == 'input' && ctrl.type != "hidden") {
79
+ if(ctrl.type == "file") {
80
+ ctrl.name = "file";
81
+
82
+ // Hack styles
83
+ tinymce.DOM.setStyles(ctrl, {
84
+ 'border': 0,
85
+ 'boxShadow': 'none',
86
+ 'webkitBoxShadow': 'none',
87
+ });
88
+ } else {
89
+ ctrl.name = "alt";
90
+ }
91
+ }
92
+ }
93
+
94
+ body.appendChild(form);
95
+ }
96
+
97
+ function insertImage() {
98
+ if(getInputValue("file") == "") {
99
+ return handleError('You must choose a file');
100
+ }
101
+
102
+ throbber = new top.tinymce.ui.Throbber(win.getEl());
103
+ throbber.show();
104
+
105
+ clearErrors();
106
+
107
+ /* Add event listeners.
108
+ * We remove the existing to avoid them being called twice in case
109
+ * of errors and re-submitting afterwards.
110
+ */
111
+ var target = iframe.getEl();
112
+ if(target.attachEvent) {
113
+ target.detachEvent('onload', uploadDone);
114
+ target.attachEvent('onload', uploadDone);
115
+ } else {
116
+ target.removeEventListener('load', uploadDone);
117
+ target.addEventListener('load', uploadDone, false);
118
+ }
119
+
120
+ form.submit();
121
+ }
122
+
123
+ function uploadDone() {
124
+ if(throbber) {
125
+ throbber.hide();
126
+ }
127
+
128
+ var target = iframe.getEl();
129
+ if(target.document || target.contentDocument) {
130
+ var doc = target.contentDocument || target.contentWindow.document;
131
+ handleResponse(doc.getElementsByTagName("body")[0].innerHTML);
132
+ } else {
133
+ handleError("Didn't get a response from the server");
134
+ }
135
+ }
136
+
137
+ function handleResponse(ret) {
138
+ try {
139
+ var json = tinymce.util.JSON.parse(ret);
140
+
141
+ if(json["error"]) {
142
+ handleError(json["error"]["message"]);
143
+ } else {
144
+ var str = buildHTML(json);
145
+ if (ed.execCommand('mceInsertContent', false, str)) {
146
+ console.log(str);
147
+ } else {
148
+ console.log("Error");
149
+ }
150
+
151
+ ed.windowManager.close();
152
+ }
153
+ } catch(e) {
154
+ console.log(e);
155
+ handleError('Got a bad response from the server');
156
+ }
157
+ }
158
+
159
+ function clearErrors() {
160
+ var message = win.find(".error")[0].getEl();
161
+
162
+ if(message)
163
+ message.getElementsByTagName("p")[0].innerHTML = "&nbsp;";
164
+ }
165
+
166
+ function handleError(error) {
167
+ var message = win.find(".error")[0].getEl();
168
+
169
+ if(message)
170
+ message.getElementsByTagName("p")[0].innerHTML = ed.translate(error);
171
+ }
172
+
173
+ function createElement(element, attributes) {
174
+ var el = document.createElement(element);
175
+ for(var property in attributes) {
176
+ if (!(attributes[property] instanceof Function)) {
177
+ el[property] = attributes[property];
178
+ }
179
+ }
180
+
181
+ return el;
182
+ }
183
+
184
+ function buildHTML(json, default_text) {
185
+ var default_class = ed.getParam("uploaddocument_default_img_class", "");
186
+ var alt_text = getInputValue("alt");
187
+
188
+ var docstr = "<a href='" + json["document"]["url"] + "' target='_blank' type='octet-stream'";
189
+
190
+ if (default_class != "") {
191
+ docstr += " class='" + default_class + "'";
192
+ }
193
+
194
+ docstr += '>'
195
+
196
+ if (json["document"]["thumb"] && json["document"]["thumb"]["url"]) {
197
+ thumb_json = json["document"]["thumb"];
198
+
199
+ docstr += "<img src='" + thumb_json["url"] + "'";
200
+
201
+ if (thumb_json["height"]) {
202
+ docstr += " height='" + thumb_json["height"] + "'";
203
+ }
204
+
205
+ if (thumb_json["width"]) {
206
+ docstr += " width='" + thumb_json["width"] + "'";
207
+ }
208
+
209
+ docstr += " alt='" + alt_text + "' />";
210
+ } else if (alt_text == "") {
211
+ docstr += ed.translate('Click to download');
212
+ } else {
213
+ docstr += alt_text;
214
+ }
215
+
216
+ docstr += "</a>";
217
+
218
+ return docstr;
219
+ }
220
+
221
+ function getInputValue(name) {
222
+ var inputs = form.getElementsByTagName("input");
223
+
224
+ for(var i in inputs)
225
+ if(inputs[i].name == name)
226
+ return inputs[i].value;
227
+
228
+ return "";
229
+ }
230
+
231
+ function getMetaContents(mn) {
232
+ var m = document.getElementsByTagName('meta');
233
+
234
+ for(var i in m)
235
+ if(m[i].name == mn)
236
+ return m[i].content;
237
+
238
+ return null;
239
+ }
240
+
241
+ // Add a button that opens a window
242
+ editor.addButton('uploaddocument', {
243
+ tooltip: ed.translate('Insert a document from your computer'),
244
+ icon : 'newdocument',
245
+ onclick: showDialog
246
+ });
247
+
248
+ // Adds a menu item to the tools menu
249
+ editor.addMenuItem('uploaddocument', {
250
+ text: ed.translate('Insert a document from your computer'),
251
+ icon : 'newdocument',
252
+ context: 'insert',
253
+ onclick: showDialog
254
+ });
255
+ }
256
+ });
257
+
258
+ tinymce.PluginManager.add('uploaddocument', tinymce.plugins.UploadDocument);
259
+ })();
@@ -8,7 +8,7 @@ Rake::Task[assets_task].enhance do
8
8
  manifest = config.assets.manifest
9
9
 
10
10
  assets = Pathname.new(File.expand_path(File.join(File.dirname(__FILE__),
11
- "../../vendor/assets/javascripts/tinymce/plugins/uploaddocument")))
12
- TinyMCE::Rails::AssetInstaller::ASSETS = assets
11
+ "../../app/assets/javascripts/tinymce/plugins/uploaddocument")))
12
+
13
13
  TinyMCE::Rails::AssetInstaller.new(target, manifest).install
14
14
  end
@@ -1,7 +1,7 @@
1
1
  module Tinymce
2
2
  module Rails
3
3
  module Documentupload
4
- VERSION = "3.5.8.7"
4
+ VERSION = "4.0.16.beta"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,97 +1,95 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tinymce-rails-documentupload
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.8.7
4
+ version: 4.0.16.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florent Morin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-09 00:00:00.000000000 Z
11
+ date: 2014-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.1'
19
+ version: '3.2'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - '>='
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '3.1'
29
+ version: '3.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: tinymce-rails
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - ~>
37
+ - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: 3.5.8.1
39
+ version: '4.0'
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - ~>
44
+ - - "~>"
39
45
  - !ruby/object:Gem::Version
40
- version: 3.5.8.1
46
+ version: '4.0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: bundler
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - ~>
51
+ - - "~>"
46
52
  - !ruby/object:Gem::Version
47
53
  version: '1.0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - ~>
58
+ - - "~>"
53
59
  - !ruby/object:Gem::Version
54
60
  version: '1.0'
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: rails
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - '>='
65
+ - - ">="
60
66
  - !ruby/object:Gem::Version
61
67
  version: '3.1'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - '>='
72
+ - - ">="
67
73
  - !ruby/object:Gem::Version
68
74
  version: '3.1'
69
- description: TinyMCE plugin for taking documents uploads in Rails >= 3.1
75
+ description: TinyMCE plugin for taking documents uploads in Rails >= 3.2
70
76
  email:
71
77
  - morinflorent@gmail.com
72
78
  executables: []
73
79
  extensions: []
74
80
  extra_rdoc_files: []
75
81
  files:
76
- - .gitignore
77
82
  - CHANGELOG.md
78
- - Gemfile
79
83
  - LICENSE
80
84
  - README.md
81
- - Rakefile
85
+ - app/assets/javascripts/tinymce/plugins/uploaddocument/langs/en.js
86
+ - app/assets/javascripts/tinymce/plugins/uploaddocument/langs/fr.js
87
+ - app/assets/javascripts/tinymce/plugins/uploaddocument/langs/fr_FR.js
88
+ - app/assets/javascripts/tinymce/plugins/uploaddocument/plugin.js
82
89
  - lib/tasks/tinymce-uploaddocument-assets.rake
83
90
  - lib/tinymce-rails-documentupload.rb
84
91
  - lib/tinymce-rails-documentupload/rails.rb
85
92
  - lib/tinymce-rails-documentupload/version.rb
86
- - tinymce-rails-documentupload.gemspec
87
- - vendor/assets/javascripts/tinymce/plugins/uploaddocument/dialog.html
88
- - vendor/assets/javascripts/tinymce/plugins/uploaddocument/editor_plugin.js
89
- - vendor/assets/javascripts/tinymce/plugins/uploaddocument/img/spinner.gif
90
- - vendor/assets/javascripts/tinymce/plugins/uploaddocument/img/uploaddocument.png
91
- - vendor/assets/javascripts/tinymce/plugins/uploaddocument/langs/en.js
92
- - vendor/assets/javascripts/tinymce/plugins/uploaddocument/langs/en_dlg.js
93
- - vendor/assets/javascripts/tinymce/plugins/uploaddocument/langs/fr.js
94
- - vendor/assets/javascripts/tinymce/plugins/uploaddocument/langs/fr_dlg.js
95
93
  homepage: https://github.com/florentmorin/tinymce-rails-documentupload
96
94
  licenses: []
97
95
  metadata: {}
@@ -101,18 +99,18 @@ require_paths:
101
99
  - lib
102
100
  required_ruby_version: !ruby/object:Gem::Requirement
103
101
  requirements:
104
- - - '>='
102
+ - - ">="
105
103
  - !ruby/object:Gem::Version
106
104
  version: '0'
107
105
  required_rubygems_version: !ruby/object:Gem::Requirement
108
106
  requirements:
109
- - - '>='
107
+ - - ">"
110
108
  - !ruby/object:Gem::Version
111
- version: '0'
109
+ version: 1.3.1
112
110
  requirements: []
113
111
  rubyforge_project:
114
- rubygems_version: 2.0.3
112
+ rubygems_version: 2.2.2
115
113
  signing_key:
116
114
  specification_version: 4
117
- summary: TinyMCE plugin for taking documents uploads in Rails >= 3.1
115
+ summary: TinyMCE plugin for taking documents uploads in Rails >= 3.2
118
116
  test_files: []
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"
@@ -1,23 +0,0 @@
1
- # encoding: utf-8
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "tinymce-rails-documentupload/version"
4
-
5
- # Describe your gem and declare its dependencies:
6
- Gem::Specification.new do |s|
7
- s.name = "tinymce-rails-documentupload"
8
- s.version = Tinymce::Rails::Documentupload::VERSION
9
- s.authors = ["Florent Morin"]
10
- s.email = ["morinflorent@gmail.com"]
11
- s.homepage = "https://github.com/florentmorin/tinymce-rails-documentupload"
12
- s.summary = %q{TinyMCE plugin for taking documents uploads in Rails >= 3.1}
13
- s.description = %q{TinyMCE plugin for taking documents uploads in Rails >= 3.1}
14
-
15
- s.files = `git ls-files`.split("\n")
16
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
- s.require_paths = ["lib"]
18
-
19
- s.add_runtime_dependency "railties", ">= 3.1"
20
- s.add_runtime_dependency "tinymce-rails", "~> 3.5.8.1"
21
- s.add_development_dependency "bundler", "~> 1.0"
22
- s.add_development_dependency "rails", ">= 3.1"
23
- end
@@ -1,163 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <title>{#uploaddocument_dlg.title}</title>
6
- <style type="text/css">
7
- form { margin-top: 0.5em; }
8
- label { margin-bottom: 0.5em; }
9
- p#error_message { color: #E00; }
10
- #upload_spinner { padding-top: 4px; padding-left: 3px; }
11
- #upload_spinner.inactive { display: none; }
12
- </style>
13
- <script type="text/javascript" src="../../tiny_mce_popup.js"></script>
14
- <script type="text/javascript">
15
- tinyMCEPopup.requireLangPack();
16
-
17
- var UploadDocumentDialog = {
18
-
19
- init: function() {
20
- this.f = document.forms[0];
21
- this.f.action = tinyMCEPopup.getParam("uploaddocument_form_url", "/tinymce_documents");
22
- document.getElementById("hint").value = tinyMCEPopup.getParam("uploaddocument_hint", "");
23
- document.getElementById("authenticity_token").value = this.getMetaContents('csrf-token');
24
-
25
- this.iframe = document.getElementById("hidden_upload");
26
- },
27
-
28
- insert: function() {
29
- // Detach events first, then attach to avoid double event triggering
30
- if(this.iframe.attachEvent) {
31
- this.iframe.detachEvent('onload', UploadDocumentDialog.uploadDone);
32
- this.iframe.attachEvent('onload', UploadDocumentDialog.uploadDone);
33
- } else {
34
- this.iframe.removeEventListener('load', UploadDocumentDialog.uploadDone);
35
- this.iframe.addEventListener('load', UploadDocumentDialog.uploadDone, false);
36
- }
37
- var input = document.getElementById("file_upload");
38
-
39
- if(input.value != "") {
40
- document.getElementById("upload_spinner").className = '';
41
- this.f.submit();
42
- } else {
43
- this.handleError(tinyMCEPopup.getLang("uploaddocument_dlg.blank_input", "Must choose a file"));
44
- }
45
- },
46
-
47
- uploadDone: function() {
48
- document.getElementById("upload_spinner").className = 'inactive';
49
- var iframe = document.getElementById("hidden_upload");
50
- if(iframe.document || iframe.contentDocument) {
51
- var doc = iframe.contentDocument || iframe.contentWindow.document;
52
- UploadDocumentDialog.handleResponse(doc.getElementsByTagName("body")[0].innerHTML);
53
- } else {
54
- UploadDocumentDialog.handleError(tinyMCEPopup.getLang("uploaddocument_dlg.blank_response", "Didn't get a response from the server"));
55
- }
56
- },
57
-
58
- handleResponse: function(ret) {
59
- try {
60
- var json = JSON.parse(ret);
61
-
62
- if(json["error"])
63
- UploadDocumentDialog.handleError(json["error"]["message"]);
64
- else {
65
- tinyMCE.execCommand('mceInsertContent', false, UploadDocumentDialog.buildHTML(json));
66
- tinyMCEPopup.close();
67
- }
68
- } catch(e) {
69
- UploadDocumentDialog.handleError(tinyMCEPopup.getLang("uploaddocument_dlg.bad_response", "Got a bad response from the server"));
70
- }
71
- },
72
-
73
- buildHTML: function(json) {
74
- var default_class = tinyMCEPopup.getParam("uploaddocument_default_a_class", "");
75
- var alt_text = document.getElementById("alt_text").value;
76
-
77
- var docstr = "<a href='" + json["document"]["url"] + "' target='_blank' type='octet-stream'";
78
-
79
- if (default_class != "") {
80
- docstr += " class='" + default_class + "'";
81
- }
82
-
83
- docstr += '>'
84
-
85
- if (json["document"]["thumb"] && json["document"]["thumb"]["url"]) {
86
- thumb_json = json["document"]["thumb"];
87
-
88
- docstr += "<img src='" + thumb_json["url"] + "'";
89
-
90
- if (thumb_json["height"]) {
91
- docstr += " height='" + thumb_json["height"] + "'";
92
- }
93
-
94
- if (thumb_json["width"]) {
95
- docstr += " width='" + thumb_json["width"] + "'";
96
- }
97
-
98
- docstr += " alt='" + alt_text + "' />";
99
- } else {
100
- docstr += alt_text;
101
- }
102
-
103
- docstr += "</a>";
104
-
105
- return docstr;
106
- },
107
-
108
- handleError: function(error) {
109
- var className = 'invalid';
110
- var label = document.getElementById("file_upload_label");
111
- var message = document.getElementById("error_message");
112
-
113
- if(message)
114
- message.innerHTML = error;
115
-
116
- // Add the 'invalid' class, avoiding duplicates
117
- if(label) {
118
- var cn = label.className;
119
- if(cn.indexOf(className) == -1) {
120
- if(cn != '')
121
- className = ' ' + className;
122
- label.className = cn + className;
123
- }
124
- }
125
- },
126
-
127
- getMetaContents: function(mn) {
128
- var m = (window.opener || window.parent).document.getElementsByTagName('meta');
129
-
130
- for(var i in m)
131
- if(m[i].name == mn)
132
- return m[i].content;
133
-
134
- return null;
135
- },
136
- };
137
-
138
- tinyMCEPopup.onInit.add(UploadDocumentDialog.init, UploadDocumentDialog);
139
- </script>
140
- </head>
141
- <body>
142
- <h1>{#uploaddocument_dlg.header}</h1>
143
-
144
- <form method="post" enctype='multipart/form-data' accept-charset="UTF-8" target="hidden_upload" action='#replaceme' name="uploaddocumentForm">
145
- <input type="hidden" name="utf8" value="✓">
146
- <input type="hidden" name="authenticity_token" id="authenticity_token" value="#replaceme">
147
- <input type="hidden" name="hint" id="hint" value="#replaceme">
148
- <iframe id="hidden_upload" name="hidden_upload" src="javascript:void(0)" style='width:0;height:0;border:0px solid #fff'></iframe>
149
-
150
- <label id='file_upload_label' for='file_upload'>{#uploaddocument_dlg.input}:</label>
151
- <input type='file' name='file' id='file_upload'>
152
- <p id="error_message"></p>
153
- <label id='alt_text_label' for='alt_text'>{#uploaddocument_dlg.alt_text}:</label>
154
- <input type="text" name="alt" id="alt_text">
155
-
156
- <div class="mceActionPanel">
157
- <input type="button" id="insert" name="insert" value="{#uploaddocument_dlg.insert}" onclick="UploadDocumentDialog.insert();"/>
158
- <img src="img/spinner.gif" alt="#{uploaddocument_dlg.uploading}" id="upload_spinner" height="16" width="16" class="inactive">
159
- <input type="button" id="cancel" name="cancel" value="{#uploaddocument_dlg.cancel}" onclick="tinyMCEPopup.close();" />
160
- </div>
161
- </form>
162
- </body>
163
- </html>
@@ -1,38 +0,0 @@
1
- (function() {
2
- tinymce.PluginManager.requireLangPack('uploaddocument');
3
- tinymce.create('tinymce.plugins.UploadDocumentPlugin', {
4
- init: function(ed, url) {
5
- ed.addCommand('mceUploadDocument', function() {
6
- return ed.windowManager.open({
7
- file: url + '/dialog.html',
8
- width: 350 + parseInt(ed.getLang('uploaddocument.delta_width', 0)),
9
- height: 180 + parseInt(ed.getLang('uploaddocument.delta_height', 0)),
10
- inline: 1
11
- }, {
12
- plugin_url: url
13
- });
14
- });
15
- ed.addButton('uploaddocument', {
16
- title: 'uploaddocument.desc',
17
- cmd: 'mceUploadDocument',
18
- image: url + '/img/uploaddocument.png'
19
- });
20
- return ed.onNodeChange.add(function(ed, cm, n) {
21
- return cm.setActive('uploaddocument', n.nodeName === 'IMG');
22
- });
23
- },
24
- createControl: function(n, cm) {
25
- return null;
26
- },
27
- getInfo: function() {
28
- return {
29
- longname: 'UploadDocument plugin',
30
- author: 'Per Florent Morin (based on work done by Christian B. Viken for image upload plugin)',
31
- authorurl: 'https://github.com/florentmorin',
32
- infourl: 'https://github.com/florentmorin/tinymce-rails-documentupload',
33
- version: '1.0'
34
- };
35
- }
36
- });
37
- return tinymce.PluginManager.add('uploaddocument', tinymce.plugins.UploadDocumentPlugin);
38
- })();
@@ -1,3 +0,0 @@
1
- tinyMCE.addI18n('en.uploaddocument', {
2
- desc: 'Insert a document from your computer'
3
- });
@@ -1,12 +0,0 @@
1
- tinyMCE.addI18n('en.uploaddocument_dlg', {
2
- title: 'Insert document',
3
- header: "Insert document",
4
- input: "Choose a document",
5
- uploading: "Uploading…",
6
- blank_input: "Must choose a file",
7
- bad_response: "Got a bad response from the server",
8
- blank_response: "Didn't get a response from the server",
9
- insert: "Insert",
10
- cancel: "Cancel",
11
- alt_text: "Document description"
12
- });
@@ -1,3 +0,0 @@
1
- tinyMCE.addI18n('fr.uploaddocument', {
2
- desc: "Envoyer un document de votre ordinateur"
3
- });
@@ -1,12 +0,0 @@
1
- tinyMCE.addI18n('fr.uploaddocument_dlg', {
2
- title: "Insérer un document",
3
- header: "Insérer un document",
4
- input: "Choisissez un document",
5
- uploading: "Transfert en cours ...",
6
- blank_input: "Vous devez sélectionner un fichier",
7
- bad_response: "Le serveur a envoyé une réponse erronée",
8
- blank_response: "Le serveur n'a pas renvoyé de réponse",
9
- insert: "Insérer",
10
- cancel: "Annuler",
11
- alt_text: "Description du document"
12
- });