remove biostar integrations

we stopped using it and this will lower our maintenance burden
This commit is contained in:
Martin Cech
2019-03-11 15:51:41 -04:00
parent 8ae44cd8cb
commit 75ae68693f
18 changed files with 2 additions and 529 deletions
-14
View File
@@ -220,20 +220,6 @@ var Collection = Backbone.Collection.extend({
target: "_blank"
});
}
if (options.biostar_url) {
helpTab.menu.unshift({
title: _l("Ask a question"),
url: "biostar/biostar_question_redirect",
target: "_blank"
});
}
if (options.biostar_url) {
helpTab.menu.unshift({
title: _l("Galaxy Biostar"),
url: options.biostar_url_redirect,
target: "_blank"
});
}
if (options.helpsite_url) {
helpTab.menu.unshift({
title: _l("Galaxy Help"),
@@ -187,22 +187,6 @@ export default FormBase.extend({
title: (!options.narrow && "Options") || null,
tooltip: "View available options"
});
if (options.biostar_url) {
menu_button.addMenu({
icon: "fa-question-circle",
title: "Question?",
onclick: function() {
window.open(`${options.biostar_url}/p/new/post/`);
}
});
menu_button.addMenu({
icon: "fa-search",
title: _l("Search"),
onclick: function() {
window.open(`${options.biostar_url}/local/search/page/?q=${options.name}`);
}
});
}
menu_button.addMenu({
icon: "fa-share",
title: _l("Share"),
@@ -13,8 +13,6 @@ QUnit.module("Masthead test", {
use_remote_user: "use_remote_user",
remote_user_logout_href: "remote_user_logout_href",
lims_doc_url: "lims_doc_url",
biostar_url: "biostar_url",
biostar_url_redirect: "biostar_url_redirect",
support_url: "support_url",
search_url: "search_url",
mailing_lists: "mailing_lists",
-8
View File
@@ -34,14 +34,6 @@
- type: sentry
user_submission: false
# Allow users to submit error reports to biostars. This requires that the
# biostars integration is configured. This *only* makes sense when
# user_submission is true, as it only generates the link for the user to click
# on and submit the bug report, it does not actually submit the bug report on
# their behalf.
# - type: biostars
# user_submission: true
# InfluxDB error reporting backend. You will need to `pip install
# influxdb` in the galaxy virtualenv yourself. This sends well tagged
# errors InfluxDB allowing you to notice relationships between tool errors and
-15
View File
@@ -721,21 +721,6 @@ galaxy:
# The URL linked by the "Support" link in the "Help" menu.
#support_url: 'https://galaxyproject.org/support/'
# Enable integration with a custom Biostar instance.
#biostar_url: ''
# Enable integration with a custom Biostar instance.
#biostar_key_name: ''
# Enable integration with a custom Biostar instance.
#biostar_key: ''
# Enable integration with a custom Biostar instance.
#biostar_enable_bug_reports: true
# Enable integration with a custom Biostar instance.
#biostar_never_authenticate: false
# The URL linked by the "How to Cite Galaxy" link in the "Help" menu.
#citation_url: 'https://galaxyproject.org/citing-galaxy'
-50
View File
@@ -1360,56 +1360,6 @@
:Type: str
~~~~~~~~~~~~~~~
``biostar_url``
~~~~~~~~~~~~~~~
:Description:
Enable integration with a custom Biostar instance.
:Default: ````
:Type: str
~~~~~~~~~~~~~~~~~~~~
``biostar_key_name``
~~~~~~~~~~~~~~~~~~~~
:Description:
Enable integration with a custom Biostar instance.
:Default: ````
:Type: str
~~~~~~~~~~~~~~~
``biostar_key``
~~~~~~~~~~~~~~~
:Description:
Enable integration with a custom Biostar instance.
:Default: ````
:Type: str
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``biostar_enable_bug_reports``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:Description:
Enable integration with a custom Biostar instance.
:Default: ``true``
:Type: bool
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``biostar_never_authenticate``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:Description:
Enable integration with a custom Biostar instance.
:Default: ``false``
:Type: bool
~~~~~~~~~~~~~~~~
``citation_url``
~~~~~~~~~~~~~~~~
-5
View File
@@ -634,11 +634,6 @@ class Configuration(object):
self.amqp_internal_connection = "sqlalchemy+" + self.database_connection
else:
self.amqp_internal_connection = "sqlalchemy+sqlite:///%s?isolation_level=IMMEDIATE" % resolve_path("database/control.sqlite", self.root)
self.biostar_url = kwargs.get('biostar_url', None)
self.biostar_key_name = kwargs.get('biostar_key_name', None)
self.biostar_key = kwargs.get('biostar_key', None)
self.biostar_enable_bug_reports = string_as_bool(kwargs.get('biostar_enable_bug_reports', True))
self.biostar_never_authenticate = string_as_bool(kwargs.get('biostar_never_authenticate', False))
self.pretty_datetime_format = expand_pretty_datetime_format(kwargs.get('pretty_datetime_format', '$locale (UTC)'))
self.user_preferences_extra_config_file = kwargs.get('user_preferences_extra_conf_path', 'config/user_preferences_extra_conf.yml')
try:
-2
View File
@@ -50,8 +50,6 @@ class ConfigSerializer(base.ModelSerializer):
'support_url' : _defaults_to(self.app.config.support_url),
'helpsite_url' : _defaults_to(self.app.config.helpsite_url),
'lims_doc_url' : _defaults_to("https://usegalaxy.org/u/rkchak/p/sts"),
'biostar_url' : _defaults_to(''),
'biostar_url_redirect' : lambda *a, **c: self.url_for(controller='biostar', action='biostar_redirect', qualified=True),
'default_locale' : _defaults_to(self.app.config.default_locale),
'enable_beta_ts_api_install' : _defaults_to(False),
-1
View File
@@ -1931,7 +1931,6 @@ class Tool(Dictifiable):
'id' : self.id,
'help' : tool_help,
'citations' : bool(self.citations),
'biostar_url' : self.app.config.biostar_url,
'sharable_url' : self.sharable_url,
'message' : tool_message,
'warnings' : tool_warnings,
@@ -1,47 +0,0 @@
"""The module describes the ``biostars`` error plugin."""
from __future__ import absolute_import
import logging
from galaxy.util import biostar
from galaxy.util import string_as_bool
from galaxy.web.base.controller import url_for
from . import ErrorPlugin
log = logging.getLogger(__name__)
class BiostarsPlugin(ErrorPlugin):
"""Send error report as an issue on Biostars
"""
plugin_type = "biostars"
def __init__(self, **kwargs):
self.app = kwargs['app']
self.verbose = string_as_bool(kwargs.get('verbose', True))
self.user_submission = string_as_bool(kwargs.get('user_submission', True))
def submit_report(self, dataset, job, tool, **kwargs):
"""Doesn't do anything, just shows a link to submit on biostars.
"""
# This class specifically does nothing special for compliance purposes
# because the user is willingly posting their data on a public
# first/third-party site. Maybe should do something about the dialog
# linking to the biostars privacy policy during the "submit to
# biostars" dialog?
try:
assert biostar.biostar_enabled(self.app), ValueError("Biostar is not configured for this galaxy instance")
assert self.app.config.biostar_enable_bug_reports, ValueError("Biostar is not configured to allow bug reporting for this galaxy instance")
print(kwargs)
url = url_for(controller='biostar',
action='biostar_tool_bug_report',
hda=self.app.security.encode_id(dataset.id),
email=kwargs['email'], message=kwargs['message'])
return ('Click <a href="%s">here</a> to submit to BioStars' % url, 'success')
except Exception as e:
return ("An error occurred submitting the report to biostars: %s" % str(e), "danger")
__all__ = ('BiostarsPlugin', )
-196
View File
@@ -1,196 +0,0 @@
"""
Support for integration with the Biostar application
"""
from __future__ import absolute_import
import hmac
import logging
import re
from unicodedata import normalize
from six import text_type
from six.moves.urllib.parse import (
urljoin,
urlsplit
)
from galaxy.tools.errors import ErrorReporter
from galaxy.web.base.controller import url_for
from . import smart_str
log = logging.getLogger(__name__)
_punct_re = re.compile(r'[\t !"#$%&\'()*\-/<=>?@\[\\\]^_`{|},.]+')
DEFAULT_GALAXY_TAG = ''
# Default values for new posts to Biostar
DEFAULT_PAYLOAD = {
'title': '',
'tag_val': DEFAULT_GALAXY_TAG,
'content': '',
}
BIOSTAR_ACTIONS = {
None: {'url': lambda x: '', 'uses_payload': False},
'new_post': {'url': lambda x: 'p/new/external/post/', 'uses_payload': True, 'hmac_values': {'content': 'digest'}},
'show_tags': {'url': lambda x: 't/%s/' % ("+".join((x.get('tag_val') or DEFAULT_GALAXY_TAG).split(','))), 'uses_payload': False},
'log_out': {'url': lambda x: 'site/logout/', 'uses_payload': False}
}
DEFAULT_BIOSTAR_COOKIE_AGE = 1
def biostar_enabled(app):
return bool(app.config.biostar_url)
# Slugifying from Armin Ronacher (http://flask.pocoo.org/snippets/5/)
def slugify(text, delim=u'-'):
"""Generates an slightly worse ASCII-only slug."""
if not isinstance(text, text_type):
text = text_type(text)
result = []
for word in _punct_re.split(text.lower()):
word = normalize('NFKD', word).encode('ascii', 'ignore')
if word:
result.append(word)
return text_type(delim.join(result))
def get_biostar_url(app, payload=None, biostar_action=None):
# Ensure biostar integration is enabled
if not biostar_enabled(app):
raise Exception("Biostar integration is not enabled")
if biostar_action not in BIOSTAR_ACTIONS:
raise Exception("Invalid action specified (%s)." % (biostar_action))
biostar_action = BIOSTAR_ACTIONS[biostar_action]
# Start building up the payload
payload = payload or {}
payload = dict(DEFAULT_PAYLOAD, **payload)
payload['name'] = app.config.biostar_key_name
for hmac_value_name, hmac_parameter_name in biostar_action.get('hmac_values', {}).items():
# Biostar requires ascii only on HMAC'd things
payload[hmac_value_name] = smart_str(payload.get(hmac_value_name, ''), encoding='ascii', errors='replace')
payload[hmac_parameter_name] = hmac.new(app.config.biostar_key, payload[hmac_value_name]).hexdigest()
# generate url, can parse payload info
url = str(urljoin(app.config.biostar_url, biostar_action.get('url')(payload)))
if not biostar_action.get('uses_payload'):
payload = {}
url = url_for(url)
return url, payload
def tag_for_tool(tool):
"""
Generate a reasonable biostar tag for a tool.
"""
# Biostar can now handle tags with spaces, do we want to generate tags differently now?
return slugify(tool.name, delim='-')
def populate_tag_payload(payload=None, tool=None):
if payload is None:
payload = {}
if DEFAULT_GALAXY_TAG:
tag_val = [DEFAULT_GALAXY_TAG]
else:
tag_val = []
if tool:
tag_val.append(tag_for_tool(tool))
payload['tag_val'] = ','.join(tag_val)
return payload
def populate_tool_payload(payload=None, tool=None):
payload = populate_tag_payload(payload=payload, tool=tool)
payload['title'] = 'Need help with "%s" tool' % (tool.name)
tool_url = None
if tool.tool_shed_repository:
tool_url = tool.tool_shed_repository.get_sharable_url(tool.app)
if tool_url:
tool_url = '</br>ToolShed URL: <a href="%s">%s</a>' % (tool_url, tool_url)
if not tool_url:
tool_url = ''
payload['content'] = '<br /><hr /><p>Tool name: %s</br>Tool version: %s</br>Tool ID: %s%s</p></br>' % (tool.name, tool.version, tool.id, tool_url)
return payload
def determine_cookie_domain(galaxy_hostname, biostar_hostname):
if galaxy_hostname == biostar_hostname:
return galaxy_hostname
sub_biostar_hostname = biostar_hostname.split('.', 1)[-1]
if sub_biostar_hostname == galaxy_hostname:
return galaxy_hostname
sub_galaxy_hostname = galaxy_hostname.split('.', 1)[-1]
if sub_biostar_hostname == sub_galaxy_hostname:
return sub_galaxy_hostname
return galaxy_hostname
def create_cookie(trans, key_name, key, email, age=DEFAULT_BIOSTAR_COOKIE_AGE, override_never_authenticate=False):
if trans.app.config.biostar_never_authenticate and not override_never_authenticate:
log.debug('A BioStar link was clicked, but never authenticate has been enabled, so we will not create the login cookie.')
return
digest = hmac.new(key, email).hexdigest()
value = "%s:%s" % (email, digest)
trans.set_cookie(value, name=key_name, path='/', age=age, version='1')
# We need to explicitly set the domain here, in order to allow for biostar in a subdomain to work
galaxy_hostname = urlsplit(url_for('/', qualified=True)).hostname
biostar_hostname = urlsplit(trans.app.config.biostar_url).hostname
trans.response.cookies[key_name]['domain'] = determine_cookie_domain(galaxy_hostname, biostar_hostname)
def delete_cookie(trans, key_name):
# Set expiration of Cookie to time in past, to cause browser to delete
if key_name in trans.request.cookies:
create_cookie(trans, trans.app.config.biostar_key_name, '', '', age=-90, override_never_authenticate=True)
def biostar_logged_in(trans):
if biostar_enabled(trans.app):
if trans.app.config.biostar_key_name in trans.request.cookies:
return True
return False
def biostar_logout(trans):
if biostar_enabled(trans.app):
delete_cookie(trans, trans.app.config.biostar_key_name)
return get_biostar_url(trans.app, biostar_action='log_out')[0]
return None
class BiostarErrorReporter(ErrorReporter):
def _send_report(self, user, email=None, message=None, **kwd):
assert biostar_enabled(self.app), ValueError("Biostar is not configured for this galaxy instance")
assert self.app.config.biostar_enable_bug_reports, ValueError("Biostar is not configured to allow bug reporting for this galaxy instance")
assert self._can_access_dataset(user), Exception("You are not allowed to access this dataset.")
tool_version_select_field, tools, tool = \
self.app.toolbox.get_tool_components(self.tool_id, tool_version=None, get_loaded_tools_by_lineage=False, set_selected=True)
# Strip out unwanted HTML characters
html_remove = ['<html>', '<body>', '</body>', '</html>', '\n', '\r']
report = self.html_report
for tag in html_remove:
report = report.replace(tag, '')
# Must lstrip spaces or it isn't recognised as HTML
report = report.lstrip()
payload = {
'title': 'Bug report on "%s" tool' % (tool.name),
'content': report,
'tag_val': slugify('bug report')
}
# Get footer for email from here
payload2 = populate_tool_payload(tool=tool)
if 'content' in payload2:
payload['content'] = "%s<br />%s" % (payload['content'], payload2['content'])
if 'tag_val' in payload2:
payload['tag_val'] = ','.join([payload2['tag_val'], payload['tag_val']])
if 'action' not in payload:
payload['action'] = 1 # Automatically post bug reports to biostar
return payload
@@ -1018,41 +1018,6 @@ mapping:
desc: |
The URL linked by the "Support" link in the "Help" menu.
biostar_url:
type: str
default: ''
required: false
desc: |
Enable integration with a custom Biostar instance.
biostar_key_name:
type: str
default: ''
required: false
desc: |
Enable integration with a custom Biostar instance.
biostar_key:
type: str
default: ''
required: false
desc: |
Enable integration with a custom Biostar instance.
biostar_enable_bug_reports:
type: bool
default: true
required: false
desc: |
Enable integration with a custom Biostar instance.
biostar_never_authenticate:
type: bool
default: false
required: false
desc: |
Enable integration with a custom Biostar instance.
citation_url:
type: str
default: https://galaxyproject.org/citing-galaxy
@@ -1,106 +0,0 @@
"""
Controller for integration with the Biostar application
"""
from galaxy.util import biostar
from galaxy.web.base.controller import (
BaseUIController,
error,
web
)
class BiostarController(BaseUIController):
"""
Provides integration with Biostar through external authentication, see: http://liondb.com/help/x/
"""
@web.expose
def biostar_redirect(self, trans, payload=None, biostar_action=None):
"""
Generate a redirect to a Biostar site using external authentication to
pass Galaxy user information and optional information about a specific tool.
"""
try:
url, payload = biostar.get_biostar_url(trans.app, payload=payload, biostar_action=biostar_action)
except Exception as e:
return error(str(e))
# Only create/log in biostar user if is registered Galaxy user
if trans.user:
biostar.create_cookie(trans, trans.app.config.biostar_key_name, trans.app.config.biostar_key, trans.user.email)
if payload:
return trans.fill_template("biostar/post_redirect.mako", post_url=url, form_inputs=payload)
return trans.response.send_redirect(url)
@web.expose
def biostar_tool_tag_redirect(self, trans, tool_id=None):
"""
Generate a redirect to a Biostar site using tag for tool.
"""
# tool_id is required
if tool_id is None:
return error("No tool_id provided")
# Load the tool
tool_version_select_field, tools, tool = \
self.app.toolbox.get_tool_components(tool_id, tool_version=None, get_loaded_tools_by_lineage=False, set_selected=True)
# No matching tool, unlikely
if not tool:
return error("No tool found matching '%s'" % tool_id)
# Tool specific information for payload
payload = biostar.populate_tag_payload(tool=tool)
# Pass on to standard redirect method
return self.biostar_redirect(trans, payload=payload, biostar_action='show_tags')
@web.expose
def biostar_question_redirect(self, trans, payload=None):
"""
Generate a redirect to a Biostar site using external authentication to
pass Galaxy user information and information about a specific tool.
"""
# Pass on to standard redirect method
return self.biostar_redirect(trans, payload=payload, biostar_action='new_post')
@web.expose
def biostar_tool_question_redirect(self, trans, tool_id=None):
"""
Generate a redirect to a Biostar site using external authentication to
pass Galaxy user information and information about a specific tool.
"""
# tool_id is required
if tool_id is None:
return error("No tool_id provided")
# Load the tool
tool_version_select_field, tools, tool = \
self.app.toolbox.get_tool_components(tool_id, tool_version=None, get_loaded_tools_by_lineage=False, set_selected=True)
# No matching tool, unlikely
if not tool:
return error("No tool found matching '%s'" % tool_id)
# Tool specific information for payload
payload = biostar.populate_tool_payload(tool=tool)
# Pass on to regular question method
return self.biostar_question_redirect(trans, payload)
@web.expose
def biostar_tool_bug_report(self, trans, hda=None, email=None, message=None):
"""
Generate a redirect to a Biostar site using external authentication to
pass Galaxy user information and information about a specific tool error.
"""
try:
error_reporter = biostar.BiostarErrorReporter(hda, trans.app)
payload = error_reporter.send_report(trans.user, email=email, message=message)
except Exception as e:
return error(str(e))
return self.biostar_redirect(trans, payload=payload, biostar_action='new_post')
@web.expose
def biostar_logout(self, trans):
"""
Log out of biostar
"""
try:
url = biostar.biostar_log_out(trans)
except Exception as e:
return error(str(e))
if url:
return trans.response.send_redirect(url)
return error("Could not determine Biostar logout URL.")
@@ -178,7 +178,6 @@ class ToolsController(BaseAPIController):
tool_dict.update({
'help' : tool_help,
'citations' : bool(tool.citations),
'biostar_url' : trans.app.config.biostar_url,
'requirements' : [{'name' : r.name, 'version' : r.version} for r in tool.requirements],
'state_inputs' : params_to_strings(tool.inputs, {}, trans.app),
'display' : tool.display_interface,
-1
View File
@@ -116,7 +116,6 @@ class Configuration(object):
self.support_url = kwargs.get('support_url', 'https://galaxyproject.org/support')
self.wiki_url = kwargs.get('wiki_url', 'https://galaxyproject.org/')
self.blog_url = kwargs.get('blog_url', None)
self.biostar_url = kwargs.get('biostar_url', None)
self.screencasts_url = kwargs.get('screencasts_url', None)
self.log_events = False
self.cloud_controller_instance = False
@@ -1,26 +0,0 @@
<%inherit file="/base.mako"/>
<%def name="javascripts()">
${parent.javascripts()}
<script>
$( document ).ready( function(){
$("div#postRedirect").hide();
$("form#postRedirectForm").submit();
});
</script>
</%def>
<%def name="title()">Post Biostar Question</%def>
<div class="infomessagelarge">
<p>You are now being forwarded to Biostar.<p>
<div id="postRedirect">
<p>If you are not automatically forwarded, click the button below:<p>
<form id="postRedirectForm" action="${post_url}" method="post" >
%for input_name, input_value in form_inputs.items():
<input type="hidden" name="${input_name | h}" value="${input_value | h}">
%endfor
<input type="submit" name="GalaxySubmitPostRedirectForm" id='GalaxySubmitPostRedirectForm' value="Click Here">
</form>
</div>
</div>
@@ -13,8 +13,6 @@
'remote_user_logout_href' : app.config.remote_user_logout_href,
'enable_cloud_launch' : app.config.get_bool('enable_cloud_launch', False),
'lims_doc_url' : app.config.get("lims_doc_url", "https://usegalaxy.org/u/rkchak/p/sts"),
'biostar_url' : app.config.biostar_url,
'biostar_url_redirect' : h.url_for( controller='biostar', action='biostar_redirect', qualified=True ),
'default_locale' : app.config.get("default_locale", "auto"),
'support_url' : app.config.get("support_url", "https://galaxyproject.org/support"),
'search_url' : app.config.get("search_url", "http://galaxyproject.org/search/"),
@@ -4,7 +4,7 @@ type:
activate: true
icon: fa-star-half-o
tooltip: Biostars Galaxy
tooltip: Galaxy Help
function: >
window.open('https://biostar.usegalaxy.org', '_blank');
window.open('https://help.galaxyproject.org', '_blank');