fossasia/loklak_webclient

View on GitHub
iframely/plugins/domains/500px/500px.com.js

Summary

Maintainability
A
0 mins
Test Coverage
module.exports = {

    re: /^https?:\/\/500px\.com\/photo.+/,

    mixins: [
        "*",
        "og-image-rel-image"
    ],

    getMeta: function(meta) {

        var keywords = meta.five_hundred_pixels.tags;
        if (keywords instanceof Array) {
            keywords = meta.five_hundred_pixels.tags.join(', ');
        }

        return {
            latitude: meta.five_hundred_pixels.location && meta.five_hundred_pixels.location.latitude,
            longitude: meta.five_hundred_pixels.location && meta.five_hundred_pixels.location.longitude,
            category: meta.five_hundred_pixels.category,
            date: meta.five_hundred_pixels.uploaded,
            keywords: keywords
        };
    },

    getLinks: function(url, oembed) {
        if (oembed.type === 'photo') {
            return {
                template_context: {
                    title: oembed.title + ' | ' + oembed.provider_name,
                    img_src: oembed.url,
                    canonical: url
                },
                type: CONFIG.T.text_html,
                rel: [CONFIG.R.image, CONFIG.R.inline, CONFIG.R.html5, CONFIG.R.ssl],
                "aspect-ratio": oembed.width / oembed.height

            }
        }
    },

    tests: [{
        pageWithFeed: "https://500px.com/flow"
    },
        "http://500px.com/photo/13541787?from=upcoming",
        "https://500px.com/photo/56891080/frozen-by-ryan-pendleton?ctx_page=1&from=user&user_id=116369"
    ]
};