<commit_before>/*!
 * Copyright 2014 Apereo Foundation (AF) Licensed under the
 * Educational Community License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may
 * obtain a copy of the License at
 *
 *     http://opensource.org/licenses/ECL-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an "AS IS"
 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

define(['jquery', 'oae.core', 'jquery.oembed'], function($, oae) {

    return function(uid, showSettings, widgetData) {

        // Cache the widget container
        var $rootel = $('#' + uid);

        /**
         * Whitelist the supported oEmbed providers
         *
         * @see http://oembed.com
         */
        var oEmbedProviders = {
            'blip': RegExp('blip\\.tv/.+'),
            'dailymotion': RegExp('dailymotion\\.com/.+'),
            'deviantart': RegExp('deviantart.com/.+'),
            'dribble': RegExp('dribbble.com/shots/.+'),
            'flickr': RegExp('flickr\\.com/photos/.+'),
            'hulu': RegExp('hulu\\.com/watch/.*'),
            'ifixit': RegExp('ifixit.com/.+'),
            'imgly': RegExp('img\\.ly/.+'),
            'instagram': RegExp('instagr\\.?am(\\.com)?/.+'),
            'pastebin': RegExp('pastebin\\.com/[\\S]{8}'),
            'pinterest': RegExp('pinterest.com/pin/.+'),
            'prezi': RegExp('prezi.com/.*'),
            'scribd': RegExp('scribd\\.com/.+'),
            'slideshare': RegExp('slideshare\\.net'),
            'soundcloud': RegExp('soundcloud.com/.+'),
            'speakerdeck': RegExp('speakerdeck.com/.+'),
            'ted': RegExp('ted.com/talks/.+'),
            'twitgoocom': RegExp('twitgoo\\.com/.+'),
            'twitpic': RegExp('twitpic.com/.+'),
            'vimeo': RegExp('vimeo\\.com/.+'),
            'youtube': RegExp('youtube\\.com/watch.+v=[\\w-]+&?')
        };

        /**
         * Override the default embed behavior for some of the supported oEmbed providers
         */
        var setUpCustomOEmbedProviders = function() {
            // Dribble
            $.fn.updateOEmbedProvider('dribbble', null, null, null, {
                'templateData' : function(data) {
                    return oae.api.util.template().render($('#linkpreview-image-template', $rootel), {
                        'img': data.image_url,
                        'linkProfile': widgetData
                    });
                }
            });

            // Img.ly
            $.fn.updateOEmbedProvider('img.ly', 'photo', ['img\\.ly/.+'],'//img.ly/show/large/$1', {
                'embedtag': {tag: 'img'}
            });

            // Twitgoo
            $.fn.updateOEmbedProvider('twitgoo.com', 'photo', ['twitgoo\\.com/.+'],'http://twitgoo.com/show/img/$1', {
                embedtag: {tag:'img'}
            });

            // TED, Twitpic
            $.fn.updateOEmbedProvider('opengraph', null, null, null, {
                yql: {<commit_msg>Added support for short Youtube and Flickr URLs<commit_after>/*!
 * Copyright 2014 Apereo Foundation (AF) Licensed under the
 * Educational Community License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may
 * obtain a copy of the License at
 *
 *     http://opensource.org/licenses/ECL-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an "AS IS"
 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

define(['jquery', 'oae.core', 'jquery.oembed'], function($, oae) {

    return function(uid, showSettings, widgetData) {

        // Cache the widget container
        var $rootel = $('#' + uid);

        /**
         * Whitelist the supported oEmbed providers
         *
         * @see http://oembed.com
         */
        var oEmbedProviders = {
            'blip': RegExp('blip\\.tv/.+'),
            'dailymotion': RegExp('dailymotion\\.com/.+'),
            'deviantart': RegExp('deviantart\\.com/.+'),
            'dribble': RegExp('dribbble\\.com/shots/.+'),
            'flickr': RegExp('flickr\\.com/photos/.+'),
            'flickrshort': RegExp('flic\\.kr/p/.+'),
            'hulu': RegExp('hulu\\.com/watch/.*'),
            'ifixit': RegExp('ifixit\\.com/.+'),
            'imgly': RegExp('img\\.ly/.+'),
            'instagram': RegExp('instagr\\.?am(\\.com)?/.+'),
            'pastebin': RegExp('pastebin\\.com/[\\S]{8}'),
            'pinterest': RegExp('pinterest.com/pin/.+'),
            'prezi': RegExp('prezi\\.com/.*'),
            'scribd': RegExp('scribd\\.com/.+'),
            'slideshare': RegExp('slideshare\\.net'),
            'soundcloud': RegExp('soundcloud\\.com/.+'),
            'speakerdeck': RegExp('speakerdeck\\.com/.+'),
            'ted': RegExp('ted\\.com/talks/.+'),
            'twitgoocom': RegExp('twitgoo\\.com/.+'),
            'twitpic': RegExp('twitpic\\.com/.+'),
            'vimeo': RegExp('vimeo\\.com/.+'),
            'youtube': RegExp('youtube\\.com/watch.+v=[\\w-]+&?'),
            'youtubeshort': RegExp('youtu\\.be\/.+')
        };

        /**
         * Override the default embed behavior for some of the supported oEmbed providers
         */
        var setUpCustomOEmbedProviders = function() {
            // Dribble
            $.fn.updateOEmbedProvider('dribbble', null, null, null, {
                'templateData' : function(data) {
                    return oae.api.util.template().render($('#linkpreview-image-template', $rootel), {
                        'img': data.image_url,
                        'linkProfile': widgetData
                    });
                }
            });

            // Img.ly
            $.fn.updateOEmbedProvider('img.ly', 'photo', ['img\\.ly/.+'],'//img.ly/show/large/$1', {
                'embedtag': {tag: 'img'}
            });

            // Twitgoo
            $.fn.updateOEmbedProvider('twitgoo.com', 'photo', ['twitgoo\\.com/.+'],'http://twitgoo.com/show/img/$1', {
                embedtag: {tag:'img'}
            });

            // TED, Twitpic
            $.fn.updateOEmbedProvider('opengraph', null, null, null, {
                yql: {
{'fraction_non_alphanumeric': 0.18037054049915785, 'fraction_numerical': 0.0033685499923442044, 'mean_word_length': 1.862401402278703, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4549726', 'n_tokens_mistral': 2024, 'n_tokens_neox': 1942, 'n_words': 413}