def test_html_mailto_obfuscation_mode_2(self):
     """urlutils - test creation of HTML "mailto" links, obfuscation mode 2"""
     self.assertEqual(create_html_mailto('*****@*****.**',
                                         subject='Hey there',
                                         body='Lunch at 8pm?\ncu!',
                                         bcc='*****@*****.**',
                                         link_label="Date creator",
                                         linkattrd={'style': 'text-decoration: blink'},
                                         email_obfuscation_mode=2),
                      '<a href="mailto:&#106;&#117;&#108;&#105;&#101;&#116;&#64;&#99;&#100;&#115;&#46;&#99;&#101;&#114;&#110;&#46;&#99;&#104;?body=Lunch%20at%208pm%3F%0D%0Acu%21&amp;bcc=romeo%40cds.cern.ch&amp;subject=Hey%20there" style="text-decoration: blink">Date creator</a>')
 def test_html_mailto_obfuscation_mode_3(self):
     """urlutils - test creation of HTML "mailto" links, obfuscation mode 3"""
     self.assertEqual(create_html_mailto('*****@*****.**',
                                         subject='Hey there',
                                         body='Lunch at 8pm?\ncu!',
                                         bcc='*****@*****.**',
                                         link_label="Date creator",
                                         linkattrd={'style': 'text-decoration: blink'},
                                         email_obfuscation_mode=3),
                      '<script language="JavaScript" type="text/javascript">document.write(\'>a/<rotaerc etaD>"knilb :noitaroced-txet"=elyts "ereht02%yeH=tcejbus;pma&hc.nrec.sdc04%oemor=ccb;pma&12%ucA0%D0%F3%mp802%ta02%hcnuL=ydob?hc.nrec.sdc@teiluj:otliam"=ferh a<\'.split("").reverse().join(""))</script>')
 def test_html_mailto_obfuscation_mode_minus1(self):
     """urlutils - test creation of HTML "mailto" links, obfuscation mode -1"""
     self.assertEqual(create_html_mailto('*****@*****.**',
                                         subject='Hey there',
                                         body='Lunch at 8pm?\ncu!',
                                         bcc='*****@*****.**',
                                         link_label="Date creator",
                                         linkattrd={'style': 'text-decoration: blink'},
                                         email_obfuscation_mode=-1),
                      '')
 def test_html_mailto_obfuscation_mode_1(self):
     """urlutils - test creation of HTML "mailto" links, obfuscation mode 1"""
     self.assertEqual(create_html_mailto('*****@*****.**',
                                         subject='Hey there',
                                         body='Lunch at 8pm?\ncu!',
                                         bcc='*****@*****.**',
                                         link_label="Date creator",
                                         linkattrd={'style': 'text-decoration: blink'},
                                         email_obfuscation_mode=1),
                      '<a href="mailto:juliet [at] cds [dot] cern [dot] ch?body=Lunch%20at%208pm%3F%0D%0Acu%21&amp;bcc=romeo%40cds.cern.ch&amp;subject=Hey%20there" style="text-decoration: blink">Date creator</a>')
Example #5
0
 def test_html_mailto_obfuscation_mode_2(self):
     """urlutils - test creation of HTML "mailto" links, obfuscation mode 2"""
     self.assertEqual(create_html_mailto('*****@*****.**',
                                         subject='Hey there',
                                         body='Lunch at 8pm?\ncu!',
                                         bcc='*****@*****.**',
                                         link_label="Date creator",
                                         linkattrd={'style': 'text-decoration: blink'},
                                         email_obfuscation_mode=2),
                      '<a href="mailto:&#106;&#117;&#108;&#105;&#101;&#116;&#64;&#99;&#100;&#115;&#46;&#99;&#101;&#114;&#110;&#46;&#99;&#104;?body=Lunch%20at%208pm%3F%0D%0Acu%21&amp;bcc=romeo%40cds.cern.ch&amp;subject=Hey%20there" style="text-decoration: blink">Date creator</a>')
