fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-12-29 05:48 am

[dw-free] Include username in community search

[commit: http://hg.dwscoalition.org/dw-free/rev/9629699438a3]

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

If from a community, search results now say "[[community]] by [[user]]"
instead of "[[community]]"

Patch by [personal profile] fu.

Files modified:
  • htdocs/search.bml
  • htdocs/search.bml.text
--------------------------------------------------------------------------------
diff -r 0a44f7843dbc -r 9629699438a3 htdocs/search.bml
--- a/htdocs/search.bml	Thu Dec 29 12:37:04 2011 +0800
+++ b/htdocs/search.bml	Thu Dec 29 13:48:16 2011 +0800
@@ -164,6 +164,7 @@
     my $matches = '<br /><br />';
     foreach my $match ( @{ $result->{matches} } ) {
         my $mu = LJ::load_userid( $match->{journal_id} );
+        my $pu = LJ::load_userid( $match->{poster_id} ) if $mu->is_comm;
 
         # Do not show filtered icon for other users
         $match->{security} = 'access'
@@ -180,8 +181,11 @@
         $tags = "<br />Tags: $tags"
             if $tags;
 
-        my $mulj = $mu->ljuser_display;
-        my $html = qq(<div class='searchres'>$mulj: $icon <a href="$match->{url}">$match->{subject}</a><br />
+        my $attribution = $mu->is_comm
+                            ? BML::ml( '.attribution.comm', { journal => $mu->ljuser_display, poster => $pu->ljuser_display } )
+                            : BML::ml( '.attribution', { journal => $mu->ljuser_display } );
+
+        my $html = qq(<div class='searchres'>$attribution: $icon <a href="$match->{url}">$match->{subject}</a><br />
                       <span class='exc'>$match->{excerpt}</span>$tags<br />Posted: <strong>$match->{eventtime}</strong><br /><br />
                       </div>);
         $matches .= $html;
diff -r 0a44f7843dbc -r 9629699438a3 htdocs/search.bml.text
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htdocs/search.bml.text	Thu Dec 29 13:48:16 2011 +0800
@@ -0,0 +1,4 @@
+;; -*- coding: utf-8 -*-
+.attribution=[[journal]]
+
+.attribution.comm=[[journal]] by [[poster]]
--------------------------------------------------------------------------------