Fix the nginx config to work with the new snapshots. Fix the snapshot creator to correctly create the request path.

This commit is contained in:
yackob03 2013-11-18 19:17:58 -05:00
parent 84b9fdd007
commit f5e6af37cf
3 changed files with 13 additions and 9 deletions

View file

@ -4,15 +4,18 @@ import stripe
from flask import (abort, redirect, request, url_for, render_template,
make_response, Response)
from flask.ext.login import login_user, UserMixin, login_required
from flask.ext.principal import identity_changed, Identity, AnonymousIdentity
from flask.ext.login import login_user, UserMixin
from flask.ext.principal import identity_changed
from urlparse import urlparse
from data import model
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.seo import render_snapshot
logger = logging.getLogger(__name__)
@ -54,7 +57,9 @@ def index(path):
@app.route('/snapshot/', methods=['GET'])
@app.route('/snapshot/<path:path>', methods=['GET'])
def snapshot(path = ''):
result = render_snapshot(path)
parsed = urlparse(request.url)
final_url = '%s://%s/%s' % (parsed.scheme, 'localhost', path)
result = render_snapshot(final_url)
if result:
return result

View file

@ -45,7 +45,7 @@ http {
ssl_prefer_server_ciphers on;
if ($args ~ "_escaped_fragment_") {
rewrite ^ /static/snapshots$uri/index.html;
rewrite ^ /snapshot$uri;
}
location /static/ {

View file

@ -6,11 +6,10 @@ from bs4 import BeautifulSoup
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG)
def render_snapshot(path):
final_url = 'http://localhost:5000/' + path
logger.info('Snapshotting url: %s -> %s' % (path, final_url))
def render_snapshot(url):
logger.info('Snapshotting url: %s' % url)
out_html = subprocess.check_output(['phantomjs', '--ignore-ssl-errors=yes',
'util/phantomjs-runner.js', final_url])
'util/phantomjs-runner.js', url])
if not out_html or out_html.strip() == 'Not Found':
return None