Fix some things with the seo snapshots and use the pep8 style guite.
This commit is contained in:
parent
af4c67d7cb
commit
6355b4a217
3 changed files with 26 additions and 27 deletions
|
@ -11,7 +11,7 @@ from data import model
|
||||||
from app import app, login_manager, mixpanel
|
from app import app, login_manager, mixpanel
|
||||||
from auth.permissions import QuayDeferredPermissionUser, AdministerOrganizationPermission
|
from auth.permissions import QuayDeferredPermissionUser, AdministerOrganizationPermission
|
||||||
from util.invoice import renderInvoiceToPdf
|
from util.invoice import renderInvoiceToPdf
|
||||||
from util.seo import renderSnapshot
|
from util.seo import render_snapshot
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ def index(path):
|
||||||
@app.route('/snapshot/', methods=['GET'])
|
@app.route('/snapshot/', methods=['GET'])
|
||||||
@app.route('/snapshot/<path:path>', methods=['GET'])
|
@app.route('/snapshot/<path:path>', methods=['GET'])
|
||||||
def snapshot(path = ''):
|
def snapshot(path = ''):
|
||||||
result = renderSnapshot(path)
|
result = render_snapshot(path)
|
||||||
if result:
|
if result:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
<ul class="nav navbar-nav navbar-right" ng-switch on="user.anonymous">
|
<ul class="nav navbar-nav navbar-right" ng-switch on="user.anonymous">
|
||||||
|
<li>
|
||||||
<form class="navbar-form navbar-left" role="search">
|
<form class="navbar-form navbar-left" role="search">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input id="repoSearch" type="text" class="form-control" placeholder="Find Repo">
|
<input id="repoSearch" type="text" class="form-control" placeholder="Find Repo">
|
||||||
|
@ -31,6 +32,7 @@
|
||||||
<span class="navbar-left user-tools" ng-show="!user.anonymous">
|
<span class="navbar-left user-tools" ng-show="!user.anonymous">
|
||||||
<a href="/new/"><i class="fa fa-upload user-tool" bs-tooltip="tooltip.title" data-placement="bottom" title="Create new repository"></i></a>
|
<a href="/new/"><i class="fa fa-upload user-tool" bs-tooltip="tooltip.title" data-placement="bottom" title="Create new repository"></i></a>
|
||||||
</span>
|
</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
<li class="dropdown" ng-switch-when="false">
|
<li class="dropdown" ng-switch-when="false">
|
||||||
<a href="javascript:void(0)" class="dropdown-toggle user-dropdown" data-toggle="dropdown">
|
<a href="javascript:void(0)" class="dropdown-toggle user-dropdown" data-toggle="dropdown">
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
import subprocess
|
import subprocess
|
||||||
import urllib
|
|
||||||
import os
|
|
||||||
import logging
|
import logging
|
||||||
import codecs
|
|
||||||
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
def renderSnapshot(path):
|
def render_snapshot(path):
|
||||||
final_url = 'http://localhost:5000/' + path
|
final_url = 'http://localhost:5000/' + path
|
||||||
logger.info('Snapshotting url: %s -> %s' % (path, final_url))
|
logger.info('Snapshotting url: %s -> %s' % (path, final_url))
|
||||||
out_html = subprocess.check_output(['phantomjs', '--ignore-ssl-errors=yes',
|
out_html = subprocess.check_output(['phantomjs', '--ignore-ssl-errors=yes',
|
||||||
|
@ -19,9 +16,9 @@ def renderSnapshot(path):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Remove script tags
|
# Remove script tags
|
||||||
soup = BeautifulSoup(out_html)
|
soup = BeautifulSoup(out_html.decode('utf8'))
|
||||||
to_extract = soup.findAll('script')
|
to_extract = soup.findAll('script')
|
||||||
for item in to_extract:
|
for item in to_extract:
|
||||||
item.extract()
|
item.extract()
|
||||||
|
|
||||||
return soup.prettify()
|
return str(soup)
|
||||||
|
|
Reference in a new issue