Skip to content

No jquery #796

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

Merged
merged 6 commits into from
Aug 1, 2022
Merged

No jquery #796

merged 6 commits into from
Aug 1, 2022

Conversation

juuz0
Copy link
Collaborator

@juuz0 juuz0 commented Jul 13, 2022

Fixes #610
Fixes #719
Fixes #369

Supersedes #639

@juuz0
Copy link
Collaborator Author

juuz0 commented Jul 13, 2022

Didn't push in previous PR to not ruin it with my experiments :P
Rebased on master
I haven't rebased it on #716 yet, as @mgautierfr told to do so. Will see that.

As a change to previous taskbar suggestions, I went with a hyperlink in suggestions, this gives us the ability to copy/open link address in new tab just how wikipedia does. If this is not needed, will pull back.
Fixed suggestions, submit button

@juuz0 juuz0 requested review from mgautierfr and kelson42 July 13, 2022 20:33
@kelson42
Copy link
Collaborator

kelson42 commented Jul 14, 2022

@juuz0 Please rebase and secure CI is OK. There a problem currently with the packages, but the rest should be green. In general, I'm not in favour of changing anything which is user visible, this ticket shiukd be purely technical.

@codecov
Copy link

codecov bot commented Jul 14, 2022

Codecov Report

Merging #796 (2bc8e49) into master (98bcf8a) will not change coverage.
The diff coverage is n/a.

❗ Current head 2bc8e49 differs from pull request most recent head baf22c2. Consider uploading reports for the commit baf22c2 to get more accurate results

@@           Coverage Diff           @@
##           master     #796   +/-   ##
=======================================
  Coverage   70.65%   70.65%           
=======================================
  Files          53       53           
  Lines        3708     3708           
  Branches     2061     2061           
=======================================
  Hits         2620     2620           
  Misses       1086     1086           
  Partials        2        2           
Impacted Files Coverage Δ
src/opds_dumper.cpp 99.13% <ø> (+0.86%) ⬆️
src/server/response.cpp 92.06% <0.00%> (-0.40%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 98bcf8a...baf22c2. Read the comment docs.

@kelson42
Copy link
Collaborator

@mgautierfr Can you please reivew this PR ?

@juuz0 juuz0 requested a review from mgautierfr July 19, 2022 15:57
@kelson42
Copy link
Collaborator

@juuz0 Can you please rebase?

@juuz0
Copy link
Collaborator Author

juuz0 commented Jul 20, 2022

@kelson42

Question:
For the codefactor thing, it shows it can autofix, should we try that?
image

@kelson42
Copy link
Collaborator

@juuz0 Honestly I prefer a manual fix.

@juuz0
Copy link
Collaborator Author

juuz0 commented Jul 20, 2022

@kelson42 done 👍

Copy link
Collaborator

@kelson42 kelson42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a user perspective, seems to work fine :)

@kelson42 kelson42 requested a review from veloman-yunkan July 21, 2022 07:26
@kelson42
Copy link
Collaborator

@veloman-yunkan Considering that @mgautierfr is away for a while, could you please review this PR?

Copy link
Collaborator

@veloman-yunkan veloman-yunkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I haven't reviewed this PR before, I would prefer to see its clean version (with fixup commits squashed). But I would also like to know the intended plan of dealing with the conflicting PR #716 - is this PR intended to be merged into master before #716 or it must be rebased on top of the latter?

@juuz0
Copy link
Collaborator Author

juuz0 commented Jul 22, 2022

But I would also like to know the intended plan of dealing with the conflicting PR #716 - is this PR intended to be merged into master before #716 or it must be rebased on top of the latter?

