tinymce-rails-imageupload 3.4.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.markdown +57 -0
- data/Rakefile +1 -0
- data/lib/tinymce-rails-imageupload.rb +2 -0
- data/lib/tinymce-rails-imageupload/rails.rb +8 -0
- data/lib/tinymce-rails-imageupload/version.rb +7 -0
- data/tinymce-rails-imageupload.gemspec +22 -0
- data/vendor/assets/javascripts/tinymce/plugins/uploadimage/dialog.html +59 -0
- data/vendor/assets/javascripts/tinymce/plugins/uploadimage/editor_plugin.js.coffee +40 -0
- data/vendor/assets/javascripts/tinymce/plugins/uploadimage/img/uploadimage.png +0 -0
- data/vendor/assets/javascripts/tinymce/plugins/uploadimage/langs/en.js +3 -0
- data/vendor/assets/javascripts/tinymce/plugins/uploadimage/langs/en_dlg.js +7 -0
- data/vendor/assets/javascripts/tinymce/plugins/uploadimage/langs/no.js +3 -0
- data/vendor/assets/javascripts/tinymce/plugins/uploadimage/langs/no_dlg.js +7 -0
- metadata +105 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT LICENSE
|
2
|
+
|
3
|
+
Copyright (c) 2011 Per Christian B. Viken <perchr@northblue.org>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# tinymce-rails-imageupload
|
2
|
+
|
3
|
+
Simple plugin for TinyMCE that allows uploading images and inserting.
|
4
|
+
It makes no assumptions about how you store the images, but it POSTs to a URL and expects JSON back (see the Setup section).
|
5
|
+
|
6
|
+
This plugin borrows heavily from work done by [Peter Shoukry](http://77effects.com/).
|
7
|
+
|
8
|
+
The icon used for the button comes from the icon set [Silk by famfamfam](http://www.famfamfam.com/lab/icons/silk/)
|
9
|
+
|
10
|
+
## Requirements
|
11
|
+
|
12
|
+
* Rails >= 3.1
|
13
|
+
* TinyMCE using the advanced theme
|
14
|
+
|
15
|
+
## Setup
|
16
|
+
|
17
|
+
Add the gem to your Gemfile
|
18
|
+
|
19
|
+
gem 'tinymce-rails-imageupload', '~> 3.4.8'
|
20
|
+
|
21
|
+
Set up TinyMCE as you would normally, but in the call to `.tinymce()`, add
|
22
|
+
|
23
|
+
plugins: "uploadimage"
|
24
|
+
# theme_advanced_buttonsX must include "uploadimage" somewhere to have the button appear
|
25
|
+
|
26
|
+
and the rest should happen automatically.
|
27
|
+
|
28
|
+
The plugin POSTs to `/tinymce_assets` by default, which is currently not configurable.
|
29
|
+
Set it up using something similar in `routes.rb`
|
30
|
+
|
31
|
+
post '/tinymce_assets' => 'tinymce_assets#create'
|
32
|
+
|
33
|
+
This action gets called with a file parameter creatively called `file`, and must respond with JSON, containing the URL to the image. Example:
|
34
|
+
|
35
|
+
class TinymceAssetsController < ApplicationController
|
36
|
+
def create
|
37
|
+
# Take upload from params[:file] and store it somehow...
|
38
|
+
|
39
|
+
render json: {
|
40
|
+
image: {
|
41
|
+
url: view_context.image_url(image)
|
42
|
+
}
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
## Versioning
|
48
|
+
|
49
|
+
The version of this gem will be mirroring the release of `tinymce-rails` it is tested against.
|
50
|
+
|
51
|
+
## Licensing
|
52
|
+
|
53
|
+
The plugin is released under the MIT license.
|
54
|
+
|
55
|
+
TinyMCE is released under the LGPL Version 2.1.
|
56
|
+
|
57
|
+
The icon used for the button comes from the icon set Silk from famfamfam, released under the [Creative Commons Attribution 3.0 License](http://creativecommons.org/licenses/by/3.0/)
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "tinymce-rails-imageupload/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "tinymce-rails-imageupload"
|
7
|
+
s.version = Tinymce::Rails::Imageupload::VERSION
|
8
|
+
s.authors = ["Per Christian B. Viken"]
|
9
|
+
s.email = ["perchr@northblue.org"]
|
10
|
+
s.homepage = "http://eastblue.org/oss"
|
11
|
+
s.summary = %q{TinyMCE plugin for taking image uploads in Rails >= 3.1}
|
12
|
+
s.description = %q{TinyMCE plugin for taking image uploads in Rails >= 3.1}
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
|
18
|
+
s.add_runtime_dependency "railties", ">= 3.1"
|
19
|
+
s.add_runtime_dependency "tinymce-rails", "~> 3.4.8"
|
20
|
+
s.add_development_dependency "bundler", "~> 1.0.0"
|
21
|
+
s.add_development_dependency "rails", ">= 3.1"
|
22
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>{#uploadimage_dlg.title}</title>
|
5
|
+
<script type="text/javascript" src="../../tiny_mce_popup.js"></script>
|
6
|
+
<script type="text/javascript">
|
7
|
+
tinyMCEPopup.requireLangPack();
|
8
|
+
|
9
|
+
function getFrameByName(name)
|
10
|
+
{
|
11
|
+
for (var i = 0; i < frames.length; i++)
|
12
|
+
if (frames[i].name == name)
|
13
|
+
return frames[i];
|
14
|
+
|
15
|
+
return null;
|
16
|
+
}
|
17
|
+
|
18
|
+
function uploadDone(name)
|
19
|
+
{
|
20
|
+
var frame = getFrameByName(name);
|
21
|
+
if(frame) {
|
22
|
+
ret = frame.document.getElementsByTagName("body")[0].innerHTML;
|
23
|
+
|
24
|
+
if(ret.length) {
|
25
|
+
var json = JSON.parse(ret);
|
26
|
+
tinyMCE.execCommand('mceInsertContent', false, '<br><img src=\'' + json["image"]["url"] + '\' />');
|
27
|
+
tinyMCEPopup.close();
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
var UploadImageDialog = {
|
33
|
+
init: function() {
|
34
|
+
var f = document.forms[0];
|
35
|
+
},
|
36
|
+
|
37
|
+
insert: function() {
|
38
|
+
document.forms[0].submit();
|
39
|
+
}
|
40
|
+
};
|
41
|
+
|
42
|
+
tinyMCEPopup.onInit.add(UploadImageDialog.init, UploadImageDialog);
|
43
|
+
</script>
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
<form method="post" enctype='multipart/form-data' accept-charset="UTF-8" target="hidden_upload" action='/tinymce_assets' name="uploadimageForm">
|
47
|
+
<input type="hidden" name="utf8" value="✓">
|
48
|
+
<iframe id="hidden_upload" name="hidden_upload" src='' onload='uploadDone("hidden_upload")' style='width:0;height:0;border:0px solid #fff'></iframe>
|
49
|
+
|
50
|
+
<h1>{#uploadimage_dlg.header}</h1>
|
51
|
+
<p>{#uploadimage_dlg.input}: <input type="file" name='file' class="file_upload"></p>
|
52
|
+
|
53
|
+
<div class="mceActionPanel">
|
54
|
+
<input type="button" id="insert" name="insert" value="{#uploadimage_dlg.insert}" onclick="UploadImageDialog.insert();"/>
|
55
|
+
<input type="button" id="cancel" name="cancel" value="{#uploadimage_dlg.cancel}" onclick="tinyMCEPopup.close();" />
|
56
|
+
</div>
|
57
|
+
</form>
|
58
|
+
</body>
|
59
|
+
</html>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
(->
|
2
|
+
tinymce.PluginManager.requireLangPack('uploadimage')
|
3
|
+
|
4
|
+
tinymce.create 'tinymce.plugins.UploadImagePlugin', {
|
5
|
+
init: (ed, url) ->
|
6
|
+
ed.addCommand 'mceUploadImage', ->
|
7
|
+
ed.windowManager.open {
|
8
|
+
file: url + '/dialog.html',
|
9
|
+
width: 320 + parseInt(ed.getLang('uploadimage.delta_width', 0)),
|
10
|
+
height: 180 + parseInt(ed.getLang('uploadimage.delta_height', 0)),
|
11
|
+
inline: 1
|
12
|
+
}, {
|
13
|
+
plugin_url: url
|
14
|
+
}
|
15
|
+
|
16
|
+
ed.addButton 'uploadimage', {
|
17
|
+
title: 'uploadimage.desc',
|
18
|
+
cmd: 'mceUploadImage',
|
19
|
+
image: url + '/img/uploadimage.png'
|
20
|
+
}
|
21
|
+
|
22
|
+
# Selects the button in the UI when a image is selected
|
23
|
+
ed.onNodeChange.add (ed, cm, n) ->
|
24
|
+
cm.setActive('uploadimage', n.nodeName == 'IMG')
|
25
|
+
|
26
|
+
createControl: (n, cm) ->
|
27
|
+
null
|
28
|
+
|
29
|
+
getInfo: () ->
|
30
|
+
{
|
31
|
+
longname: 'UploadImage plugin',
|
32
|
+
author: 'Per Christian B. Viken (borrows heavily from work done by Peter Shoukry of 77effects.com)',
|
33
|
+
authorurl: 'eastblue.org/oss',
|
34
|
+
infourl: 'eastblue.org/oss',
|
35
|
+
version: '1.0'
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
tinymce.PluginManager.add 'uploadimage', tinymce.plugins.UploadImagePlugin
|
40
|
+
)()
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tinymce-rails-imageupload
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.4.8
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Per Christian B. Viken
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: railties
|
16
|
+
requirement: &8464640 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.1'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *8464640
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: tinymce-rails
|
27
|
+
requirement: &8463960 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.4.8
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *8463960
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: bundler
|
38
|
+
requirement: &8463280 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.0.0
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *8463280
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rails
|
49
|
+
requirement: &8462580 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.1'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *8462580
|
58
|
+
description: TinyMCE plugin for taking image uploads in Rails >= 3.1
|
59
|
+
email:
|
60
|
+
- perchr@northblue.org
|
61
|
+
executables: []
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- .gitignore
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE
|
68
|
+
- README.markdown
|
69
|
+
- Rakefile
|
70
|
+
- lib/tinymce-rails-imageupload.rb
|
71
|
+
- lib/tinymce-rails-imageupload/rails.rb
|
72
|
+
- lib/tinymce-rails-imageupload/version.rb
|
73
|
+
- tinymce-rails-imageupload.gemspec
|
74
|
+
- vendor/assets/javascripts/tinymce/plugins/uploadimage/dialog.html
|
75
|
+
- vendor/assets/javascripts/tinymce/plugins/uploadimage/editor_plugin.js.coffee
|
76
|
+
- vendor/assets/javascripts/tinymce/plugins/uploadimage/img/uploadimage.png
|
77
|
+
- vendor/assets/javascripts/tinymce/plugins/uploadimage/langs/en.js
|
78
|
+
- vendor/assets/javascripts/tinymce/plugins/uploadimage/langs/en_dlg.js
|
79
|
+
- vendor/assets/javascripts/tinymce/plugins/uploadimage/langs/no.js
|
80
|
+
- vendor/assets/javascripts/tinymce/plugins/uploadimage/langs/no_dlg.js
|
81
|
+
homepage: http://eastblue.org/oss
|
82
|
+
licenses: []
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 1.8.10
|
102
|
+
signing_key:
|
103
|
+
specification_version: 3
|
104
|
+
summary: TinyMCE plugin for taking image uploads in Rails >= 3.1
|
105
|
+
test_files: []
|