Example #6
0
 def test_html_mailto_obfuscation_mode_1(self):
     """urlutils - test creation of HTML "mailto" links, obfuscation mode 1"""
     self.assertEqual(create_html_mailto('*****@*****.**',
                                         subject='Hey there',
                                         body='Lunch at 8pm?\ncu!',
                                         bcc='*****@*****.**',
                                         link_label="Date creator",
                                         linkattrd={'style': 'text-decoration: blink'},
                                         email_obfuscation_mode=1),
                      '<a href="mailto:juliet [at] cds [dot] cern [dot] ch?body=Lunch%20at%208pm%3F%0D%0Acu%21&amp;bcc=romeo%40cds.cern.ch&amp;subject=Hey%20there" style="text-decoration: blink">Date creator</a>')
Example #7
0
 def test_html_mailto_obfuscation_mode_minus1(self):
     """urlutils - test creation of HTML "mailto" links, obfuscation mode -1"""
     self.assertEqual(create_html_mailto('*****@*****.**',
                                         subject='Hey there',
                                         body='Lunch at 8pm?\ncu!',
                                         bcc='*****@*****.**',
                                         link_label="Date creator",
                                         linkattrd={'style': 'text-decoration: blink'},
                                         email_obfuscation_mode=-1),
                      '')
 def test_html_mailto_obfuscation_mode_3(self):
     """urlutils - test creation of HTML "mailto" links, obfuscation mode 3"""
     self.assertEqual(create_html_mailto('*****@*****.**',
                                         subject='Hey there',
                                         body='Lunch at 8pm?\ncu!',
                                         bcc='*****@*****.**',
                                         link_label="Date creator",
                                         linkattrd={'style': 'text-decoration: blink'},
                                         email_obfuscation_mode=3),
                      '<script language="JavaScript" type="text/javascript">document.write(\'>a/<rotaerc etaD>"knilb :noitaroced-txet"=elyts "ereht02%yeH=tcejbus;pma&hc.nrec.sdc04%oemor=ccb;pma&12%ucA0%D0%F3%mp802%ta02%hcnuL=ydob?hc.nrec.sdc@teiluj:otliam"=ferh a<\'.split("").reverse().join(""))</script>')
 def test_html_mailto_obfuscation_mode_4(self):
     """urlutils - test creation of HTML "mailto" links, obfuscation mode 4"""
     self.assertEqual(create_html_mailto('*****@*****.**',
                                         subject='Hey there',
                                         body='Lunch at 8pm?\ncu!',
                                         bcc='*****@*****.**',
                                         link_label="Date creator",
                                         linkattrd={'style': 'text-decoration: blink'},
                                         email_obfuscation_mode=4),
                      'juliet<img src="%(CFG_SITE_URL)s/img/at.gif" alt=" [at] " style="vertical-align:baseline" />cds<img src="%(CFG_SITE_URL)s/img/dot.gif" alt=" [dot] " style="vertical-align:bottom"  />cern<img src="%(CFG_SITE_URL)s/img/dot.gif" alt=" [dot] " style="vertical-align:bottom"  />ch' % \
                      {'CFG_SITE_URL': CFG_SITE_URL})
Example #10
0
 def test_html_mailto_obfuscation_mode_4(self):
     """urlutils - test creation of HTML "mailto" links, obfuscation mode 4"""
     self.assertEqual(create_html_mailto('*****@*****.**',
                                         subject='Hey there',
                                         body='Lunch at 8pm?\ncu!',
                                         bcc='*****@*****.**',
                                         link_label="Date creator",
                                         linkattrd={'style': 'text-decoration: blink'},
                                         email_obfuscation_mode=4),
                      'juliet<img src="%(CFG_SITE_URL)s/img/at.gif" alt=" [at] " style="vertical-align:baseline" />cds<img src="%(CFG_SITE_URL)s/img/dot.gif" alt=" [dot] " style="vertical-align:bottom"  />cern<img src="%(CFG_SITE_URL)s/img/dot.gif" alt=" [dot] " style="vertical-align:bottom"  />ch' % \
                      {'CFG_SITE_URL': CFG_SITE_URL})
