Skip to content
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

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 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
6 changes: 3 additions & 3 deletions boxes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor Author

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


def inx(self, name, viewname, arg):
return (' <param name="%s" type="optiongroup" appearance="combo" gui-text="%s" gui-description=%s>\n' %
Expand All @@ -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 "")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got rid of the comment


boolarg = BoolArg()

Expand Down
30 changes: 11 additions & 19 deletions scripts/boxesserver
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class FileChecker(threading.Thread):
super(FileChecker, self).__init__()
self.checkmodules = checkmodules
self.timestamps = {}
self._stopped = False
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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:
Expand All @@ -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):
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -250,6 +246,7 @@ class BServer:

for a in group._group_actions:
if a.dest in ("input", "output"):

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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>")
Expand Down Expand Up @@ -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

Expand Down