text
stringlengths 0
828
|
---|
# Basic Munging
|
email = email.replace(""@"", "" [at] "").replace(""."", "" [dot] "")
|
elif email_obfuscation_mode == 2:
|
# Transparent name mangling
|
email = string_to_numeric_char_reference(email)
|
if '%(email)s' in link_label:
|
link_label = link_label % {'email': email}
|
mailto_link = create_html_link('mailto:' + email, parameters,
|
link_label, linkattrd,
|
escape_urlargd, escape_linkattrd)
|
if email_obfuscation_mode == 0:
|
# Return ""as is""
|
return mailto_link
|
elif email_obfuscation_mode == 1:
|
# Basic Munging
|
return mailto_link
|
elif email_obfuscation_mode == 2:
|
# Transparent name mangling
|
return mailto_link
|
elif email_obfuscation_mode == 3:
|
# Javascript-based
|
return '''<script language=""JavaScript"" ''' \
|
'''type=""text/javascript"">''' \
|
'''document.write('%s'.split("""").reverse().join(""""))''' \
|
'''</script>''' % \
|
mailto_link[::-1].replace(""'"", ""\\'"")
|
elif email_obfuscation_mode == 4:
|
# GIFs-based
|
email = email.replace(
|
'.', '<img src=""%s/img/dot.gif"" alt="" [dot] "" '
|
'style=""vertical-align:bottom"" />' %
|
cfg.get('CFG_SITE_URL'))
|
email = email.replace(
|
'@', '<img src=""%s/img/at.gif"" alt="" [at] "" '
|
'style=""vertical-align:baseline"" />' %
|
cfg.get('CFG_SITE_URL'))
|
return email
|
# All other cases, including mode -1:
|
return """""
|
4739,"def string_to_numeric_char_reference(string):
|
""""""
|
Encode a string to HTML-compatible numeric character reference.
|
Eg: encode_html_entities(""abc"") == 'abc'
|
""""""
|
out = """"
|
for char in string:
|
out += ""&#"" + str(ord(char)) + "";""
|
return out"
|
4740,"def get_canonical_and_alternates_urls(
|
url,
|
drop_ln=True,
|
washed_argd=None,
|
quote_path=False):
|
""""""
|
Given an Invenio URL returns a tuple with two elements. The first is the
|
canonical URL, that is the original URL with CFG_SITE_URL prefix, and
|
where the ln= argument stripped. The second element element is mapping,
|
language code -> alternate URL
|
@param quote_path: if True, the path section of the given C{url}
|
is quoted according to RFC 2396
|
""""""
|
dummy_scheme, dummy_netloc, path, dummy_params, query, fragment = urlparse(
|
url)
|
canonical_scheme, canonical_netloc = urlparse(cfg.get('CFG_SITE_URL'))[0:2]
|
parsed_query = washed_argd or parse_qsl(query)
|
no_ln_parsed_query = [(key, value)
|
for (key, value) in parsed_query if key != 'ln']
|
if drop_ln:
|
canonical_parsed_query = no_ln_parsed_query
|
else:
|
canonical_parsed_query = parsed_query
|
if quote_path:
|
path = urllib.quote(path)
|
canonical_query = urlencode(canonical_parsed_query)
|
canonical_url = urlunparse(
|
(canonical_scheme,
|
canonical_netloc,
|
path,
|
dummy_params,
|
canonical_query,
|
fragment))
|
alternate_urls = {}
|
for ln in cfg.get('CFG_SITE_LANGS'):
|
alternate_query = urlencode(no_ln_parsed_query + [('ln', ln)])
|
alternate_url = urlunparse(
|
(canonical_scheme,
|
canonical_netloc,
|
path,
|
dummy_params,
|
alternate_query,
|
fragment))
|
alternate_urls[ln] = alternate_url
|
return canonical_url, alternate_urls"
|
4741,"def create_url(urlbase, urlargd, escape_urlargd=True, urlhash=None):
|
""""""Creates a W3C compliant URL. Output will look like this:
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.