Files
edx-platform/common/templates/license.html
Sarina Canelake ca64c665cc Default course license to All Rights Reserved
Clicking on conflicting option box unchecks all conflicts
LMS: Clicking license text should bring to new window
updated styles to reflect html reuse inside of xblock edit modal area.

Add ARIA attributes to license for a11y

Gracefully handle re-selecting of selected license
2015-05-18 14:37:32 -04:00

61 lines
2.2 KiB
HTML

<%page args="license, button=False, button_size='88x31'"/>
## keep this synchronized with the contents of cms/templates/js/license-selector.underscore
<%!
from django.utils.translation import ugettext as _
def parse_license(lic):
"""
Returns a two-tuple: license type, and options.
"""
if not lic:
return None, {}
if ":" not in lic:
# no options, so the entire thing is the license type
return lic, {}
ltype, option_str = lic.split(":", 1)
options = {}
for part in option_str.split():
if "=" in part:
key, value = part.split("=", 1)
options[key] = value
else:
options[part] = True
return ltype, options
%>
<% license_type, license_options = parse_license(license) %>
% if license_type == "all-rights-reserved":
© <span class="license-text">${_("All Rights Reserved")}</span>
% elif license_type == "creative-commons":
<%
possible = ["by", "nc", "nd", "sa"]
names = {
"by": _("Attribution"), "nc": _("Noncommercial"),
"nd": _("No Derivatives"), "sa": _("Share Alike")
}
enabled = [opt for opt in possible
if license_options.get(opt) or license_options.get(opt.upper())]
version = license_options.get("ver", "4.0")
if len(enabled) == 0:
enabled = ["zero"]
version = license_options.get("ver", "1.0")
%>
<a rel="license" href="https://creativecommons.org/licenses/${'-'.join(enabled)}/${version}/" target="_blank">
% if button:
<img src="https://licensebuttons.net/l/${'-'.join(enabled)}/${version}/${button_size}.png"
alt="${license}"
/>
</a>
% else:
## <span> must come before <i> icon or else spacing gets messed up
<span class="sr">${_("Creative Commons licensed content, with terms as follow:")}&nbsp;</span><i aria-hidden="true" class="icon-cc"></i>
% for option in enabled:
<span class="sr">${names[option]}&nbsp;</span><i aria-hidden="true" class="icon-cc-${option}"></i>
% endfor
<span class="license-text">${_("Some Rights Reserved")}</span>
% endif
</a>
% else:
${license}
% endif