summaryrefslogtreecommitdiffstats
path: root/module/api
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-05 23:21:44 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-05 23:21:44 +0100
commit9b12691ad66269ca8b67e80516548e8ae10bd7b2 (patch)
tree6df55bd94d02b216cb2ec51899f0d0e78899d3e2 /module/api
parentfixed position of autocompletion, updated libraries (diff)
downloadpyload-9b12691ad66269ca8b67e80516548e8ae10bd7b2.tar.xz
working search suggestions
Diffstat (limited to 'module/api')
-rw-r--r--module/api/ApiComponent.py1
-rw-r--r--module/api/FileApi.py12
2 files changed, 8 insertions, 5 deletions
diff --git a/module/api/ApiComponent.py b/module/api/ApiComponent.py
index fadcf98da..c3b8c974b 100644
--- a/module/api/ApiComponent.py
+++ b/module/api/ApiComponent.py
@@ -18,5 +18,6 @@ class ApiComponent(Iface):
self.core = core
assert isinstance(user, User)
self.user = user
+ self.userHandle = 0
# No instantiating!
raise Exception() \ No newline at end of file
diff --git a/module/api/FileApi.py b/module/api/FileApi.py
index fa9d728cb..8f09f3cb7 100644
--- a/module/api/FileApi.py
+++ b/module/api/FileApi.py
@@ -2,9 +2,11 @@
# -*- coding: utf-8 -*-
from module.Api import Api, RequirePerm, Permission, DownloadState, PackageDoesNotExists, FileDoesNotExists
+from module.utils import uniqify
from ApiComponent import ApiComponent
+# TODO: user context
class FileApi(ApiComponent):
"""Everything related to available packages or files. Deleting, Modifying and so on."""
@@ -74,13 +76,13 @@ class FileApi(ApiComponent):
@RequirePerm(Permission.All)
def findFiles(self, pattern):
- pass
+ return self.core.files.getTree(-1, True, DownloadState.All, pattern)
@RequirePerm(Permission.All)
- def getAutocompletion(self, pattern):
- # TODO
-
- return ["static", "autocompletion", "demo"]
+ def searchSuggestions(self, pattern):
+ names = self.core.db.getMatchingFilenames(pattern, self.userHandle)
+ # TODO: stemming and reducing the names to provide better suggestions
+ return uniqify(names)
@RequirePerm(Permission.All)
def findPackages(self, tags):