示例#1
0
def choose_xmp_view(request):
    request_form = request.GET or request.POST
    license = _issue_license(request_form)
    target_lang = util.get_target_lang_from_request(request)

    def attrib_or_none(field_name):
        return request_form.get(field_name, u"").strip() or None

    context = xmp_template.get_xmp_info(request_form, license, target_lang)
    context["default_lang"] = target_lang
    context["work_title"] = attrib_or_none("field_worktitle")
    context["attrib_name"] = attrib_or_none("field_attribute_to_name")
    context["attrib_url"] = attrib_or_none("field_attribute_to_url")
    context["permissions_url"] = attrib_or_none("field_morepermissionsurl")
    context["licenses"] = [
        {"lang": "x-default", "notice": context["notice"]},
        {"lang": target_lang, "notice": context["notice"]},
    ]
    del context["notice"]
    if target_lang != "en":
        xmp_info_en = xmp_template.get_xmp_info(request_form, license, "en")
        context["licenses"].append({"lang": "en", "notice": xmp_info_en["notice"]})

    xmp_data = util.render_template(request, target_lang, "chooser_pages/metadata.xmp", context)

    return Response(
        xmp_data,
        content_type="application/xmp; charset=UTF-8",
        charset="UTF-8",
        content_disposition='attachment; filename="CC_%s.xmp' % (license.title().strip().replace(" ", "_")),
    )
示例#2
0
    def GET(self, jid=''):

        locale = web.input().get('locale', 'en')

        # return non-newest versions?
        current_only = web.input().get('current', '1')
        current_only = bool(int(current_only))

        j = cc.license.jurisdictions.by_code(str(jid))
        if not j or not j.launched:
            return api_exceptions.invalidjurisdiction()

        juri = ET.Element(
            'jurisdiction',
            dict(name=j.title(str(locale)),
                 url=j.id,
                 local_url=(j.local_url or '')))

        licenses = cc.license.jurisdictions.get_licenses_by_code(str(jid))

        if current_only:
            current_version = cc.license._lib.functions.current_version(
                'by', str(jid))

        for l in licenses:
            license = cc.license.by_uri(l)

            if current_only and license.version != current_version:
                continue

            ET.SubElement(juri, 'license',
                          dict(name=license.title(str(locale)), url=l))

        return juri
示例#3
0
def xhr_api(request):
    target_lang = util.get_target_lang_from_request(request)
    request_form = request.GET or request.POST

    # Select a license based on the request form
    license = _issue_license(request_form)

    # Generate the HTML+RDFa for the license + provided work information
    work_dict = _formatter_work_dict(request_form)

    license_html = HTML_FORMATTER.format(
        license, work_dict, target_lang)

    def has_code(code):
        return license.license_code.count(code) >= 1

    ret = {
        #'license': license,
        'uri' : license.uri,
        'libre' : license.libre,
        'currency' : util.currency_symbol_from_request_form(request_form),
        'license_logo': license.logo_method('88x31'),
        'license_slim_logo': license.logo_method('80x15'),
        'license_title': license.title(target_lang),
        'license_html': license_html,
        'license_code' : {
            'sa' : has_code('sa'),
            'nc' : has_code('nc'),
            'nd' : has_code('nd'),
            },
        }

    return Response(json.dumps(ret))
示例#4
0
def xhr_api(request):
    target_lang = util.get_target_lang_from_request(request)
    request_form = request.GET or request.POST

    # Select a license based on the request form
    license = _issue_license(request_form)

    # Generate the HTML+RDFa for the license + provided work information
    work_dict = _formatter_work_dict(request_form)

    license_html = HTML_FORMATTER.format(license, work_dict, target_lang)

    def has_code(code):
        return license.license_code.count(code) >= 1

    ret = {
        #'license': license,
        'uri': license.uri,
        'libre': license.libre,
        'currency': util.currency_symbol_from_request_form(request_form),
        'license_logo': license.logo_method('88x31'),
        'license_slim_logo': license.logo_method('80x15'),
        'license_title': license.title(target_lang),
        'license_html': license_html,
        'license_code': {
            'sa': has_code('sa'),
            'nc': has_code('nc'),
            'nd': has_code('nd'),
        },
    }

    return Response(json.dumps(ret))
