-
Notifications
You must be signed in to change notification settings - Fork 364
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
Fixes Accessibility issues #428
Changes from 6 commits
a9d6416
19d43ab
2877481
350e396
89621ff
4b8fcdf
df76c9a
a0756c2
55cef3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,7 +198,7 @@ def html(self, name, default, translate): | |
("""<option value="%s"%s>%s</option>""" % | ||
(e, ' selected="selected"' if e == default else "", | ||
translate("%s %s" % (e, self.names.get(e, "")))) for e in self.edges)) | ||
return """<select name="%s" size="1">\n%s</select>\n""" % (name, options) | ||
return """<select name="%s" id="%s" aria-labeledby="%s %s" size="1">\n%s</select>\n""" % (name, name, name+"_id", name+"_description", options) | ||
|
||
def inx(self, name, viewname, arg): | ||
return (' <param name="%s" type="optiongroup" appearance="combo" gui-text="%s" gui-description=%s>\n' % | ||
|
@@ -218,8 +218,8 @@ def html(self, name, default, _): | |
if isinstance(default, (str)): | ||
default = self(default) | ||
return """<input name="%s" type="hidden" value="0"> | ||
<input name="%s" type="checkbox" value="1"%s>""" % \ | ||
(name, name, ' checked="checked"' if default else "") | ||
<input name="%s" id="%s" aria-labeledby="%s %s" type="checkbox" value="1"%s>""" % \ | ||
(name, name, name, name+"_id", name+"_description",' checked="checked"' if default else "") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. got rid of the comment |
||
|
||
boolarg = BoolArg() | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,6 @@ class FileChecker(threading.Thread): | |
super(FileChecker, self).__init__() | ||
self.checkmodules = checkmodules | ||
self.timestamps = {} | ||
self._stopped = False | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry I guess I did not integrate your most recent changes sorry about that :/ |
||
for path in files: | ||
self.timestamps[path] = os.stat(path).st_mtime | ||
if checkmodules: | ||
|
@@ -71,14 +70,11 @@ class FileChecker(threading.Thread): | |
return True | ||
|
||
def run(self): | ||
while not self._stopped: | ||
while True: | ||
if not self.filesOK(): | ||
os.execv(__file__, sys.argv) | ||
time.sleep(1) | ||
|
||
def stop(self): | ||
self._stopped = True | ||
|
||
class ArgumentParserError(Exception): pass | ||
|
||
class ThrowingArgumentParser(argparse.ArgumentParser): | ||
|
@@ -160,25 +156,25 @@ class BServer: | |
viewname = name[len(prefix)+1:] | ||
|
||
default = defaults.get(name, None) | ||
|
||
row = """<tr><td>%s</td><td>%%s</td><td>%s</td></tr>\n""" % \ | ||
(_(viewname), "" if not a.help else markdown.markdown(_(a.help))) | ||
#fix here? | ||
row = """<tr><td id="%s"><label for="%s">%s</label></td><td>%%s</td><td id="%s">%s</td></tr>\n""" % \ | ||
(name+"_id", name, _(viewname), name+"_description","" if not a.help else markdown.markdown(_(a.help))) | ||
if (isinstance(a, argparse._StoreAction) and | ||
hasattr(a.type, "html")): | ||
input = a.type.html(name, default or a.default, _) | ||
elif a.dest == "layout": | ||
val = (default or a.default).split("\n") | ||
input = """<textarea name="%s" cols="%s" rows="%s">%s</textarea>""" % \ | ||
(name, max((len(l) for l in val))+10, len(val)+1, default or a.default) | ||
input = """<textarea name="%s" id="%s" aria-labeledby="%s %s" cols="%s" rows="%s">%s</textarea>""" % \ | ||
(name, name, name+"_id", name+"_description", max((len(l) for l in val))+10, len(val)+1, default or a.default) | ||
elif a.choices: | ||
options = "\n".join( | ||
("""<option value="%s"%s>%s</option>""" % | ||
(e, ' selected="selected"' if (e == (default or a.default)) or (str(e) == str(default or a.default)) else "", | ||
_(e)) for e in a.choices)) | ||
input = """<select name="%s" size="1">\n%s</select>\n""" % (name, options) | ||
input = """<select name="%s" id="%s" aria-labeledby="%s %s" size="1" >\n%s</select>\n""" % (name, name, name+"_id", name+"_description", options) | ||
else: | ||
input = """<input name="%s" type="text" value="%s">""" % \ | ||
(name, default or a.default) | ||
input = """<input name="%s" id="%s" aria-labeledby="%s %s" type="text" value="%s" >""" % \ | ||
(name, name, name+"_id", name+"_description", default or a.default) | ||
|
||
return row % input | ||
|
||
|
@@ -250,6 +246,7 @@ class BServer: | |
|
||
for a in group._group_actions: | ||
if a.dest in ("input", "output"): | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This newline doesn't need to be integrated my bad... |
||
continue | ||
result.append(self.arg2html(a, prefix, defaults, _)) | ||
result.append("</table>") | ||
|
@@ -559,12 +556,7 @@ if __name__=="__main__": | |
boxserver = BServer() | ||
httpd = make_server(host, port, boxserver.serve) | ||
print("BoxesServer serving on host:port %s:%s..." % (host, port) ) | ||
try: | ||
httpd.serve_forever() | ||
except KeyboardInterrupt: | ||
fc.stop() | ||
httpd.server_close() | ||
print("BoxesServer stops.") | ||
httpd.serve_forever() | ||
else: | ||
application = BServer().serve | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this adds and id and aria-labeled by that references the id, name, and description from the boxesserver file this allows for screen readers to announce the label to the left of the input and the description to the right of the input for the combo box