diff --git a/.gitignore b/.gitignore index ecd08a107..7080f312c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ *.pyc venv -static/snapshots/ screenshots/screenshots/ stack grunt/node_modules diff --git a/Dockerfile b/Dockerfile index 4a2d9988e..07863ee3d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,6 @@ RUN apt-get install -y \ libsasl2-modules \ nodejs \ npm \ - phantomjs \ python-dev \ python-pip \ python-virtualenv diff --git a/conf/server-base.conf b/conf/server-base.conf index 04513c122..d43258221 100644 --- a/conf/server-base.conf +++ b/conf/server-base.conf @@ -8,10 +8,6 @@ if ($host = "www.quay.io") { return 301 $proper_scheme://quay.io$request_uri; } -if ($args ~ "_escaped_fragment_") { - rewrite ^ /snapshot$uri; -} - # Disable the ability to be embedded into iframes add_header X-Frame-Options DENY; diff --git a/endpoints/web.py b/endpoints/web.py index fa3ebb522..952d77b57 100644 --- a/endpoints/web.py +++ b/endpoints/web.py @@ -32,7 +32,6 @@ from health.healthcheck import get_healthchecker from util.cache import no_cache from util.headers import parse_basic_auth from util.invoice import renderInvoiceToPdf -from util.seo import render_snapshot from util.systemlogs import build_logs_archive from util.useremails import send_email_changed @@ -84,19 +83,6 @@ def user_view(path): return index('') -@web.route('/snapshot', methods=['GET']) -@web.route('/snapshot/', methods=['GET']) -@web.route('/snapshot/', methods=['GET']) -def snapshot(path = ''): - parsed = urlparse(request.url) - final_url = '%s://%s/%s' % (parsed.scheme, 'localhost', path) - result = render_snapshot(final_url) - if result: - return result - - abort(404) - - @route_show_if(features.ACI_CONVERSION) @web.route('/aci-signing-key') @no_cache diff --git a/util/seo.py b/util/seo.py deleted file mode 100644 index 6212443dd..000000000 --- a/util/seo.py +++ /dev/null @@ -1,44 +0,0 @@ -import subprocess -import logging - -from urllib import urlencode -from urlparse import parse_qs, urlsplit, urlunsplit -from bs4 import BeautifulSoup - -logger = logging.getLogger(__name__) - -def set_query_parameter(url, param_name, param_value): - # From: http://stackoverflow.com/questions/4293460/how-to-add-custom-parameters-to-an-url-query-string-with-python - scheme, netloc, path, query_string, fragment = urlsplit(url) - query_params = parse_qs(query_string) - - query_params[param_name] = [param_value] - new_query_string = urlencode(query_params, doseq=True) - - return urlunsplit((scheme, netloc, path, new_query_string, fragment)) - - -def render_snapshot(url): - logger.info('Snapshotting url: %s' % url) - - url = set_query_parameter(url, 'use_cdn', False) - out_html = subprocess.check_output(['phantomjs', '--ignore-ssl-errors=yes', - '--disk-cache=yes', '--ssl-protocol=tlsv1', - 'util/phantomjs-runner.js', url]) - - if not out_html or out_html.strip() == 'Not Found': - return None - - # Remove script tags - logger.info('Removing script tags: %s' % url) - - try: - soup = BeautifulSoup(out_html.decode('utf8'), 'html.parser') - to_extract = soup.findAll('script') - for item in to_extract: - item.extract() - except: - logger.exception('Exception when trying to parse served HTML') - return out_html - - return str(soup)