Page MenuHomePhabricator

Suggestions in search for Wikipedia Mobile
Closed, ResolvedPublic

Description

Author: malrase

Description:
Is it possible to have a "suggested searches" thing for the search box? I.e. typing "Fra-" gives "France" as one of the first ones, or something.


Version: unspecified
Severity: enhancement

Details

Reference
bz19956

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:39 PM
bzimport set Reference to bz19956.
bzimport added a subscriber: Unknown Object (MLST).

I'm guessing you'll have to wait quite a while more on this one.

  • Bug 29559 has been marked as a duplicate of this bug. ***

admin wrote:

The source code for a working example

This is a problem made easy by Wikipedia's existing API. I have a working example (modified after mobile.wikipedia.org) at http://rossbender.com/temp/testwiki/ - try it on your mobile phone! See also my personal site's example (a stripped down version): http://rossbender.com/random/wikipedia/

The changes attached are minimal to the already existing page at mobile.wikipedia.org. I'm using that as comparison instead of en.m.wikipedia.org for simplicity's sake only--the changes would be similar there. If you compare the HTML source from mobile.wikipedia.org with the source attached that you will see I have only added 4 lines in the <head> (meta tag for mobile compatibility, 1 link to an external stylesheet, and 2 links to external Javascript files) and 1 line in the <body> (results div).

(Note that the wikiapi.php file is only necessary on my server because I cannot do cross-domain XML requests in Javascript. So the wikiapi.php file simply returns the results of the Wikipedia API results.)

I personally prefer the results being displayed as part of the page, but adding the same effect to a dropdown box is not difficult using http://jqueryui.com/demos/autocomplete/. For my own personal site I had actually started with that but preferred to opt for the more simplistic version.

I would be happy to help out with this where necessary. Autocomplete for search engines nowadays is basically a must (read more on my thoughts here: http://rossbender.com/2011/09/25/mobile-wikipedia-search/).

Let me know if there's anything more I can do to help. Thanks!

Attached:

preilly wrote:

Ross great work!

How hard do you think it would be to remove the dependency on jQuery?

admin wrote:

I updated the page at http://www.rossbender.com/temp/testwiki/ to be jQuery independent (see the JavaScript file at http://www.rossbender.com/temp/testwiki/main.js compared to the old one: http://www.rossbender.com/temp/testwiki/mainJquery.js ).

I removed a few "nice-ities" such as the window automatically scrolling to the top as well as the colored background on a touch event. They wouldn't be super difficult to add back in but I figured those would be more of a site-wide design rather than through the plugin.

This feature will be launching shortly. Ideally this week.

Feature has been out in production for a bit.