Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve layout of oembed url and add omebeds to the end of the messag… #668

Merged
merged 1 commit into from
Sep 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions client/stylesheets/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ blockquote {
position: relative;
&:before {
content: ' ';
background-color: #ccc;
background-color: #eaeaea;
height: 100%;
width: 3px;
width: 4px;
position: absolute;
left: 0px;
border-radius: 10px;
}
}

Expand Down
2 changes: 1 addition & 1 deletion client/views/app/message.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Template.message.onViewRendered = (context) ->
do (item) ->
urlNode = lastNode.querySelector('.body a[href="'+item.url+'"]')
if urlNode?
$(urlNode).replaceWith Blaze.toHTMLWithData Template.oembedBaseWidget, item
$(lastNode.querySelector('.body')).append Blaze.toHTMLWithData Template.oembedBaseWidget, item

if not lastNode.nextElementSibling?
if lastNode.classList.contains('own') is true
Expand Down
36 changes: 23 additions & 13 deletions packages/rocketchat-oembed/client/oembedUrlWidget.coffee
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
Template.oembedUrlWidget.helpers
description: ->
if not this.meta?
return
getTitle = (self) ->
if not self.meta?
return

description = this.meta.ogDescription or this.meta.twitterDescription or this.meta.description
if not description?
return
return self.meta.ogTitle or self.meta.twitterTitle or self.meta.title or self.meta.pageTitle

return description.replace /(^“)|(”$)/g, ''
getDescription = (self) ->
if not self.meta?
return

title: ->
if not this.meta?
return
description = self.meta.ogDescription or self.meta.twitterDescription or self.meta.description
if not description?
return

return this.meta.ogTitle or this.meta.twitterTitle or this.meta.title or this.meta.pageTitle
return description.replace /(^“)|(”$)/g, ''


Template.oembedUrlWidget.helpers
description: ->
return getDescription this

title: ->
return getTitle this

image: ->
if not this.meta?
return

return this.meta.ogImage or this.meta.twitterImage
return this.meta.ogImage or this.meta.twitterImage

show: ->
return getDescription(this)? or getTitle(this)?
11 changes: 5 additions & 6 deletions packages/rocketchat-oembed/client/oembedUrlWidget.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<template name="oembedUrlWidget">
<a href="{{url}}" target="_blank">{{url}}</a>
{{#if parsedUrl}}
{{#if show}}
<blockquote>
<a href="{{url}}" target="_blank">{{parsedUrl.host}}</a>
<div style="{{#if image}}min-height: 60px;{{/if}}">
<div style="{{#if image}}min-height: 60px;{{/if}} padding: 10px 3px;">
{{#if image}}
{{#if meta.ogImageUserGenerated}}
<div>
Expand All @@ -13,13 +11,14 @@
</div>
{{else}}
<a href="{{url}}" target="_blank">
<img src="{{image}}" height="60" align="left" style="margin-right: 5px;"/>
<img src="{{image}}" height="60" align="left" style="margin-right: 10px;"/>
</a>
{{/if}}
{{/if}}
<div style="color: #AAA;">{{parsedUrl.host}}</div>
{{#if title}}
<div>
<strong>{{title}}</strong>
<a href="{{url}}" target="_blank"><strong>{{title}}</strong></a>
</div>
{{/if}}
{{{description}}}
Expand Down