Skip to content
Snippets Groups Projects
Commit 96c78906 authored by Gabriel Engel's avatar Gabriel Engel
Browse files

OEmbed

parent e9a17fbd
No related branches found
No related tags found
No related merge requests found
......@@ -81,6 +81,15 @@ q {
border-radius: 0px;
}
.iframely-oembed {
margin: 0;
clear: both;
max-width: 400px;
font {
display: none;
}
}
.alert {
padding: 15px;
margin-bottom: 20px;
......@@ -1407,7 +1416,6 @@ a.github-fork {
> div {
display: table-cell;
vertical-align: middle;
padding-top: 4px;
}
h2 {
max-width: 90%;
......
......@@ -43,6 +43,11 @@
{{/if}}
<div dir="auto">
{{{renderMessage}}}
{{#if urls}}
{{#each urls}}
{{> oembed url=this}}
{{/each}}
{{/if}}
</div>
{{/if}}
{{/if}}
......
###
# ObjEmbedder is a temporary image and map embedder for bots development
# OEmbed is a temporary image and map embedder for bots development
# @param {Object} msg - The message object
# to be replaced by proper implementation in 1.0
###
class ObjEmbedder
# IframelyOembed.setEndpoint 'http://open.iframe.ly/api/oembed?api_key=' + Meteor.settings.public?.iframelyApiKey?
IframelyOembed.setCacheOptions
cacheTTL: 1000 * 60 * 60, # Hour.
cacheErrorTTL: 1000 * 60, # Minute.
cacheEnabled: true
class OEmbed
constructor: (message) ->
console.log "ObjEmbedder constructor" if window.rocketDebug
console.log "OEmbed constructor" if window.rocketDebug
message.urls?.forEach (url) ->
console.log "OEmbed iframely.oembed", url if window.rocketDebug
Meteor.call 'iframely.oembed', url, (error, data) =>
console.log "OEmbed iframely.oembed callback", error, data if window.rocketDebug
if _.trim data.html
message.html = message.html + data.html
if _.trim message.msg
console.log "ObjEmbedder trim" if window.rocketDebug
# if _.trim message.msg
picmatch = message.msg.match(/^https?:\/\/(?:[a-z0-9\-]+\.)+[a-z0-9]{2,6}(?:\/[^\/#?]+)+\.(?:jpe?g|gif|png)$/i)
if picmatch?
# inline style to limit code pollution
console.log "ObjEmbedder picmatch" if window.rocketDebug
message.html = "<img style='width:400px;height:auto;' src='" + message.msg + "'></img>"
# picmatch = message.msg.match(/^https?:\/\/(?:[a-z0-9\-]+\.)+[a-z0-9]{2,6}(?:\/[^\/#?]+)+\.(?:jpe?g|gif|png)$/i)
# if picmatch?
# # inline style to limit code pollution
# console.log "OEmbed picmatch" if window.rocketDebug
# message.html = "<img style='width:400px;height:auto;' src='" + message.msg + "'></img>"
else
mapmatch = message.msg.match(/^https?\:\/\/maps\.(google|googleapis)\.[a-z]+\/maps\/api.*format=png$/i)
if mapmatch?
console.log "ObjEmbedder mapmatch" if window.rocketDebug
message.html = "<img style='width:400px;height:auto;' src='" + message.msg + "'></img>"
# else
# mapmatch = message.msg.match(/^https?\:\/\/maps\.(google|googleapis)\.[a-z]+\/maps\/api.*format=png$/i)
# if mapmatch?
# console.log "OEmbed mapmatch" if window.rocketDebug
# message.html = "<img style='width:400px;height:auto;' src='" + message.msg + "'></img>"
# end of temporary pre-1.0 image embed
return message
RocketChat.callbacks.add 'renderMessage', ObjEmbedder, RocketChat.callbacks.priority.HIGH
# RocketChat.callbacks.add 'renderMessage', OEmbed, RocketChat.callbacks.priority.HIGH
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment