[Bps-public-commit] r17804 - in Net-Google-Code/trunk: lib/Net/Google/Code t/sample
fayland at bestpractical.com
fayland at bestpractical.com
Sat Jan 17 18:37:22 EST 2009
Author: fayland
Date: Sat Jan 17 18:37:22 2009
New Revision: 17804
Added:
Net-Google-Code/trunk/t/sample/11.TestPage.wiki
Modified:
Net-Google-Code/trunk/lib/Net/Google/Code/WikiEntry.pm
Net-Google-Code/trunk/t/11.wiki.t
Net-Google-Code/trunk/t/sample/11.TODO.wiki
Net-Google-Code/trunk/t/sample/11.wiki.TestPage.html
Log:
add labels in WikiEntry.pm
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 Sat Jan 17 18:37:22 2009
@@ -110,11 +110,39 @@
my $tree = $self->__html_tree;
my $title = $tree->find_by_tag_name('title')->content_array_ref->[0];
my @parts = split(/\s+\-\s+/, $title, 4);
- return $parts[3] if ( scalar @parts == 4 );
+ return $parts[2] if ( scalar @parts == 4 );
return;
},
);
+has 'labels' => (
+ isa => 'ArrayRef',
+ is => 'ro',
+ lazy => 1,
+ default => sub {
+ my $self = shift;
+
+ if ( $self->has_source ) { # get from source
+ my @lines = split(/\n/, $self->source);
+ foreach my $line (@lines ) {
+ if ( $line =~ /^\#labels\s+(.*?)$/ ) {
+ return [ split(/\,/, $1) ];
+ }
+ last if ( $line !~ /^\#/ );
+ }
+ return [];
+ }
+ # get from the html tree
+ my $tree = $self->__html_tree;
+ my @tags = $tree->look_down( href => qr/q\=label\:/);
+ my @labels;
+ foreach my $tag ( @tags ) {
+ push @labels, $tag->content_array_ref->[0];
+ }
+ return \@labels;
+ },
+);
+
no Moose;
__PACKAGE__->meta->make_immutable;
@@ -140,26 +168,34 @@
=head1 ATTRIBUTES
-=head2 source
+=over 4
+
+=item source
wiki source code
-=head2 html
+=item html
html code of this wiki entry
-=head2 summary
+=item summary
summary of this wiki entry
-=head2 updated_time
+=item labels
+
+labels of this wiki entry
+
+=item updated_time
last updated time of this wiki entry
-=head2 updated_by
+=item updated_by
last updator of this wiki entry
+=back
+
=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 Sat Jan 17 18:37:22 2009
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 10;
+use Test::More tests => 13;
use Test::MockModule;
use FindBin qw/$Bin/;
use File::Slurp;
@@ -11,9 +11,11 @@
my $svn_file = "$Bin/sample/11.wiki.html";
my $wiki_file = "$Bin/sample/11.TODO.wiki";
+my $wiki_file2 = "$Bin/sample/11.TestPage.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 $wiki_content2 = read_file($wiki_file2);
my $entry_content = read_file($entry_file);
use Net::Google::Code::Wiki;
@@ -24,10 +26,11 @@
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' ) {
+ } elsif ( $uri eq 'http://code.google.com/p/foorum/wiki/TestPage' ) {
return $entry_content;
+ } elsif ( $uri eq 'http://foorum.googlecode.com/svn/wiki/TestPage.wiki' ) {
+ return $wiki_content2;
}
-
};
my $mock_wiki = Test::MockModule->new('Net::Google::Code::Wiki');
@@ -48,11 +51,19 @@
my $entry = $wiki->entry('TODO');
isa_ok( $entry, 'Net::Google::Code::WikiEntry' );
+
+# test source
+is $entry->source, $wiki_content;
+is $entry->summary, 'TODO list';
+is_deeply $entry->labels, ['Featured', 'Phase-Support'];
+
+# test HTML
+$entry = $wiki->entry('TestPage');
like $entry->html, qr/Add your content here/;
-is $entry->updated_time, 'Wed Jan 7 22:32:44 2009';
+is $entry->updated_time, 'Sat Jan 17 15:21:27 2009';
is $entry->updated_by, 'fayland';
is $entry->summary, 'One-sentence summary of this page.';
-is $entry->source, 'Please check [http://code.google.com/p/foorum/issues/list] for more issues.';
+is_deeply $entry->labels, ['Phase-QA', 'Phase-Support'];
1;
Modified: Net-Google-Code/trunk/t/sample/11.TODO.wiki
==============================================================================
--- Net-Google-Code/trunk/t/sample/11.TODO.wiki (original)
+++ Net-Google-Code/trunk/t/sample/11.TODO.wiki Sat Jan 17 18:37:22 2009
@@ -1 +1,4 @@
+#summary TODO list
+#labels Featured,Phase-Support
+
Please check [http://code.google.com/p/foorum/issues/list] for more issues.
\ No newline at end of file
Added: Net-Google-Code/trunk/t/sample/11.TestPage.wiki
==============================================================================
--- (empty file)
+++ Net-Google-Code/trunk/t/sample/11.TestPage.wiki Sat Jan 17 18:37:22 2009
@@ -0,0 +1,14 @@
+#summary One-sentence summary of this page.
+#labels Phase-QA,Phase-Support
+
+= Introduction =
+
+Add your content here.
+
+
+= Details =
+
+Add your content here. Format your content with:
+ * Text in *bold* or _italic_
+ * Headings, paragraphs, and lists
+ * Automatic links to other wiki pages
\ No newline at end of file
Modified: Net-Google-Code/trunk/t/sample/11.wiki.TestPage.html
==============================================================================
--- Net-Google-Code/trunk/t/sample/11.wiki.TestPage.html (original)
+++ Net-Google-Code/trunk/t/sample/11.wiki.TestPage.html Sat Jan 17 18:37:22 2009
@@ -1,4 +1,3 @@
-
@@ -6,44 +5,61 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
+ <script type="text/javascript">
+
+
+ var codesite_token = "a210549fc285c51b9bd931ff486be137";
+
+ </script>
<title>TestPage -
net-google-code -
- Google Code - One-sentence summary of this page.</title>
+ One-sentence summary of this page. - Google Code</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">
+ <link type="text/css" rel="stylesheet" href="http://www.gstatic.com/codesite/ph/3110769620637069882/css/d_20081117.css">
<!--[if IE]>
- <link type="text/css" rel="stylesheet" href="http://www.gstatic.com/codesite/ph/3596478537346627501/css/d_ie.css" >
+ <link type="text/css" rel="stylesheet" href="http://www.gstatic.com/codesite/ph/3110769620637069882/css/d_ie.css" >
<![endif]-->
+
</head>
<body class="t6">
<div id="gaia">
<font size="-1">
- <b>fayland at gmail.com</b>
+ <b>xxx 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="/u/xxx/">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>
+ | <a href="http://www.google.com/accounts/Logout?continue=http%3A%2F%2Fcode.google.com%2Fp%2Fnet-google-code%2Fwiki%2FTestPage%3Fts%3D1232234488%26updated%3DTestPage">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="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">
@@ -54,6 +70,7 @@
</div>
</td>
+
<td style="white-space:nowrap; text-align:right">
<form action="/hosting/search">
@@ -66,6 +83,7 @@
<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">
@@ -74,6 +92,7 @@
<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>
@@ -87,6 +106,7 @@
<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>
@@ -100,6 +120,7 @@
<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>
@@ -113,6 +134,7 @@
<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>
@@ -121,6 +143,7 @@
</div>
</div>
</th><td> </td>
+
@@ -134,6 +157,7 @@
<div class="box-inner">
<a onclick="cancelBubble=true;" href="/p/net-google-code/source/list">Source</a>
</div>
+
</div>
</th><td> </td>
@@ -149,6 +173,7 @@
<td>
<div class="issueDetail">
<div class="isf">
+
@@ -164,6 +189,7 @@
<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>
@@ -174,6 +200,7 @@
</select>
<span>for</span>
+
<input type="text" size="32" id="q" name="q" value="" style="font-size:92%" >
@@ -187,6 +214,7 @@
| <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>
+
@@ -210,6 +238,7 @@
<div class="round1"></div>
</td>
</tr>
+
</table>
<script type="text/javascript">
var cancelBubble = false;
@@ -247,18 +276,35 @@
<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>
+ <tr><td colspan="2" style="padding-bottom:5px">Updated <span title="Sat Jan 17 15:21:27 2009">Today (moments ago)</span>
by <a href="/u/fayland/">fayland</a>
</td></tr>
+ <tr><th class="vt">Labels:</th>
+
+ <td>
+
+ <a href="/p/net-google-code/w/list?q=label:Phase-QA"
+ title=""
+ >Phase-QA</a>,
+
+ <a href="/p/net-google-code/w/list?q=label:Phase-Support"
+ title=""
+ >Phase-Support</a>
+
+ </td>
+ </tr>
+
</table>
</div>
<div class="round1"></div>
+
<div class="round2"></div>
<div class="round4"></div>
</div>
@@ -271,11 +317,13 @@
<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>
@@ -305,6 +353,7 @@
<div style="float:right; margin-right:.3em; text-align:right">
+
<a style="font-size: 90%" href="#"
onclick="return delComment('0', '1')"
@@ -321,10 +370,11 @@
<a href="/u/fayland/">fayland</a>,
</span>
- <span class="date" title="Wed Jan 7 22:37:57 2009">Today (moments ago)</span>
+ <span class="date" title="Wed Jan 7 22:37:57 2009">Jan 07, 2009</span>
<div>
<div class="commentcontent">
<p>comment1 </p>
+
</div>
@@ -354,7 +404,8 @@
<a href="/u/fayland/">fayland</a>,
</span>
- <span class="date" title="Wed Jan 7 22:38:07 2009">Today (moments ago)</span>
+
+ <span class="date" title="Wed Jan 7 22:38:07 2009">Jan 07, 2009</span>
<div>
<div class="commentcontent">
<p>two line comment 2. </p>
@@ -389,8 +440,9 @@
<table>
<tr><td class="vt">
<input type="hidden" name="pagename" value="TestPage" >
- <input type="hidden" name="token" value="607bf9a85c196330d4160fe9849d83a0" >
+ <input type="hidden" name="token" value="a210549fc285c51b9bd931ff486be137" >
<div>Enter a comment:</div>
+
<textarea name="content" rows="6" cols="80"></textarea><br><br>
<input type="submit" name="submit" value="Submit" >
</td>
@@ -399,6 +451,7 @@
<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"
@@ -410,12 +463,14 @@
<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>
@@ -423,6 +478,7 @@
# numbered list<br>
<br>
{{{<br>
+
verbatim code block<br>
}}}<br>
<br>
@@ -431,6 +487,7 @@
<br>
<br>
WikiWordLink<br>
+
[http://domain/page label]<br>
http://domain/page<br>
<br>
@@ -439,6 +496,7 @@
</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>
@@ -450,6 +508,7 @@
<input type="hidden" name="wikihelp" id="wikihelp" value="opened" >
</td></tr>
+
</table>
</form>
</div>
@@ -461,25 +520,26 @@
<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" >
+ <input type="hidden" name="token" value="a210549fc285c51b9bd931ff486be137" >
</form>
-<script src="http://www.gstatic.com/codesite/ph/3596478537346627501/js/prettify_20080714.js"></script>
+<script src="http://www.gstatic.com/codesite/ph/3110769620637069882/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/3110769620637069882/js/dit_scripts_20081013.js"></script>
- <script type="text/javascript" src="http://www.gstatic.com/codesite/ph/3596478537346627501/js/core_scripts_20081103.js"></script>
+ <script type="text/javascript" src="http://www.gstatic.com/codesite/ph/3110769620637069882/js/core_scripts_20081103.js"></script>
</div>
+
<div id="footer" dir="ltr">
<div class="text">
@@ -491,6 +551,7 @@
<a href="/more/">Site Directory</a>
</div>
+
</div>
<script type="text/javascript">
/**
More information about the Bps-public-commit
mailing list