Skip to content

Instantly share code, notes, and snippets.

@ku
Created January 14, 2009 11:58
Show Gist options
  • Save ku/46873 to your computer and use it in GitHub Desktop.
Save ku/46873 to your computer and use it in GitHub Desktop.
clipboard_poster.js
models.register( {
name : 'Clipboard',
ICON : 'data:image/png;base64,'+
'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0'+
'U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHvSURBVDjLjZI/aFNRFMZ/Ly+GlCYlaMF/'+
'1D+4FQRJREigk7OiIAguHSwUkrkgLhVcpIurQjdBcLAITi4FETpIAw46CGIHJ0tFamlt3rvnfA7J'+
'i2kTwQOXe4b7/c73HW4kCYCnc+engU8M1/b88kaFf1T05O65KvAAuFY6epw79xfZ3XoPwPjkFZ4t'+
'3uP37i+A58DK/PLGy0FAHli5euPmmbFSmfTrByRhnV0AJDFzcYrcyQtIuvXm1evrwBDg7FhpgmRn'+
'k+CBjRePQQLEltoIsb/5jeLk6QJQOBwhD4AbCoFc5QRuAckP5tzfI9neG7mDPIDc8RDwtIOnnZ6D'+
'/6seIOCW9ie7Ij7+mGDfYlB3F4oKfD8yTavVWnJ3zAwz+9wDGB5SsICbkYQc8dgkt+cekiTJ4aEL'+
'kojjOG02m0t9ACFF5ig4bsLN6XQ6rK2toYFIWV+v1wkh8NeBOR4cD4ZbhJkBUK1WDwizXtIgwPHU'+
'UHAUDLcc3hO02+2+eBBSr9cxsy6gO70L8CwChqSRDrLqO8CEp97bgSGL8CgAsL6+PiSURKPR6Dt4'+
'lybJzPipKeRC7uRTiH+WkUStVhsSZ3cGePR2dbUMXMoeGXl2KpcpFotEUTTyA8VxjJkRjco2Ozub'+
'M7MFMzvW+zD94+6D58sfRXpka4kRkDcAAAAASUVORK5CYII=',
check : function(ps) {
return (/(quote|link)/).test(ps.type);
},
converters: {
renderingTemplates: {
link: '<><a href={ps.pageUrl} title={ps.page}>{ps.page}</a>{ps.description}</>',
quote: '<><blockquote>{ps.body}<a href={ps.pageUrl}>{ps.page}</a></blockquote>{ps.description}</>',
},
__noSuchMethod__: function(name, args){
var ps = args[0];
return {
body: eval( this.renderingTemplates[name] ).toSource()
};
},
},
post : function(ps){
var content = this.converters[ps.type](ps);
ClipboardHelper.copyString(content.body);
return succeed();
},
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment