Пример #1
0
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
    browser_name = get_browser_name(ua_header)
    # GET means you want to file a report.
    if g.user:
        get_user_info()
    return render_template('index.html', form=bug_form, browser=browser_name)
Пример #2
0
def index():
    """Set the main view where people come to report issues."""
    push('/dist/webcompat.css', **{
        'as': 'style',
        'rel': 'preload'
    })
    push(bust_cache('/dist/vendor.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    push(bust_cache('/dist/webcompat.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    push(bust_cache('/dist/index.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    ua_header = request.headers.get('User-Agent')

    # browser_name is used in topbar.html to show the right add-on link
    browser_name = get_browser_name(ua_header)
    # GET means you want to file a report.
    if g.user:
        get_user_info()
    return render_template('index.html', browser=browser_name)
Пример #3
0
def show_issue(number):
    """Route to display a single issue."""
    push('/dist/webcompat.css', **{
        'as': 'style',
        'rel': 'preload'
    })
    push(bust_cache('/dist/vendor.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    push(bust_cache('/dist/webcompat.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    push(bust_cache('/dist/issue-page.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    if g.user:
        get_user_info()
    if session.get('show_thanks'):
        flash(number, 'thanks')
        session.pop('show_thanks')
    issue_data = proxy_issue(number)
    return render_template('issue.html',
                           issue_data=json.loads(issue_data[0]),
                           json_data=to_str(issue_data[0]))
Пример #4
0
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
    browser_name = get_browser_name(ua_header)
    # GET means you want to file a report.
    if g.user:
        get_user_info()
    return render_template('index.html', form=bug_form, browser=browser_name)
Пример #5
0
def show_issues():
    """Route to display global issues view."""
    push('/dist/webcompat.css', **{'as': 'style', 'rel': 'preload'})
    push(bust_cache('/dist/vendor.js'), **{'as': 'script', 'rel': 'preload'})
    push(bust_cache('/dist/webcompat.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    push(bust_cache('/dist/issues-list.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    if g.user:
        get_user_info()
    categories = app.config['CATEGORIES']
    return render_template('list-issue.html', categories=categories)
Пример #6
0
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'):
        flash(number, 'thanks')
        session.pop('show_thanks')
    return render_template('issue.html', number=number)
Пример #7
0
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']
    return render_template('list-issue.html', categories=categories)
Пример #8
0
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'):
        flash(number, 'thanks')
        session.pop('show_thanks')
    return render_template('issue.html', number=number)
Пример #9
0
def create_issue():
    """Create a new issue or prefill a form for submission.

    * HTTP GET with (optional) parameters
      * create a form with prefilled data.
      * parameters:
        * url: URL of the Web site
        * src: source of the request (web, addon, etc.)
        * label: controled list of labels
    * HTTP POST with a JSON payload
      * create a form with prefilled data
      * content-type is application/json
      * json may include:
        * title
        * User agent string
        * OS identification
        * labels list
        * type of bugs
        * short summary
        * full description
        * tested in another browser
        * body
        * utm_ params for Google Analytics
    * HTTP POST with an attached form
      * submit a form to GitHub to create a new issue
      * form submit type:
        * authenticated: Github authentification
        * anonymous: handled by webcompat-bot

    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)
    if g.user:
        get_user_info()
    # We define which type of requests we are dealing with.
    request_type = form_type(request)
    # Form Prefill section
    if request_type == 'prefill':
        form_data = prepare_form(request)
        # XXXTemp Hack: if the user clicked on Report Site Issue from Release,
        # we want to redirect them somewhere else and forget all their data.
        # See https://bugzilla.mozilla.org/show_bug.cgi?id=1513541
        if form_data == 'release':
            return render_template('thanks.html')
        bug_form = get_form(form_data)
        session['extra_labels'] = form_data['extra_labels']
        source = form_data.pop('utm_source', None)
        campaign = form_data.pop('utm_campaign', None)
        return render_template('new-issue.html',
                               form=bug_form,
                               source=source,
                               campaign=campaign,
                               nonce=request.nonce)
    # Issue Creation section
    elif request_type == 'create':
        # Check if there is a form
        if not request.form:
            log.info('POST request without form.')
            abort(400)
        # Adding parameters to the form
        form = request.form.copy()
        extra_labels = session.pop('extra_labels', None)
        if extra_labels:
            form['extra_labels'] = extra_labels
        # Logging the ip and url for investigation
        log.info('{ip} {url}'.format(ip=request.remote_addr,
                                     url=form['url'].encode('utf-8')))
        # Check if the form is valid
        if not is_valid_issue_form(form):
            abort(400)
        if form.get('submit_type') == PROXY_REPORT:
            # Checking blacklisted domains
            domain = urlparse.urlsplit(form['url']).hostname
            if is_blacklisted_domain(domain):
                msg = app.config['IS_BLACKLISTED_DOMAIN'].format(form['url'])
                flash(msg, 'notimeout')
                return redirect(url_for('index'))
            # Anonymous reporting
            json_response = report_issue(form, proxy=True)
            session['show_thanks'] = True
            return redirect(
                url_for('show_issue', number=json_response.get('number')))
        # Authenticated reporting
        if form.get('submit_type') == AUTH_REPORT:
            if g.user:  # If you're already authed, submit the bug.
                json_response = report_issue(form)
                session['show_thanks'] = True
                return redirect(
                    url_for('show_issue', number=json_response.get('number')))
            else:
                # Stash form data into session, go do GitHub auth
                session['form'] = form
                return redirect(url_for('login'))
    else:
        abort(400)
Пример #10
0
def create_issue():
    """Create a new issue or prefill a form for submission.

    * HTTP GET with (optional) parameters
      * create a form with prefilled data.
      * parameters:
        * url: URL of the Web site
        * src: source of the request (web, addon, etc.)
        * label: controled list of labels
    * HTTP POST with a JSON payload
      * create a form with prefilled data
      * content-type is application/json
      * json may include:
        * title
        * User agent string
        * OS identification
        * labels list
        * type of bugs
        * short summary
        * full description
        * tested in another browser
        * body
        * utm_ params for Google Analytics
    * HTTP POST with an attached form
      * submit a form to GitHub to create a new issue
      * form submit type:
        * authenticated: Github authentification
        * anonymous: handled by webcompat-bot

    Any deceptive requests will be ended as a 400.
    See https://tools.ietf.org/html/rfc7231#section-6.5.1
    """
    push('/dist/webcompat.css', **{'as': 'style', 'rel': 'preload'})
    push(bust_cache('/dist/vendor.js'), **{'as': 'script', 'rel': 'preload'})
    push(bust_cache('/dist/webcompat.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    push(bust_cache('/dist/formv2.js'), **{'as': 'script', 'rel': 'preload'})
    # Starting a logger
    log = app.logger
    log.setLevel(logging.INFO)
    if g.user:
        get_user_info()
    # We define which type of requests we are dealing with.
    request_type = form_type(request)
    # Form Prefill section
    if request_type == 'prefill':
        form_data = prepare_form(request)
        bug_form = get_form(form_data, form=FormWizard)
        pagetitle = "New Issue"
        session['extra_labels'] = form_data['extra_labels']
        source = form_data.pop('utm_source', None)
        campaign = form_data.pop('utm_campaign', None)
        anonymous_reporting = app.config['ANONYMOUS_REPORTING_ENABLED']
        return render_template('new-issue.html',
                               form=bug_form,
                               source=source,
                               campaign=campaign,
                               nonce=request.nonce,
                               pagetitle=pagetitle,
                               anonymous_reporting=anonymous_reporting)
    # Issue Creation section
    elif request_type == 'create':
        # Check if there is a form
        if not request.form:
            log.info('400: POST request without form.')
            abort(400)
        # Adding parameters to the form
        form = request.form.copy()
        extra_labels = get_extra_labels(form)
        if extra_labels:
            form['extra_labels'] = extra_labels
        # Logging the ip and url for investigation
        log.info('{ip} {url}'.format(ip=request.remote_addr,
                                     url=form['url'].encode('utf-8')))
        # Check if the form is valid
        if not is_valid_issue_form(form):
            log.info('400: POST request w/o valid form (is_valid_issue_form).')
            abort(400)
        domain = urllib.parse.urlsplit(normalize_url(form['url'])).hostname
        if is_darknet_domain(domain):
            msg = app.config['IS_DARKNET_DOMAIN'].format(form['url'])
            flash(msg, 'notimeout')
            return redirect(url_for('index'))
        if form.get('submit_type') == PROXY_REPORT:
            if not app.config['ANONYMOUS_REPORTING_ENABLED']:
                abort(400)
            # Checking blocked domains
            if is_blocked_domain(domain):
                msg = app.config['IS_BLOCKED_DOMAIN'].format(form['url'])
                flash(msg, 'notimeout')
                return redirect(url_for('index'))
            # Anonymous reporting
            json_response = report_issue(form, proxy=True)
            session['show_thanks'] = True
            return redirect(
                url_for('show_issue', number=json_response.get('number')))
        # Authenticated reporting
        if form.get('submit_type') == AUTH_REPORT:
            if g.user:  # If you're already authed, submit the bug.
                json_response = report_issue(form)
                session['show_thanks'] = True
                return redirect(
                    url_for('show_issue', number=json_response.get('number')))
            else:
                # Stash form data into session, go do GitHub auth
                session['form'] = form
                return redirect(url_for('login'))
    else:
        log.info('400: Something else happened.')
        abort(400)
Пример #11
0
def render_doc2():
    push('/static/js/vendor/modernizr-3.5.0.min.js', **{
        'as': 'script',
        'rel': 'preload'
    })
    return render_template('doc2.html')
Пример #12
0
def create_issue():
    """Create a new issue or prefill a form for submission.

    * HTTP GET with (optional) parameters
      * create a form with prefilled data.
      * parameters:
        * url: URL of the Web site
        * src: source of the request (web, addon, etc.)
        * label: controled list of labels
    * HTTP POST with a JSON payload
      * create a form with prefilled data
      * content-type is application/json
      * json may include:
        * title
        * User agent string
        * OS identification
        * labels list
        * type of bugs
        * short summary
        * full description
        * tested in another browser
        * body
        * utm_ params for Google Analytics
    * HTTP POST with an attached form
      * submit a form to GitHub to create a new issue
      * form submit type:
        * authenticated: Github authentification
        * anonymous: handled by webcompat-bot

    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)
    if g.user:
        get_user_info()
    # We define which type of requests we are dealing with.
    request_type = form_type(request)
    # Form Prefill section
    if request_type == 'prefill':
        form_data = prepare_form(request)
        bug_form = get_form(form_data)
        session['extra_labels'] = form_data['extra_labels']
        source = form_data.pop('utm_source', None)
        campaign = form_data.pop('utm_campaign', None)
        return render_template('new-issue.html', form=bug_form, source=source,
                               campaign=campaign, nonce=request.nonce)
    # Issue Creation section
    elif request_type == 'create':
        # Check if there is a form
        if not request.form:
            log.info('POST request without form.')
            abort(400)
        # Adding parameters to the form
        form = request.form.copy()
        extra_labels = session.pop('extra_labels', None)
        if extra_labels:
            form['extra_labels'] = extra_labels
        # Logging the ip and url for investigation
        log.info('{ip} {url}'.format(
            ip=request.remote_addr,
            url=form['url'].encode('utf-8')))
        # Check if the form is valid
        if not is_valid_issue_form(form):
            abort(400)
        if form.get('submit_type') == PROXY_REPORT:
            # Checking blacklisted domains
            domain = urlparse.urlsplit(form['url']).hostname
            if is_blacklisted_domain(domain):
                msg = app.config['IS_BLACKLISTED_DOMAIN'].format(form['url'])
                flash(msg, 'notimeout')
                return redirect(url_for('index'))
            # Anonymous reporting
            json_response = report_issue(form, proxy=True)
            session['show_thanks'] = True
            return redirect(
                url_for('show_issue', number=json_response.get('number')))
        # Authenticated reporting
        if form.get('submit_type') == AUTH_REPORT:
            if g.user:  # If you're already authed, submit the bug.
                json_response = report_issue(form)
                session['show_thanks'] = True
                return redirect(url_for('show_issue',
                                        number=json_response.get('number')))
            else:
                # Stash form data into session, go do GitHub auth
                session['form'] = form
                return redirect(url_for('login'))
    else:
        abort(400)