Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: handle android.intent.action.WEB_SEARCH and open wikipedia links #3864

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

farfromrefug
Copy link

@farfromrefug farfromrefug commented Jun 5, 2024

Fixes #731

This PR adds 2 things:

  • supports for wikipedia search links to be opened. Different links are supported:
    • search links https://en.wikipedia.org/wiki/Special:Search?search=query
    • i added support for the common q query parameter and the wikipedia search query parameter
    • for now i only added links for wikipedia.com/.org/.fr/.de
  • support for android.intent.action.WEB_SEARCH which is the default web search intent. If an app triggers a web search then Kiwix can be used to handle the search. It is disabled by default and can be enabled in the settings

I also added a setting to automatically open supported external links within the app.
How does the project handles localization? i only added english localization.

When you make a search with openSearch, is it searched in all books?

I have a remaining question. If i have an url pointing to an existing page within a book like https://fr.wikipedia.org/wiki/Gi%C3%A8res is it possible to open it directly within a book? Right now it is always seen as a search so i kind of end up in a endless search loop

EDIT: i found a "basic" way of finding the correct book/zim for an url (https://fr.wikipedia.org/wiki/Gi%C3%A8res) but when i try to open that page within that book i get an webview error the page cannot be loaded. Are the URLs transformed in the zim? @kelson42 maybe you know?

Screenshots

@kelson42
Copy link
Collaborator

@farfromrefug Thank you for your PR. we are currently very focused on releasing 3.11.1. Once made we will review your PR. Thank younformOurnpatience.

@MohitMaliFtechiz
Copy link
Collaborator

@farfromrefug Thanks for your PR.

How does the project handles localization? i only added english localization.

We are handling the localization in the LanguageUtils class. You can change the application language from the settings screen.

When you make a search with openSearch, is it searched in all books?

If anyone tried to search any word with the kiwix from context menu with "Search kiwix" then openSearch method will be called. For now, it will search in the currently opened book.

1719577916015

I have a remaining question. If i have an url pointing to an existing page within a book like https://fr.wikipedia.org/wiki/Gi%C3%A8res is it possible to open it directly within a book? Right now it is always seen as a search so i kind of end up in a endless search loop

Currently, if someone uses the "Search kiwix" option then openSearch method will call to search the article for that searchTerm in current book. This behavior is implemented for this scenario. For the second question: yes you can directly search for any page if you have the URL that is pointing to a page, you can use the openArticle(articleUrl: String?) method of CoreReaderFragment it will open that page.

EDIT: i found a "basic" way of finding the correct book/zim for an url (https://fr.wikipedia.org/wiki/Gi%C3%A8res) but when i try to open that page within that book i get an webview error the page cannot be loaded. Are the URLs transformed in the zim?

Have you used the openArticle() method for opening the URL? This method asks the libkiwix to provide the actual article URL for the given URL and loads it into the webView. Since we need to decode the URL before passing it to the libkiwix all the things are already handled when we try to load the URL via this method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Open Wikipedia Links
3 participants