embeditor-rails 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +24 -3
- data/app/assets/javascripts/embeditor/adapter.js.coffee +47 -15
- data/app/assets/javascripts/embeditor/adapters/embedly.js.coffee +13 -3
- data/app/assets/javascripts/embeditor/adapters/google_fusion.js.coffee +16 -0
- data/app/assets/javascripts/embeditor/embeditor.js.coffee +14 -4
- data/app/assets/javascripts/embeditor/templates/google_fusion.jst.eco +1 -0
- data/lib/embeditor-rails/version.rb +1 -1
- metadata +21 -3
data/README.md
CHANGED
@@ -15,8 +15,11 @@ gem 'embeditor'
|
|
15
15
|
|
16
16
|
## Dependencies
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
The following dependencies must be included manually. I hope to remove these
|
19
|
+
eventually.
|
20
|
+
|
21
|
+
* [jQuery](http://jquery.com/)
|
22
|
+
* [underscore.js](http://underscorejs.org/)
|
20
23
|
|
21
24
|
|
22
25
|
## Usage
|
@@ -134,7 +137,12 @@ endpoint:
|
|
134
137
|
When initializing the global `Embeditor.Base` object, you may specify
|
135
138
|
configuration for individual adapters.
|
136
139
|
|
137
|
-
The `plugin` object is for configuring the adapter.
|
140
|
+
The `plugin` object is for configuring the adapter. The properties depends on
|
141
|
+
the adapter.
|
142
|
+
|
143
|
+
The `display` object is for configuring display options. Properties:
|
144
|
+
* `placement` - the method to use for placing the embed, such as
|
145
|
+
`before`, `after`, or `replace`. Default is `after`.
|
138
146
|
|
139
147
|
The `query` object is for configuring the query parameters, or in the case of
|
140
148
|
an adapter which doesn't use a query, it's for configuring the embed properties.
|
@@ -154,6 +162,9 @@ new Embeditor.Base({
|
|
154
162
|
FireTracker: {
|
155
163
|
query: {
|
156
164
|
maxheight: 350
|
165
|
+
},
|
166
|
+
display: {
|
167
|
+
placement: 'replaceWith'
|
157
168
|
}
|
158
169
|
},
|
159
170
|
CoverItLive: {
|
@@ -187,6 +198,9 @@ class Embeditor.Adapters.Twitter extends Embeditor.Adapter
|
|
187
198
|
@QueryDefaults =
|
188
199
|
maxheight: 500
|
189
200
|
|
201
|
+
@DisplayDefaults =
|
202
|
+
placement: 'before'
|
203
|
+
|
190
204
|
# ...
|
191
205
|
```
|
192
206
|
|
@@ -222,6 +236,11 @@ This eliminates any oEmbed headaches (Access-Control-Allowed-Origin, for
|
|
222
236
|
example), and also reduces the time it takes for an embed to load.
|
223
237
|
|
224
238
|
|
239
|
+
## CKEditor plugin
|
240
|
+
|
241
|
+
An unofficial CKEditor plugin can be found [HERE](https://github.com/SCPR/SCPRv4/blob/master/vendor/assets/javascripts/ckeditor/plugins/embed-placeholder/plugin.js).
|
242
|
+
Copy and paste it into your own repository.
|
243
|
+
|
225
244
|
|
226
245
|
## Extending
|
227
246
|
|
@@ -236,6 +255,8 @@ You can extend your adapter from:
|
|
236
255
|
* `Embeditor.Adapters.StaticTemplate`, for embeds where the embed code is
|
237
256
|
stored in the `/templates` directory and rendered with JST.
|
238
257
|
|
258
|
+
**NOTE** Any function beginning with an underscore, like `_extractData()`,
|
259
|
+
should be considered a private function.
|
239
260
|
|
240
261
|
## Known Issues
|
241
262
|
|
@@ -6,33 +6,51 @@ class Embeditor.Adapter
|
|
6
6
|
|
7
7
|
@QueryDefaults = {}
|
8
8
|
|
9
|
+
@DisplayDefaults =
|
10
|
+
placement : 'after'
|
11
|
+
|
12
|
+
|
9
13
|
constructor: (@element, @options={}) ->
|
10
|
-
@adapter
|
11
|
-
@href
|
12
|
-
@
|
13
|
-
|
14
|
+
@adapter = Embeditor.Adapters[@className]
|
15
|
+
@href = @element.attr('href')
|
16
|
+
@wrapper = $("<div />", class: @options.wrapperClass)
|
17
|
+
|
18
|
+
displayData = @_extractData('DisplayDefaults')
|
19
|
+
@display = @_buildDisplayOptions(displayData)
|
14
20
|
|
15
|
-
|
21
|
+
queryData = @_extractData('QueryDefaults')
|
22
|
+
@dataOptions = queryData # Deprecated
|
23
|
+
@queryParams = @_buildQueryParams(queryData)
|
16
24
|
|
17
25
|
|
26
|
+
# @Override
|
18
27
|
swap: ->
|
19
28
|
return
|
20
29
|
|
21
30
|
|
22
31
|
embed: (html) ->
|
23
32
|
@wrapper.html(html)
|
24
|
-
@element.
|
33
|
+
@element[Embeditor.PlacementFunctions[@display.placement]](@wrapper)
|
25
34
|
|
26
35
|
|
27
|
-
|
28
|
-
|
36
|
+
|
37
|
+
_extractData: (defaults) ->
|
38
|
+
data = {}
|
29
39
|
|
30
40
|
for key,val of @element.data()
|
31
41
|
# Make sure we care about this attribute
|
32
|
-
if @adapter
|
33
|
-
|
42
|
+
if @adapter[defaults]?[key]
|
43
|
+
data[key] = val
|
44
|
+
|
45
|
+
data
|
34
46
|
|
35
|
-
|
47
|
+
|
48
|
+
_buildDisplayOptions: (data) ->
|
49
|
+
@_defaultsWithoutEmptyStrings(data, # What the user wants
|
50
|
+
@options[@adapter]?['display'], # What the developer wants
|
51
|
+
@options['display'], # What the developer wants globally
|
52
|
+
@adapter.DisplayDefaults # What Embeditor wants
|
53
|
+
)
|
36
54
|
|
37
55
|
|
38
56
|
# We're combining a few things (in order of precedence):
|
@@ -41,9 +59,23 @@ class Embeditor.Adapter
|
|
41
59
|
# initialization,
|
42
60
|
# 3. The global options specified at Embeditor initialization,
|
43
61
|
# 4. This adapter's default options (fallback options).
|
44
|
-
|
45
|
-
|
46
|
-
@adapter
|
47
|
-
options['query'],
|
62
|
+
_buildQueryParams: (data) ->
|
63
|
+
@_defaultsWithoutEmptyStrings(data,
|
64
|
+
@options[@adapter]?['query'],
|
65
|
+
@options['query'],
|
48
66
|
@adapter.QueryDefaults
|
49
67
|
)
|
68
|
+
|
69
|
+
# Like Underscore.defaults, but it will also fill in empty strings.
|
70
|
+
# This should be used when merging objects that including any user
|
71
|
+
# input.
|
72
|
+
_defaultsWithoutEmptyStrings: (obj) ->
|
73
|
+
args = Array.prototype.slice.call(arguments, 1)
|
74
|
+
|
75
|
+
for source in args
|
76
|
+
continue if !source
|
77
|
+
|
78
|
+
for prop,value of source
|
79
|
+
obj[prop] = source[prop] if !obj[prop]
|
80
|
+
|
81
|
+
obj
|
@@ -3,6 +3,12 @@
|
|
3
3
|
class Embeditor.Adapters.Embedly extends Embeditor.Adapter
|
4
4
|
className: "Embedly"
|
5
5
|
|
6
|
+
# Map `data-placement` to Embedly `method` parameter options.
|
7
|
+
@MethodMap =
|
8
|
+
replace : 'replace'
|
9
|
+
before : 'before'
|
10
|
+
after : 'after'
|
11
|
+
|
6
12
|
# This object should hold any keys that we want to
|
7
13
|
# send to the API. Any key not in this object will
|
8
14
|
# be ignored as a data attribute.
|
@@ -10,14 +16,14 @@ class Embeditor.Adapters.Embedly extends Embeditor.Adapter
|
|
10
16
|
maxheight : 450
|
11
17
|
|
12
18
|
@PluginDefaults =
|
13
|
-
method :
|
19
|
+
method : 'after'
|
14
20
|
className : Embeditor.DefaultOptions.wrapperClass
|
15
21
|
endpoint : 'oembed'
|
16
22
|
# Key must be specified
|
17
23
|
|
18
24
|
|
19
25
|
constructor: (@element, @options={}) ->
|
20
|
-
pluginOpts = options['Embedly']?['plugin']
|
26
|
+
pluginOpts = @options['Embedly']?['plugin']
|
21
27
|
@pluginOptions = _.defaults(pluginOpts, Embedly.PluginDefaults)
|
22
28
|
|
23
29
|
super
|
@@ -25,6 +31,7 @@ class Embeditor.Adapters.Embedly extends Embeditor.Adapter
|
|
25
31
|
|
26
32
|
swap: ->
|
27
33
|
params = @_buildEmbedlyParams()
|
34
|
+
console.log params
|
28
35
|
@element.embedly(params)
|
29
36
|
|
30
37
|
|
@@ -32,6 +39,9 @@ class Embeditor.Adapters.Embedly extends Embeditor.Adapter
|
|
32
39
|
if @embedlyParams
|
33
40
|
return @embedlyParams
|
34
41
|
|
42
|
+
# Use `data-placement` as the embedly method parameter
|
35
43
|
@embedlyParams = _.extend(
|
36
|
-
|
44
|
+
_.defaults({
|
45
|
+
method : Embedly.MethodMap[@display.placement]
|
46
|
+
}, @pluginOptions),
|
37
47
|
query : @queryParams)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Embeditor.Adapters.GoogleFusion extends Embeditor.Adapters.StaticTemplate
|
2
|
+
className: "GoogleFusion"
|
3
|
+
|
4
|
+
@Template = Embeditor.Template('google_fusion')
|
5
|
+
|
6
|
+
@QueryDefaults =
|
7
|
+
maxwidth : 620
|
8
|
+
maxheight : 550
|
9
|
+
|
10
|
+
@Matchers = []
|
11
|
+
|
12
|
+
swap: ->
|
13
|
+
@embed GoogleFusion.Template
|
14
|
+
maxheight : @queryParams.maxheight
|
15
|
+
maxwidth : @queryParams.maxwidth
|
16
|
+
url : @href
|
@@ -9,6 +9,7 @@ window.Embeditor = {
|
|
9
9
|
'livestream' : 'Embedly'
|
10
10
|
'vine' : 'Embedly'
|
11
11
|
'googlemaps' : 'Embedly'
|
12
|
+
'googlefusion' : 'GoogleFusion'
|
12
13
|
'scribd' : 'Embedly'
|
13
14
|
# 'documentcloud' : 'DocumentCloud'
|
14
15
|
'polldaddy' : 'Polldaddy'
|
@@ -29,10 +30,19 @@ window.Embeditor = {
|
|
29
30
|
JST[@TemplatePath + template]
|
30
31
|
|
31
32
|
DefaultOptions :
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
# Adapter that gets used when the service isn't recognized
|
34
|
+
defaultAdapter : 'Embedly'
|
35
|
+
# Service that gets used when the `data-service` attribute is missing
|
36
|
+
defaultService : 'other'
|
37
|
+
# The class that the embed placeholders have
|
38
|
+
placeholderClass : "embed-placeholder"
|
39
|
+
# The class the embed's wrapper should be given
|
40
|
+
wrapperClass : "embed-wrapper"
|
41
|
+
|
42
|
+
PlacementFunctions :
|
43
|
+
before : 'before'
|
44
|
+
after : 'after'
|
45
|
+
replace : 'replaceWith'
|
36
46
|
}
|
37
47
|
|
38
48
|
|
@@ -0,0 +1 @@
|
|
1
|
+
<iframe width="<%=@maxwidth%>" height="<%=@maxheight%>" scrolling="no" frameborder="no" src="<%=@url%>"></iframe>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embeditor-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,10 +9,26 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: actionpack
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: coffee-rails
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
17
33
|
none: false
|
18
34
|
requirements:
|
@@ -74,6 +90,7 @@ files:
|
|
74
90
|
- app/assets/javascripts/embeditor/adapters/document_cloud.js.coffee
|
75
91
|
- app/assets/javascripts/embeditor/adapters/embedly.js.coffee
|
76
92
|
- app/assets/javascripts/embeditor/adapters/fire_tracker.js.coffee
|
93
|
+
- app/assets/javascripts/embeditor/adapters/google_fusion.js.coffee
|
77
94
|
- app/assets/javascripts/embeditor/adapters/instagram.js.coffee
|
78
95
|
- app/assets/javascripts/embeditor/adapters/oembed.js.coffee
|
79
96
|
- app/assets/javascripts/embeditor/adapters/polldaddy.js.coffee
|
@@ -85,6 +102,7 @@ files:
|
|
85
102
|
- app/assets/javascripts/embeditor/embeditor.js.coffee
|
86
103
|
- app/assets/javascripts/embeditor/templates/brightcove.jst.eco
|
87
104
|
- app/assets/javascripts/embeditor/templates/cover_it_live.jst.eco
|
105
|
+
- app/assets/javascripts/embeditor/templates/google_fusion.jst.eco
|
88
106
|
- app/assets/javascripts/embeditor/templates/instagram.jst.eco
|
89
107
|
- app/assets/javascripts/embeditor/templates/polldaddy_poll.jst.eco
|
90
108
|
- app/assets/javascripts/embeditor/templates/polldaddy_survey.jst.eco
|