示例#5
0
def xhr_api(request):
    target_lang = util.get_target_lang_from_request(request)
    request_form = request.GET or request.POST

    # Select a license based on the request form
    license = _issue_license(request_form)

    # Generate the HTML+RDFa for the license + provided work information
    work_dict = _formatter_work_dict(request_form)

    license_html = HTML_FORMATTER.format(license, work_dict, target_lang)

    def has_code(code):
        return license.license_code.count(code) >= 1

    ret = {
        #'license': license,
        "uri": license.uri,
        "libre": license.libre,
        "currency": util.currency_symbol_from_request_form(request_form),
        "license_logo": license.logo_method("88x31"),
        "license_slim_logo": license.logo_method("80x15"),
        "license_title": license.title(target_lang),
        "license_html": license_html,
        "license_code": {"sa": has_code("sa"), "nc": has_code("nc"), "nd": has_code("nd")},
    }

    return Response(json.dumps(ret))
示例#6
0
文件: license.py 项目: cloe4u/cc.api
    def GET(self, jid=''):
        
        locale = web.input().get('locale', 'en')

        # return non-newest versions?
        current_only = web.input().get('current', '1')
        current_only = bool(int(current_only))

        j = cc.license.jurisdictions.by_code(str(jid))
        if not j or not j.launched:
            return api_exceptions.invalidjurisdiction()

        juri = ET.Element('jurisdiction', dict(name=j.title(str(locale)),
                                               url=j.id,
                                               local_url=(j.local_url or '')))

        licenses = cc.license.jurisdictions.get_licenses_by_code(str(jid))

        if current_only:
            current_version = cc.license._lib.functions.current_version('by',
                                                                        str(jid))
        
        for l in licenses:
            license = cc.license.by_uri(l)
            
            if current_only and license.version != current_version:
                continue

            ET.SubElement(juri, 'license', dict(name=license.title(str(locale)),
                                                    url=l))
        
        return juri
示例#7
0
def choose_results_view(request):
    target_lang = util.get_target_lang_from_request(request)

    context = _base_context(request, target_lang)
    request_form = request.GET or request.POST

    # Special case: if anyone is linking to GPL/LGPL (mistake on old
    # deeds), redirect them to gnu.org
    if request_form.get('license_code') in ("GPL", "LGPL"):
        return exc.HTTPMovedPermanently(
            location='http://www.gnu.org/licenses/gpl-howto.html')

    # Select a license based on the request form
    license = _issue_license(request_form)

    # If the request didn't have all the required information, we have no license
    if not license:
        return exc.HTTPBadRequest('Could not determine license from parameters.')

    # If the license is retired, redirect to info page
    if license.deprecated:
        # Special case: PDCC should redirect to /publicdomain/
        if license.license_code == 'publicdomain':
            return exc.HTTPMovedPermanently(location="/publicdomain/")
        else:
            return exc.HTTPMovedPermanently(location="/retiredlicenses")

    # Generate the HTML+RDFa for the license + provided work information
    work_dict = _formatter_work_dict(request_form)
    license_slim_logo = license.logo_method('80x15')

    license_html = HTML_FORMATTER.format(
        license, work_dict, target_lang)

    context.update(
        {'license': license,
         'license_slim_logo': license_slim_logo,
         'license_title': license.title(target_lang),
         'license_html': license_html})

    if request.GET.get('partner'):
        context.update(
            {'exit_url': _generate_exit_url(
                    request_form.get('exit_url', ''),
                    request_form.get('referrer', ''),
                    license)})

    if request.GET.get('partner'):
        return Response(
            util.render_template(
                request, target_lang,
                'chooser_pages/partner/results.html', context))
    else:
        return Response(
            util.render_template(
                request, target_lang,
                'chooser_pages/results.html', context))
