add first webhook

This commit is contained in:
anatskiy
2016-10-09 21:28:12 +02:00
committed by Evgeny Anatskiy
parent 117c5263ac
commit ed2282d60b
4 changed files with 21 additions and 14 deletions
@@ -8,13 +8,13 @@ define([], function() {
urlRoot: galaxyRoot + 'api/webhooks/toolview',
defaults: {
name: '',
path: ''
styles: '',
script: ''
}
});
var WebhookView = Backbone.View.extend({
el: '#webhook-toolview',
webhookTemplate: _.template('<p>name: <%= name %><br>path: <%= path %></p>'),
initialize: function() {
var me = this;
@@ -27,9 +27,10 @@ define([], function() {
},
render: function() {
var webhookContent = this.model.toJSON();
if (webhookContent.css_styles) $('<style/>').text(webhookContent.css_styles).appendTo('head');
this.$el.html(this.webhookTemplate(webhookContent));
var webhook = this.model.toJSON();
this.$el.html('<div id="' + webhook.name + '"></div>');
if (webhook.styles) $('<style/>', {type: 'text/css'}).text(webhook.styles).appendTo('head');
if (webhook.script) $('<script/>', {type: 'text/javascript'}).text(webhook.script).appendTo('head');
return this;
}
});
@@ -1,2 +0,0 @@
name: Plugin 2
type: toolview
@@ -1,2 +0,0 @@
#webhook-toolview {border:1px solid #ccc;border-radius:3px;padding:10px;}
#webhook-toolview p {margin-bottom:0;}
+15 -5
View File
@@ -114,15 +114,25 @@ class WebhooksRegistry(object):
path = os.path.normpath(os.path.join(config_dir, '..'))
# Read styles into a string, assuming all styles are in a
# single file
try:
with open(os.path.join(path, 'static/style.css'), 'r') as f:
css_styles = f.read().replace('\n', '')
with open(os.path.join(path, 'static/styles.css'), 'r') as f:
styles = f.read().replace('\n', '')
except IOError:
css_styles = ''
styles = ''
# Read script into a string, assuming everything is in a
# single file
try:
with open(os.path.join(path, 'static/script.js'), 'r') as f:
script = f.read()
except IOError:
script = ''
config.update({
'path': path,
'css_styles': css_styles
'styles': styles,
'script': script
})
self.webhooks[config['type']].append(config)
except Exception as e: