Author: fayland
Date: Sat Jan 31 17:08:57 2009
New Revision: 53
Modified:
trunk/Changes
trunk/lib/WWW/Contact.pm
trunk/lib/WWW/Contact/Hotmail.pm
trunk/t/samples/hotmail.html
Log:
for 0.20 ship: fix Hotmail issues.
Modified: trunk/Changes
==============================================================================
--- trunk/Changes (original)
+++ trunk/Changes Sat Jan 31 17:08:57 2009
@@ -1,5 +1,10 @@
Revision history for WWW-Contact
+0.20 2009.02.01
+ add Hotmail/Gmail into social_network (RT 42924)
+ fix Hotmail whacky results by David Moreno (RT 42925)
+ fix Hotmail "You spoke, Hotmail listened" bug by FAYLAND
+
0.19 2009.01.03
no code change
try to fix CPAN install
Modified: trunk/lib/WWW/Contact.pm
==============================================================================
--- trunk/lib/WWW/Contact.pm (original)
+++ trunk/lib/WWW/Contact.pm Sat Jan 31 17:08:57 2009
@@ -4,7 +4,7 @@
use Moose;
use Moose::Util::TypeConstraints;
-our $VERSION = '0.19';
+our $VERSION = '0.20';
our $AUTHORITY = 'cpan:FAYLAND';
has 'errstr' => ( is => 'rw', isa => 'Maybe[Str]' );
@@ -73,6 +73,8 @@
{
# Social networks.
'plaxo' => 'Plaxo',
+ 'Hotmail' => 'Hotmail',
+ 'Gmail' => 'Gmail',
}
}
);
Modified: trunk/lib/WWW/Contact/Hotmail.pm
==============================================================================
--- trunk/lib/WWW/Contact/Hotmail.pm (original)
+++ trunk/lib/WWW/Contact/Hotmail.pm Sat Jan 31 17:08:57 2009
@@ -6,7 +6,7 @@
use HTTP::Request::Common qw/POST/;
use HTML::TokeParser::Simple;
-our $VERSION = '0.16';
+our $VERSION = '0.20';
our $AUTHORITY = 'cpan:FAYLAND';
sub get_contacts {
@@ -71,6 +71,13 @@
$self->get( $url ) || return;
}
+ # You spoke, Hotmail listened
+ if ( $ua->content =~ /MessageAtLoginForm/ ) {
+ $self->submit_form(
+ form_name => 'MessageAtLoginForm',
+ ) || return;
+ }
+
$self->get('/mail/PrintShell.aspx?type=contact') || return;
@contacts = $self->get_contacts_from_html( $ua->content );
@@ -90,7 +97,14 @@
if ($class and $class eq 'cDisplayName') {
my $name = $p->peek(1);
$name =~ s/(^\s+|\s+$)//isg;
+ $name =~ s/\x{200e}$//;
push @names, $name;
+ } elsif( $class and $class eq 'cCol1' ) {
+ $p->get_tag; # this "should" be table
+ $tag = $p->get_tag;
+ unless ($tag->is_start_tag('tr')) {
+ push @emails, undef;
+ }
}
} elsif ( $token->is_start_tag('td') ) {
my $class = $token->get_attr('class');
@@ -99,7 +113,7 @@
my $email = $p->peek(1);
$email =~ s/(^\s+|\s+$)//isg;
$email =~ s/\&\#64\;/\@/;
- push @emails, $email;
+ push @emails, $email if $email =~ /\@/;
}
}
}
Modified: trunk/t/samples/hotmail.html
==============================================================================
--- trunk/t/samples/hotmail.html (original)
+++ trunk/t/samples/hotmail.html Sat Jan 31 17:08:57 2009
@@ -1,215 +1,217 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Strict//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Strict//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html dir="ltr">
-
<head>
-
<title>Windows Live Hotmail Print Contacts</title>
-
- <link rel="stylesheet"
href="/mail/ThemeCommon_13.1.0132.0805.aspx?Theme=4&culture=en-CN"
type="text/css" id="ssThemeService"/>
-
- <link rel="stylesheet"
href="
http://gfx8.hotmail.com/mail/13.1.0132.0805/LayoutCommon.css"
type="text/css"/>
-
- <link rel="stylesheet"
href="/mail/LayoutCommon_13.1.0132.0805.aspx?Theme=4&culture=en-CN"
type="text/css"/>
-
- <link rel="stylesheet"
href="
http://gfx8.hotmail.com/mail/13.1.0132.0805/LayoutContactCommon.css"
type="text/css"/>
-
+ <link rel="stylesheet"
href="
http://gfx8.hotmail.com/mail/13.2.0260.1209/styles/Base/hig.css"
type="text/css"/>
+ <link rel="stylesheet"
href="/mail/LayoutCommon_13.2.0260.1209.aspx?culture=en-CN"
type="text/css"/>
+ <link rel="stylesheet"
href="
http://gfx8.hotmail.com/mail/13.2.0260.1209/styles/Base/LayoutContactCommon.css"
type="text/css"/>
-
<style type="text/css">
-
.FloatLeft, .HeaderLabel, .HeaderData {float:left;}
-
.FloatRight {float:right;}
-
.HeaderLabel {margin-right:0.45em;}
-
- .ContainerPadding {margin:0;padding:0.32em 0.64em 0.64em
0.64em;}
-
+ .ContainerPadding {padding:4px 4px 8px 4px;}
+ .PrintContent {padding:0px 12px;}
+ #PrintShellToolbar IMG {padding-right:4px;}
</style>
<script type="text/javascript">
-
function PrintDocument()
-
{
-
- document.getElementById("PrintShellToolbar").style.display
= "none";
-
- window.setTimeout("window.print();",1)
-
-
window.setTimeout("document.getElementById(\'PrintShellToolbar\').style.display
= \'block\';",1)
-
+ var elem = document.getElementById("PrintShellToolbar");
+ if (elem)
+ {
+ elem.style.display = "none";
+ window.setTimeout("window.print();",1)
+
window.setTimeout("document.getElementById('PrintShellToolbar').style.display
= 'block';",1)
+ }
}
-
</script>
-
</head>
-
<body onload="javascript:PrintDocument();">
-
- <div id="HeaderContainer">
-
- <img style="display:none"
src="http://
accountservices.msn.com/loginmsn.srf?lc=1055&ct=1225012330&rver=4.5.2130.0&lc=1055&id=64855&ru=http:%2F%
2Fmail.live.com%2Fmail%2Fmail.aspx&MSNPPAuth="Bx81xYwJirJuwHJOzaY*fIVEQkLmKS7gyKgkhUFBkfN9X!SGSnwGO!U*2r!dnm0kq!brIS3JvZLY*yRvukZUVInen5eaH1oFzsIYUfoDc3RhezCVlkDdl2Fkxo5bwafwLdfYJ3*RwxHtL!3nn5UCqVnzaAYGgpxQOZpqdU!5B70JXxi0SRqI3DF4t68D0LrCxB6CFmPcI!iVjqyNIzQX!NfS3IMir2qHUJSRM9WGH8E1d53THaugXUouWWtw5R6kzDKPtLL1VdrtwVhb17mxDKQIwo9mdj036RPy0V2qroC2D1rdZQQeTErDZYGQBDT!bMpIY3TCkXDkfJuxh5bdvG9ATlcHN5mbDeyCvN5Ph!UNNbRkHE!Onew8ThHIYJeBAi9UmZNXSEwSTu6Ew1KASqmE5W7TlebzyF05i96KPkl3sS4kegyUg7OjyjO9Z6KJDZ86E3yR*jitD6DKoSrIOqI0z!VR!uxCjLMSEIcJnEubMTAChnNLegNcPEYU""/><script
type="text/javascript">function
uxp_p(t){t.parentNode.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'"+t.src+"\')";}</script><table
cellspacing="0" id="uxp_hdr" class="uxp_hdr_miniMode"><tr><td
class="uxp_hdrInner"><table class="uxp_hdrInnerTable"
cellspacing="0"><tr><td><span style="vertical-align:middle;zoom:1"><img
src="
http://gfx1.hotmail.com/mail/uxp/w2/pr04/HIG/img/h/flag_24.png"
alt="More services" style="visibility:hidden"
onload="uxp_p(this)"/></span><span class="uxp_hdr_windowsLiveText">Windows
Live<span class="uxp_hdr_tm">™</span></span><br
/></td></tr></table></td></tr></table>
-
- </div>
-
-
-
-
- <div class="cPrintDiv">
-
+ <div class="PrintContent">
-
<style type="text/css">
-
.ContactsPrintPane .ContactHeader {padding:0em 0em
1.33em .41em;padding-right:0em;padding-left:.41em;position:relative;}
-
.ContactHeader .cDisplayName {padding-top:.45em;}
-
-.ContactsPrintPane DIV.Label {width:12.91em;padding:.36em 1.64em .36em
0;padding-right:1.64em;padding-left:0;text-align:right;}
-
-.ContactsPrintPane DIV.Value {margin-left:13.91em;padding:.36em 0;}
-
+.ContactsPrintPane TD.Label {width:12.91em;padding:.36em 1.64em .36em
0;padding-right:1.64em;padding-left:0;text-align:right;}
+.ContactsPrintPane TD.Value {margin-left:13.91em;padding:.36em 0;}
.cPrintContact {padding:1em 0em
1em .41em;padding-right:0em;padding-left:.41em;}
-
-.cLinks {padding-left:.91em;)
-
+.cLinks {padding-left:.91em;}
+.ContactsPrintPane .cCol1 {float:none;padding:0px;}
</style>
-
-
<div id="PrintShellToolbar">
-
<div class="ContainerPadding">
-
<span class="FloatRight">
<a href="javascript:window.close();" >
-
- <img alt=""
src="
http://gfx1.hotmail.com/mail/w3/pr01/ltr/glyph_close_rest.gif"
/> Close window
-
+ <img alt=""
src="
http://gfx1.hotmail.com/mail/w3/ltr/glyph_close_rest.gif"
/> Close window
</a>
-
</span>
-
<span>
-
<a href="javascript:PrintDocument();" >
-
- <img alt=""
src="
http://gfx2.hotmail.com/mail/w3/pr01/ltr/i_print.gif" /> Print
-
+ <img alt=""
src="
http://gfx2.hotmail.com/mail/w3/ltr/i_print.gif" /><span
class='VAlignTop'> Print</span>
</a>
-
</span>
</div>
-
</div>
-
-
<div class="ContactsPrintPane cPrintContact BorderTop">
-
-<div class="ContactHeader">
-
-
-
+<script type="text/javascript">
+ function ToggleDetails(hideId, showId)
+ {
+ var e = document.getElementById(hideId);
+ if (e)
+ {
+ e.style.display = "none";
+ e = document.getElementById(showId);
+ if (e)
+ e.style.display = "block";
+ }
+ }
+</script>
+<div class="ContactHeader ClearBoth">
<div class="cContactHeaderInfo">
-
+
<div class="cDisplayName" >
-
fayland xxx
</div>
-
-
-
+
</div>
</div>
-<table>
-
-
-
-<tr>
-
-<td class="TextAlignRight Label" >Personal e-mail</td>
-
-<td class="Value" >xxxx@
gmail.com<span> (preferred e-mail
address)</span></td>
-
-</tr>
-
-
-
-<tr>
-
-<td class="TextAlignRight Label" >Windows Live ID</td>
-
-<td class="Value" >yyyy@
gmail.com</td>
-
-</tr>
+ <div id="cFullView" class="ClearBoth"
+>
+ <div class="cCol1">
+ <table>
+
+ <tr>
+ <td class="TextAlignRight Label" >Name:</td>
+ <td class="Value" >fayland xxx</td>
+
+ </tr>
+
+ </table>
+ </div>
+ <div class="cCol2">
+ <table>
+
+ </table>
+ </div>
+ <div class="cDetailsSeparator"> </div>
+
+ <div class="cCol1">
+ <table>
+
+ <tr>
+ <td class="TextAlignRight Label" >Personal e-mail:</td>
+ <td class="Value" >xxxx@
gmail.com</td>
+ </tr>
+
+ <tr>
+ <td class="TextAlignRight Label" >Windows Live ID:</td>
+
+ <td class="Value" >xxxx@
gmail.com</td>
+ </tr>
+
+ </table>
+ </div>
+ <div class="cCol2">
+ <table>
+
+ </table>
+ </div>
+ <div class="cDetailsSeparator"> </div>
+
-</table>
+</div>
</div>
-
-
<div class="ContactsPrintPane cPrintContact BorderTop">
-
-<div class="ContactHeader">
-
-
-
+<script type="text/javascript">
+ function ToggleDetails(hideId, showId)
+ {
+ var e = document.getElementById(hideId);
+ if (e)
+ {
+ e.style.display = "none";
+ e = document.getElementById(showId);
+ if (e)
+ e.style.display = "block";
+ }
+ }
+</script>
+<div class="ContactHeader ClearBoth">
<div class="cContactHeaderInfo">
-
+
<div class="cDisplayName" >
-
fayland lam
</div>
-
-
-
+
</div>
</div>
-<table>
-
-
-
-<tr>
-
-<td class="TextAlignRight Label" >Personal e-mail</td>
-
-<td class="Value" >zzz@
gmail.com</td>
-
-</tr>
+ <div id="cFullView" class="ClearBoth"
+>
+ <div class="cCol1">
+ <table>
+
+ <tr>
+ <td class="TextAlignRight Label" >Name:</td>
+ <td class="Value" >fayland lam</td>
+
+ </tr>
+
+ </table>
+ </div>
+ <div class="cCol2">
+ <table>
+
+ </table>
+ </div>
+ <div class="cDetailsSeparator"> </div>
+
+ <div class="cCol1">
+ <table>
+
+ <tr>
+ <td class="TextAlignRight Label" >Personal e-mail:</td>
+ <td class="Value" >zzz@
gmail.com</td>
+ </tr>
+
+ </table>
+ </div>
-</table>
+ <div class="cCol2">
+ <table>
+
+ </table>
+ </div>
+ <div class="cDetailsSeparator"> </div>
+
+</div>
</div>
-
-
<img id="cleargif" alt=""
src="
http://h.msn.com/c.gif?RF=&PI=7324&DI=5698&PS=93140" width="1"
height="1" />
-
-
</div>
-
-
</body>
-</html>
\ No newline at end of file
+</html>