[Bps-public-commit] r17632 - in Net-Google-Code/trunk: lib/Net/Google/Code t/sample

fayland at bestpractical.com fayland at bestpractical.com
Thu Jan 8 01:58:38 EST 2009


Author: fayland
Date: Thu Jan  8 01:58:38 2009
New Revision: 17632

Added:
   Net-Google-Code/trunk/t/sample/11.wiki.TestPage.html
Modified:
   Net-Google-Code/trunk/lib/Net/Google/Code/Mechanize.pm
   Net-Google-Code/trunk/lib/Net/Google/Code/WikiEntry.pm
   Net-Google-Code/trunk/t/11.wiki.t

Log:
add ->html in WikiEntry

Modified: Net-Google-Code/trunk/lib/Net/Google/Code/Mechanize.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code/Mechanize.pm	(original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/Mechanize.pm	Thu Jan  8 01:58:38 2009
@@ -3,7 +3,7 @@
 extends 'WWW::Mechanize';
 
 no Moose;
-__PACKAGE__->meta->make_immutable;
+#__PACKAGE__->meta->make_immutable;
 1;
 
 __END__

Modified: Net-Google-Code/trunk/lib/Net/Google/Code/WikiEntry.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code/WikiEntry.pm	(original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/WikiEntry.pm	Thu Jan  8 01:58:38 2009
@@ -32,6 +32,56 @@
     }
 );
 
+has '__html' => (
+    isa => 'Str',
+    is  => 'ro',
+    lazy => 1,
+    default => sub {
+        my $self = shift;
+        
+        my $name       = $self->name;
+        my $connection = $self->connection;
+        my $project    = $connection->project;
+        
+        # http://code.google.com/p/net-google-code/wiki/TestPage
+        my $wiki_url = "http://code.google.com/p/$project/wiki/$name";
+        my $content = $connection->_fetch( $wiki_url );
+        
+        return $content;
+    }
+);
+
+has '__html_tree' => (
+    is  => 'ro',
+    lazy => 1,
+    default => sub {
+        my $self = shift;
+        
+        my $html = $self->__html;
+        
+        require HTML::TreeBuilder;
+        my $tree = HTML::TreeBuilder->new;
+        $tree->parse_content($html);
+        $tree->elementify;
+        
+        return $tree;
+    },
+);
+
+has 'html' => (
+    isa => 'Str',
+    is  => 'ro',
+    lazy => 1,
+    default => sub {
+        my $self = shift;
+        
+        my $tree = $self->__html_tree;
+        my $meta = $tree->look_down(id => 'wikimaincol');
+
+        return $tree->content_array_ref->[-1]->as_HTML;
+    },
+);
+
 no Moose;
 __PACKAGE__->meta->make_immutable;
 
@@ -60,6 +110,10 @@
 
 wiki source code
 
+=head2 html
+
+html code of this wiki entry
+
 =head1 AUTHOR
 
 Fayland Lam, C<< <fayland at gmail.com> >>

Modified: Net-Google-Code/trunk/t/11.wiki.t
==============================================================================
--- Net-Google-Code/trunk/t/11.wiki.t	(original)
+++ Net-Google-Code/trunk/t/11.wiki.t	Thu Jan  8 01:58:38 2009
@@ -3,15 +3,17 @@
 use strict;
 use warnings;
 
-use Test::More tests => 9;
+use Test::More tests => 10;
 use Test::MockModule;
 use FindBin qw/$Bin/;
 use File::Slurp;
 
-my $svn_file  = "$Bin/sample/11.wiki.html";
-my $wiki_file = "$Bin/sample/11.TODO.wiki";
-my $svn_content  = read_file($svn_file);
-my $wiki_content = read_file($wiki_file);
+my $svn_file   = "$Bin/sample/11.wiki.html";
+my $wiki_file  = "$Bin/sample/11.TODO.wiki";
+my $entry_file = "$Bin/sample/11.wiki.TestPage.html";
+my $svn_content   = read_file($svn_file);
+my $wiki_content  = read_file($wiki_file);
+my $entry_content = read_file($entry_file);
 
 my $mock_connection = Test::MockModule->new('Net::Google::Code::Connection');
 $mock_connection->mock(
@@ -22,7 +24,9 @@
     		return $svn_content;
     	} elsif ( $uri eq 'http://foorum.googlecode.com/svn/wiki/TODO.wiki' ) {
     	    return $wiki_content;
-    	}
+    	} elsif ( $uri eq 'http://code.google.com/p/foorum/wiki/TODO' ) {
+    	    return $entry_content;
+        }
     }
 );
 
