Lets stop filling syntactical fields with non-meta-data

This commit is contained in:
Zixaphir 2013-08-05 13:01:44 -07:00
parent 250323d304
commit c44014b19e
3 changed files with 83 additions and 66 deletions

View File

@ -4428,21 +4428,28 @@
}
},
embed: function(data) {
var embed, key, link, options, uid;
var embed, href, key, link, name, options, uid, value, _ref;
key = data[0], uid = data[1], options = data[2], link = data[3];
href = link.href;
embed = $.el('a', {
name: uid,
option: options,
className: 'embedder',
href: 'javascript:;',
textContent: '(embed)'
});
embed.dataset.service = key;
embed.dataset.originalurl = link.href;
$.addClass(link, "" + embed.dataset.service);
_ref = {
key: key,
href: href,
uid: uid,
options: options
};
for (name in _ref) {
value = _ref[name];
embed.dataset[name] = value;
}
$.addClass(link, "" + embed.dataset.key);
$.on(embed, 'click', Linkify.cb.toggle);
return $.after(link, [$.tn(' '), embed]);
$.after(link, [$.tn(' '), embed]);
},
title: function(data) {
var err, key, link, options, service, title, titles, uid;
@ -4488,23 +4495,24 @@
embed: function(a) {
var el, style, type;
el = (type = Linkify.types[a.dataset.service]).el.call(a);
el = (type = Linkify.types[a.dataset.key]).el.call(a);
el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px";
a.textContent = '(unembed)';
return el;
},
unembed: function(a) {
var el, url;
var el, href;
href = a.dataset.href;
el = $.el('a', {
rel: 'nofollow noreferrer',
target: 'blank',
className: 'linkify',
href: url = a.dataset.originalurl,
textContent: a.dataset.title || url
href: href,
textContent: a.dataset.title || href
});
a.textContent = '(embed)';
$.addClass(el, "" + a.dataset.service);
$.addClass(el, "" + a.dataset.key);
return el;
},
title: function(data) {
@ -4538,7 +4546,7 @@
return $.el('audio', {
controls: 'controls',
preload: 'auto',
src: this.name
src: this.dataset.uid
});
}
},
@ -4548,7 +4556,7 @@
var div;
return div = $.el('iframe', {
src: "http://www.purplegene.com/script?url=https://gist.github.com/" + this.name + ".js"
src: "http://www.purplegene.com/script?url=https://gist.github.com/" + this.dataset.uid + ".js"
});
},
title: {
@ -4572,7 +4580,7 @@
style: 'border: 0; width: auto; height: auto;',
el: function() {
return $.el('div', {
innerHTML: "<a target=_blank href='" + this.dataset.originalurl + "'><img src='" + this.dataset.originalurl + "'></a>"
innerHTML: "<a target=_blank href='" + this.dataset.href + "'><img src='" + this.dataset.href + "'></a>"
});
}
},
@ -4580,7 +4588,7 @@
regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/,
el: function() {
return $.el('iframe', {
src: "http://paste.installgentoo.com/view/embed/" + this.name
src: "http://paste.installgentoo.com/view/embed/" + this.dataset.uid
});
}
},
@ -4588,7 +4596,7 @@
regExp: /.*(?:liveleak.com\/view.+i=)([0-9a-z_]+)/,
el: function() {
return $.el('object', {
innerHTML: "<embed src='http://www.liveleak.com/e/" + this.name + "?autostart=true' wmode='opaque' width='640' height='390' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
innerHTML: "<embed src='http://www.liveleak.com/e/" + this.dataset.uid + "?autostart=true' wmode='opaque' width='640' height='390' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
});
}
},
@ -4598,7 +4606,7 @@
var div;
return div = $.el('iframe', {
src: "http://pastebin.com/embed_iframe.php?i=" + this.name
src: "http://pastebin.com/embed_iframe.php?i=" + this.dataset.uid
});
}
},
@ -4612,7 +4620,7 @@
className: "soundcloud",
name: "soundcloud"
});
$.ajax("//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + this.name, {
$.ajax("//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + this.dataset.uid, {
div: div,
onloadend: function() {
return this.div.innerHTML = JSON.parse(this.responseText).html;
@ -4634,7 +4642,7 @@
style: 'border: 0; width: 150px; height: 45px;',
el: function() {
return $.el('object', {
innerHTML: "<embed src='http://vocaroo.com/player.swf?playMediaID=" + (this.name.replace(/^i\//, '')) + "&autoplay=0' wmode='opaque' width='150' height='45' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
innerHTML: "<embed src='http://vocaroo.com/player.swf?playMediaID=" + (this.dataset.uid.replace(/^i\//, '')) + "&autoplay=0' wmode='opaque' width='150' height='45' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
});
}
},
@ -4642,7 +4650,7 @@
regExp: /.*(?:vimeo.com\/)([^#\&\?]*).*/,
el: function() {
return $.el('iframe', {
src: "//player.vimeo.com/video/" + this.name + "?wmode=opaque"
src: "//player.vimeo.com/video/" + this.dataset.uid + "?wmode=opaque"
});
},
title: {
@ -4659,7 +4667,7 @@
style: 'border: none; width: 500px; height: 500px;',
el: function() {
return $.el('iframe', {
src: "https://vine.co/" + this.name + "/card"
src: "https://vine.co/" + this.dataset.uid + "/card"
});
}
},
@ -4667,7 +4675,7 @@
regExp: /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([^#\&\?]*)\??(t\=.*)?/,
el: function() {
return $.el('iframe', {
src: "//www.youtube.com/embed/" + this.name + (this.option ? '#' + this.option : '') + "?wmode=opaque"
src: "//www.youtube.com/embed/" + this.dataset.uid + (this.dataset.option ? '#' + this.dataset.option : '') + "?wmode=opaque"
});
},
title: {

View File

@ -4433,21 +4433,28 @@
}
},
embed: function(data) {
var embed, key, link, options, uid;
var embed, href, key, link, name, options, uid, value, _ref;
key = data[0], uid = data[1], options = data[2], link = data[3];
href = link.href;
embed = $.el('a', {
name: uid,
option: options,
className: 'embedder',
href: 'javascript:;',
textContent: '(embed)'
});
embed.dataset.service = key;
embed.dataset.originalurl = link.href;
$.addClass(link, "" + embed.dataset.service);
_ref = {
key: key,
href: href,
uid: uid,
options: options
};
for (name in _ref) {
value = _ref[name];
embed.dataset[name] = value;
}
$.addClass(link, "" + embed.dataset.key);
$.on(embed, 'click', Linkify.cb.toggle);
return $.after(link, [$.tn(' '), embed]);
$.after(link, [$.tn(' '), embed]);
},
title: function(data) {
var err, key, link, options, service, title, titles, uid;
@ -4493,23 +4500,24 @@
embed: function(a) {
var el, style, type;
el = (type = Linkify.types[a.dataset.service]).el.call(a);
el = (type = Linkify.types[a.dataset.key]).el.call(a);
el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px";
a.textContent = '(unembed)';
return el;
},
unembed: function(a) {
var el, url;
var el, href;
href = a.dataset.href;
el = $.el('a', {
rel: 'nofollow noreferrer',
target: 'blank',
className: 'linkify',
href: url = a.dataset.originalurl,
textContent: a.dataset.title || url
href: href,
textContent: a.dataset.title || href
});
a.textContent = '(embed)';
$.addClass(el, "" + a.dataset.service);
$.addClass(el, "" + a.dataset.key);
return el;
},
title: function(data) {
@ -4543,7 +4551,7 @@
return $.el('audio', {
controls: 'controls',
preload: 'auto',
src: this.name
src: this.dataset.uid
});
}
},
@ -4553,7 +4561,7 @@
var div;
return div = $.el('iframe', {
src: "http://www.purplegene.com/script?url=https://gist.github.com/" + this.name + ".js"
src: "http://www.purplegene.com/script?url=https://gist.github.com/" + this.dataset.uid + ".js"
});
},
title: {
@ -4577,7 +4585,7 @@
style: 'border: 0; width: auto; height: auto;',
el: function() {
return $.el('div', {
innerHTML: "<a target=_blank href='" + this.dataset.originalurl + "'><img src='" + this.dataset.originalurl + "'></a>"
innerHTML: "<a target=_blank href='" + this.dataset.href + "'><img src='" + this.dataset.href + "'></a>"
});
}
},
@ -4585,7 +4593,7 @@
regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/,
el: function() {
return $.el('iframe', {
src: "http://paste.installgentoo.com/view/embed/" + this.name
src: "http://paste.installgentoo.com/view/embed/" + this.dataset.uid
});
}
},
@ -4593,7 +4601,7 @@
regExp: /.*(?:liveleak.com\/view.+i=)([0-9a-z_]+)/,
el: function() {
return $.el('object', {
innerHTML: "<embed src='http://www.liveleak.com/e/" + this.name + "?autostart=true' wmode='opaque' width='640' height='390' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
innerHTML: "<embed src='http://www.liveleak.com/e/" + this.dataset.uid + "?autostart=true' wmode='opaque' width='640' height='390' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
});
}
},
@ -4603,7 +4611,7 @@
var div;
return div = $.el('iframe', {
src: "http://pastebin.com/embed_iframe.php?i=" + this.name
src: "http://pastebin.com/embed_iframe.php?i=" + this.dataset.uid
});
}
},
@ -4617,7 +4625,7 @@
className: "soundcloud",
name: "soundcloud"
});
$.ajax("//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + this.name, {
$.ajax("//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/" + this.dataset.uid, {
div: div,
onloadend: function() {
return this.div.innerHTML = JSON.parse(this.responseText).html;
@ -4639,7 +4647,7 @@
style: 'border: 0; width: 150px; height: 45px;',
el: function() {
return $.el('object', {
innerHTML: "<embed src='http://vocaroo.com/player.swf?playMediaID=" + (this.name.replace(/^i\//, '')) + "&autoplay=0' wmode='opaque' width='150' height='45' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
innerHTML: "<embed src='http://vocaroo.com/player.swf?playMediaID=" + (this.dataset.uid.replace(/^i\//, '')) + "&autoplay=0' wmode='opaque' width='150' height='45' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
});
}
},
@ -4647,7 +4655,7 @@
regExp: /.*(?:vimeo.com\/)([^#\&\?]*).*/,
el: function() {
return $.el('iframe', {
src: "//player.vimeo.com/video/" + this.name + "?wmode=opaque"
src: "//player.vimeo.com/video/" + this.dataset.uid + "?wmode=opaque"
});
},
title: {
@ -4664,7 +4672,7 @@
style: 'border: none; width: 500px; height: 500px;',
el: function() {
return $.el('iframe', {
src: "https://vine.co/" + this.name + "/card"
src: "https://vine.co/" + this.dataset.uid + "/card"
});
}
},
@ -4672,7 +4680,7 @@
regExp: /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([^#\&\?]*)\??(t\=.*)?/,
el: function() {
return $.el('iframe', {
src: "//www.youtube.com/embed/" + this.name + (this.option ? '#' + this.option : '') + "?wmode=opaque"
src: "//www.youtube.com/embed/" + this.dataset.uid + (this.dataset.option ? '#' + this.dataset.option : '') + "?wmode=opaque"
});
},
title: {

View File

@ -137,20 +137,20 @@ Linkify =
embed: (data) ->
[key, uid, options, link] = data
href = link.href
embed = $.el 'a',
name: uid
option: options
className: 'embedder'
href: 'javascript:;'
textContent: '(embed)'
embed.dataset.service = key
embed.dataset.originalurl = link.href
for name, value of {key, href, uid, options}
embed.dataset[name] = value
$.addClass link, "#{embed.dataset.service}"
$.addClass link, "#{embed.dataset.key}"
$.on embed, 'click', Linkify.cb.toggle
$.after link, [$.tn(' '), embed]
return
title: (data) ->
[key, uid, options, link] = data
@ -190,7 +190,7 @@ Linkify =
embed: (a) ->
# We create an element to embed
el = (type = Linkify.types[a.dataset.service]).el.call a
el = (type = Linkify.types[a.dataset.key]).el.call a
# Set style values.
el.style.cssText = if style = type.style
@ -204,15 +204,16 @@ Linkify =
unembed: (a) ->
# Recreate the original link.
{href} = a.dataset
el = $.el 'a',
rel: 'nofollow noreferrer'
target: 'blank'
className: 'linkify'
href: url = a.dataset.originalurl
textContent: a.dataset.title or url
href: href
textContent: a.dataset.title or href
a.textContent = '(embed)'
$.addClass el, "#{a.dataset.service}"
$.addClass el, "#{a.dataset.key}"
return el
@ -239,14 +240,14 @@ Linkify =
$.el 'audio',
controls: 'controls'
preload: 'auto'
src: @name
src: @dataset.uid
gist:
regExp: /.*(?:gist.github.com.*\/)([^\/][^\/]*)$/
el: ->
div = $.el 'iframe',
# Github doesn't allow embedding straight from the site, so we use an external site to bypass that.
src: "http://www.purplegene.com/script?url=https://gist.github.com/#{@name}.js"
src: "http://www.purplegene.com/script?url=https://gist.github.com/#{@dataset.uid}.js"
title:
api: (uid) -> "https://api.github.com/gists/#{uid}"
text: ->
@ -258,25 +259,25 @@ Linkify =
style: 'border: 0; width: auto; height: auto;'
el: ->
$.el 'div',
innerHTML: "<a target=_blank href='#{@dataset.originalurl}'><img src='#{@dataset.originalurl}'></a>"
innerHTML: "<a target=_blank href='#{@dataset.href}'><img src='#{@dataset.href}'></a>"
InstallGentoo:
regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/
el: ->
$.el 'iframe',
src: "http://paste.installgentoo.com/view/embed/#{@name}"
src: "http://paste.installgentoo.com/view/embed/#{@dataset.uid}"
LiveLeak:
regExp: /.*(?:liveleak.com\/view.+i=)([0-9a-z_]+)/
el: ->
$.el 'object',
innerHTML: "<embed src='http://www.liveleak.com/e/#{@name}?autostart=true' wmode='opaque' width='640' height='390' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
innerHTML: "<embed src='http://www.liveleak.com/e/#{@dataset.uid}?autostart=true' wmode='opaque' width='640' height='390' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
pastebin:
regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/
el: ->
div = $.el 'iframe',
src: "http://pastebin.com/embed_iframe.php?i=#{@name}"
src: "http://pastebin.com/embed_iframe.php?i=#{@dataset.uid}"
SoundCloud:
regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/
@ -286,7 +287,7 @@ Linkify =
className: "soundcloud"
name: "soundcloud"
$.ajax(
"//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/#{@name}"
"//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/#{@dataset.uid}"
div: div
onloadend: ->
@div.innerHTML = JSON.parse(@responseText).html
@ -315,13 +316,13 @@ Linkify =
style: 'border: 0; width: 150px; height: 45px;'
el: ->
$.el 'object',
innerHTML: "<embed src='http://vocaroo.com/player.swf?playMediaID=#{@name.replace /^i\//, ''}&autoplay=0' wmode='opaque' width='150' height='45' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
innerHTML: "<embed src='http://vocaroo.com/player.swf?playMediaID=#{@dataset.uid.replace /^i\//, ''}&autoplay=0' wmode='opaque' width='150' height='45' pluginspage='http://get.adobe.com/flashplayer/' type='application/x-shockwave-flash'></embed>"
Vimeo:
regExp: /.*(?:vimeo.com\/)([^#\&\?]*).*/
el: ->
$.el 'iframe',
src: "//player.vimeo.com/video/#{@name}?wmode=opaque"
src: "//player.vimeo.com/video/#{@dataset.uid}?wmode=opaque"
title:
api: (uid) -> "https://vimeo.com/api/oembed.json?url=http://vimeo.com/#{uid}"
text: -> JSON.parse(@responseText).title
@ -331,13 +332,13 @@ Linkify =
style: 'border: none; width: 500px; height: 500px;'
el: ->
$.el 'iframe',
src: "https://vine.co/#{@name}/card"
src: "https://vine.co/#{@dataset.uid}/card"
YouTube:
regExp: /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([^#\&\?]*)\??(t\=.*)?/
el: ->
$.el 'iframe',
src: "//www.youtube.com/embed/#{@name}#{if @option then '#' + @option else ''}?wmode=opaque"
src: "//www.youtube.com/embed/#{@dataset.uid}#{if @dataset.option then '#' + @dataset.option else ''}?wmode=opaque"
title:
api: (uid) -> "https://gdata.youtube.com/feeds/api/videos/#{uid}?alt=json&fields=title/text(),yt:noembed,app:control/yt:state/@reasonCode"
text: -> JSON.parse(@responseText).entry.title.$t