3 var env
= require('gitter-web-env');
4 var nconf
= env
.config
;
5 var avatars
= require('gitter-web-avatars');
6 const truncateText
= require('gitter-web-shared/truncate-text');
8 var facebookAppId
= nconf
.get('facebook:appId');
10 function getMetadata(options
) {
11 var room
= options
&& options
.room
;
13 var title
= (room
&& room
.uri
) || 'Gitter';
14 var description
= (room
&& room
.topic
) || 'Where developers come to talk.';
15 var imageUrl
= (room
&& room
.avatarUrl
) || avatars
.getDefault();
19 'og:description': description
,
22 'fb:app_id': facebookAppId
,
23 'twitter:card': 'summary',
24 'twitter:site': '@gitchat',
25 'twitter:title': truncateText(title
, 70),
26 'twitter:description': truncateText(description
, 200),
27 'twitter:image': imageUrl
31 function getMetadataForChatPermalink(options
) {
32 var room
= options
&& options
.room
;
33 var chat
= options
&& options
.chat
;
35 if (!chat
|| !chat
.fromUser
) return getMetadata(options
);
37 var fromUser
= chat
.fromUser
;
39 var title
= (room
&& room
.uri
) || 'Gitter';
40 var description
= '@' + fromUser
.username
+ ': ' + chat
.text
;
41 var imageUrl
= (room
&& room
.avatarUrl
) || avatars
.getDefault();
45 'og:description': description
,
48 'fb:app_id': facebookAppId
,
49 'twitter:card': 'summary',
50 'twitter:site': '@gitchat',
51 'twitter:title': truncateText(title
, 70),
52 'twitter:description': truncateText(description
, 200),
53 'twitter:image': imageUrl
58 getMetadata
: getMetadata
,
59 getMetadataForChatPermalink
: getMetadataForChatPermalink