示例#8
0
def choose_results_view(request):
    target_lang = util.get_target_lang_from_request(request)

    context = _base_context(request, target_lang)
    request_form = request.GET or request.POST

    # Special case: if anyone is linking to GPL/LGPL (mistake on old
    # deeds), redirect them to gnu.org
    if request_form.get('license_code') in ("GPL", "LGPL"):
        return exc.HTTPMovedPermanently(
            location='http://www.gnu.org/licenses/gpl-howto.html')

    # Select a license based on the request form
    license = _issue_license(request_form)

    # If the request didn't have all the required information, we have no license
    if not license:
        return exc.HTTPBadRequest(
            'Could not determine license from parameters.')

    # If the license is retired, redirect to info page
    if license.deprecated:
        # Special case: PDCC should redirect to /publicdomain/
        if license.license_code == 'publicdomain':
            return exc.HTTPMovedPermanently(location="/publicdomain/")
        else:
            return exc.HTTPMovedPermanently(location="/retiredlicenses")

    # Generate the HTML+RDFa for the license + provided work information
    work_dict = _formatter_work_dict(request_form)
    license_slim_logo = license.logo_method('80x15')

    license_html = HTML_FORMATTER.format(license, work_dict, target_lang)

    context.update({
        'license': license,
        'license_slim_logo': license_slim_logo,
        'license_title': license.title(target_lang),
        'license_html': license_html
    })

    if request.GET.get('partner'):
        context.update({
            'exit_url':
            _generate_exit_url(request_form.get('exit_url', ''),
                               request_form.get('referrer', ''), license)
        })

    if request.GET.get('partner'):
        return Response(
            util.render_template(request, target_lang,
                                 'chooser_pages/partner/results.html',
                                 context))
    else:
        return Response(
            util.render_template(request, target_lang,
                                 'chooser_pages/results.html', context))
示例#9
0
def choose_results_view(request):
    target_lang = util.get_target_lang_from_request(request)

    context = _base_context(request, target_lang)
    request_form = request.GET or request.POST

    # Special case: if anyone is linking to GPL/LGPL (mistake on old
    # deeds), redirect them to gnu.org
    if request_form.get("license_code") in ("GPL", "LGPL"):
        return exc.HTTPMovedPermanently(location="http://www.gnu.org/licenses/gpl-howto.html")

    # Select a license based on the request form
    license = _issue_license(request_form)

    # If the license is retired, redirect to info page
    if license.deprecated:
        # Special case: PDCC should redirect to /publicdomain/
        if license.license_code == "publicdomain":
            return exc.HTTPMovedPermanently(location="/publicdomain/")
        else:
            return exc.HTTPMovedPermanently(location="/retiredlicenses")

    # Generate the HTML+RDFa for the license + provided work information
    work_dict = _formatter_work_dict(request_form)
    license_slim_logo = license.logo_method("80x15")

    license_html = HTML_FORMATTER.format(license, work_dict, target_lang)

    context.update(
        {
            "license": license,
            "license_slim_logo": license_slim_logo,
            "license_title": license.title(target_lang),
            "license_html": license_html,
        }
    )

    if request.GET.get("partner"):
        context.update(
            {
                "exit_url": _generate_exit_url(
                    request_form.get("exit_url", ""), request_form.get("referrer", ""), license
                )
            }
        )

    if request.GET.get("partner"):
        return Response(util.render_template(request, target_lang, "chooser_pages/partner/results.html", context))
    else:
        return Response(util.render_template(request, target_lang, "chooser_pages/results.html", context))
def _generate_exit_url(url, referrer, license):
    url = unquote_plus(url)

    # test if the exit_url is an absolute uri
    if urlparse(url).scheme not in ['http', 'https']:

        # this will accomodate only for 'valid' relative paths
        # e.g. foo/bar.php or /foo/bar.php?id=1, etc.
        url = urljoin(referrer, url)

    url = url.replace('[license_url]', quote(license.uri))
    url = url.replace('[license_name]', quote(license.title()))
    url = url.replace('[license_button]', quote(license.logo))
    url = url.replace('[deed_url]', quote(license.uri))

    return url
示例#11
0
def _generate_exit_url(url, referrer, license):
    url = unquote_plus(url)

    # test if the exit_url is an absolute uri
    if urlparse(url).scheme not in ['http', 'https']:

        # this will accomodate only for 'valid' relative paths
        # e.g. foo/bar.php or /foo/bar.php?id=1, etc.
        url = urljoin(referrer, url)

    url = url.replace('[license_url]', quote(license.uri))
    url = url.replace('[license_name]', quote(license.title()))
    url = url.replace('[license_button]', quote(license.logo))
    url = url.replace('[deed_url]', quote(license.uri))

    return url
