simditor_aliyun_rails 0.1.0 → 2.3.6

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: 2ffd4ce8dbb7430af876622a90a9cab76182445d
4
- data.tar.gz: af00e30e3572b5b4db6f09d1991e02f64b9e27e7
3
+ metadata.gz: a711852fcb2975369757920048d6a43b789b1535
4
+ data.tar.gz: b5b9212ffb179e297988596eedc18283b7105b75
5
5
  SHA512:
6
- metadata.gz: 3d1bc669671f31fb51bba446f92afdbdb83abc1eaeade491202d27e4d2865e9c3f9fada302ab6ac84111b6e5feae1ec98439e1edc1e193b42586b2113595a41e
7
- data.tar.gz: fa501fa4d7dce35fec8deb95e8900680470b5849c74513dde7d8241bc2e4faae82df0f39af5061b153a381d27935b1e3d31b18ac84cd6e5cf5a6dea08038fdb1
6
+ metadata.gz: 00d6afec8cb119ca37faaccb0ef08dcd1e03ce5b4c4fdb08f595f8fa582e086bef93bdeb1974a123f654d00745d1876f639032ab3f298f0a021032d5324e7790
7
+ data.tar.gz: 9b80fba222cad21f80a7b1a01572211f3d2d90c1864f523199b225898d2e546da25917154d4292a9a0d5bc815a3779ba0fd8749afc78e302651d3c91345c1a5e
data/.gitignore CHANGED
@@ -6,3 +6,5 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+
10
+ .DS_Store
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # SimditorAliyunRails
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/simditor_aliyun_rails`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Using the Aliyun OSS JavaScript SDK to upload pictures on the basis of [Simditor-Rails](https://github.com/wentaoliu/simditor-rails).
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ [![Gem Version](https://badge.fury.io/rb/simditor_aliyun_rails.svg)](https://badge.fury.io/rb/simditor_aliyun_rails)
6
6
 
7
7
  ## Installation
8
8
 
@@ -22,7 +22,66 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ in application.js
26
+ ```
27
+ //= require simditor
28
+ ```
29
+
30
+ in application.css
31
+ ```
32
+ *= require simditor
33
+ ```
34
+
35
+ ## Initialization
36
+
37
+ ```javascript
38
+ var editor = new Simditor({
39
+ textarea: $('#question_content'),
40
+ upload: {
41
+ url: '',
42
+ params: {
43
+ // main account or sub account accessKeyId accessKeySecret
44
+ accessKeyId: 'LTAI8vWypOgeFVqA',
45
+ accessKeySecret: 'ghiXS9HQnosR9f9Bw191C7DloNEaDp',
46
+ bucket: 'example',
47
+ region: 'oss-cn-beijing',
48
+
49
+ // sts accessKeyId accessKeySecret
50
+ // region: 'oss-cn-beijing',
51
+ // accessKeyId: 'STS.EHaAs5yC5RtBc7BAEDNLyznui',
52
+ // accessKeySecret: 'HJ6nUeLF71PCv9hpUgM5RkZpzYbtDoq3WqrcX4XMV6YY',
53
+ // stsToken: 'CAIS9QF1q6Ft5B2CfSjIpIvUIcmBlJwU5bapYRHzpUURQsNVlaveizz2IH9JfnBqCegas/QwmGFR7fcTlq9uUIUdHRWcxTOEK38To22beIPkl5Gfz95t0e+IewW6Dxr8w7WhAYHQR8/cffGAck3NkjQJr5LxaTSlWS7OU/TL8+kFCO4aRQ6ldzFLKc5LLw950q8gOGDWKOymP2yB4AOSLjIx51cg1D4itvTgn5TAtkeGtjCglL9J/baWC4O/csxhMK14V9qIx+FsfsLDqnUPtkITrvcu0PEUpmuW54rMUkMp4gWbPuOR6sdoIEpmfKkmFr7+YG5fPi7x0BqAAXKfsK6VgPxxOzF2VZtxlS4clBhR5+LY3RbWlH5we4BNVpuHACb4AqgfLNCnQnrbec7Dh4BDZPmJixhXubiI9+Dptp43eMZigbUxrj8BOR1RtLwUPRmYh3cvDfPcEkLV+yZRLsxKIscg6qMZyQr2dUL42hHNuUDhqw0ZxUartu9T',
54
+ // bucket: 'example',
55
+
56
+ // image prefix
57
+ image_prefix_url: '//prod.example.com/',
58
+ image_prefix_folder: 'questions/',
59
+ },
60
+ fileKey: 'upload_file',
61
+ connectionCount: 3,
62
+ leaveConfirm: 'Uploading is in progress, are you sure to leave this page?'
63
+ }
64
+ //optional options
65
+ });
66
+ ```
67
+
68
+ The params will be passed to the Aliyun OSS JavaScript SDK, and the other configuration is the same as the official version, please check here[http://simditor.tower.im/](http://simditor.tower.im/)
69
+
70
+ The final picture url is image_prefix_url+image_prefix_folder+fileName,example:
71
+
72
+ //prod.example.com/questions/a.jpg
73
+
74
+ image_prefix_url is mainly used for OSS custom domain names, and if the OSS address is not filled in, image_prefix_folder is mainly used to divide the picture catalog according to the business.
75
+
76
+ Aliyun OSS JavaScript SDk is here[https://github.com/ali-sdk/ali-oss?spm=5176.doc32068.2.4.4u5zfu](https://github.com/ali-sdk/ali-oss?spm=5176.doc32068.2.4.4u5zfu)
77
+
78
+ ## Risk
79
+
80
+ //TODO upload failed handle
81
+
82
+ Because SDK uploaded pictures through XHR. Now it has been replaced by Aliyun OSS SDK. It doesn't know how to deal with error handling. Friends who know it trouble us to deal with it. Thank you very much!
83
+
84
+ In vendor/assets/javascripts/simditor/uploader.js line 155.
26
85
 
27
86
  ## Development
28
87
 
@@ -32,4 +91,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
91
 
33
92
  ## Contributing
34
93
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/simditor_aliyun_rails.
94
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ixuea/simditor_aliyun_rails.
@@ -1,7 +1,6 @@
1
1
  require "simditor_aliyun_rails/version"
2
+ require "simditor_aliyun_rails/engine"
2
3
 
3
4
  module SimditorAliyunRails
4
- def self.hi
5
- puts "Hello world!"
6
- end
5
+
7
6
  end
@@ -0,0 +1,7 @@
1
+ module SimditorAliyunRails
2
+ class Engine < ::Rails::Engine
3
+ initializer :assets do |app|
4
+ app.config.assets.precompile += %w( upload-loading.png )
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module SimditorAliyunRails
2
- VERSION = "0.1.0"
2
+ VERSION = "2.3.6"
3
3
  end
Binary file
@@ -0,0 +1,4 @@
1
+ //= require simditor/module
2
+ //= require simditor/hotkeys
3
+ //= require simditor/uploader
4
+ //= require simditor/simditor
@@ -0,0 +1,241 @@
1
+ (function (root, factory) {
2
+ if (typeof define === 'function' && define.amd) {
3
+ // AMD. Register as an anonymous module unless amdModuleId is set
4
+ define('simple-hotkeys', ["jquery","simple-module"], function ($, SimpleModule) {
5
+ return (root['hotkeys'] = factory($, SimpleModule));
6
+ });
7
+ } else if (typeof exports === 'object') {
8
+ // Node. Does not work with strict CommonJS, but
9
+ // only CommonJS-like environments that support module.exports,
10
+ // like Node.
11
+ module.exports = factory(require("jquery"),require("simple-module"));
12
+ } else {
13
+ root.simple = root.simple || {};
14
+ root.simple['hotkeys'] = factory(jQuery,SimpleModule);
15
+ }
16
+ }(this, function ($, SimpleModule) {
17
+
18
+ var Hotkeys, hotkeys,
19
+ extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
20
+ hasProp = {}.hasOwnProperty;
21
+
22
+ Hotkeys = (function(superClass) {
23
+ extend(Hotkeys, superClass);
24
+
25
+ function Hotkeys() {
26
+ return Hotkeys.__super__.constructor.apply(this, arguments);
27
+ }
28
+
29
+ Hotkeys.count = 0;
30
+
31
+ Hotkeys.keyNameMap = {
32
+ 8: "Backspace",
33
+ 9: "Tab",
34
+ 13: "Enter",
35
+ 16: "Shift",
36
+ 17: "Control",
37
+ 18: "Alt",
38
+ 19: "Pause",
39
+ 20: "CapsLock",
40
+ 27: "Esc",
41
+ 32: "Spacebar",
42
+ 33: "PageUp",
43
+ 34: "PageDown",
44
+ 35: "End",
45
+ 36: "Home",
46
+ 37: "Left",
47
+ 38: "Up",
48
+ 39: "Right",
49
+ 40: "Down",
50
+ 45: "Insert",
51
+ 46: "Del",
52
+ 91: "Meta",
53
+ 93: "Meta",
54
+ 48: "0",
55
+ 49: "1",
56
+ 50: "2",
57
+ 51: "3",
58
+ 52: "4",
59
+ 53: "5",
60
+ 54: "6",
61
+ 55: "7",
62
+ 56: "8",
63
+ 57: "9",
64
+ 65: "A",
65
+ 66: "B",
66
+ 67: "C",
67
+ 68: "D",
68
+ 69: "E",
69
+ 70: "F",
70
+ 71: "G",
71
+ 72: "H",
72
+ 73: "I",
73
+ 74: "J",
74
+ 75: "K",
75
+ 76: "L",
76
+ 77: "M",
77
+ 78: "N",
78
+ 79: "O",
79
+ 80: "P",
80
+ 81: "Q",
81
+ 82: "R",
82
+ 83: "S",
83
+ 84: "T",
84
+ 85: "U",
85
+ 86: "V",
86
+ 87: "W",
87
+ 88: "X",
88
+ 89: "Y",
89
+ 90: "Z",
90
+ 96: "0",
91
+ 97: "1",
92
+ 98: "2",
93
+ 99: "3",
94
+ 100: "4",
95
+ 101: "5",
96
+ 102: "6",
97
+ 103: "7",
98
+ 104: "8",
99
+ 105: "9",
100
+ 106: "Multiply",
101
+ 107: "Add",
102
+ 109: "Subtract",
103
+ 110: "Decimal",
104
+ 111: "Divide",
105
+ 112: "F1",
106
+ 113: "F2",
107
+ 114: "F3",
108
+ 115: "F4",
109
+ 116: "F5",
110
+ 117: "F6",
111
+ 118: "F7",
112
+ 119: "F8",
113
+ 120: "F9",
114
+ 121: "F10",
115
+ 122: "F11",
116
+ 123: "F12",
117
+ 124: "F13",
118
+ 125: "F14",
119
+ 126: "F15",
120
+ 127: "F16",
121
+ 128: "F17",
122
+ 129: "F18",
123
+ 130: "F19",
124
+ 131: "F20",
125
+ 132: "F21",
126
+ 133: "F22",
127
+ 134: "F23",
128
+ 135: "F24",
129
+ 59: ";",
130
+ 61: "=",
131
+ 186: ";",
132
+ 187: "=",
133
+ 188: ",",
134
+ 190: ".",
135
+ 191: "/",
136
+ 192: "`",
137
+ 219: "[",
138
+ 220: "\\",
139
+ 221: "]",
140
+ 222: "'"
141
+ };
142
+
143
+ Hotkeys.aliases = {
144
+ "escape": "esc",
145
+ "delete": "del",
146
+ "return": "enter",
147
+ "ctrl": "control",
148
+ "space": "spacebar",
149
+ "ins": "insert",
150
+ "cmd": "meta",
151
+ "command": "meta",
152
+ "wins": "meta",
153
+ "windows": "meta"
154
+ };
155
+
156
+ Hotkeys.normalize = function(shortcut) {
157
+ var i, j, key, keyname, keys, len;
158
+ keys = shortcut.toLowerCase().replace(/\s+/gi, "").split("+");
159
+ for (i = j = 0, len = keys.length; j < len; i = ++j) {
160
+ key = keys[i];
161
+ keys[i] = this.aliases[key] || key;
162
+ }
163
+ keyname = keys.pop();
164
+ keys.sort().push(keyname);
165
+ return keys.join("_");
166
+ };
167
+
168
+ Hotkeys.prototype.opts = {
169
+ el: document
170
+ };
171
+
172
+ Hotkeys.prototype._init = function() {
173
+ this.id = ++this.constructor.count;
174
+ this._map = {};
175
+ this._delegate = typeof this.opts.el === "string" ? document : this.opts.el;
176
+ return $(this._delegate).on("keydown.simple-hotkeys-" + this.id, this.opts.el, (function(_this) {
177
+ return function(e) {
178
+ var ref;
179
+ return (ref = _this._getHander(e)) != null ? ref.call(_this, e) : void 0;
180
+ };
181
+ })(this));
182
+ };
183
+
184
+ Hotkeys.prototype._getHander = function(e) {
185
+ var keyname, shortcut;
186
+ if (!(keyname = this.constructor.keyNameMap[e.which])) {
187
+ return;
188
+ }
189
+ shortcut = "";
190
+ if (e.altKey) {
191
+ shortcut += "alt_";
192
+ }
193
+ if (e.ctrlKey) {
194
+ shortcut += "control_";
195
+ }
196
+ if (e.metaKey) {
197
+ shortcut += "meta_";
198
+ }
199
+ if (e.shiftKey) {
200
+ shortcut += "shift_";
201
+ }
202
+ shortcut += keyname.toLowerCase();
203
+ return this._map[shortcut];
204
+ };
205
+
206
+ Hotkeys.prototype.respondTo = function(subject) {
207
+ if (typeof subject === 'string') {
208
+ return this._map[this.constructor.normalize(subject)] != null;
209
+ } else {
210
+ return this._getHander(subject) != null;
211
+ }
212
+ };
213
+
214
+ Hotkeys.prototype.add = function(shortcut, handler) {
215
+ this._map[this.constructor.normalize(shortcut)] = handler;
216
+ return this;
217
+ };
218
+
219
+ Hotkeys.prototype.remove = function(shortcut) {
220
+ delete this._map[this.constructor.normalize(shortcut)];
221
+ return this;
222
+ };
223
+
224
+ Hotkeys.prototype.destroy = function() {
225
+ $(this._delegate).off(".simple-hotkeys-" + this.id);
226
+ this._map = {};
227
+ return this;
228
+ };
229
+
230
+ return Hotkeys;
231
+
232
+ })(SimpleModule);
233
+
234
+ hotkeys = function(opts) {
235
+ return new Hotkeys(opts);
236
+ };
237
+
238
+ return hotkeys;
239
+
240
+ }));
241
+
@@ -0,0 +1,172 @@
1
+ (function (root, factory) {
2
+ if (typeof define === 'function' && define.amd) {
3
+ // AMD. Register as an anonymous module unless amdModuleId is set
4
+ define('simple-module', ["jquery"], function (a0) {
5
+ return (root['Module'] = factory(a0));
6
+ });
7
+ } else if (typeof exports === 'object') {
8
+ // Node. Does not work with strict CommonJS, but
9
+ // only CommonJS-like environments that support module.exports,
10
+ // like Node.
11
+ module.exports = factory(require("jquery"));
12
+ } else {
13
+ root['SimpleModule'] = factory(jQuery);
14
+ }
15
+ }(this, function ($) {
16
+
17
+ var Module,
18
+ slice = [].slice;
19
+
20
+ Module = (function() {
21
+ Module.extend = function(obj) {
22
+ var key, ref, val;
23
+ if (!((obj != null) && typeof obj === 'object')) {
24
+ return;
25
+ }
26
+ for (key in obj) {
27
+ val = obj[key];
28
+ if (key !== 'included' && key !== 'extended') {
29
+ this[key] = val;
30
+ }
31
+ }
32
+ return (ref = obj.extended) != null ? ref.call(this) : void 0;
33
+ };
34
+
35
+ Module.include = function(obj) {
36
+ var key, ref, val;
37
+ if (!((obj != null) && typeof obj === 'object')) {
38
+ return;
39
+ }
40
+ for (key in obj) {
41
+ val = obj[key];
42
+ if (key !== 'included' && key !== 'extended') {
43
+ this.prototype[key] = val;
44
+ }
45
+ }
46
+ return (ref = obj.included) != null ? ref.call(this) : void 0;
47
+ };
48
+
49
+ Module.connect = function(cls) {
50
+ if (typeof cls !== 'function') {
51
+ return;
52
+ }
53
+ if (!cls.pluginName) {
54
+ throw new Error('Module.connect: cannot connect plugin without pluginName');
55
+ return;
56
+ }
57
+ cls.prototype._connected = true;
58
+ if (!this._connectedClasses) {
59
+ this._connectedClasses = [];
60
+ }
61
+ this._connectedClasses.push(cls);
62
+ if (cls.pluginName) {
63
+ return this[cls.pluginName] = cls;
64
+ }
65
+ };
66
+
67
+ Module.prototype.opts = {};
68
+
69
+ function Module(opts) {
70
+ var base, cls, i, instance, instances, len, name;
71
+ this.opts = $.extend({}, this.opts, opts);
72
+ (base = this.constructor)._connectedClasses || (base._connectedClasses = []);
73
+ instances = (function() {
74
+ var i, len, ref, results;
75
+ ref = this.constructor._connectedClasses;
76
+ results = [];
77
+ for (i = 0, len = ref.length; i < len; i++) {
78
+ cls = ref[i];
79
+ name = cls.pluginName.charAt(0).toLowerCase() + cls.pluginName.slice(1);
80
+ if (cls.prototype._connected) {
81
+ cls.prototype._module = this;
82
+ }
83
+ results.push(this[name] = new cls());
84
+ }
85
+ return results;
86
+ }).call(this);
87
+ if (this._connected) {
88
+ this.opts = $.extend({}, this.opts, this._module.opts);
89
+ } else {
90
+ this._init();
91
+ for (i = 0, len = instances.length; i < len; i++) {
92
+ instance = instances[i];
93
+ if (typeof instance._init === "function") {
94
+ instance._init();
95
+ }
96
+ }
97
+ }
98
+ this.trigger('initialized');
99
+ }
100
+
101
+ Module.prototype._init = function() {};
102
+
103
+ Module.prototype.on = function() {
104
+ var args, ref;
105
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
106
+ (ref = $(this)).on.apply(ref, args);
107
+ return this;
108
+ };
109
+
110
+ Module.prototype.one = function() {
111
+ var args, ref;
112
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
113
+ (ref = $(this)).one.apply(ref, args);
114
+ return this;
115
+ };
116
+
117
+ Module.prototype.off = function() {
118
+ var args, ref;
119
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
120
+ (ref = $(this)).off.apply(ref, args);
121
+ return this;
122
+ };
123
+
124
+ Module.prototype.trigger = function() {
125
+ var args, ref;
126
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
127
+ (ref = $(this)).trigger.apply(ref, args);
128
+ return this;
129
+ };
130
+
131
+ Module.prototype.triggerHandler = function() {
132
+ var args, ref;
133
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
134
+ return (ref = $(this)).triggerHandler.apply(ref, args);
135
+ };
136
+
137
+ Module.prototype._t = function() {
138
+ var args, ref;
139
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
140
+ return (ref = this.constructor)._t.apply(ref, args);
141
+ };
142
+
143
+ Module._t = function() {
144
+ var args, key, ref, result;
145
+ key = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
146
+ result = ((ref = this.i18n[this.locale]) != null ? ref[key] : void 0) || '';
147
+ if (!(args.length > 0)) {
148
+ return result;
149
+ }
150
+ result = result.replace(/([^%]|^)%(?:(\d+)\$)?s/g, function(p0, p, position) {
151
+ if (position) {
152
+ return p + args[parseInt(position) - 1];
153
+ } else {
154
+ return p + args.shift();
155
+ }
156
+ });
157
+ return result.replace(/%%s/g, '%s');
158
+ };
159
+
160
+ Module.i18n = {
161
+ 'zh-CN': {}
162
+ };
163
+
164
+ Module.locale = 'zh-CN';
165
+
166
+ return Module;
167
+
168
+ })();
169
+
170
+ return Module;
171
+
172
+ }));