Make "did you mean" more Googley
authorAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 2 Jan 2009 02:17:27 +0000 (02:17 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 2 Jan 2009 02:17:27 +0000 (02:17 +0000)
It wasn't prominent enough; the red text and bolding should make it more
visible, and also more familiar (since I took the styling straight from
Google).  I also moved it up way to the top: it *needs* to be one of the first
things the user sees to be really useful.  This was particularly terrible on
enwiki, where the enormous bloated help message means you have to scroll down
through half a page of largely useless nonsense before even seeing the
suggestion.

RELEASE-NOTES
includes/specials/SpecialSearch.php
skins/common/shared.css

index e2204e1..77d3a8a 100644 (file)
@@ -256,6 +256,7 @@ The following extensions are migrated into MediaWiki 1.14:
 * (bug 16121) Add a note that a page move was without creating a redirect in the
   move log
 * Image moving is now enabled for sysops by default
+* Make "Did you mean" search feature more noticeable
 
 === Bug fixes in 1.14 ===
 
index 3dcf3b0..08d4f45 100644 (file)
@@ -930,6 +930,24 @@ class SpecialSearchOld {
                
                $this->setupPage( $term );
 
+               $rewritten = $search->replacePrefixes($term);
+               $titleMatches = $search->searchTitle( $rewritten );
+               $textMatches = $search->searchText( $rewritten );
+
+               // did you mean... suggestions
+               if($textMatches && $textMatches->hasSuggestion()){
+                       $st = SpecialPage::getTitleFor( 'Search' );                     
+                       $stParams = wfArrayToCGI( array( 
+                                       'search'        => $textMatches->getSuggestionQuery(), 
+                                       'fulltext'      => wfMsg('search')),
+                                       $this->powerSearchOptions());
+                                       
+                       $suggestLink = '<a href="'.$st->escapeLocalURL($stParams).'">'.
+                                       $textMatches->getSuggestionSnippet().'</a>';
+                                       
+                       $wgOut->addHTML('<div class="searchdidyoumean">'.wfMsg('search-suggest',$suggestLink).'</div>');
+               }
+
                $wgOut->addWikiMsg( 'searchresulttext' );
 
                if( '' === trim( $term ) ) {
@@ -967,9 +985,6 @@ class SpecialSearchOld {
                }
 
                $wgOut->addHTML( $this->shortDialog( $term ) );         
-               $rewritten = $search->replacePrefixes($term);
-
-               $titleMatches = $search->searchTitle( $rewritten );
 
                // Sometimes the search engine knows there are too many hits
                if ($titleMatches instanceof SearchResultTooMany) {
@@ -980,22 +995,6 @@ class SpecialSearchOld {
                        return;
                }
                
-               $textMatches = $search->searchText( $rewritten );
-
-               // did you mean... suggestions
-               if($textMatches && $textMatches->hasSuggestion()){
-                       $st = SpecialPage::getTitleFor( 'Search' );                     
-                       $stParams = wfArrayToCGI( array( 
-                                       'search'        => $textMatches->getSuggestionQuery(), 
-                                       'fulltext'      => wfMsg('search')),
-                                       $this->powerSearchOptions());
-                                       
-                       $suggestLink = '<a href="'.$st->escapeLocalURL($stParams).'">'.
-                                       $textMatches->getSuggestionSnippet().'</a>';
-                                       
-                       $wgOut->addHTML('<div class="searchdidyoumean">'.wfMsg('search-suggest',$suggestLink).'</div>');
-               }
-
                // show number of results
                $num = ( $titleMatches ? $titleMatches->numRows() : 0 )
                        + ( $textMatches ? $textMatches->numRows() : 0);
index 6be252d..bd30616 100644 (file)
@@ -142,8 +142,14 @@ span.searchalttitle {
 
 div.searchdidyoumean {
        font-size: 127%;
-       padding-bottom:1ex;
-       padding-top:1ex; 
+       margin-bottom: 1ex;
+       margin-top: 1ex;
+       /* Note that this color won't affect the link, as desired. */
+       color: #c00;
+}
+
+div.searchdidyoumean em {
+       font-weight: bold;
 }
 
 .searchmatch {