ckeditor-imgur 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +48 -0
- data/Rakefile +2 -0
- data/ckeditor-imgur.gemspec +23 -0
- data/lib/ckeditor/imgur.rb +9 -0
- data/lib/ckeditor/imgur/version.rb +5 -0
- data/vendor/assets/javascripts/ckeditor/plugins/imgur/images/icon.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/imgur/lang/en.js +5 -0
- data/vendor/assets/javascripts/ckeditor/plugins/imgur/lang/zh.js +5 -0
- data/vendor/assets/javascripts/ckeditor/plugins/imgur/plugin.js +79 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2eff047b45b7c5ff062cd2361b4d346482b7a3be
|
4
|
+
data.tar.gz: 02f581b75a4f88b7e023dbffe5cc851aca219884
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d6ae2359f154044fb438c70cd5cd30fee5683f4ed29ed141d039a30e90004bdc68342e4a483eabaa4f29af9f7c830758659e31b5eebf7e76a6a7393ab52091b4
|
7
|
+
data.tar.gz: 65187d558ac7b92729363b17dfc32751150f77dbe410bde6daab02f7eaa165a9379fda71807355b428d6c4c6a17c48a2f35767244049c14ac31c185dcbe739e8
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.idea
|
4
|
+
.bundle
|
5
|
+
.config
|
6
|
+
.yardoc
|
7
|
+
Gemfile.lock
|
8
|
+
InstalledFiles
|
9
|
+
_yardoc
|
10
|
+
coverage
|
11
|
+
doc/
|
12
|
+
lib/bundler/man
|
13
|
+
pkg
|
14
|
+
rdoc
|
15
|
+
spec/reports
|
16
|
+
test/tmp
|
17
|
+
test/version_tmp
|
18
|
+
tmp
|
19
|
+
*.bundle
|
20
|
+
*.so
|
21
|
+
*.o
|
22
|
+
*.a
|
23
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 JSON
|
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
@@ -0,0 +1,48 @@
|
|
1
|
+
# Ckeditor::Imgur
|
2
|
+
|
3
|
+
A CKEditor plugin that help you upload images to `imgur` in easy way.
|
4
|
+
|
5
|
+
`imgur` is a photo storage service for free.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
You must install [CKEditor](https://github.com/galetahub/ckeditor) first and do following:
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'ckeditor-imgur'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install ckeditor-imgur
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
After ckeditor-imgur installed, add plugin setting to your CKEditor `app/assets/javascripts/ckeditor/config.js`:
|
26
|
+
|
27
|
+
```
|
28
|
+
CKEDITOR.editorConfig = function (config) {
|
29
|
+
...
|
30
|
+
config.extraPlugins = 'imgur';
|
31
|
+
// Get your client-id from https://api.imgur.com/oauth2/addclient
|
32
|
+
config.imgurClientID = '55d8ba08326ec75';
|
33
|
+
...
|
34
|
+
};
|
35
|
+
```
|
36
|
+
|
37
|
+
That's all. Your CKEditor have a imgur button in insert group.
|
38
|
+
|
39
|
+
![ckeditor-imgur demo](http://g.recordit.co/bogXrZl0H0.gif)
|
40
|
+
|
41
|
+
|
42
|
+
## Contributing
|
43
|
+
|
44
|
+
1. Fork it ( https://github.com/[my-github-username]/ckeditor-imgur/fork )
|
45
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
46
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
47
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
48
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ckeditor/imgur/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ckeditor-imgur"
|
8
|
+
spec.version = Ckeditor::Imgur::VERSION
|
9
|
+
spec.authors = ["JSON"]
|
10
|
+
spec.email = ["yfxie@me.com"]
|
11
|
+
spec.summary = %q{CKEditor image upload plugin}
|
12
|
+
spec.description = %q{A CKEditor plugin that help you upload image to imgur in easy way}
|
13
|
+
spec.homepage = "https://github.com/yfxie/ckeditor-imgur"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
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_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
Binary file
|
@@ -0,0 +1,79 @@
|
|
1
|
+
( function() {
|
2
|
+
CKEDITOR.plugins.add( 'imgur',
|
3
|
+
{
|
4
|
+
lang: ['zh', 'en'],
|
5
|
+
init: function( editor )
|
6
|
+
{
|
7
|
+
ClientId = editor.config.imgurClientId;
|
8
|
+
if(!ClientId)
|
9
|
+
alert(editor.lang.imgur.clientIdMissing);
|
10
|
+
|
11
|
+
var count = 0;
|
12
|
+
var $placeholder = $("<div></div>").css({
|
13
|
+
position: 'absolute', bottom: 0, left: 0, right: 0, backgroundColor: "rgba(20, 20, 20, .6)", padding: 5, color: "#fff"
|
14
|
+
}).hide();
|
15
|
+
|
16
|
+
editor.on("instanceReady", function (){
|
17
|
+
var $w = $(editor.window.getFrame().$).parent();
|
18
|
+
$w.css({ position:'relative' });
|
19
|
+
$placeholder.appendTo($w);
|
20
|
+
});
|
21
|
+
|
22
|
+
editor.ui.addButton( 'Imgur',
|
23
|
+
{
|
24
|
+
label : "Imgur",
|
25
|
+
toolbar : 'insert',
|
26
|
+
command : 'imgur',
|
27
|
+
icon : this.path + 'images/icon.png'
|
28
|
+
});
|
29
|
+
|
30
|
+
editor.addCommand( 'imgur', {
|
31
|
+
exec: function(){
|
32
|
+
$input = $('<input type="file" multiple/>');
|
33
|
+
$input.on("change", function (e) {
|
34
|
+
files = e.target.files;
|
35
|
+
$.each(files, function(i, file){
|
36
|
+
count++;
|
37
|
+
form = new FormData();
|
38
|
+
form.append('image', file);
|
39
|
+
$.ajax({
|
40
|
+
url: 'https://api.imgur.com/3/image',
|
41
|
+
headers: { Authorization: "Client-ID " + ClientId },
|
42
|
+
type: 'POST',
|
43
|
+
data: form,
|
44
|
+
cache: false,
|
45
|
+
contentType: false,
|
46
|
+
processData: false
|
47
|
+
}).always(function(jqXHR){
|
48
|
+
count--;
|
49
|
+
$placeholder.text(count + editor.lang.imgur.uploading).toggle(count != 0);
|
50
|
+
|
51
|
+
if(jqXHR.status != 200 ) {
|
52
|
+
res = $.parseJSON(jqXHR.responseText);
|
53
|
+
}else{
|
54
|
+
res = jqXHR;
|
55
|
+
}
|
56
|
+
|
57
|
+
if(res.data.error) {
|
58
|
+
alert(editor.lang.imgur.failToUpload + res.data.error);
|
59
|
+
} else {
|
60
|
+
content = '<img src="' + res.data.link +'"/>';
|
61
|
+
var element = CKEDITOR.dom.element.createFromHtml(content);
|
62
|
+
editor.insertElement(element);
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
});
|
67
|
+
});
|
68
|
+
$placeholder.text(count + editor.lang.imgur.uploading).fadeIn();
|
69
|
+
});
|
70
|
+
|
71
|
+
$input.click();
|
72
|
+
|
73
|
+
}
|
74
|
+
});
|
75
|
+
|
76
|
+
}
|
77
|
+
});
|
78
|
+
})();
|
79
|
+
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ckeditor-imgur
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- JSON
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: A CKEditor plugin that help you upload image to imgur in easy way
|
42
|
+
email:
|
43
|
+
- yfxie@me.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- ckeditor-imgur.gemspec
|
54
|
+
- lib/ckeditor/imgur.rb
|
55
|
+
- lib/ckeditor/imgur/version.rb
|
56
|
+
- vendor/assets/javascripts/ckeditor/plugins/imgur/images/icon.png
|
57
|
+
- vendor/assets/javascripts/ckeditor/plugins/imgur/lang/en.js
|
58
|
+
- vendor/assets/javascripts/ckeditor/plugins/imgur/lang/zh.js
|
59
|
+
- vendor/assets/javascripts/ckeditor/plugins/imgur/plugin.js
|
60
|
+
homepage: https://github.com/yfxie/ckeditor-imgur
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.2.2
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: CKEditor image upload plugin
|
84
|
+
test_files: []
|