示例#12
0
def pdmark_results(request):
    """
    Results page for the Public Domain Mark chooser.

    Includes the user's RDFa copy-paste html.
    Also handles email sending if the user requests it.
    """
    target_lang = util.get_target_lang_from_request(request)

    request_form = request.GET or request.POST

    ## RDFA generation
    license = cc.license.by_code('mark')
    license_html = PDMARK_HTML_FORMATTER.format(license, request_form,
                                                target_lang).strip()

    ## Did the user request an email?
    email_addr = request_form.get('email')
    successful_send = False
    if email_addr and request.method == 'POST':
        successful_send = util.send_license_info_email(
            license.title(target_lang), license_html, email_addr, target_lang)

    context = _base_context(request, target_lang)
    context.update({
        'request_form':
        request_form,
        'rdfa':
        license_html,
        'email_requested':
        bool(email_addr),
        'email_addr':
        email_addr,
        'successful_send':
        successful_send,
        'requested_send_updates':
        request_form.get('send_updates', False)
    })

    return util.render_to_response(request, target_lang,
                                   'chooser_pages/pdmark/results.html',
                                   context)
示例#13
0
def choose_xmp_view(request):
    request_form = request.GET or request.POST
    license = _issue_license(request_form)
    target_lang = util.get_target_lang_from_request(request)

    def attrib_or_none(field_name):
        return request_form.get(field_name, u'').strip() or None

    context = xmp_template.get_xmp_info(request_form, license, target_lang)
    context["default_lang"] = target_lang
    context["work_title"] = attrib_or_none("field_worktitle")
    context["attrib_name"] = attrib_or_none("field_attribute_to_name")
    context["attrib_url"] = attrib_or_none("field_attribute_to_url")
    context["permissions_url"] = attrib_or_none("field_morepermissionsurl")
    context["licenses"] = [{
        "lang": "x-default",
        "notice": context["notice"]
    }, {
        "lang": target_lang,
        "notice": context["notice"]
    }]
    del context["notice"]
    if target_lang != 'en':
        xmp_info_en = xmp_template.get_xmp_info(request_form, license, 'en')
        context["licenses"].append({
            "lang": 'en',
            "notice": xmp_info_en["notice"]
        })

    xmp_data = util.render_template(request, target_lang,
                                    'chooser_pages/metadata.xmp', context)

    return Response(xmp_data,
                    content_type='application/xmp; charset=UTF-8',
                    charset='UTF-8',
                    content_disposition='attachment; filename="CC_%s.xmp' %
                    (license.title().strip().replace(' ', '_')))
示例#14
0
文件: support.py 项目: cloe4u/cc.api
def build_results_tree(license, work_xml=None, work_dict=None, locale='en'):
    """ Build an ElementTree to be returned for an issue or details call.
    Properly wraps the formatter markup of a license as a valid xhtml tree.
    """    
    
    root = ET.Element('result')
    # add the license uri and name
    ET.SubElement(root, 'license-uri').text = license.uri
    ET.SubElement(root, 'license-name').text = license.title(locale)
    ET.SubElement(root, 'deprecated').text = \
                        (license.deprecated and u'true' or u'false')
    
    # parse the RDF and RDFa from cc.license
    license_rdf = ET.parse( StringIO(license.rdf) )
    
    # prepare the RDFa for xml parsing
    try:
        formatter = FORMATTERS.get(license.license_class, HTMLFormatter)
        rdfa = formatter().format(license, work_dict, locale)
    except Exception, e:
        # cc.license formatter choked on something
        # such an example would be an invalid work_jurisdiction value passed
        # to the CC0 formatter
        raise e
