mirror of
https://github.com/searxng/searxng.git
synced 2024-11-22 04:01:40 +01:00
[enh] Add API Key support for discourse.org forums
This commit is contained in:
parent
dde94751d6
commit
b9ddd59c5b
@ -10,6 +10,8 @@ engine offers some additional settings:
|
|||||||
- :py:obj:`api_order`
|
- :py:obj:`api_order`
|
||||||
- :py:obj:`search_endpoint`
|
- :py:obj:`search_endpoint`
|
||||||
- :py:obj:`show_avatar`
|
- :py:obj:`show_avatar`
|
||||||
|
- :py:obj:`api_key`
|
||||||
|
- :py:obj:`api_username`
|
||||||
|
|
||||||
Example
|
Example
|
||||||
=======
|
=======
|
||||||
@ -27,6 +29,20 @@ for the ``paddling.com`` forum:
|
|||||||
categories: ['social media', 'sports']
|
categories: ['social media', 'sports']
|
||||||
show_avatar: true
|
show_avatar: true
|
||||||
|
|
||||||
|
If the forum is private, you need to add an API key and username for the search:
|
||||||
|
|
||||||
|
.. code:: yaml
|
||||||
|
|
||||||
|
- name: paddling
|
||||||
|
engine: discourse
|
||||||
|
shortcut: paddle
|
||||||
|
base_url: 'https://forums.paddling.com/'
|
||||||
|
api_order: views
|
||||||
|
categories: ['social media', 'sports']
|
||||||
|
show_avatar: true
|
||||||
|
api_key: '<KEY>'
|
||||||
|
api_username: 'system'
|
||||||
|
|
||||||
|
|
||||||
Implementations
|
Implementations
|
||||||
===============
|
===============
|
||||||
@ -65,6 +81,12 @@ api_order = 'likes'
|
|||||||
show_avatar = False
|
show_avatar = False
|
||||||
"""Show avatar of the user who send the post."""
|
"""Show avatar of the user who send the post."""
|
||||||
|
|
||||||
|
api_key = ''
|
||||||
|
"""API key of the Discourse forum."""
|
||||||
|
|
||||||
|
api_username = ''
|
||||||
|
"""API username of the Discourse forum."""
|
||||||
|
|
||||||
paging = True
|
paging = True
|
||||||
time_range_support = True
|
time_range_support = True
|
||||||
|
|
||||||
@ -98,6 +120,12 @@ def request(query, params):
|
|||||||
'X-Requested-With': 'XMLHttpRequest',
|
'X-Requested-With': 'XMLHttpRequest',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if api_key != '':
|
||||||
|
params['headers']['Api-Key'] = api_key
|
||||||
|
|
||||||
|
if api_username != '':
|
||||||
|
params['headers']['Api-Username'] = api_username
|
||||||
|
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user