Fix some things with the seo snapshots and use the pep8 style guite.

This commit is contained in:
yackob03 2013-11-18 18:42:27 -05:00
parent af4c67d7cb
commit 6355b4a217
3 changed files with 26 additions and 27 deletions

View file

@ -11,7 +11,7 @@ from data import model
from app import app, login_manager, mixpanel
from auth.permissions import QuayDeferredPermissionUser, AdministerOrganizationPermission
from util.invoice import renderInvoiceToPdf
from util.seo import renderSnapshot
from util.seo import render_snapshot
logger = logging.getLogger(__name__)
@ -54,7 +54,7 @@ def index(path):
@app.route('/snapshot/', methods=['GET'])
@app.route('/snapshot/<path:path>', methods=['GET'])
def snapshot(path = ''):
result = renderSnapshot(path)
result = render_snapshot(path)
if result:
return result

View file

@ -22,6 +22,7 @@
<ul class="nav navbar-nav navbar-right" ng-switch on="user.anonymous">
<li>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<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">
<a href="/new/"><i class="fa fa-upload user-tool" bs-tooltip="tooltip.title" data-placement="bottom" title="Create new repository"></i></a>
</span>
</li>
<li class="dropdown" ng-switch-when="false">
<a href="javascript:void(0)" class="dropdown-toggle user-dropdown" data-toggle="dropdown">

View file

@ -1,15 +1,12 @@
import subprocess
import urllib
import os
import logging
import codecs
from bs4 import BeautifulSoup
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG)
def renderSnapshot(path):
def render_snapshot(path):
final_url = 'http://localhost:5000/' + path
logger.info('Snapshotting url: %s -> %s' % (path, final_url))
out_html = subprocess.check_output(['phantomjs', '--ignore-ssl-errors=yes',
@ -19,9 +16,9 @@ def renderSnapshot(path):
return None
# Remove script tags
soup = BeautifulSoup(out_html)
soup = BeautifulSoup(out_html.decode('utf8'))
to_extract = soup.findAll('script')
for item in to_extract:
item.extract()
return soup.prettify()
return str(soup)