<%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": © ${_("All Rights Reserved")} % 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") %> % if button: % else: ## must come before icon or else spacing gets messed up ${_("Creative Commons licensed content, with terms as follow:")} % for option in enabled: ${names[option]} % endfor ${_("Some Rights Reserved")} % endif % else: ${license} % endif