def pdmark_results(request):
    """
    Results page for the Public Domain Mark chooser.

    Includes the user's RDFa copy-paste html.
    Also handles email sending if the user requests it.
    """
    target_lang = util.get_target_lang_from_request(request)

    request_form = request.GET or request.POST

    ## RDFA generation
    license = cc.license.by_code('mark')
    license_html = PDMARK_HTML_FORMATTER.format(
        license, request_form, target_lang).strip()

    ## Did the user request an email?
    email_addr = request_form.get('email')
    successful_send = False
    if email_addr and request.method == 'POST':
        successful_send = util.send_license_info_email(
            license.title(target_lang), license_html,
            email_addr, target_lang)

    context = _base_context(request, target_lang)
    context.update({
            'request_form': request_form,
            'rdfa': license_html,
            'email_requested': bool(email_addr),
            'email_addr': email_addr,
            'successful_send': successful_send,
            'requested_send_updates': request_form.get('send_updates', False)})

    return util.render_to_response(
        request, target_lang,
        'chooser_pages/pdmark/results.html', context)
示例#16
0
def build_results_tree(license, work_xml=None, work_dict=None, locale='en'):
    """ Build an ElementTree to be returned for an issue or details call.
    Properly wraps the formatter markup of a license as a valid xhtml tree.
    """

    root = ET.Element('result')
    # add the license uri and name
    ET.SubElement(root, 'license-uri').text = license.uri
    ET.SubElement(root, 'license-name').text = license.title(locale)
    ET.SubElement(root, 'deprecated').text = \
                        (license.deprecated and u'true' or u'false')

    # parse the RDF and RDFa from cc.license
    license_rdf = ET.parse(StringIO(license.rdf))

    # prepare the RDFa for xml parsing
    try:
        formatter = FORMATTERS.get(license.license_class, HTMLFormatter)
        rdfa = formatter().format(license, work_dict, locale)
    except Exception, e:
        # cc.license formatter choked on something
        # such an example would be an invalid work_jurisdiction value passed
        # to the CC0 formatter
        raise e
示例#17
0
def pdmark_results(request):
    """
    Results page for the Public Domain Mark chooser.

    Includes the user's RDFa copy-paste html.
    Also handles email sending if the user requests it.
    """
    target_lang = util.get_target_lang_from_request(request)

    request_form = request.GET or request.POST

    ## RDFA generation
    license = cc.license.by_code("mark")
    license_html = PDMARK_HTML_FORMATTER.format(license, request_form, target_lang).strip()

    ## Did the user request an email?
    email_addr = request_form.get("email")
    successful_send = False
    if email_addr and request.method == "POST":
        successful_send = util.send_license_info_email(
            license.title(target_lang), license_html, email_addr, target_lang
        )

    context = _base_context(request, target_lang)
    context.update(
        {
            "request_form": request_form,
            "rdfa": license_html,
            "email_requested": bool(email_addr),
            "email_addr": email_addr,
            "successful_send": successful_send,
            "requested_send_updates": request_form.get("send_updates", False),
        }
    )

    return util.render_to_response(request, target_lang, "chooser_pages/pdmark/results.html", context)
