Skip to content

Fixes #2778 - Implements HTTP/2 Push through Flask #2792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,13 @@ jobs:
command: |
. venv/bin/activate
pep8 --ignore=E402 webcompat/ tests/ config/secrets.py.example
python run.py -t &
sleep 5
nosetests
npm run lint
npm run build
nosetests
python run.py -t &
sleep 5
node --max-old-space-size=8192 ./tests/functional/_intern.js --reporters="runner" --firefoxBinary=`which firefox`
firefox --version

- store_artifacts:
path: test-reports
destination: test-reports
1 change: 1 addition & 0 deletions config/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
blinker==1.4
Flask==1.0.2
Flask-Firehose==0.2.2
Flask-Limiter==0.9.3
Flask-SQLAlchemy==2.1
Flask-WTF==0.14.2
Expand Down
5 changes: 5 additions & 0 deletions webcompat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@
import logging

from flask import Flask
from flask_firehose import Firehose
from flask_github import GitHub
from flask_limiter import Limiter
from flask_limiter.util import get_remote_address

# Define the application
app = Flask(__name__, static_url_path='')
Firehose(app)
# Adds the HTTP/2 Server Push functionality to app
# firehose = Firehose(connector=Custom_connector())
# firehose.init_app(app)

# Configurations
app.config.from_object('config')
Expand Down
50 changes: 50 additions & 0 deletions webcompat/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
from flask import url_for

from dashboard import filter_needstriage
from flask_firehose import push
from form import AUTH_REPORT
from form import get_form
from form import PROXY_REPORT
from helpers import add_csp
from helpers import add_sec_headers
from helpers import bust_cache
from helpers import cache_policy
from helpers import form_type
from helpers import get_browser_name
Expand Down Expand Up @@ -153,6 +155,22 @@ def file_issue():
@app.route('/', methods=['GET'])
def index():
"""Set the main view where people come to report issues."""
push('/css/dist/webcompat.min.css', **{
'as': 'style',
'rel': 'preload'
})
push(bust_cache('/js/dist/webcompat.min.js'), **{
'as': 'script',
'rel': 'preload'
})
push('/img/svg/icons/svg-leaf_right.svg', **{
'as': 'img',
'rel': 'preload'
})
push('/img/svg/icons/svg-leaf_left.svg', **{
'as': 'img',
'rel': 'preload'
})
ua_header = request.headers.get('User-Agent')
bug_form = get_form({'user_agent': ua_header})
# browser_name is used in topbar.html to show the right add-on link
Expand All @@ -167,6 +185,18 @@ def index():
@cache_policy(private=True, uri_max_age=0, must_revalidate=True)
def show_issues():
"""Route to display global issues view."""
push('/css/dist/webcompat.min.css', **{
'as': 'style',
'rel': 'preload'
})
push(bust_cache('/js/dist/webcompat.min.js'), **{
'as': 'script',
'rel': 'preload'
})
push(bust_cache('/js/dist/issues.min.js'), **{
'as': 'script',
'rel': 'preload'
})
if g.user:
get_user_info()
categories = app.config['CATEGORIES']
Expand Down Expand Up @@ -206,6 +236,14 @@ def create_issue():
Any deceptive requests will be ended as a 400.
See https://tools.ietf.org/html/rfc7231#section-6.5.1
"""
push('/css/dist/webcompat.min.css', **{
'as': 'style',
'rel': 'preload'
})
push(bust_cache('/js/dist/webcompat.min.js'), **{
'as': 'script',
'rel': 'preload'
})
# Starting a logger
log = app.logger
log.setLevel(logging.INFO)
Expand Down Expand Up @@ -276,6 +314,18 @@ def create_issue():
@cache_policy(private=True, uri_max_age=0, must_revalidate=True)
def show_issue(number):
"""Route to display a single issue."""
push('/css/dist/webcompat.min.css', **{
'as': 'style',
'rel': 'preload'
})
push(bust_cache('/js/dist/webcompat.min.js'), **{
'as': 'script',
'rel': 'preload'
})
push(bust_cache('/js/dist/issues.min.js'), **{
'as': 'script',
'rel': 'preload'
})
if g.user:
get_user_info()
if session.get('show_thanks'):
Expand Down