kareila: (Default)
kareila ([personal profile] kareila) wrote in [site community profile] changelog2009-07-23 02:07 pm

[dw-free] Handle OpenID results in directory search

[commit: http://hg.dwscoalition.org/dw-free/rev/20fcd6a3bb50]

http://bugs.dwscoalition.org/show_bug.cgi?id=1108

Allow directory search results to be filtered for matching OpenID users.

Patch by [personal profile] kareila.

Files modified:
  • htdocs/directory.bml
  • htdocs/directory.bml.text
--------------------------------------------------------------------------------
diff -r 99c48a83486a -r 20fcd6a3bb50 htdocs/directory.bml
--- a/htdocs/directory.bml	Wed Jul 22 12:31:14 2009 -0500
+++ b/htdocs/directory.bml	Thu Jul 23 09:06:54 2009 -0500
@@ -194,45 +194,34 @@ body<=
     };
 
 
-    my ($uri, $args) = (BML::get_uri(), BML::get_query_string());
-    my $filter_url;
+    my ( $uri, $args ) = ( BML::get_uri(), BML::get_query_string() );
 
     $args =~ s/(\?|\&)page=\d*//gi;
-    $args =~ s/(\?|\&)journaltype=(C|P)?//gi;
+    $args =~ s/(\?|\&)journaltype=[CPI]?//gi;
     $args =~ s/(\?|\&)start_search=\d*//gi;
     $uri .= '?' . $args if $args;
 
+    my $filter_url = LJ::ehtml( $LJ::SITEROOT . $uri );
+    $filter_url .= ($args ? "&" : "?") . 'start_search=1';
+
     my $all_search = "$ML{'.new_all_search'}";
+    $all_search = "<a href='$filter_url'>$all_search</a>"
+        if uc( $GET{journaltype} ) =~ /^[CPI]$/;
+
     my $community_search = "$ML{'.new_community_search'}";
+    $community_search = "<a href='$filter_url&journaltype=C'>$community_search</a>"
+        unless uc( $GET{journaltype} ) eq 'C';
+
     my $user_search = "$ML{'.new_user_search'}";
+    $user_search = "<a href='$filter_url&journaltype=P'>$user_search</a>"
+        unless uc( $GET{journaltype} ) eq 'P';
 
-    # All search
-    if ('C' eq uc($GET{journaltype}) || 'P' eq uc($GET{journaltype}))
-    {
-        $filter_url = LJ::ehtml($LJ::SITEROOT . $uri);
-        $filter_url .= ($args ? "&" : "?") . 'start_search=1';
-        $all_search = "<a href='$filter_url'>$all_search</a>";
-    }
+    my $identity_search = "$ML{ '.new_identity_search' }";
+    $identity_search = "<a href='$filter_url&journaltype=I'>$identity_search</a>"
+        unless uc( $GET{journaltype} ) eq 'I';
 
-    # Community search
-    if ('C' ne uc($GET{journaltype}))
-    {
-        $filter_url = LJ::ehtml($LJ::SITEROOT . $uri);
-        $filter_url .= ($args ? "&" : "?") . 'journaltype=C&start_search=1';
-        $community_search = "<a href='$filter_url'>$community_search</a>";
-    }
-
-    # Users search
-    if ('P' ne uc($GET{journaltype}))
-    {
-        $filter_url = LJ::ehtml($LJ::SITEROOT . $uri);
-        $filter_url .= ($args ? "&" : "?") . 'journaltype=P&start_search=1';
-        $user_search = "<a href='$filter_url'>$user_search</a>";
-    }
-
-    $ret .= qq {
-        <div id="FilterSearch">$ML{'.new_search_show'}&nbsp;$all_search&nbsp;|&nbsp;$community_search&nbsp;|&nbsp;$user_search</div>
-    };
+    $ret .= qq {\n<div id="FilterSearch">$ML{'.new_search_show'}&nbsp;$all_search&nbsp;|&nbsp;};
+    $ret .= qq {$community_search&nbsp;|&nbsp;$user_search&nbsp;|&nbsp;$identity_search</div>\n};
 
     if (LJ::run_hook("interest_search_ignore", query => $GET{int_like})) {
         $ret .= $ML{'.unable_find_users'};
diff -r 99c48a83486a -r 20fcd6a3bb50 htdocs/directory.bml.text
--- a/htdocs/directory.bml.text	Wed Jul 22 12:31:14 2009 -0500
+++ b/htdocs/directory.bml.text	Thu Jul 23 09:06:54 2009 -0500
@@ -29,6 +29,8 @@ directory usage, be sure that you are lo
 
 .new_community_search=Communities Only
 
+.new_identity_search=OpenIDs Only
+
 .new_user_search=Users Only
 
 .no_results=No Results Found!
--------------------------------------------------------------------------------