Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
facebookHref: Ember.computed('model', function() {
const queryParams = {
app_id: config.FB_APP_ID,
display: 'popup',
href: window.location.href,
redirect_uri: window.location.href
};
return `https://www.facebook.com/dialog/share?${queryStringify(queryParams)}`;
}),
// https://developer.linkedin.com/docs/share-on-linkedin
return preprint.get('node').then(node => {
this.set('node', node);
if (this.get('editMode')) {
let userPermissions = this.get('node.currentUserPermissions') || [];
if (userPermissions.indexOf(permissions.ADMIN) === -1) {
this.replaceWith('forbidden'); // Non-admin trying to access edit form.
}
}
const {origin} = window.location;
const image = this.get('theme.logoSharing');
const imageUrl = `${origin.replace(/^https/, 'http')}${image.path}`;
const ogp = [
['fb:app_id', config.FB_APP_ID],
['og:title', node.get('title')],
['og:image', imageUrl],
['og:image:secure_url', `${origin}${image.path}`], // We should always be on https in staging/prod
['og:image:width', image.width.toString()],
['og:image:height', image.height.toString()],
['og:image:type', image.type],
['og:url', window.location.href],
['og:description', node.get('description')],
['og:site_name', this.get('theme.provider.name')],
['og:type', 'article'],
['article:published_time', preprint.get('datePublished').toISOString()],
];
const modified = preprint.get('dateModified') || preprint.get('dateCreated');
if (modified)
getMetaTags(this: MetaTags, metaTagsOverrides: MetaTagsData): MetaTagsDefs {
// Default values.
const metaTagsData: MetaTagsData = {
type: 'article',
description: this.get('i18n').t('general.hosted_on_the_osf'),
url: pathJoin(config.OSF.url, this.get('router').get('currentURL')),
language: this.get('i18n').get('locale'),
image: pathJoin(config.OSF.url, 'static/img/preprints_assets/osf/sharing.png'),
imageType: 'image/png',
imageWidth: 1200,
imageHeight: 630,
imageAlt: this.get('i18n').t('home.brand'),
siteName: this.get('i18n').t('home.brand'),
institution: this.get('i18n').t('general.cos'),
fbAppId: config.FB_APP_ID,
twitterSite: config.social.twitter.viaHandle,
twitterCreator: config.social.twitter.viaHandle,
...metaTagsOverrides,
};
// Include URL, DOI, and any additional identifiers.
const identifiers = toArray(metaTagsData.url)
.concat(toArray(metaTagsData.doi))
.concat(toArray(metaTagsData.identifier));
return {
// Citation
citation_title: metaTagsData.title,
citation_doi: metaTagsData.doi,
citation_publisher: metaTagsData.siteName,
citation_author_institution: metaTagsData.institution,
const description = node.get('description');
const doi = preprint.get('doi');
const image = this.get('theme.logoSharing');
const imageUrl = `${origin.replace(/^https/, 'http')}${image.path}`;
const dateCreated = new Date(preprint.get('dateCreated') || null);
const dateModified = new Date(preprint.get('dateModified') || dateCreated);
if (!preprint.get('datePublished'))
preprint.set('datePublished', dateCreated);
const providerName = provider.get('name');
const canonicalUrl = preprint.get('links.html');
// NOTE: Ordering of meta tags matters for scrapers (Facebook, LinkedIn, Google, etc)
// Open Graph Protocol
const openGraph = [
['fb:app_id', config.FB_APP_ID],
['og:title', title],
['og:image', imageUrl],
['og:image:secure_url', `${origin}${image.path}`], // We should always be on https in staging/prod
['og:image:width', image.width.toString()],
['og:image:height', image.height.toString()],
['og:image:type', image.type],
['og:url', canonicalUrl],
['og:description', description],
['og:site_name', providerName],
['og:type', 'article'],
['article:published_time', dateCreated.toISOString()],
['article:modified_time', dateModified.toISOString()]
];
// Highwire Press
const highwirePress = [
import Component from '@ember/component';
import config from 'ember-get-config';
import { layout } from 'ember-osf-web/decorators/component';
import param from 'ember-osf-web/utils/param';
import template from './template';
@layout(template)
export default class SharingIcons extends Component {
// optional arguments
title!: string;
hyperlink!: string;
description?: string;
resultId?: string;
parentId?: string;
facebookAppId?: string = config.FB_APP_ID || '';
@computed('hyperlink', 'title')
get twitterHref(this: SharingIcons): string {
const queryParams = {
url: this.hyperlink,
text: this.title,
via: config.social.twitter.viaHandle,
};
return `https://twitter.com/intent/tweet?${param(queryParams)}`;
}
@computed('hyperlink', 'facebookAppId')
get facebookHref(this: SharingIcons): string | null {
if (!this.facebookAppId) {
return null;
}
facebookAppId: computed('model', function() {
return this.get('model.provider.facebookAppId') ? this.get('model.provider.facebookAppId') : config.FB_APP_ID;
}),
supplementalMaterialDisplayLink: computed('node.links.html', function() {