r45305 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45304‎ | r45305 | r45306 >
Date:02:17, 2 January 2009
Author:simetrical
Status:ok
Tags:
Comment:
Make "did you mean" more Googley

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.
Modified paths:
  • /trunk/extensions/MWSearch/MWSearch_body.php (modified) (history)
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/specials/SpecialSearch.php (modified) (history)
  • /trunk/phase3/skins/common/shared.css (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/shared.css
@@ -142,10 +142,16 @@
143143
144144 div.searchdidyoumean {
145145 font-size: 127%;
146 - padding-bottom:1ex;
147 - padding-top:1ex;
 146+ margin-bottom: 1ex;
 147+ margin-top: 1ex;
 148+ /* Note that this color won't affect the link, as desired. */
 149+ color: #c00;
148150 }
149151
 152+div.searchdidyoumean em {
 153+ font-weight: bold;
 154+}
 155+
150156 .searchmatch {
151157 font-weight: bold;
152158 }
Index: trunk/phase3/includes/specials/SpecialSearch.php
@@ -930,6 +930,24 @@
931931
932932 $this->setupPage( $term );
933933
 934+ $rewritten = $search->replacePrefixes($term);
 935+ $titleMatches = $search->searchTitle( $rewritten );
 936+ $textMatches = $search->searchText( $rewritten );
 937+
 938+ // did you mean... suggestions
 939+ if($textMatches && $textMatches->hasSuggestion()){
 940+ $st = SpecialPage::getTitleFor( 'Search' );
 941+ $stParams = wfArrayToCGI( array(
 942+ 'search' => $textMatches->getSuggestionQuery(),
 943+ 'fulltext' => wfMsg('search')),
 944+ $this->powerSearchOptions());
 945+
 946+ $suggestLink = '<a href="'.$st->escapeLocalURL($stParams).'">'.
 947+ $textMatches->getSuggestionSnippet().'</a>';
 948+
 949+ $wgOut->addHTML('<div class="searchdidyoumean">'.wfMsg('search-suggest',$suggestLink).'</div>');
 950+ }
 951+
934952 $wgOut->addWikiMsg( 'searchresulttext' );
935953
936954 if( '' === trim( $term ) ) {
@@ -967,10 +985,7 @@
968986 }
969987
970988 $wgOut->addHTML( $this->shortDialog( $term ) );
971 - $rewritten = $search->replacePrefixes($term);
972989
973 - $titleMatches = $search->searchTitle( $rewritten );
974 -
975990 // Sometimes the search engine knows there are too many hits
976991 if ($titleMatches instanceof SearchResultTooMany) {
977992 $wgOut->addWikiText( '==' . wfMsg( 'toomanymatches' ) . "==\n" );
@@ -980,22 +995,6 @@
981996 return;
982997 }
983998
984 - $textMatches = $search->searchText( $rewritten );
985 -
986 - // did you mean... suggestions
987 - if($textMatches && $textMatches->hasSuggestion()){
988 - $st = SpecialPage::getTitleFor( 'Search' );
989 - $stParams = wfArrayToCGI( array(
990 - 'search' => $textMatches->getSuggestionQuery(),
991 - 'fulltext' => wfMsg('search')),
992 - $this->powerSearchOptions());
993 -
994 - $suggestLink = '<a href="'.$st->escapeLocalURL($stParams).'">'.
995 - $textMatches->getSuggestionSnippet().'</a>';
996 -
997 - $wgOut->addHTML('<div class="searchdidyoumean">'.wfMsg('search-suggest',$suggestLink).'</div>');
998 - }
999 -
1000999 // show number of results
10011000 $num = ( $titleMatches ? $titleMatches->numRows() : 0 )
10021001 + ( $textMatches ? $textMatches->numRows() : 0);
Index: trunk/phase3/RELEASE-NOTES
@@ -256,6 +256,7 @@
257257 * (bug 16121) Add a note that a page move was without creating a redirect in the
258258 move log
259259 * Image moving is now enabled for sysops by default
 260+* Make "Did you mean" search feature more noticeable
260261
261262 === Bug fixes in 1.14 ===
262263
Index: trunk/extensions/MWSearch/MWSearch_body.php
@@ -599,7 +599,7 @@
600600 $suggestText = "";
601601 for($i=1;$i<count($points);$i+=2){
602602 $suggestText .= substr($sug,$points[$i-1],$points[$i]-$points[$i-1]);
603 - $suggestText .= "<i>".substr($sug,$points[$i],$points[$i+1]-$points[$i])."</i>";
 603+ $suggestText .= '<em>'.substr($sug,$points[$i],$points[$i+1]-$points[$i])."</em>";
604604 }
605605 $suggestText .= substr($sug,end($points));
606606

Follow-up revisions

RevisionCommit summaryAuthorDate
r45502Make sure that "did you mean" displays at the top...simetrical14:22, 7 January 2009

Status & tagging log