[Cpan-forum-commit] rev 240 - in trunk: . lib/CPAN lib/CPAN/Forum/DB lib/CPAN/Forum/RM templates

svn at pti.co.il svn at pti.co.il
Wed Jul 4 00:03:35 IDT 2007


Author: gabor
Date: 2007-07-04 00:03:35 +0300 (Wed, 04 Jul 2007)
New Revision: 240

Added:
   trunk/templates/tags.tmpl
Modified:
   trunk/
   trunk/lib/CPAN/Forum.pm
   trunk/lib/CPAN/Forum/DB/Tags.pm
   trunk/lib/CPAN/Forum/RM/Tags.pm
   trunk/lib/CPAN/Forum/RM/Update.pm
   trunk/templates/groups.tmpl
   trunk/templates/navigation.tmpl
Log:
add page to display all the tags
remove spaces from two ends of tags before adding them to database



Property changes on: trunk
___________________________________________________________________
Name: svk:merge
   - 7bc34947-122d-0410-bc5a-f898d2bb5f81:/local/cpan-forum:4099
8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:12752
   + 7bc34947-122d-0410-bc5a-f898d2bb5f81:/local/cpan-forum:4100
8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:12752

Modified: trunk/lib/CPAN/Forum/DB/Tags.pm
===================================================================
--- trunk/lib/CPAN/Forum/DB/Tags.pm	2007-07-03 21:02:47 UTC (rev 239)
+++ trunk/lib/CPAN/Forum/DB/Tags.pm	2007-07-03 21:03:35 UTC (rev 240)
@@ -99,7 +99,23 @@
     return $id;
 }
 
+sub get_all_tags {
+    my ($self) = @_;
 
+    my $dbh = CPAN::Forum::DBI::db_Main();
+    my $sql = "SELECT name
+                FROM tags
+                WHERE id IN (SELECT DISTINCT tag_id FROM tag_cloud) ORDER BY name ASC";
+    my $sth = $dbh->prepare($sql);
+    $sth->execute;
+    my @tags;
+    while (my $hr = $sth->fetchrow_hashref) {
+        push @tags, $hr;
+    }
+    return \@tags;
+}
+
+
 =head1 Design
 
 Every person can put any tage on any module

Modified: trunk/lib/CPAN/Forum/RM/Tags.pm
===================================================================
--- trunk/lib/CPAN/Forum/RM/Tags.pm	2007-07-03 21:02:47 UTC (rev 239)
+++ trunk/lib/CPAN/Forum/RM/Tags.pm	2007-07-03 21:03:35 UTC (rev 240)
@@ -1,7 +1,19 @@
-package CPAN::Forum::RM::Search;
+package CPAN::Forum::RM::Tags;
 use strict;
 use warnings;
 
+sub tags {
+    my ($self) = @_;
+
+    my $t = $self->load_tmpl("tags.tmpl",
+        loop_context_vars => 1,
+        global_vars => 1,
+    );
+    my $tags = CPAN::Forum::DB::Tags->get_all_tags();
+    $t->param(tags => $tags);
+    return $t->output; 
+}
+
 1;
 
 

Modified: trunk/lib/CPAN/Forum/RM/Update.pm
===================================================================
--- trunk/lib/CPAN/Forum/RM/Update.pm	2007-07-03 21:02:47 UTC (rev 239)
+++ trunk/lib/CPAN/Forum/RM/Update.pm	2007-07-03 21:03:35 UTC (rev 240)
@@ -25,7 +25,7 @@
     $new_tags =~ s/^\s+//;
     $new_tags =~ s/\s+$//;
     $new_tags =~ s{<>/}{};
-    my @tags = split /,/, lc $new_tags;
+    my @tags = map {s/^\s+|\s+$//g; $_}  split /,/, lc $new_tags;
 
     my $uid = $self->session->param('uid');
 

Modified: trunk/lib/CPAN/Forum.pm
===================================================================
--- trunk/lib/CPAN/Forum.pm	2007-07-03 21:02:47 UTC (rev 239)
+++ trunk/lib/CPAN/Forum.pm	2007-07-03 21:03:35 UTC (rev 240)
@@ -554,6 +554,7 @@
 use base 'CPAN::Forum::RM::Notify';
 use base 'CPAN::Forum::RM::Search';
 use base 'CPAN::Forum::RM::Subscriptions';
+use base 'CPAN::Forum::RM::Tags';
 use base 'CPAN::Forum::RM::UserAccounts';
 use base 'CPAN::Forum::RM::Update';
 

Modified: trunk/templates/groups.tmpl
===================================================================
--- trunk/templates/groups.tmpl	2007-07-03 21:02:47 UTC (rev 239)
+++ trunk/templates/groups.tmpl	2007-07-03 21:03:35 UTC (rev 240)
@@ -14,12 +14,12 @@
 <TMPL_IF show_tags>
 <p>
 <TMPL_IF tags>
-My Tags: <TMPL_LOOP tags><a href="/tags/name/<TMPL_VAR name>"><TMPL_VAR name></a>, </TMPL_LOOP>
+My Tags: <TMPL_LOOP tags><a href="/tags/name/<TMPL_VAR name>"><TMPL_VAR name></a><TMPL_UNLESS __last__>, </TMPL_UNLESS></TMPL_LOOP>
 </TMPL_IF><br />
 <form method="post" action="/update/">
 <input type="hidden" name="what" value="tags" />
 <input type="hidden" name="group_id" value="<TMPL_VAR group_id>" />
-<input name="new_tags" value="<TMPL_LOOP tags><TMPL_VAR name>, </TMPL_LOOP>" />
+<input name="new_tags" value="<TMPL_LOOP tags><TMPL_VAR name><TMPL_UNLESS __last__>,</TMPL_UNLESS> </TMPL_LOOP>" />
 <input type="submit" value="Update tags" />
 </form>
 </p>

Modified: trunk/templates/navigation.tmpl
===================================================================
--- trunk/templates/navigation.tmpl	2007-07-03 21:02:47 UTC (rev 239)
+++ trunk/templates/navigation.tmpl	2007-07-03 21:03:35 UTC (rev 240)
@@ -17,6 +17,7 @@
         | <a href="/login/">login</a>
         | <a href="/register/">register</a>
     </TMPL_IF>
+    | <a href="/tags/">tags</a>
 ]
 </div>
 <div class="navigation">

Added: trunk/templates/tags.tmpl
===================================================================
--- trunk/templates/tags.tmpl	                        (rev 0)
+++ trunk/templates/tags.tmpl	2007-07-03 21:03:35 UTC (rev 240)
@@ -0,0 +1,12 @@
+<TMPL_INCLUDE NAME="head.tmpl">
+<p id="pageTitle"><b>Tags</b></p>
+<TMPL_INCLUDE NAME="navigation.tmpl">
+<TMPL_INCLUDE NAME="search_form.tmpl">
+<TMPL_INCLUDE NAME="links.tmpl">
+
+<TMPL_LOOP tags>
+<a href="/tags/name/<TMPL_VAR name>"><TMPL_VAR name></a>
+<TMPL_UNLESS __last__>, </TMPL_UNLESS>
+</TMPL_LOOP>
+
+<TMPL_INCLUDE NAME="footer.tmpl">



More information about the Cpan-forum-commit mailing list