-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Conversation
Didn't push in previous PR to not ruin it with my experiments :P 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. |
@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 Report
@@ 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
Continue to review full report at Codecov.
|
@mgautierfr Can you please reivew this PR ? |
@juuz0 Can you please rebase? |
@juuz0 Honestly I prefer a manual fix. |
@kelson42 done 👍 |
There was a problem hiding this 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 :)
@veloman-yunkan Considering that @mgautierfr is away for a while, could you please review this PR? |
There was a problem hiding this 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?
I believe it is intended to be rebased on top of it later (#639 (comment)) |
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. |
There was a problem hiding this 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:
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:
- Migrate the suggestions UI to autocomplete.js
- Say thank you and good-bye to jquery.
There was a problem hiding this 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:
- I don't think we need the first two commits (the new unit test and the .gitignore) in this PR.
- 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. - Having a separate change for fixing codefactor warnings is not justified.
There was a problem hiding this 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
static/skin/taskbar.js
Outdated
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)); |
There was a problem hiding this comment.
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 &.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?
There was a problem hiding this comment.
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.
Added autoComplete.css and .js files. Linked files in head_taskbar.html
This change only shows suggestions. Clicking them does nothing.
There was a problem hiding this 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.
There was a problem hiding this 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!
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 :)
Done. |
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. |
@kelson42 Please validate the PR from user perspective once again before merging. |
@veloman-yunkan I will, glad to see ir ready. Thx a lot for all the review work. |
Thanks to both of you to finish and cleanup this PR ! |
* [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)
Fixes #610
Fixes #719
Fixes #369
Supersedes #639