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

Allows multiple shareIt button sets, for different URL's #52

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
28 changes: 20 additions & 8 deletions client/views/facebook/facebook.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,30 @@ Template.shareit_facebook.rendered = ->
@autorun ->
template = Template.instance()
data = Template.currentData()

$('meta[property^="og:"]').remove()
# console.log(data)

noMeta=data.url && (data.url!=(location.origin + location.pathname))
# console.log(data.url)
# console.log((location.origin + location.pathname))
if not noMeta
$('meta[property^="og:"]').remove()
#
# OpenGraph tags
#
description = data.facebook?.description || data.excerpt || data.description || data.summary
url = data.url || location.origin + location.pathname
title = data.title
$('<meta>', { property: 'og:type', content: 'article' }).appendTo 'head'
$('<meta>', { property: 'og:site_name', content: location.hostname }).appendTo 'head'
$('<meta>', { property: 'og:url', content: url }).appendTo 'head'
$('<meta>', { property: 'og:title', content: title }).appendTo 'head'
$('<meta>', { property: 'og:description', content: description }).appendTo 'head'

if not noMeta
$('<meta>', { property: 'og:type', content: 'article' }).appendTo 'head'
if not noMeta
$('<meta>', { property: 'og:site_name', content: location.hostname }).appendTo 'head'
if not noMeta
$('<meta>', { property: 'og:url', content: url }).appendTo 'head'
if not noMeta
$('<meta>', { property: 'og:title', content: title }).appendTo 'head'
if not noMeta
$('<meta>', { property: 'og:description', content: description }).appendTo 'head'

if data.thumbnail
if typeof data.thumbnail == "function"
Expand All @@ -27,7 +38,8 @@ Template.shareit_facebook.rendered = ->
if not /^http(s?):\/\/+/.test(img)
img = location.origin + img

$('<meta>', { property: 'og:image', content: img }).appendTo 'head'
if not noMeta
$('<meta>', { property: 'og:image', content: img }).appendTo 'head'

if ShareIt.settings.sites.facebook.appId?
template.$('.fb-share').click (e) ->
Expand Down
20 changes: 14 additions & 6 deletions client/views/googleplus/googleplus.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ Template.shareit_googleplus.rendered = () ->
@autorun ->
template = Template.instance()
data = Template.currentData()
$('meta[itemscope]').remove()
noMeta=data.url && (data.url!=(location.origin + location.pathname))

if not noMeta
$('meta[itemscope]').remove()

#
# Schema tags
Expand All @@ -13,10 +16,14 @@ Template.shareit_googleplus.rendered = () ->
url = data.url || location.origin + location.pathname
title = data.title
itemtype = data.googleplus?.itemtype || 'Article'
$('html').attr('itemscope', '').attr('itemtype', "http://schema.org/#{itemtype}")
$('<meta>', { itemprop: 'name', content: location.hostname }).appendTo 'head'
$('<meta>', { itemprop: 'url', content: url }).appendTo 'head'
$('<meta>', { itemprop: 'description', content: description }).appendTo 'head'
if not noMeta
$('html').attr('itemscope', '').attr('itemtype', "http://schema.org/#{itemtype}")
if not noMeta
$('<meta>', { itemprop: 'name', content: location.hostname }).appendTo 'head'
if not noMeta
$('<meta>', { itemprop: 'url', content: url }).appendTo 'head'
if not noMeta
$('<meta>', { itemprop: 'description', content: description }).appendTo 'head'

if data.thumbnail
if typeof data.thumbnail == "function"
Expand All @@ -27,7 +34,8 @@ Template.shareit_googleplus.rendered = () ->
if not /^http(s?):\/\/+/.test(img)
img = location.origin + img

$('<meta>', { itemprop: 'image', content: img }).appendTo 'head'
if not noMeta
$('<meta>', { itemprop: 'image', content: img }).appendTo 'head'
#
# Google share button
#
Expand Down
1 change: 1 addition & 0 deletions client/views/pinterest/pinterest.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Template.shareit_pinterest.rendered = ->
@autorun ->
template = Template.instance()
data = Template.currentData()
noMeta=data.url && (data.url!=(location.origin + location.pathname))

preferred_url = data.url || location.origin + location.pathname
url = encodeURIComponent preferred_url
Expand Down
23 changes: 16 additions & 7 deletions client/views/twitter/twitter.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ Template.shareit_twitter.rendered = ->
@autorun ->
template = Template.instance()
data = Template.currentData()
$('meta[property^="twitter:"]').remove()
noMeta=data.url && (data.url!=(location.origin + location.pathname))

if not noMeta
$('meta[property^="twitter:"]').remove()

if data.thumbnail
if typeof data.thumbnail == "function"
Expand All @@ -19,18 +22,24 @@ Template.shareit_twitter.rendered = ->
# Twitter cards
#

$('<meta>', { property: 'twitter:card', content: 'summary' }).appendTo 'head'
if not noMeta
$('<meta>', { property: 'twitter:card', content: 'summary' }).appendTo 'head'
# What should go here?
#$('<meta>', { property: 'twitter:site', content: '' }).appendTo 'head'

if data.author
$('<meta>', { property: 'twitter:creator', content: data.author }).appendTo 'head'
if not noMeta
$('<meta>', { property: 'twitter:creator', content: data.author }).appendTo 'head'

description = data.twitter?.description || data.excerpt || data.description || data.summary
$('<meta>', { property: 'twitter:url', content: location.origin + location.pathname }).appendTo 'head'
$('<meta>', { property: 'twitter:title', content: "#{data.title}" }).appendTo 'head'
$('<meta>', { property: 'twitter:description', content: description }).appendTo 'head'
$('<meta>', { property: 'twitter:image', content: img }).appendTo 'head'
if not noMeta
$('<meta>', { property: 'twitter:url', content: location.origin + location.pathname }).appendTo 'head'
if not noMeta
$('<meta>', { property: 'twitter:title', content: "#{data.title}" }).appendTo 'head'
if not noMeta
$('<meta>', { property: 'twitter:description', content: description }).appendTo 'head'
if not noMeta
$('<meta>', { property: 'twitter:image', content: img }).appendTo 'head'

#
# Twitter share button
Expand Down
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Package.describe({

Package.onUse(function(api) {
api.versionsFrom("[email protected]");
api.use(['coffeescript', 'less', 'templating', 'underscore', 'jquery'], 'client');
api.use(['coffeescript', 'less@2.5.0_1', 'templating', 'underscore', 'jquery'], 'client');
api.use(['fortawesome:[email protected]'], 'client');

api.imply('spiderable', ['client', 'server']);
Expand Down
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
],
[
"less",
"1.0.11"
"2.5.0_1"
],
[
"logging",
Expand Down