def chooser_view(request):
    # Preserve the old partner interface by calling the old chooser view..
    if request.GET.get('partner'):
        return classic_chooser_view(request)

    #
    #  Used by the new-style chooser demos, for now.
    #
    target_lang = util.get_target_lang_from_request(request)
    context = _base_context(request, target_lang)
    request_form = request.GET or request.POST
    gettext = context['gettext']

    available_jurisdiction_codes = [
        j.code for j in get_selector_jurisdictions('standard')
        if j.code != '']
    
    requested_jurisdiction = None
    if request.GET.has_key('jurisdiction') and \
            request.GET['jurisdiction'] in available_jurisdiction_codes:
        requested_jurisdiction = request.GET['jurisdiction']        

    # Sort the jurisdictions for the dropdown via the translated name
    jurisdictions_names = [
        (juris, gettext(mappers.COUNTRY_MAP[juris]))
        for juris in available_jurisdiction_codes]
    jurisdictions_names = sorted(
        jurisdictions_names, key=lambda juris: juris[1])

    show_jurisdiction = request.GET.get('jurisdiction_choose') == '1'

    # Select a license based on the request form
    license = _issue_license(request_form)
    
    # Sets form default values, based on the request form or lack thereof
    defaults = {
        "license" : {
            "nc" : False,
            "sa" : False,
            "nd" : False,
            "jurisdiction" : "",
            "currency" : "",
            },
        "meta" : {
            "standard" : "html+rdfa",
            "format" : "",
            "title" : "",
            "attrib_name" : "",
            "attrib_url" : "",
            "src_url" : "",
            "permissions" : "",
            },
        "out" : {
            "format" : "html",
            "badge" : "normal",
            },
        "misc" : {
            "lang" : "",
            }
        }
    def equal_or_default(field, value, default=False):
        if request_form.has_key(field):
            return request_form[field] == value
        else:
            return default

    def value_or_default(field, default=""):
        if request_form.has_key(field):
            return unquote(request_form[field]).encode("utf-8")
        else:
            return default

    if request_form:
        defaults["license"] = {
            "nc" : equal_or_default('field_commercial', u'n'),
            "sa" : equal_or_default('field_derivatives', u'sa'),
            "nd" : equal_or_default('field_derivatives', u'n'),
            "jurisdiction" : value_or_default('field_jurisdiction'),
            "currency" : util.currency_symbol_from_request_form(request_form),
            }
        defaults["meta"] = {
            "standard"    : value_or_default("field_metadata_standard", "html+rdfa"),
            "format"      : value_or_default("field_format"),
            "title"       : value_or_default("field_worktitle"),
            "attrib_name" : value_or_default("field_attribute_to_name"),
            "attrib_url"  : value_or_default("field_attribute_to_url"),
            "src_url"     : value_or_default("field_sourceurl"),
            "permissions" : value_or_default("field_morepermissionsurl"),
            }
        defaults["out"]["badge"] = value_or_default("field_iconsize", "normal");
        defaults["misc"] = {
            "lang" : value_or_default("lang", ""),
            }

    # If the license is retired, redirect to info page
    if license.deprecated:
        # Special case: PDCC should redirect to /publicdomain/
        if license.license_code == 'publicdomain':
            return exc.HTTPMovedPermanently(location="/publicdomain/")
        else:
            return exc.HTTPMovedPermanently(location="/retiredlicenses")

    # Generate the HTML+RDFa for the license + provided work information
    work_dict = _formatter_work_dict(request_form)
    license_norm_logo = license.logo_method('88x13')
    license_slim_logo = license.logo_method('80x15')
    picked_logo = {
        "normal" : license_norm_logo,
        "small" : license_slim_logo
        }[defaults['out']['badge']]

    license_html = HTML_FORMATTER.format(
        license, work_dict, target_lang)

    if defaults['out']['badge'] == u"small":
        license_html = license_html.replace("88x31.png", "80x15.png")

    def has_code(code):
        return license.license_code.count(code) >= 1

    context.update(
        {'jurisdictions_names': jurisdictions_names,
         'show_jurisdiction': show_jurisdiction,
         'requested_jurisdiction': requested_jurisdiction,
         'referrer': request.headers.get('REFERER',''),
         'page_style': '2cols',
         'last_query': request.query_string,
         'form' : defaults,
         'currency' : util.currency_symbol_from_request_form(request_form),
         'license': license,
         'license_logo': picked_logo,
         'license_norm_logo': license_norm_logo,
         'license_slim_logo': license_slim_logo,
         'license_title': license.title(target_lang),
         'license_html': license_html,
         'license_code' : {
                'sa' : has_code('sa'),
                'nc' : has_code('nc'),
                'nd' : has_code('nd'),
                },
         })

    return Response(util.render_template(
            request, target_lang,
            'chooser_pages/interactive_chooser.html', context))
