Ticket #839 (closed Enhancement: fixed)

Opened 9 years ago

Last modified 9 years ago

Webclient: redesign search mode extension mechanism

Reported by: jri Owned by: jri
Priority: Major Milestone: Release 4.7
Component: DeepaMehta Standard Distribution Version: 4.6.1
Keywords: Cc: dgf, Malte
Complexity: 3 Area: Application Framework / API
Module: deepamehta-webclient


Providing a search mode implementation should be more easy for the plugin developer. The current approach based on events ("search", "searchmode_widget") doesn't represent the problem well.

Change History

comment:1 Changed 9 years ago by jri

  • Status changed from new to accepted

comment:2 Changed 9 years ago by Malte

My reply to the ticket scope:

Webclient: redesign search mode extension mechanism

From my personal experience, implementing a search mode js- and java-wise is already easy but provides some challenges for the user-interface design of the search-dialog.

Just my two cents for consideration in a potential revision of "Search"-modes.

  • All third party search modes plugged in i know of _extend_ and not replace the "By Text" search mode about, 1-3 optional settings. For example, Wikidata is an extra "Source" and needs additionally a specific "Language" and "Type" as parameters for a "By Text" search)
  • Consider also searching tracks on "SoundCloud?" or Albums on "Bandcamp", "By Text", etc.
  • Similarly one could imagine that a "By Type" search is used to search for types (in terms of "Classes", "Schemas" or other "well defined model structures") from other "Sources"

I think a revision of the search dialog would be the most helpful thing one can currently do when aiming at supporting third party developers. I am sorry that atm i can not provide a idea on how one could exactly successfully do so but just wanted to give my input on this because currently i can not see the problem as described above.

Cheers & all the best!

comment:3 Changed 9 years ago by jri

These are good points but out of the scope of this ticket.
Consider opening a separate ticket, e.g. "Redesign the search widget to include external data sources".

The scope of this ticket is just the long overdue refactoring of the searchmode API, no new functionality.

comment:4 Changed 9 years ago by Jörg Richter <jri@…>

In 921d03463989f4e17a393482fabd8629d4365e47/deepamehta:

Webclient: revise searchmode extension API (#839).

Providing a search mode implementation is slightly more convenient for the plugin developer. She must no longer handle events but implements all the searchmode in a concise constructor function. Furthermore she can rely on a higher-level API and must not interact with the toolbar DOM.


1 method dropped:


Use dm4c.toolbar.do_search() instead (see below).

2 client-side events dropped:


A searchmode implementation is added to the Webclient's toolbar by calling dm4c.toolbar.add_searchmode(). You pass 2 parameters: an URI to identify your searchmode and a constructor function which contains all aspectes a searchmode is made of, that is 1) the label to display in the searchmode menu, 2) the searchmode widget, and 3) the actual search operation.


dm4c.toolbar.add_searchmode(MY_SEARCHMODE_URI, function() {

    this.label = "My searchmode label"

    this.widget = function() {
        ... build my widget
        return my_searchmode_widget

    this.search = function() {
        ... doing my search
        return my_searchresult_topic

You see you're no longer required to interact with the toolbar DOM, e.g. adding your searchmode to the menu. And you must no longer register event listeners and check if the event is directed to your very searchmode.

You can place the add_searchmode() call directly into your plugin's constructor function.

To select a searchmode by default (when the Webclient starts) your plugin can use a "init[x]" handler and call:


Note: the dm4c.toolbar.select_searchmode() method exists like before but is no a high-level call. You must no longer care about manually choosing the searchmode from the searchmode menu.

Overview of the new searchmode API (5 methods)

Adds a searchmode to the searchmode menu

dm4c.toolbar.add_searchmode(searchmode_uri, constructor_func)

Selects a searchmode programmatically


Returns the URI of the selected searchmode


Triggers the current search programmatically


Enables/disables the toolbar's search button


For a detailed description see the API comments in:

For example implementations see the "By Text" and "By Type" searchmodes:

See #839.

Last edited 9 years ago by jri (previous) (diff)

comment:5 Changed 9 years ago by jri

  • Status changed from accepted to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.