Merge pull request #3 from eviltrout/new-api-better

I changed the `decorateWidget` API slightly, sorry!
This commit is contained in:
Rafael dos Santos Silva 2016-02-22 13:39:35 -03:00
commit 8ed18d772f

View File

@ -12,14 +12,16 @@ function oldPluginCode() {
function attachSignature(api) { function attachSignature(api) {
api.includePostAttributes('user_signature_url'); api.includePostAttributes('user_signature_url');
api.decorateWidget('post-contents:after', (h, attrs) => { api.decorateWidget('post-contents:after', dec => {
const attrs = dec.attrs;
if (Ember.isEmpty(attrs.user_signature_url)) { return; } if (Ember.isEmpty(attrs.user_signature_url)) { return; }
const currentUser = api.getCurrentUser(); const currentUser = api.getCurrentUser();
if (currentUser) { if (currentUser) {
const enabled = currentUser.get('custom_fields.see_signatures'); const enabled = currentUser.get('custom_fields.see_signatures');
if (enabled) { if (enabled) {
return [h('hr'), h('img.signature-img', { attributes: { src: attrs.user_signature_url } } )]; return [dec.h('hr'), dec.h('img.signature-img', { attributes: { src: attrs.user_signature_url } } )];
} }
} }
}); });