kiwix / kiwix-tools

Command line Kiwix tools: kiwix-serve, kiwix-manage, ...
https://download.kiwix.org/release/kiwix-tools/
GNU General Public License v3.0
435 stars 85 forks source link

Please extend "The requested URL was not found on this server." page with a search link #430

Closed JensKorte closed 3 years ago

JensKorte commented 3 years ago

If I enter a complete URL and the page doesn't exist, it would be nice if there would be a link for searching the whole zim file.

http://127.0.0.1:8888/wikipedia_en_all_maxi/A/Open Suse doesn't exist...

Not Found

The requested URL "/wikipedia_en_all_maxi/A/Open Suse" was not found on this server.

Do you want to search for "Open Suse" in this zim file?

Note beside: In Firefox and kiwix a space in the URL works, github uses it as a delimiter. I changed it to %20.

MananJethwani commented 3 years ago

@kelson42 should I work on this next?

kelson42 commented 3 years ago

@MananJethwani It seems @soumyankar is already on it.

@soumyankar It would be good you explain first (before doing a PR) what you plan to do to fix the problem because many things can be wrong: (1) The ZIM URL part, in that case we would like probably to search within the book and THIS WORKS ALREADY (2) The bookname part of the URL, in this case we would like probably to search within all ZIM THIS DOES NOT WORK

Here are example with the online Kiwix serve: (1) Bad ZIM URL part: https://library.kiwix.org/wikipedia_en_all_maxi/A/Open%20Suse (2) Bad Bookname: https://library.kiwix.org/foobar_en_all_maxi/A/Open%20Suse

Like you can see, the taskbar is always printed properly and we see the searchbox. Actually, I'm not sure why @JensKorte is requesting a link?! On the top of that, the only thing which seems to not work is the global/multi-zim suggestion... but this seems broken anyway and does not work on the welcome page either (but this is an other bug, but not sure if this is tracked yet).

On the top of this, what I remark is that the button in the middle (between home and random) in the taskbar is always broken and that should be fixed!

@JensKorte @MananJethwani @soumyankar To me this ticket needs to be refine first, what do you think?

MananJethwani commented 3 years ago

@kelson42 I had a similar doubt regarding this issue what if instead of an article someone is trying to directly open an image and image is not found same page is loaded in that case what should be done in that case? for example https://library.kiwix.org/wikipedia_en_all_maxi/I/foobar.png

JensKorte commented 3 years ago

I didn't think of "(2) Bad Bookname" and I didn't have a global view on the projekt, that (1) and (2) generate the same error page. I didn't think of images either. Maybe this has to be splitted. I thought, the /wikipedia_en_all_maxi/ redirects all request to that ZIM file, though a ZIM doesn't have code in it.

crazy idea: Would it be possible to do a first regex search like /wikipedia_en_all_maxi[year_month]/ belongs to ZIM file XY and in the ZIM file there is a list with regex -> html pages, e.g. (first match wins):

JensKorte commented 3 years ago

Actually, I'm not sure why @JensKorte is requesting a link?!

@kelson42 On a mobile phone tapping a link is easier then writing. I wouldn't start a search as soon as a file is not found, the user should decide, if he wants to start a search. I just realize, the search is a bigger project and not just a rewriting of a html file. Maybe this issue should be closed and reopened if it is of use.

soumyankar commented 3 years ago

Like you can see, the taskbar is always printed properly and we see the searchbox. Actually, I'm not sure why @JensKorte is requesting a link?!

@kelson42 I feel like the link is a good idea because it increases accessibility; Always better to click a link(that's right in front) than type.

@soumyankar It would be good you explain first (before doing a PR) what you plan to do to fix the problem because many things can be wrong.

I'll do that from the next time onwards. Keeping the issue in mind, I think we could grab the name of the book from the URL and figure out if such a book does exist in the library and then show "Do you want to search for the page in this zim file?" Otherwise just prompt that the book name is wrong and show suggestions(if that exists) for the bad book name.

JensKorte commented 3 years ago

I think we could grab the name of the book from the URL and figure out if such a book does exist in the library and then show "Do you want to search for the page in this zim file?"

If it is no extra work, maybe you can support "-z, --nodatealiases create URL aliases for each content by removing the date" and use the alias if it was used before.

Otherwise just prompt that the book name is wrong and show suggestions(if that exists) for the bad book name.

The easiest suggestion would be: "Do you want to see the start page with all available ZIM files?"

soumyankar commented 3 years ago

(2) The bookname part of the URL, in this case we would like probably to search within all ZIM THIS DOES NOT WORK

@kelson42 Could you help me out with this part? I am confused about how to check if the book name does exist in the library or not.

kelson42 commented 3 years ago

I have open the following tickets:

So we can focus this ticket on its original purpose which is to extend the current message:

Not Found

The requested URL "/First_test/A/index.htdml" was not found on this server.

To something like

Not Found

The requested URL "/First_test/A/index.htdml" was not found on this server.

Make a full text search for "Open Suse".

@soumyankar @JensKorte I have rephrased the sentence as I don't really like the interrogative form and the fact that we talk about the ZIM file (most people don't care about this format details). If the bookname is valid is search in the zim, otherwise a multizim search.

JensKorte commented 3 years ago

@JensKorte I have rephrased the sentence as I don't really like the interrogative form and the fact that we talk about the ZIM file (most people don't care about this format details). If the bookname is valid is search in the zim, otherwise a multizim search.

@kelson42 That's OK to me.

soumyankar commented 3 years ago

If the bookname is valid is search in the zim, otherwise a multizim search.

@kelson42 Got it, I'll keep that in mind. I just want someone to review my code and I'll get working!