Skip to content

Commit 133cffe

Browse files
author
Mike Taylor
committed
Merge branch 'master' into issues/564/1
* master: (46 commits) Fixes #509 - mention [ci skip] in docs. v1.6.2 changelog Issues #588 - list style Fix #583 Using the function for checking dependencies Checking dependencies Modules needed for checking dependencies Two cases to handle Adding message Issue #368 - Remove (now) unused STARTUP variable Issue #368 - Compute cache busting param based on md5 hash of file Issue #368 - Move bust_cache function into a Jinja template helper Issue #368: Part 1, add bust_cache param to minified production JS Issue #587 - Add a task to check npm dependencies and run by default v1.6.1 Fixes #591 - Typo in form field. >_< Tag v1.6.0 Issue #572 - Remove right float for GitHub issue warp hint Issue #432 - Add js-form-error and js-no-error classes and update tests. Issue #432 - Add wc-Form-required class to problem label Added wc-Form, wc-ReportForm ...
2 parents 0056ef4 + c9dfbf4 commit 133cffe

32 files changed

+438
-304
lines changed

CHANGELOG.md

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
## 1.6.2 - 2014-03-25
2+
3+
* CSS refactor around forms [Pull #585](https://github.com/webcompat/webcompat.com/pull/585)
4+
* md5 checksum-based cache busting for static assets [Pull #594](https://github.com/webcompat/webcompat.com/pull/594) [Issue #368](https://github.com/webcompat/webcompat.com/issues/368)
5+
* Better dependency checking for PIP [Pull #597](https://github.com/webcompat/webcompat.com/pull/597) [Issue #583](https://github.com/webcompat/webcompat.com/issues/583)
6+
* Add a grunt task to check NPM dependencies [Pull #593](https://github.com/webcompat/webcompat.com/pull/593) [Issue #587](https://github.com/webcompat/webcompat.com/issues/587)
7+
* Update list style [Pull #598](https://github.com/webcompat/webcompat.com/pull/598) [Issue #588](https://github.com/webcompat/webcompat.com/issues/588)
8+
9+
## 1.6.1 - 2014-03-10
10+
11+
* Typo fix (lol) [Issue #591](https://github.com/webcompat/webcompat.com/issues/591)
12+
13+
## 1.6.0 - 2014-03-09
14+
15+
* Fix bug with Issue back arrow & history [Pull #570](https://github.com/webcompat/webcompat.com/pull/570) [Issue #569](https://github.com/webcompat/webcompat.com/issues/569)
16+
* Add link to "G takes you to GitHub" note for mobile users [Pull #573](https://github.com/webcompat/webcompat.com/pull/573) [Issue #572](https://github.com/webcompat/webcompat.com/issues/572)
17+
* Link to HTTPS [Pull #574](https://github.com/webcompat/webcompat.com/pull/574)
18+
* Add anchors to headings on contributors page [Pull #578](https://github.com/webcompat/webcompat.com/pull/578) [Issue #577](https://github.com/webcompat/webcompat.com/issues/577)
19+
* Remove text-overflow on titles [Pull #580](https://github.com/webcompat/webcompat.com/pull/580)
20+
* Provide "Greatest hits" for compat issues in bug form [Pull #579](https://github.com/webcompat/webcompat.com/pull/579) [Issue #432](https://github.com/webcompat/webcompat.com/issues/432)
21+
* Update some css-related modules (`cssnext`, `cssrecipes-utils`, `cssrecipes-reset`) [Pull #581](https://github.com/webcompat/webcompat.com/pull/581)
22+
* Update contribution links on homepage [Pull #584](https://github.com/webcompat/webcompat.com/pull/584) [Issue #576](https://github.com/webcompat/webcompat.com/issues/576)
23+
* Refactor CSS related to new form changes [Pull #585](https://github.com/webcompat/webcompat.com/pull/585)
24+
125
## 1.5.3 - 2014-02-26
226

327
* Add a "Report an Issue" link to the global nav [Pull #568](https://github.com/webcompat/webcompat.com/pull/568) [Issue #565](https://github.com/webcompat/webcompat.com/issues/565)

CONTRIBUTING.md

+2
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ You can run the Python unit tests from the project root with the `nosetests` com
318318
319319
Running functional tests is a bit more involved (see the next section).
320320
321+
Tests are also run automatically on [Travis](https://travis-ci.org/webcompat/webcompat.com) for each commit. If you would like to skip running tests for a given commit, you can use use the magical `[ci skip]` string in your commit message. See the [Travis docs](http://docs.travis-ci.com/user/how-to-skip-a-build/#Not-All-Commits-Need-CI-Builds) for more info.
322+
321323
### Functional Tests
322324
323325
We use [Intern](http://theintern.io/) to run functional tests.

Gruntfile.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ module.exports = function (grunt) {
1919
require('load-grunt-tasks')(grunt)
2020

2121
// Default task.
22-
grunt.registerTask('default', ['jshint', 'concat', 'uglify','cssnext','cmq', 'cssmin', 'imagemin']);
22+
grunt.registerTask('default', [
23+
'checkDependencies', 'jshint', 'concat', 'uglify','cssnext', 'cssmin', 'imagemin'
24+
]);
2325
};

config.py.example

-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ DEBUG = False
4141
if not PRODUCTION:
4242
DEBUG = True
4343

44-
STARTUP = str(datetime.now())
45-
4644
# Get the secrets from [1] if you're part of the webcompat organization.
4745
# Otherwise, create your own test and production applications.
4846
#

grunt-tasks/check-deps.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = function(grunt) {
2+
grunt.config('checkDependencies', {
3+
default: {
4+
this: {}
5+
}
6+
});
7+
};

grunt-tasks/cssnext.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@ module.exports = function(grunt) {
22
grunt.config('cssnext', {
33
options: {
44
sourcemap: true,
5-
features:{
6-
autoprefixer: {
7-
browsers: ['ff >= 4', 'ie >= 8', 'safari >= 5.1', 'opera >= 12', 'chrome >=10']
8-
},
9-
import: {
10-
path: ["node_modules"]
11-
}
12-
}
5+
url : false,
6+
browsers: ['ff >= 4', 'ie >= 8', 'safari >= 5.1', 'opera >= 12', 'chrome >=10'],
7+
import: { path: ["node_modules"] }
138
},
149
dist: {
1510
files: {

package.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"name": "The fine folks who contribute to webcompat.com",
66
"url": "http://webcompat.com"
77
},
8-
"repository" : {
9-
"type" : "git",
10-
"url" : "https://github.com/webcompat/webcompat.com.git"
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/webcompat/webcompat.com.git"
1111
},
1212
"engines": {
1313
"node": ">= 0.10.0"
@@ -19,16 +19,16 @@
1919
"grunt-contrib-concat": "~0.3.0",
2020
"grunt-contrib-uglify": "~0.2.7",
2121
"grunt-contrib-cssmin": "~0.9.0",
22-
"grunt-combine-media-queries": "~1.0.19",
22+
"grunt-check-dependencies": "~0.9.0",
2323
"load-grunt-tasks": "~0.6.0",
2424
"intern": "2.2.0",
2525
"grunt-contrib-imagemin": "~0.7.1",
26-
"grunt-cssnext" : "^0.3.0",
27-
"suitcss-utils-display" : "^0.4.0",
28-
"suitcss-utils-align" : "^0.2.0",
29-
"cssrecipes-reset" : "^0.4.0",
30-
"cssrecipes-utils" : "^0.4.0",
31-
"cssrecipes-grid" : "^0.4.0",
32-
"cssrecipes-custom-media-queries" : "0.3.0"
26+
"grunt-cssnext": "^1.0.0",
27+
"suitcss-utils-display": "^0.4.0",
28+
"suitcss-utils-align": "^0.2.0",
29+
"cssrecipes-reset": "^0.5.0",
30+
"cssrecipes-utils": "^0.5.0",
31+
"cssrecipes-grid": "^0.4.0",
32+
"cssrecipes-custom-media-queries": "0.3.0"
3333
}
3434
}

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Flask-Cache==0.13.1
44
Flask-Limiter==0.7.4
55
Flask-SQLAlchemy==1.0
66
GitHub-Flask==0.3.4
7-
WTForms==1.0.5
7+
WTForms==2.0.2
88
ua-parser==0.3.5
99
nose==1.3.1
1010
blinker==1.3

run.py

+44-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
66

77
import argparse
8+
import pkg_resources
9+
from pkg_resources import DistributionNotFound, VersionConflict
10+
import subprocess
811
import sys
912

1013
IMPORT_ERROR = '''
@@ -29,6 +32,44 @@
2932
https://github.com/webcompat/webcompat.com/blob/master/CONTRIBUTING.md#configuring-the-server
3033
'''
3134

35+
DEPS_VERSION_HELP = '''
36+
The following required versions do not match your locally installed versions:
37+
38+
%s
39+
40+
Install the correct versions using the commands below before continuing:
41+
42+
pip uninstall name
43+
pip install name==1.2.1
44+
'''
45+
46+
DEPS_NOTFOUND_HELP = '''
47+
The following required module is missing from your installation.
48+
49+
%s
50+
51+
Install the module using the command below before continuing:
52+
53+
pip install name==1.2.1
54+
'''
55+
56+
57+
def check_pip_deps():
58+
'''Check installed pip dependencies.
59+
60+
Make sure that the installed pip packages match what is in
61+
requirements.txt, prompting the user to upgrade if not.
62+
'''
63+
req = subprocess.check_output(["cat", "requirements.txt"]).splitlines()
64+
try:
65+
pkg_resources.require(req)
66+
except VersionConflict as e:
67+
print(DEPS_VERSION_HELP % e)
68+
except DistributionNotFound as e:
69+
print(DEPS_NOTFOUND_HELP % e)
70+
else:
71+
return True
72+
3273

3374
def config_validator():
3475
'''Make sure the config file is ready.'''
@@ -50,7 +91,7 @@ def config_validator():
5091
# can interact with them. *ONLY* do this for testing.
5192
app.config['SESSION_COOKIE_HTTPONLY'] = False
5293
print("Starting server in ~*TEST MODE*~")
53-
app.run()
94+
app.run(host='localhost')
5495
else:
55-
print("[Use http://localhost:5000/]")
56-
app.run()
96+
if check_pip_deps():
97+
app.run(host='localhost')

tests/functional/reporting.js

+26-11
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,40 @@ define([
3636
.get(require.toUrl(url + '?open=1'))
3737
.findByCssSelector('#url').click()
3838
.end()
39-
.findByCssSelector('#summary').click()
39+
.findByCssSelector('#browser').click()
4040
.end()
41-
.findByCssSelector('#url').type('hi')
41+
.findByXpath('//*[@id="new-report"]/div/form/div[1]/div[2]/div[1]').getAttribute('class')
42+
.then(function (className) {
43+
assert.include(className, 'js-form-error');
44+
assert.notInclude(className, 'js-no-error');
45+
})
46+
.end()
47+
.findByCssSelector('#url').type('sup')
48+
.end()
49+
// xpath to the #url formGroup
50+
.findByXpath('//*[@id="new-report"]/div/form/div[1]/div[2]/div[1]').getAttribute('class')
51+
.then(function (className) {
52+
assert.include(className, 'js-no-error');
53+
assert.notInclude(className, 'js-form-error');
54+
})
4255
.end()
43-
.findByCssSelector('#summary').click()
56+
// click in the textarea to trigger validation for radios
57+
.findByCssSelector('#description').click()
4458
.end()
45-
.findByCssSelector('.u-formGroup').getAttribute('class')
59+
.findByXpath('//*[@id="new-report"]/div/form/div[1]/div[1]/fieldset').getAttribute('class')
4660
.then(function (className) {
47-
assert.include(className, 'no-error');
48-
assert.notInclude(className, 'has-error');
61+
assert.include(className, 'js-form-error');
62+
assert.notInclude(className, 'js-no-error');
4963
})
5064
.end()
51-
.findByCssSelector('#summary').type('sup')
65+
// pick a problem type
66+
.findByCssSelector('#problem_category-0').click()
5267
.end()
53-
// xpath to the #summary formGroup
54-
.findByXpath('//*[@id="new-report"]/div/form/div[1]/div[2]/div').getAttribute('class')
68+
// validation message should be removed now
69+
.findByXpath('//*[@id="new-report"]/div/form/div[1]/div[1]/fieldset').getAttribute('class')
5570
.then(function (className) {
56-
assert.include(className, 'no-error');
57-
assert.notInclude(className, 'has-error');
71+
assert.include(className, 'js-no-error');
72+
assert.notInclude(className, 'js-form-error');
5873
})
5974
.end()
6075
// now make sure the buttons aren't disabled anymore

webcompat/form.py

+43-38
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,32 @@
1414
from wtforms import RadioField
1515
from wtforms import StringField
1616
from wtforms import TextAreaField
17+
from wtforms.validators import InputRequired
1718
from wtforms.validators import Length
1819
from wtforms.validators import Optional
19-
from wtforms.validators import Required
2020

2121
AUTH_REPORT = 'github-auth-report'
2222
PROXY_REPORT = 'github-proxy-report'
2323
SCHEMES = ('http://', 'https://')
2424

25-
owner_choices = [(u'True', u'Yes'), (u'False', u'No')]
26-
problem_choices = [(u'browser_bug', u'Looks like the browser has a bug'),
27-
(u'site_bug', u'Looks like the website has a bug.'),
28-
(u'unknown_bug', u'Don\'t know but something\'s wrong.')]
25+
problem_choices = [
26+
(u'detection_bug', u'Desktop site instead of mobile site'),
27+
(u'mobile_site_bug', u'Mobile site is not usable'),
28+
(u'video_bug', u'Video doesn\'t play'),
29+
(u'layout_bug', u'Layout is messed up'),
30+
(u'text_bug', u'Text is not visible'),
31+
(u'unknown_bug', u'Something else - I\'ll add details below')
32+
]
33+
2934
url_message = u'A URL is required.'
30-
summary_message = u'Please give a summary.'
35+
radio_message = u'Problem type required.'
3136
username_message = u'A valid username must be {0} characters long'.format(
3237
random.randrange(0, 99))
3338

39+
problem_label = (u'What seems to be the trouble?',
40+
'<span class="wc-Form-required">*</span>')
41+
url_label = u'Site URL <span class="wc-Form-required">*</span>'
42+
3443
desc_default = u'''1) Navigate to: Site URL
3544
2) …
3645
@@ -41,19 +50,17 @@
4150

4251
class IssueForm(Form):
4352
'''Define form fields and validation for our bug reporting form.'''
44-
url = StringField(u'Site URL*', [Required(message=url_message)])
53+
url = StringField(url_label,
54+
[InputRequired(message=url_message)])
4555
browser = StringField(u'Browser / Version', [Optional()])
4656
os = StringField(u'Operating System', [Optional()])
47-
summary = StringField(u'Problem in 5 words*',
48-
[Required(message=summary_message)])
4957
username = StringField(u'Username',
5058
[Length(max=0, message=username_message)])
51-
description = TextAreaField(u'How can we replicate this?', [Optional()],
59+
description = TextAreaField(u'Give more details', [Optional()],
5260
default=desc_default)
53-
site_owner = RadioField(u'Is this your website?', [Optional()],
54-
choices=owner_choices)
55-
problem_category = RadioField(u'What seems to be the trouble?',
56-
[Optional()], choices=problem_choices)
61+
problem_category = RadioField(problem_label,
62+
[InputRequired(message=radio_message)],
63+
choices=problem_choices)
5764

5865

5966
def get_problem(category):
@@ -65,14 +72,12 @@ def get_problem(category):
6572
return u'Unknown'
6673

6774

68-
def get_owner(is_site_owner):
69-
'''Return human-readable language (Y/N) for site owner form value.'''
70-
if is_site_owner == 'True':
71-
return u'Yes'
72-
elif is_site_owner == 'False':
73-
return u'No'
75+
def get_problem_summary(category):
76+
'''Allows us to special case the "Other" radio choice summary.'''
77+
if category == 'unknown_bug':
78+
return u'see bug description'
7479
else:
75-
return u'Unknown'
80+
return get_problem(category).lower()
7681

7782

7883
def wrap_label(label):
@@ -127,7 +132,6 @@ def build_formdata(form_object):
127132
URL -> part of body
128133
Description -> part of body
129134
Category -> labels
130-
Owner -> labels
131135
132136
We'll try to parse the Browser and come up with a browser label, as well
133137
as labels like mobile, desktop, tablet.
@@ -150,27 +154,28 @@ def build_formdata(form_object):
150154
normalized_url = normalize_url(url)
151155
# Domain extraction
152156
domain = domain_name(normalized_url)
157+
problem_summary = get_problem_summary(form_object.get('problem_category'))
153158
if domain:
154-
summary = '{0} - {1}'.format(domain, form_object.get('summary'))
159+
summary = '{0} - {1}'.format(domain, problem_summary)
155160
else:
156-
summary = '{0}'.format(form_object.get('summary'))
161+
summary = '{0} - {1}'.format(normalized_url, problem_summary)
157162
# Preparing the body
158-
body = u'''{0}{1}
159-
**URL**: {2}
160-
**Browser / Version**: {3}
161-
**Operating System**: {4}
162-
**Problem type**: {5}
163-
**Site owner**: {6}
163+
body = u'''{browser_label}{ua_label}
164+
**URL**: {url}
165+
**Browser / Version**: {browser}
166+
**Operating System**: {os}
167+
**Problem type**: {problem_type}
164168
165169
**Steps to Reproduce**
166-
{7}'''.format(get_labels(form_object.get('browser')),
167-
wrap_label(('ua_header', form_object.get('ua_header'))),
168-
form_object.get('url'),
169-
form_object.get('browser'),
170-
form_object.get('os'),
171-
get_problem(form_object.get('problem_category')),
172-
get_owner(form_object.get('site_owner')),
173-
form_object.get('description'))
170+
{description}'''.format(
171+
browser_label=get_labels(form_object.get('browser')),
172+
ua_label=wrap_label(('ua_header', form_object.get('ua_header'))),
173+
url=form_object.get('url'),
174+
browser=form_object.get('browser'),
175+
os=form_object.get('os'),
176+
problem_type=get_problem(form_object.get('problem_category')),
177+
description=form_object.get('description')
178+
)
174179
result = {}
175180
result['title'] = summary
176181
result['body'] = body

0 commit comments

Comments
 (0)