<commit_before>(function() {
	
	var Media = window.Media = {
		handlers: [ ]
	};
	
	Media.register = function(pattern, fn) {
		this.handlers.push({ pattern: pattern, fn: fn });
	};
	
	Media.createImageCell = function(imageUri, thumbnailUri, title) {
		return (
			$('<a>')
			.attr('href', imageUri)
			.append(
				$('<img>')
				.error(function() { $(this).addClass('broken') })
				.attr('src', thumbnailUri)
				.attr('alt', title)
				.attr('title', title)));
	}
	
	Media.loadMedia = function(message, link) {
		var handler, match, media, container, uri;
		
		container = $('.media', message);
		uri       = link.href;
		
		for ( var i = 0, L = Media.handlers.length; i < L; ++i )
		{
			handler = this.handlers[i];
			if ( match = uri.match(handler.pattern) )
			{
				media = handler.fn.apply(this, [link, match]);
				$('<div>')
					.addClass('media-item')
					.append(media)
					.appendTo(container);
			}
		};
	}
	
})();

Media.register(/^https?:\/\/(?:i\.)?imgur\.com\/([a-z0-9]+)(?:\..+)?$/i, function(link, match) {
	return Media.createImageCell(
		link.href, 'http://i.imgur.com/' + match[1] + 's.png', $(link).text());
});

(function() {
	var fn = function(link, match) {
		return Media.createImageCell(
			link.href, 'http://img.youtube.com/vi/' + match[1] + '/1.jpg', $(link).text());
	}
	
	Media.register(/youtube\.com\/watch.*v=([a-z0-9_]+)/i, fn);
	Media.register(/youtu\.be\/([a-z0-9_]+)/i, fn);
})();
<commit_msg>fixed imgur to support gallery images<commit_after>(function() {
	
	var Media = window.Media = {
		handlers: [ ]
	};
	
	Media.register = function(pattern, fn) {
		this.handlers.push({ pattern: pattern, fn: fn });
	};
	
	Media.createImageCell = function(imageUri, thumbnailUri, title) {
		return (
			$('<a>')
			.attr('href', imageUri)
			.append(
				$('<img>')
				.error(function() { $(this).addClass('broken') })
				.attr('src', thumbnailUri)
				.attr('alt', title)
				.attr('title', title)));
	}
	
	Media.loadMedia = function(message, link) {
		var handler, match, media, container, uri;
		
		container = $('.media', message);
		uri       = link.href;
		
		for ( var i = 0, L = Media.handlers.length; i < L; ++i )
		{
			handler = this.handlers[i];
			if ( match = uri.match(handler.pattern) )
			{
				media = handler.fn.apply(this, [link, match]);
				$('<div>')
					.addClass('media-item')
					.append(media)
					.appendTo(container);
			}
		};
	}
	
})();

Media.register(/imgur\.com\/(?:gallery\/)?([a-z0-9]+)/i, function(link, match) {
	return Media.createImageCell(
		link.href, 'http://i.imgur.com/' + match[1] + 's.png', $(link).text());
});

(function() {
	var fn = function(link, match) {
		return Media.createImageCell(
			link.href, 'http://img.youtube.com/vi/' + match[1] + '/1.jpg', $(link).text());
	}
	
	Media.register(/youtube\.com\/watch.*v=([a-z0-9_]+)/i, fn);
	Media.register(/youtu\.be\/([a-z0-9_]+)/i, fn);
})();

{'fraction_non_alphanumeric': 0.2354368932038835, 'fraction_numerical': 0.006934812760055479, 'mean_word_length': 3.1038406827880514, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '5912387', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1069, 'n_words': 191}