diff --git a/bauh/gems/web/controller.py b/bauh/gems/web/controller.py index 18b6d202..8efb1d99 100644 --- a/bauh/gems/web/controller.py +++ b/bauh/gems/web/controller.py @@ -62,44 +62,46 @@ class WebApplicationManager(SoftwareManager): def search(self, words: str, disk_loader: DiskCacheLoader, limit: int = -1, is_url: bool = False) -> SearchResult: res = SearchResult([], [], 0) + installed = self.read_installed(disk_loader=disk_loader, limit=limit).installed + 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 - - 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] + installed_matches = [app for app in installed if RE_PROTOCOL_STRIP.split(app.url)[1].strip().lower() == url_no_protocol] if 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: - soup = BeautifulSoup(url_res.text, 'lxml', parse_only=SoupStrainer('head')) + name_tag = soup.head.find('meta', attrs={'name': 'application-name'}) + name = name_tag.get('content') if name_tag else words.split('.')[0].split('://')[1] - name_tag = soup.head.find('meta', attrs={'name': 'application-name'}) - name = name_tag.get('content') if name_tag else words.split('.')[0].split('://')[1] + desc_tag = soup.head.find('meta', attrs={'name': 'description'}) + desc = desc_tag.get('content') if desc_tag else words - desc_tag = soup.head.find('meta', attrs={'name': 'description'}) - desc = desc_tag.get('content') if desc_tag else words + icon_tag = soup.head.find('link', attrs={"rel": "icon"}) + icon_url = icon_tag.get('href') if icon_tag else None - icon_tag = soup.head.find('link', attrs={"rel": "icon"}) - icon_url = icon_tag.get('href') if icon_tag else None + app = WebApplication(url=words, name=name, description=desc, icon_url=icon_url) - 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'): - app.version = self.env_settings['electron']['version'] - app.latest_version = app.version - - res.new = [app] - res.total = 1 + res.new = [app] else: - # TODO - pass + lower_words = words.lower().strip() + 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 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: diff --git a/bauh/gems/web/resources/locale/en b/bauh/gems/web/resources/locale/en index 280e2984..0c0bebbf 100644 --- a/bauh/gems/web/resources/locale/en +++ b/bauh/gems/web/resources/locale/en @@ -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.tip=If the app should always be opened maximized 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.tip=If the app should not have a frame around it ( like browsers have ) web.install.option.nocache.label=No cache diff --git a/bauh/gems/web/resources/locale/pt b/bauh/gems/web/resources/locale/pt index a357dd4a..4214dcc3 100644 --- a/bauh/gems/web/resources/locale/pt +++ b/bauh/gems/web/resources/locale/pt @@ -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.tip=Se o aplicativo deve sempre ser aberto maximizado 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.tip=Se o aplicativo não deve ter uma moldura em volta ( como os navegadores têm ) web.install.option.nocache.label=Sem cache