Commit 3f814e88 authored by Dupin's avatar Dupin
Browse files

Ajout recherche instance

parent 6f1aebf1
......@@ -9,6 +9,7 @@ STRINGS = {
'browse_instances': 30001,
'my_instances': 30002,
'my_channels': 30003,
'search_instances': 30004,
'add_to_my_instances': 30011,
'del_from_my_instances': 30012,
......@@ -33,6 +34,8 @@ def show_root_menu():
items = (
{'label': _('browse_instances'),
'path': plugin.url_for('show_list_of_instances')},
{'label': _('search_instances'),
'path': plugin.url_for('search_instances')},
{'label': _('my_instances'),
'path': plugin.url_for('show_my_instances')},
{'label': _('my_channels'),
......@@ -40,16 +43,25 @@ def show_root_menu():
)
return plugin.finish(items)
@plugin.route('/instances/')
def show_list_of_instances():
@plugin.route('/search/instances/<search>', name='search_instances_result')
@plugin.route('/instances')
def show_list_of_instances(search=None):
__init_request_args()
__init_pagine()
plugin.request.args['search'] = search
instances = peertube.load_list_of_instances(params=plugin.request.args)
items = __instance_item_list(instances['data'])
return __pagine(show_list_of_instances, items, instances['total'])
@plugin.route('/search/instances')
def search_instances():
search_string = plugin.keyboard(heading=_('search_instances'))
if search_string:
url = plugin.url_for('search_instances_result', search=search_string)
plugin.redirect(url)
@plugin.route('/instances/<host>/')
def show_instance(host):
items = [
......
......@@ -9,6 +9,7 @@
<string id="30001">Parcourir les instances</string>
<string id="30002">Mes instances</string>
<string id="30003">Mes chaines</string>
<string id="30004">Rechercher une instance</string>
<!-- Instance Context Menu -->
<string id="30011">Ajouter à mes instances</string>
......
......@@ -24,6 +24,7 @@ def __build_query_string(args):
return urllib.urlencode(args)
# params are: start, count, sort, search
def load_list_of_instances(params={}):
query_string = __build_query_string(params)
url = 'https://{host}/api/v1/instances?{query}'.format(host=INSTANCES_PROVIDER, query=query_string)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment