Limit search realm when using quick search bar
|Reported by:||Owned by:|
I frequently find myself using the quick search bar at the top of the page to search for things in a particular realm (wiki, milestones, etc). My typical workflow looks like this:
- Type search terms in quick search bar, press enter
- Once the results page loads, untick the boxes for changesets, tickets, and milestones
- Click 'Search'
- Desired search page finally loads
Doing a realm-limited search actually requires two searches, which can take a long time on systems that have a lot of content or are behind a slow connection. It would be helpful if there was a way to limit a search to a specific realm from the quick search bar. This would reduce the above process to one step and reduce the number of page loads needed. It would also reduce the number of times the user has to switch between using the mouse and the keyboard, which is something that slows many users down (especially those of us stuck on laptops with trackpads).
You can do a realm-limited search like this by clicking the "Search" button on the top toolbar and using that search form instead of the quick search bar. This approach is sub-optimal because it still requires an unnecessary page load. It also doesn't handle some handy use cases like dragging and dropping text from a page into the quick search bar.
You can also do this by entering a complete Trac search string in the quick search bar (like
search:?q=search+terms&wiki=on). The syntax required for this method is too arcane for most users to use on a regular basis.
The quick search bar can be enhanced to recognize a specially-formatted realm name as the first argument, and then limit the results of the search to that realm. For example, something like this could be used to perform a quick search that only covers the wiki:
[wiki] search terms realm:wiki search terms wiki: search terms
I'm not sure what the best syntax for this sort of thing would be, but you get the idea. You could even extend this to support multiple or inverted selections, like:
# Limit search to wiki and commit messages realm:wiki,changesets search terms # Search everything *except* the wiki realm:-wiki search terms
Based on my limited understanding of the Trac code, it looks like this would require the
process_request method of
class SearchModule to update the local variable
filters when one of these realm-limiting tags is present and then delete that portion of the search string from