mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-10 06:34:15 +02:00
[wgem] fix search matches and allow matches per name
This commit is contained in:
@@ -62,44 +62,46 @@ class WebApplicationManager(SoftwareManager):
|
|||||||
def search(self, words: str, disk_loader: DiskCacheLoader, limit: int = -1, is_url: bool = False) -> SearchResult:
|
def search(self, words: str, disk_loader: DiskCacheLoader, limit: int = -1, is_url: bool = False) -> SearchResult:
|
||||||
res = SearchResult([], [], 0)
|
res = SearchResult([], [], 0)
|
||||||
|
|
||||||
|
installed = self.read_installed(disk_loader=disk_loader, limit=limit).installed
|
||||||
|
|
||||||
if is_url:
|
if is_url:
|
||||||
|
url_no_protocol = RE_PROTOCOL_STRIP.split(words)[1].strip().lower()
|
||||||
|
|
||||||
installed = self.read_installed(disk_loader=disk_loader, limit=limit).installed
|
installed_matches = [app for app in installed if RE_PROTOCOL_STRIP.split(app.url)[1].strip().lower() == url_no_protocol]
|
||||||
|
|
||||||
url_no_protocol = RE_PROTOCOL_STRIP.split(words)[0].strip().lower()
|
|
||||||
|
|
||||||
installed_matches = [app for app in installed if RE_PROTOCOL_STRIP.split(app.url)[0].lower() == url_no_protocol]
|
|
||||||
|
|
||||||
if installed_matches:
|
if installed_matches:
|
||||||
res.installed.extend(installed_matches)
|
res.installed.extend(installed_matches)
|
||||||
return res
|
else:
|
||||||
|
url_res = self.http_client.get(words, headers={'Accept-language': self._get_lang_header()})
|
||||||
|
|
||||||
url_res = self.http_client.get(words, headers={'Accept-language': self._get_lang_header()})
|
if url_res:
|
||||||
|
soup = BeautifulSoup(url_res.text, 'lxml', parse_only=SoupStrainer('head'))
|
||||||
|
|
||||||
if url_res:
|
name_tag = soup.head.find('meta', attrs={'name': 'application-name'})
|
||||||
soup = BeautifulSoup(url_res.text, 'lxml', parse_only=SoupStrainer('head'))
|
name = name_tag.get('content') if name_tag else words.split('.')[0].split('://')[1]
|
||||||
|
|
||||||
name_tag = soup.head.find('meta', attrs={'name': 'application-name'})
|
desc_tag = soup.head.find('meta', attrs={'name': 'description'})
|
||||||
name = name_tag.get('content') if name_tag else words.split('.')[0].split('://')[1]
|
desc = desc_tag.get('content') if desc_tag else words
|
||||||
|
|
||||||
desc_tag = soup.head.find('meta', attrs={'name': 'description'})
|
icon_tag = soup.head.find('link', attrs={"rel": "icon"})
|
||||||
desc = desc_tag.get('content') if desc_tag else words
|
icon_url = icon_tag.get('href') if icon_tag else None
|
||||||
|
|
||||||
icon_tag = soup.head.find('link', attrs={"rel": "icon"})
|
app = WebApplication(url=words, name=name, description=desc, icon_url=icon_url)
|
||||||
icon_url = icon_tag.get('href') if icon_tag else None
|
|
||||||
|
|
||||||
app = WebApplication(url=words, name=name, description=desc, icon_url=icon_url)
|
if self.env_settings.get('electron') and self.env_settings['electron'].get('version'):
|
||||||
|
app.version = self.env_settings['electron']['version']
|
||||||
|
app.latest_version = app.version
|
||||||
|
|
||||||
if self.env_settings.get('electron') and self.env_settings['electron'].get('version'):
|
res.new = [app]
|
||||||
app.version = self.env_settings['electron']['version']
|
|
||||||
app.latest_version = app.version
|
|
||||||
|
|
||||||
res.new = [app]
|
|
||||||
res.total = 1
|
|
||||||
else:
|
else:
|
||||||
# TODO
|
lower_words = words.lower().strip()
|
||||||
pass
|
installed_matches = [app for app in installed if lower_words in app.name.lower()]
|
||||||
|
|
||||||
|
if installed_matches:
|
||||||
|
res.installed.extend(installed_matches)
|
||||||
|
|
||||||
|
res.total += len(res.installed)
|
||||||
|
res.total += len(res.new)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def read_installed(self, disk_loader: DiskCacheLoader, limit: int = -1, only_apps: bool = False, pkg_types: Set[Type[SoftwarePackage]] = None, internet_available: bool = True) -> SearchResult:
|
def read_installed(self, disk_loader: DiskCacheLoader, limit: int = -1, only_apps: bool = False, pkg_types: Set[Type[SoftwarePackage]] = None, internet_available: bool = True) -> SearchResult:
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ web.install.option.single.tip=It will not allow the app to be opened again if it
|
|||||||
web.install.option.max.label=Open maximized
|
web.install.option.max.label=Open maximized
|
||||||
web.install.option.max.tip=If the app should always be opened maximized
|
web.install.option.max.tip=If the app should always be opened maximized
|
||||||
web.install.option.fullscreen.label=Open in fullscreen
|
web.install.option.fullscreen.label=Open in fullscreen
|
||||||
web.install.option.fullscreen.tip=If the app should always be opened in fullscreen
|
web.install.option.fullscreen.tip=If the app should always be opened in fullscreen ( the Alt key opens the upper menu )
|
||||||
web.install.option.noframe.label=No frame
|
web.install.option.noframe.label=No frame
|
||||||
web.install.option.noframe.tip=If the app should not have a frame around it ( like browsers have )
|
web.install.option.noframe.tip=If the app should not have a frame around it ( like browsers have )
|
||||||
web.install.option.nocache.label=No cache
|
web.install.option.nocache.label=No cache
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ web.install.option.single.tip=Não permitirá que o aplicativo seja aberto novam
|
|||||||
web.install.option.max.label=Abrir maximizado
|
web.install.option.max.label=Abrir maximizado
|
||||||
web.install.option.max.tip=Se o aplicativo deve sempre ser aberto maximizado
|
web.install.option.max.tip=Se o aplicativo deve sempre ser aberto maximizado
|
||||||
web.install.option.fullscreen.label=Abrir em tela cheia
|
web.install.option.fullscreen.label=Abrir em tela cheia
|
||||||
web.install.option.fullscreen.tip=Se o aplicativo sempre deve ser aberto em tela cheia
|
web.install.option.fullscreen.tip=Se o aplicativo sempre deve ser aberto em tela cheia ( a tecla Alt abre o menu superior )
|
||||||
web.install.option.noframe.label=Sem moldura
|
web.install.option.noframe.label=Sem moldura
|
||||||
web.install.option.noframe.tip=Se o aplicativo não deve ter uma moldura em volta ( como os navegadores têm )
|
web.install.option.noframe.tip=Se o aplicativo não deve ter uma moldura em volta ( como os navegadores têm )
|
||||||
web.install.option.nocache.label=Sem cache
|
web.install.option.nocache.label=Sem cache
|
||||||
|
|||||||
Reference in New Issue
Block a user