combo/combo/apps/search
Lauréline Guérin 69d97b1c08
gitea-wip/combo/pipeline/head Build started... Details
gitea/combo/pipeline/head Build started... Details
search: fix view when indexed cell has no page (#51251)
2021-02-18 14:14:51 +01:00
..
migrations trivial: apply black 2021-02-15 18:02:39 +01:00
templates/combo search: cards engine without current user (#48261) 2020-11-20 11:01:48 +01:00
README search: add possibility to specify templates for hits (#25614) 2018-08-31 16:01:16 +02:00
__init__.py trivial: apply black 2021-02-15 18:02:39 +01:00
engines.py trivial: apply black 2021-02-15 18:02:39 +01:00
forms.py trivial: apply black 2021-02-15 18:02:39 +01:00
manager_views.py trivial: apply black 2021-02-15 18:02:39 +01:00
models.py trivial: apply black 2021-02-15 18:02:39 +01:00
urls.py trivial: apply black 2021-02-15 18:02:39 +01:00
utils.py search: fix view when indexed cell has no page (#51251) 2021-02-18 14:14:51 +01:00

README

Configure search services in settings.COMBO_SEARCH_SERVICES:

  COMBO_SEARCH_SERVICES = {
      'user': {
          'label': 'Search a user',
          'url': 'https://.../api/user/?q=%(q)s',
          # 'cache_duration': 60,  # in seconds, default is 0
          # 'signature': True,     # boolean, default is False
      },
  }

'url' must return a JSON:

  {
    "err": 0,
    "data": [
      {
        'url': 'https://example.net/page3/',
        'text': 'example, page3',
        'description': 'this can be <b>html</b> text'
      },
      { ... }, ...
    ]
    ...
  }

which is sent to template 'combo/search-cell-results.html'

If the cell slug is "foo" and a variable named "foo" exists in the
query_string, it is added to the global page context, so it can be
used, for example, by a JsonCell.


It is also possible to extend the search service definition with custom
templates for hit URLs and labels:

  COMBO_SEARCH_SERVICES = {
      'user': {
          'label': 'Search a user',
          'url': 'https://.../api/user/?q=%(q)s',
          'hit_url_template': '/fiche-usager/{{user_name_identifier_0}}/',
          'hit_label_template': '{{first_name}} {{last_name}}',
      },
  }