Add Facebook Open Graph

This commit is contained in:
Jonathan Cremin 2014-12-06 14:42:01 +00:00
parent 90c59078c0
commit 01c7f418dc
2 changed files with 17 additions and 6 deletions

View file

@ -26,7 +26,12 @@ module.exports = function(req, res, next) {
req.db.matches.findOne({_id:serviceId + itemId}).then(function(doc) {
if (doc) {
res.render(type, {page: type, title: doc.items[0].name + " by " + doc.items[0].artist.name, item: doc.items[0], items: doc.items});
res.render(type, {
page: type,
title: doc.items[0].name + " by " + doc.items[0].artist.name,
items: doc.items,
thisUrl: req.protocol + '://' + req.get('host') + req.originalUrl
});
} else {
Q.timeout(services[serviceId].lookupId(itemId, type), 5000).then(function(item) {
for (var id in services) {
@ -54,7 +59,12 @@ module.exports = function(req, res, next) {
items.unshift(item);
req.db.matches.save({_id:serviceId + itemId, items:items});
res.render(type, {page: type, title: item.name + " by " + item.artist.name, item: item, items: items});
res.render(type, {
page: type,
title: item.name + " by " + item.artist.name,
items: items,
thisUrl: req.protocol + '://' + req.get('host') + req.originalUrl
});
});
}, function(error) {
if (error.code == "ETIMEDOUT") {

View file

@ -6,12 +6,13 @@
<title><% if (locals.title) { %><%= title %> - <% } %>Match Audio</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<% if (locals.item) { %>
<% if (locals.items) { var item = items[0] %>
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@MatchAudio">
<meta name="twitter:title" content="<%= item.name + " by " + item.artist.name %>">
<meta name="twitter:description" content="We've matched this music on Rdio, Spotify, Deezer, Beats Music, Google Music and iTunes so you can open it in the service you use" />
<meta name="twitter:image" content="<%= item.artwork %>" />
<meta name="twitter:title" property="og:title" content="<%= item.name + " by " + item.artist.name %>">
<meta name="twitter:description" property="og:description" content="We've matched this music on Rdio, Spotify, Deezer, Beats Music, Google Music and iTunes so you can open it in the service you use." />
<meta name="twitter:image" property="og:image" content="<%= item.artwork %>" />
<meta property="og:url" content="<%= thisUrl %>" />
<% } %>
<link rel="shortcut icon" href="/images/favicon.png">
<link href='//fonts.googleapis.com/css?family=Open+Sans:400,300,700' rel='stylesheet' type='text/css'>