I believe it is intended to be rebased on top of it later (#639 (comment))

@kelson42
Copy link
Collaborator

kelson42 commented Jul 22, 2022

This PR is old and simple in comparison to the iframe one, I would like to merge it ASAP. I see no reason to make the other way around.

Copy link
Collaborator

@veloman-yunkan veloman-yunkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Selecting the suggestion using the keyboard (with arrow keys) and pressing ENTER runs a search for the text found in the searchbox instead of going to the suggested page.

Also I ran against an issue mostly unrelated to this PR but the previous version seemed to work fine under those circumstances. In my browser suggestions are not displayed nicely on the main page of the Ray Charles ZIM:

Screenshot from 2022-07-23 16-36-24

Also the styling of the taskbar slightly changes between the said page and other pages. Firefox reports the following warning in the console which probably explains the issue:

This page is in Quirks Mode. Page layout may be impacted. For Standards Mode use “”

Regarding the history of this PR - I would say that it is somewhat messy. The need for the new unit test in the context of this PR is not clear at all. Next, Jquery is removed first and the problems are then fixed. Such style of work can lead to problems if a bigger change is undertaken. A safer approach of dropping something is to first eliminate the dependency on it and only then removing it. So a better sequence would be:

  1. Migrate the suggestions UI to autocomplete.js
  2. Say thank you and good-bye to jquery.

Copy link
Collaborator

@veloman-yunkan veloman-yunkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've approached the final review. Please rebase-fixup and fix the history of the PR as follow:

  1. I don't think we need the first two commits (the new unit test and the .gitignore) in this PR.
  2. The commit titled "Update index.js to not use jquery anymore" should be taught good manners. Squeezing oneself between two logically related changes is impolite.
  3. Having a separate change for fixing codefactor warnings is not justified.

Copy link
Collaborator

@veloman-yunkan veloman-yunkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few final touches

let bookName = (window.location.pathname == `${root}/search`)
? (new URLSearchParams(window.location.search)).get('content')
: window.location.pathname.split(`${root}/`)[1].split('/')[0];
bookName = encodeURIComponent(htmlDecode(bookName));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you htmlDecode() the book name? Typically there will be no harm from it, but what if the ZIM file's name is &amp;.zim? You only must decode data that is known to be encoded. Does any code in libkiwix HTML-encode the book name that goes into the URL?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I shouldn't. I have also only url-encoded it in
const source = await fetch(${root}/suggest?content=${encodeURIComponent(bookName)}&term=${encodeURIComponent(query)});
now. If whole bookName was url encoded it caused problems with the zimfile&other.zim file.

juuz0 and others added 2 commits July 31, 2022 16:16
Added autoComplete.css and .js files.
Linked files in head_taskbar.html
This change only shows suggestions. Clicking them does nothing.
Copy link
Collaborator

@veloman-yunkan veloman-yunkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a PR with multiple commits and changes amounting to more than a couple dozen lines, please don't fix comments in place unless asked to do so. Fixup commits help the reviewer to quickly analyze all changes since the last review instead of trying to be more careful catching modifications in excess of what was requested.

@juuz0 juuz0 requested a review from veloman-yunkan July 31, 2022 13:34
Copy link
Collaborator

@veloman-yunkan veloman-yunkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Time to rebase, fixup and put the final cacheids!

juuz0 added 3 commits July 31, 2022 19:11
The suggestions are now clickable hyperlinks.
Completes the porting of remaining jQuery code in taskbar.js - scroll function, blur and focus events and the cybook hack.
Now after porting index.js and taskbar.js to vanilla JS, it is time to remove files.
Deleted static/skin/jquery-ui
Updated customIndexPage template in README.md.
Thank you for your service, jQuery :)
@juuz0
Copy link
Collaborator Author

juuz0 commented Jul 31, 2022

Done.
Now time for a doubt I had since forever,
what's the correct way to find cache IDs?
Currently, I compile, run the tests, let them fail. Go to testlog, find the correct cacheid -> replace. Is the only way?

@veloman-yunkan
Copy link
Collaborator

Now time for a doubt I had since forever, what's the correct way to find cache IDs? Currently, I compile, run the tests, let them fail. Go to testlog, find the correct cacheid -> replace. Is the only way?

That's how I do it too. The actual values of cacheids don't matter much. The important behaviour that is being checked is that whenever certain files change links to those resources get updated.

@veloman-yunkan
Copy link
Collaborator

From a user perspective, seems to work fine :)

@kelson42 Please validate the PR from user perspective once again before merging.

@kelson42
Copy link
Collaborator

@veloman-yunkan I will, glad to see ir ready. Thx a lot for all the review work.

@kelson42 kelson42 merged commit 4cd52b0 into master Aug 1, 2022
@kelson42 kelson42 deleted the noJquery branch August 1, 2022 13:15
@mgautierfr
Copy link
Member

Thanks to both of you to finish and cleanup this PR !

mgautierfr added a commit that referenced this pull request Nov 30, 2022
* [API Break] Remove wrapper around libzim (@mgautierfr #789)
* Allow kiwix-serve to use custom resource files (@veloman-yunkan #779)
* Properly handle searchProtocolPrefix when rendering search result (@veloman-yunkan #823)
* Prevent search on multi language content (@veloman-yunkan #838)
* Use new `zim::Archive::getMediaCount` from libzim (@mgautierfr #836)
* Catalog:
 - Include tags in free text catalog search (@veloman-yunkan #802)
 - Illustration's url is based on book's uuid (@veloman-yunkan #804)
 - Cleanup of the opds-dumper (@veloman-yunkan #829)
 - Allow filtering of catalog content using multiple languages (@veloman-yunkan #841)
 - Make opds-dumper respect the namemapper (@mgautierfr #837)
* Server:
 - Correctly handle `\` in suggestion json generation (@veloman-yunkan #843)
 - Better http caching (@veloman-yunkan #833)
 - Make `/suggest` endpoint thread-safe (@veloman-yunkan #834)
 - Better redirection of main page (@veloman-yunkan #827)
 - Remove jquery (@mgautierfr @juuz0 #796)
 - Better Viewer of zim content :
   . Introduce `/content` endpoints (@veloman-yunkan #806)
   . Switch to iframe based content viewer (@veloman-yunkan #716)
 - Optimised design of the welcome page:
   . Alignement (@juuz0 @kelson42 #786)
   . Exit download modal on pressing escape key (@Juzz0 #800)
   . Add favicon for different devices (@Juzz0 #805)
   . Fix auto hidding of the toolbar (@veloman-yunkan #821)
   . Allow user to filter books by tags in the front page (@juuz0 #711)
* CI :
  - Trigger CI on pull_request (@kelson42 #791)
  - Drop Ubuntu Impish packaging (@legoktm #825)
  - Add Ubuntu Kinetic packaging (@legoktm #801)
* Testing:
  - Test ICULanguageInfo (@veloman-yunkan #795)
  - Introduce fake `test` language to test i18n (@veloman-yunkan #848)
* Fix documentation (@kelson42 #816)
* Udpate translation (#787 #839 #847)
@mgautierfr mgautierfr mentioned this pull request Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants