Quickly find contents in SENAITE by pressing Ctrl-Space
and start typing.
See the screencast how to use it: https://www.youtube.com/watch?v=AIA5atToc-c
The spotlight search calls an multi adapter to get the search results.
This adapter needs to implement the ISpotlightSearchAdapter
and adapts the
context and the request. It must be implemented that it returns a dictionary
containing the search results when calling it.
The results dictionary has to provide at least a list of items
, where each
item is a dictionary containing the following data:
{
"id": id,
"title": title,
"title_or_id": title or id,
"description": description,
"url": url,
"parent_title": parent_title,
"parent_url": parent_url,
"icon": icon,
}
A simple implementation looks like this:
dummy_item = {
"id": "test",
"title": "Test Item",
"title_or_id": "Test Item",
"description": "A search result item",
"url": "",
"parent_title": "",
"parent_url": "",
"icon": "",
}
@implementer(ISpotlightSearchAdapter)
class MySpotlightSearchAdapter(object):
"""Spotlight Search Adapter
"""
def __init__(self, context, request):
self.context = context
self.request = request
def __call__(self):
items = [dummy_item]
return {
"count": len(items),
"items": items,
}
And is registered like this:
<!-- A custom Spotlight Search Adapter -->
<adapter
for="*
.interfaces.IMyBrowserLayer"
factory=".adapters.MySpotlightSearchAdapter" />
Note that the custom adapter needs to be more specific than the default adapter. Therefore, adapting it either to your custom browser layer or to a specific content type interface.
The JavaScript code for senaite.app.spotlight
is built via
Webpack. To setup the development environment, go to
the root of this package install the required dependencies with yarn
:
$ yarn install
Note: You need to have node
installed.
The JavaScript code is located at src/senaite.app.spotlight/static/src
.
After this, you can start watching for changes in the code files:
$ yarn watch
When you are done, you can create a production build of the JavaScript with this command:
$ yarn build
SENAITE.APP.SPOTLIGHT Copyright (C) RIDING BYTES & NARALABS
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.