add very basic plugin system (for tools)

This commit is contained in:
anatskiy
2016-10-09 21:28:01 +02:00
committed by Evgeny Anatskiy
parent 143a740dc3
commit 117c5263ac
4 changed files with 57 additions and 6 deletions
@@ -0,0 +1,40 @@
/**
Webhooks
**/
define([], function() {
var galaxyRoot = typeof Galaxy != 'undefined' ? Galaxy.root : '/';
var WebhookModel = Backbone.Model.extend({
urlRoot: galaxyRoot + 'api/webhooks/toolview',
defaults: {
name: '',
path: ''
}
});
var WebhookView = Backbone.View.extend({
el: '#webhook-toolview',
webhookTemplate: _.template('<p>name: <%= name %><br>path: <%= path %></p>'),
initialize: function() {
var me = this;
this.model = new WebhookModel;
this.model.fetch({
success: function() {
me.render();
}
});
},
render: function() {
var webhookContent = this.model.toJSON();
if (webhookContent.css_styles) $('<style/>').text(webhookContent.css_styles).appendTo('head');
this.$el.html(this.webhookTemplate(webhookContent));
return this;
}
});
return {
WebhookView: WebhookView
};
});
@@ -1,2 +1,2 @@
name: Plugin 2
type: mainview
type: toolview
@@ -0,0 +1,2 @@
#webhook-toolview {border:1px solid #ccc;border-radius:3px;padding:10px;}
#webhook-toolview p {margin-bottom:0;}
+14 -5
View File
@@ -69,7 +69,6 @@ class WebhooksRegistry(object):
conf.endswith('.yaml')][0]
if config_file:
<<<<<<< HEAD
self.load_webhook_from_config(config_dir, config_file)
def load_webhook_from_config(self, config_dir, config_file):
@@ -102,7 +101,6 @@ class WebhooksRegistry(object):
webhook.config = config
self.webhooks.append(webhook)
=======
self.load_webhook_from_config(
os.path.join(config_dir, config_file))
@@ -110,11 +108,22 @@ class WebhooksRegistry(object):
try:
with open(config_file) as f:
config = yaml.load(f)
if config['type'] not in self.webhooks.keys():
self.webhooks[config['type']] = []
self.webhooks[config['type']].append({
'name': config['name']
path = os.path.normpath(os.path.join(config_dir, '..'))
try:
with open(os.path.join(path, 'static/style.css'), 'r') as f:
css_styles = f.read().replace('\n', '')
except IOError:
css_styles = ''
config.update({
'path': path,
'css_styles': css_styles
})
>>>>>>> add Webhooks draft
self.webhooks[config['type']].append(config)
except Exception as e:
log.exception(e)