Paste tool remake and more video-services added

This commit is contained in:
George Berezhnoy 2017-01-12 16:56:06 +03:00
commit 089c8b59de
12 changed files with 277 additions and 289 deletions

68
plugins/paste/patterns.js Normal file
View file

@ -0,0 +1,68 @@
/**
* Patterns
*
*/
pasteTool.patterns = [
{
type: 'image',
regex: /(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*\.(?:jpe?g|gif|png))(?:\?([^#]*))?(?:#(.*))?/i,
callback: ceImage.urlPastedCallbacks.uploadImage
},
{
type: 'instagram',
regex: new RegExp("http?.+instagram.com\/p?."),
callback: instagramTool.urlPastedCallback
},
{
type: 'twitter',
regex: new RegExp("http?.+twitter.com?.+\/"),
callback: twitterTool.urlPastedCallback
},
{
type: 'facebook',
regex: /https?.+facebook.+\/\d+\?/,
callback: ''//pasteTool.callbacks.facebookMedia
},
{
type: 'vk',
regex: /https?.+vk?.com\/feed\?w=wall\d+_\d+/,
callback: ''//pasteTool.callbacks.vkMedia
},
{
type: 'youtube',
regex: /^.*(?:(?:youtu\.be\/)|(?:youtube\.com)\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*)(?:[\?\&]t\=(\d*)|)/,
callback: videoTool.urlPastedCallbacks.generalCallback
},
{
type: 'vimeo',
regex: /(?:http[s]?:\/\/)?(?:www.)?vimeo\.co(?:.+\/([^\/]\d+)(?:#t=[\d]+)?s?$)/,
callback: videoTool.urlPastedCallbacks.generalCallback
},
{
type: 'coub',
regex: /https?:\/\/coub\.com\/view\/([^\/\?\&]+)/,
callback: videoTool.urlPastedCallbacks.generalCallback
},
{
type: 'vine',
regex: /https?:\/\/vine\.co\/v\/([^\/\?\&]+)/,
callback: videoTool.urlPastedCallbacks.generalCallback
},
{
type: 'vk',
regex: /https?:\/\/vk\.com\/.*(?:video)([-_0-9]+)/,
callback: videoTool.urlPastedCallbacks.generalCallback
},
{
type: 'imgur',
regex: /https?:\/\/(?:i\.)?imgur\.com.*\/([a-zA-Z0-9]+)(?:\.gifv)?/,
callback: videoTool.urlPastedCallbacks.generalCallback
},
{
type: 'gfycat',
regex: /https?:\/\/gfycat\.com(?:\/detail)?\/([a-zA-Z]+)/,
callback: videoTool.urlPastedCallbacks.generalCallback
}
];