@@ -43,6 +47,7 @@
 my $entry = $wiki->entry('TODO');
 isa_ok( $entry, 'Net::Google::Code::WikiEntry' );
 is $entry->source, 'Please check [http://code.google.com/p/foorum/issues/list] for more issues.';
+like $entry->html, qr/Add your content here/;
 
 1;
 

Added: Net-Google-Code/trunk/t/sample/11.wiki.TestPage.html
==============================================================================
--- (empty file)
+++ Net-Google-Code/trunk/t/sample/11.wiki.TestPage.html	Thu Jan  8 01:58:38 2009
@@ -0,0 +1,523 @@
+
+ 
+
+
+ 
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ 
+ <title>TestPage - 
+ net-google-code -
+ 
+ Google Code - One-sentence summary of this page.</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
+ 
+ <link type="text/css" rel="stylesheet" href="http://www.gstatic.com/codesite/ph/3596478537346627501/css/d_20081117.css">
+ 
+ 
+ 
+<!--[if IE]>
+ <link type="text/css" rel="stylesheet" href="http://www.gstatic.com/codesite/ph/3596478537346627501/css/d_ie.css" >
+<![endif]-->
+</head>
+<body class="t6">
+ <div id="gaia">
+  <font size="-1">
+ 
+ <b>fayland at gmail.com</b>
+ 
+ | <a href="/p/support/wiki/WhatsNew" style="color:#a03">What's new?</a>
+ | <a href="/u/fayland/">Profile</a>
+ | <a href="/hosting/settings">Settings</a>
+ | <a href="/p/support/">Help</a>
+ | <a href="http://www.google.com/accounts/Logout?continue=http%3A%2F%2Fcode.google.com%2Fp%2Fnet-google-code%2Fwiki%2FTestPage">Sign out</a>
+ 
+ </font> 
+
+ </div>
+ <div class="gbh" style="left: 0pt;"></div>
+ <div class="gbh" style="right: 0pt;"></div>
+ 
+ 
+ <div style="height: 1px"></div>
+ <table style="padding:0px; margin: 20px 0px 0px 0px; width:100%" cellpadding="0" cellspacing="0">
+ <tr>
+ <td style="width:153px"><a href="/"><img src="http://www.gstatic.com/codesite/ph/images/code_sm.png" width="153" height="55" alt="Google"></a></td>
+ <td style="padding-left: 0.8em">
+ 
+ <div id="pname" style="margin: 0px 0px -3px 0px">
+ <a href="/p/net-google-code/" style="text-decoration:none; color:#000">net-google-code</a>
+ </div>
+ <div id="psum">
+ <i><a href="/p/net-google-code/" style="text-decoration:none; color:#000">a simple client library for google code</a></i>
+ </div>
+ 
+ </td>
+ <td style="white-space:nowrap; text-align:right">
+ 
+ <form action="/hosting/search">
+ <input size="30" name="q" value="">
+ <input type="submit" name="projectsearch" value="Search Projects" >
+ </form>
+ 
+ </tr>
+ </table>
+
+
+<table id="mt" cellspacing="0" cellpadding="0" width="100%" border="0">
+ <tr>
+ <th onclick="if (!cancelBubble) _go('/p/net-google-code/');">
+ <div class="tab inactive">
+ <div class="round4"></div>
+ <div class="round2"></div>
+ <div class="round1"></div>
+ <div class="box-inner">
+ <a onclick="cancelBubble=true;" href="/p/net-google-code/">Project Home</a>
+ </div>
+ </div>
+ </th><td>  </td>
+ 
+ 
+ 
+ 
+ <th onclick="if (!cancelBubble) _go('/p/net-google-code/downloads/list');">
+ <div class="tab inactive">
+ <div class="round4"></div>
+ <div class="round2"></div>
+ <div class="round1"></div>
+ <div class="box-inner">
+ <a onclick="cancelBubble=true;" href="/p/net-google-code/downloads/list">Downloads</a>
+ </div>
+ </div>
+ </th><td>  </td>
+ 
+ 
+ 
+ 
+ 
+ <th onclick="if (!cancelBubble) _go('/p/net-google-code/w/list');">
+ <div class="tab active">
+ <div class="round4"></div>
+ <div class="round2"></div>
+ <div class="round1"></div>
+ <div class="box-inner">
+ <a onclick="cancelBubble=true;" href="/p/net-google-code/w/list">Wiki</a>
+ </div>
+ </div>
+ </th><td>  </td>
+ 
+ 
+ 
+ 
+ 
+ <th onclick="if (!cancelBubble) _go('/p/net-google-code/issues/list');">
+ <div class="tab inactive">
+ <div class="round4"></div>
+ <div class="round2"></div>
+ <div class="round1"></div>
+ <div class="box-inner">
+ <a onclick="cancelBubble=true;" href="/p/net-google-code/issues/list">Issues</a>
+ </div>
+ </div>
+ </th><td>  </td>
+ 
+ 
+ 
+ 
+ 
+ <th onclick="if (!cancelBubble) _go('/p/net-google-code/source/list');">
+ <div class="tab inactive">
+ <div class="round4"></div>
+ <div class="round2"></div>
+ <div class="round1"></div>
+ <div class="box-inner">
+ <a onclick="cancelBubble=true;" href="/p/net-google-code/source/list">Source</a>
+ </div>
+ </div>
+ </th><td>  </td>
+ 
+ 
+ <td width="100%"> </td>
+ </tr>
+</table>
+<table cellspacing="0" cellpadding="0" width="100%" align="center" border="0" class="st">
+ <tr>
+ 
+ 
+ 
+ <td>
+ <div class="issueDetail">
+<div class="isf">
+ 
+ 
+ 
+ 
+ <span class="inIssueEntry"> 
+ <a href="/p/net-google-code/w/edit">New Page</a>
+ </span> |
+ 
+ 
+ 
+ <span class="inIssueList"> 
+ <span>Search</span>
+ <form action="/p/net-google-code/w/list" method="GET" style="display:inline">
+ <select id="can" name="can" style="font-size:92%">
+ <option disabled="disabled">Search Within:</option>
+ 
+ <option value="1" > All Wiki Pages</option>
+ <option value="3" > Featured Pages</option>
+ <option value="2" selected="selected"> Current Pages</option>
+ 
+ 
+ <option value="4" > Deprecated Pages</option>
+ 
+ </select>
+ <span>for</span>
+ <input type="text" size="32" id="q" name="q" value="" style="font-size:92%" >
+ 
+ 
+ <input type="submit" value="Search" style="font-size:92%" >
+ </form>
+ </span>
+
+ 
+ 
+ 
+ 
+  | <a href="/p/net-google-code/w/edit/TestPage">Edit This Page</a>
+  | <a href="/p/net-google-code/w/delete/TestPage">Delete This Page</a>
+ 
+ 
+ 
+ 
+
+</div>
+</div>
+
+ </td>
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ <td height="4" align="right" valign="top" class="bevel-right">
+ <div class="round4"></div>
+ <div class="round2"></div>
+ <div class="round1"></div>
+ </td>
+ </tr>
+</table>
+<script type="text/javascript">
+ var cancelBubble = false;
+ function _go(url) { document.location = url; }
+</script>
+
+<div id="maincol">
+<!-- IE -->
+
+
+
+
+
+
+ <style type="text/css">
+ .artifactcomment, #commentform {
+ margin: .5em 0 0 0;
+ padding: .3em 0 .3em .3em;
+ border-top: 3px solid #c3d9ff;
+ }
+ #commentform { padding-top: 1em; }
+ .delcom { background: #e8e8e8 }
+ .commentcontent { margin: 1em 0;}
+ </style>
+
+
+ <div id="wikicontent">
+ <table width="100%" border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ 
+ <td class="vt" id="wikimaincol" width="100%">
+ 
+ <div style="float:right; width:18em" id="wikimeta">
+ <div class="pmeta_bubble_bg">
+ <div class="round4"></div>
+ <div class="round2"></div>
+ <div class="round1"></div>
+ <div class="box-inner">
+ <table style="padding: 5px">
+ <tr><td colspan="2" style="padding-bottom:5px">Updated <span title="Wed Jan  7 22:32:44 2009">Today (5 minutes ago)</span>
+ 
+ by <a href="/u/fayland/">fayland</a>
+ </td></tr>
+ 
+ 
+ 
+ </table>
+ </div>
+ <div class="round1"></div>
+ <div class="round2"></div>
+ <div class="round4"></div>
+ </div>
+ </div>
+ 
+ <div id="wikiheader" style="margin-bottom:1em">
+ 
+ <span style="font-size:120%;font-weight:bold">TestPage</span>
+  
+ 
+ 
+ <div style="font-style:italic; margin-top: 3px">One-sentence summary of this page.</div>
+ 
+ </div>
+ <h1><a name="Introduction"/>Introduction</h1><p>Add your content here. </p><h1><a name="Details"/>Details</h1><p>Add your content here.  Format your content with: <ul><li>Text in <strong>bold</strong> or <i>italic</i> </li><li>Headings, paragraphs, and lists </li><li>Automatic links to other wiki pages </li></ul></p>
+ </td> 
+ </tr>
+ </table>
+ </div>
+
+
+ 
+ <br>
+ <div id="commentlist">
+ 
+
+
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+
+<div class="collapse">
+
+
+ 
+ <div class="artifactcomment">
+ 
+ 
+ 
+ <div style="float:right; margin-right:.3em; text-align:right">
+ 
+ <a style="font-size: 90%" href="#"
+ onclick="return delComment('0', '1')"
+ >Delete comment</a>
+ 
+ </div>
+ 
+ 
+ 
+ <span class="author">Comment
+ 
+ by
+ 
+ <a href="/u/fayland/">fayland</a>,
+ 
+ </span>
+ <span class="date" title="Wed Jan  7 22:37:57 2009">Today (moments ago)</span>
+ <div>
+<div class="commentcontent">
+<p>comment1 </p>
+</div>
+ 
+ 
+ </div>
+ </div>
+ 
+
+ 
+ <div class="artifactcomment">
+ 
+ 
+ 
+ <div style="float:right; margin-right:.3em; text-align:right">
+ 
+ <a style="font-size: 90%" href="#"
+ onclick="return delComment('1', '1')"
+ >Delete comment</a>
+ 
+ </div>
+ 
+ 
+ 
+ <span class="author">Comment
+ 
+ by
+ 
+ <a href="/u/fayland/">fayland</a>,
+ 
+ </span>
+ <span class="date" title="Wed Jan  7 22:38:07 2009">Today (moments ago)</span>
+ <div>
+<div class="commentcontent">
+<p>two line comment 2. </p>
+</div>
+ 
+ 
+ </div>
+ </div>
+ 
+
+</div>
+
+ <script type="text/javascript">
+ function delComment(sequence_num, delete_mode) {
+ var f = document.forms["delcom"];
+ f.sequence_num.value = sequence_num;
+ f.mode.value = delete_mode;
+ f.submit();
+ return false;
+ }
+ </script>
+
+
+ </div>
+ 
+ 
+ 
+ 
+ 
+ <div id="commentform">
+ <form action="../w/detail.do" method="post">
+ <table>
+ <tr><td class="vt">
+ <input type="hidden" name="pagename" value="TestPage" >
+ <input type="hidden" name="token" value="607bf9a85c196330d4160fe9849d83a0" >
+ <div>Enter a comment:</div>
+ <textarea name="content" rows="6" cols="80"></textarea><br><br>
+ <input type="submit" name="submit" value="Submit" >
+ </td>
+ <td class="vt">
+ <div id="whb" class="tip" style="width:15em">
+ <div class="round4"></div>
+ <div class="round2"></div>
+ <div class="round1"></div>
+ <div class="box-inner opened"
+ id="entrybubble">
+ <a class="ifClosed" href="#whb" style="float:right"
+ onclick="_toggleHidden(this); document.getElementById('wikihelp').value='opened'">show</a>
+ <a class="ifOpened" href="#whb" style="float:right"
+ onclick="_toggleHidden(this); document.getElementById('wikihelp').value='closed'"
+ >hide</a>
+ <b>Wiki Markup Help</b>
+ <div class="ifOpened">
+ <div style="padding:2px; font-size:96%">
+ =Heading1=<br>
+ ==Heading2==<br>
+ ===Heading3===<br>
+ <br>
+ *bold*    
+ _italic_<br>
+ `inline code`<br>
+ escape: `*`<br>
+ <br>
+ Indent lists 2 spaces:<br>
+   * bullet item<br>
+   # numbered list<br>
+ <br>
+ {{{<br>
+ verbatim code block<br>
+ }}}<br>
+ <br>
+ Horizontal rule<br>
+ ----
+ <br>
+ <br>
+ WikiWordLink<br>
+ [http://domain/page label]<br>
+ http://domain/page<br>
+ <br>
+ || table || cells ||<br>
+ 
+ </div><br>
+ <a href="http://code.google.com/p/support/wiki/WikiSyntax" target="new">More
+ examples</a>
+ <a href="http://code.google.com/p/support/wiki/WikiSyntax" target="new"><img
+ src="http://www.gstatic.com/codesite/ph/images/tearoff_icon.gif"/></a>
+ </div>
+ </div>
+ <div class="round1"></div>
+ <div class="round2"></div>
+ <div class="round4"></div>
+</div>
+<input type="hidden" name="wikihelp" id="wikihelp" value="opened" >
+
+ </td></tr>
+ </table>
+ </form>
+ </div>
+ 
+ 
+ 
+
+<form name="delcom" action="../w/delComment.do" method="POST">
+ <input type="hidden" name="sequence_num" value="" >
+ <input type="hidden" name="mode" value="" >
+ <input type="hidden" name="pagename" value="TestPage" >
+ <input type="hidden" name="token" value="607bf9a85c196330d4160fe9849d83a0" >
+</form>
+
+
+
+<script src="http://www.gstatic.com/codesite/ph/3596478537346627501/js/prettify_20080714.js"></script>
+<script type="text/javascript">
+ prettyPrint();
+</script>
+<script type="text/javascript" src="http://www.gstatic.com/codesite/ph/3596478537346627501/js/dit_scripts_20081013.js"></script>
+
+
+
+  
+ <script type="text/javascript" src="http://www.gstatic.com/codesite/ph/3596478537346627501/js/core_scripts_20081103.js"></script>
+ 
+ 
+ 
+ </div>
+<div id="footer" dir="ltr">
+ 
+ <div class="text">
+ 
+ ©2008 Google -
+ <a href="/">Code Home</a> -
+ <a href="/tos.html">Terms of Service</a> -
+ <a href="http://www.google.com/privacy.html">Privacy Policy</a> -
+ <a href="/more/">Site Directory</a>
+ 
+ </div>
+</div>
+<script type="text/javascript">
+/**
+ * Reports analytics.
+ * It checks for the analytics functionality (window._gat) every 100ms
+ * until the analytics script is fully loaded in order to invoke siteTracker.
+ */
+function _CS_reportAnalytics() {
+ window.setTimeout(function() {
+ if (window._gat) {
+ var siteTracker = _gat._getTracker("UA-18071-1");
+ siteTracker._initData();
+ siteTracker._trackPageview();
+ 
+ } else {
+ _CS_reportAnalytics();
+ }
+ }, 100);
+}
+</script>
+
+ 
+ 
+
+
+ 
+ </body>
+</html>
+
+



More information about the Bps-public-commit mailing list