def format_element(
        bfo,
        separator,
        display_email='yes',
        email_obfuscation_mode=CFG_WEBSTYLE_EMAIL_ADDRESSES_OBFUSCATION_MODE):
    """
    Display article author(s)

    @param separator: separator between authors
    @param display_email: if yes, display link to authors' emails
    @param email_obfuscation_mode: how email are protected. See possible values in CFG_WEBSTYLE_EMAIL_ADDRESSES_OBFUSCATION_MODE in invenio.conf.
    """
    args = parse_url_string(bfo.user_info['uri'])
    ln = args["ln"]
    _ = gettext_set_language(ln)

    try:
        email_obfuscation_mode_int = int(str(email_obfuscation_mode))
    except:
        email_obfuscation_mode_int = CFG_WEBSTYLE_EMAIL_ADDRESSES_OBFUSCATION_MODE

    email_subject = _("About your article at %(url)s") % \
                    {'url': CFG_SITE_URL + bfo.user_info['uri']}

    authors = bfo.fields('100__a', escape=1)
    emails = bfo.fields('859__a', escape=1)
    # Add empty items to match length of authors list
    emails += [''] * (len(authors) - len(emails))

    authors_list = []
    for author, email in zip(authors, emails):
        if not author:
            continue
        if email.strip() and display_email.lower() == 'yes':
            authors_list.append(
                create_html_mailto(
                    email,
                    link_label=author,
                    subject=email_subject,
                    email_obfuscation_mode=email_obfuscation_mode_int))
        else:
            authors_list.append(author)

    return separator.join(authors_list)
def __add_email_button(title, uri, ln):
    """
    adds an email this article button, providing a standard subject text,
    title and a link to the article.
    """
    _ = gettext_set_language(ln)

    email_button = '<li id="mail">'
    email_body = _('''Hi,

Have a look at the following article:
<%(url)s>''') % uri
    email_button += create_html_mailto('',
                                       subject=title,
                                       body=email_body,
                                       link_label=_("Send this article"))
    email_button += '</li>'

    return email_button
def format(bfo, separator, display_email='yes',
           email_obfuscation_mode=CFG_WEBSTYLE_EMAIL_ADDRESSES_OBFUSCATION_MODE):
    """
    Display article author(s)

    @param separator: separator between authors
    @param display_email: if yes, display link to authors' emails
    @param email_obfuscation_mode: how email are protected. See possible values in CFG_WEBSTYLE_EMAIL_ADDRESSES_OBFUSCATION_MODE in invenio.conf.
    """
    args = parse_url_string(bfo.user_info['uri'])
    ln = args["ln"]
    _ = gettext_set_language(ln)

    try:
        email_obfuscation_mode_int = int(str(email_obfuscation_mode))
    except:
        email_obfuscation_mode_int = CFG_WEBSTYLE_EMAIL_ADDRESSES_OBFUSCATION_MODE

    email_subject = _("About your article at %(url)s") % \
                    {'url': CFG_SITE_URL + bfo.user_info['uri']}

    authors = bfo.fields('100__a', escape=1)
    emails = bfo.fields('859__a', escape=1)
    # Add empty items to match length of authors list
    emails += ['']*(len(authors) - len(emails))

    authors_list = []
    for author, email in zip(authors, emails):
        if not author:
            continue
        if email.strip() and display_email.lower() == 'yes' :
            authors_list.append(create_html_mailto(email,
                                                   link_label=author,
                                                   subject=email_subject,
                                                   email_obfuscation_mode=email_obfuscation_mode_int))
        else:
            authors_list.append(author)

    return separator.join(authors_list)