示例#19
0
def chooser_view(request):
    # Preserve the old partner interface by calling the old chooser view..
    if request.GET.get('partner'):
        return classic_chooser_view(request)

    #
    #  Used by the new-style chooser demos, for now.
    #
    target_lang = util.get_target_lang_from_request(request)
    context = _base_context(request, target_lang)
    request_form = request.GET or request.POST
    gettext = context['gettext']

    available_jurisdiction_codes = [
        j.code for j in get_selector_jurisdictions('standard') if j.code != ''
    ]

    requested_jurisdiction = None
    if request.GET.has_key('jurisdiction') and \
            request.GET['jurisdiction'] in available_jurisdiction_codes:
        requested_jurisdiction = request.GET['jurisdiction']

    # Sort the jurisdictions for the dropdown via the translated name
    jurisdictions_names = [(juris, gettext(mappers.COUNTRY_MAP[juris]))
                           for juris in available_jurisdiction_codes]
    jurisdictions_names = sorted(jurisdictions_names,
                                 key=lambda juris: juris[1])

    show_jurisdiction = request.GET.get('jurisdiction_choose') == '1'

    # Select a license based on the request form
    license = _issue_license(request_form)

    # Sets form default values, based on the request form or lack thereof
    defaults = {
        "license": {
            "nc": False,
            "sa": False,
            "nd": False,
            "jurisdiction": "",
            "currency": "",
        },
        "meta": {
            "standard": "html+rdfa",
            "format": "",
            "title": "",
            "attrib_name": "",
            "attrib_url": "",
            "src_url": "",
            "permissions": "",
        },
        "out": {
            "format": "html",
            "badge": "normal",
        },
        "misc": {
            "lang": "",
        }
    }

    def equal_or_default(field, value, default=False):
        if request_form.has_key(field):
            return request_form[field] == value
        else:
            return default

    def value_or_default(field, default=""):
        if request_form.has_key(field):
            return unquote(request_form[field]).encode("utf-8")
        else:
            return default

    if request_form:
        defaults["license"] = {
            "nc": equal_or_default('field_commercial', u'n'),
            "sa": equal_or_default('field_derivatives', u'sa'),
            "nd": equal_or_default('field_derivatives', u'n'),
            "jurisdiction": value_or_default('field_jurisdiction'),
            "currency": util.currency_symbol_from_request_form(request_form),
        }
        defaults["meta"] = {
            "standard": value_or_default("field_metadata_standard",
                                         "html+rdfa"),
            "format": value_or_default("field_format"),
            "title": value_or_default("field_worktitle"),
            "attrib_name": value_or_default("field_attribute_to_name"),
            "attrib_url": value_or_default("field_attribute_to_url"),
            "src_url": value_or_default("field_sourceurl"),
            "permissions": value_or_default("field_morepermissionsurl"),
        }
        defaults["out"]["badge"] = value_or_default("field_iconsize", "normal")
        defaults["misc"] = {
            "lang": value_or_default("lang", ""),
        }

    # If the license is retired, redirect to info page
    if license.deprecated:
        # Special case: PDCC should redirect to /publicdomain/
        if license.license_code == 'publicdomain':
            return exc.HTTPMovedPermanently(location="/publicdomain/")
        else:
            return exc.HTTPMovedPermanently(location="/retiredlicenses")

    # Generate the HTML+RDFa for the license + provided work information
    work_dict = _formatter_work_dict(request_form)
    license_norm_logo = license.logo_method('88x13')
    license_slim_logo = license.logo_method('80x15')
    picked_logo = {
        "normal": license_norm_logo,
        "small": license_slim_logo
    }[defaults['out']['badge']]

    license_html = HTML_FORMATTER.format(license, work_dict, target_lang)

    if defaults['out']['badge'] == u"small":
        license_html = license_html.replace("88x31.png", "80x15.png")

    def has_code(code):
        return license.license_code.count(code) >= 1

    context.update({
        'jurisdictions_names':
        jurisdictions_names,
        'show_jurisdiction':
        show_jurisdiction,
        'requested_jurisdiction':
        requested_jurisdiction,
        'referrer':
        request.headers.get('REFERER', ''),
        'page_style':
        '2cols',
        'last_query':
        request.query_string,
        'form':
        defaults,
        'currency':
        util.currency_symbol_from_request_form(request_form),
        'license':
        license,
        'license_logo':
        picked_logo,
        'license_norm_logo':
        license_norm_logo,
        'license_slim_logo':
        license_slim_logo,
        'license_title':
        license.title(target_lang),
        'license_html':
        license_html,
        'license_code': {
            'sa': has_code('sa'),
            'nc': has_code('nc'),
            'nd': has_code('nd'),
        },
    })

    return Response(
        util.render_template(request, target_lang,
                             'chooser_pages/interactive_chooser.html',
                             context))