Skip to content

Implement search functions only with fzf-for-js 🍽️ #72

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 3 commits into from
Dec 17, 2023

Conversation

CoralPink
Copy link
Owner

@CoralPink CoralPink commented Dec 17, 2023

The search functionality, which until now has been implemented in mdbook by overriding elasticlunr with fzf-for-js, can now be done using only fzf-for-js.

Summary by CodeRabbit

  • New Features

    • Enhanced search functionality using a new search mechanism.
  • Refactor

    • Updated search initialization to use a more efficient data structure.
  • Chores

    • Updated service worker cache version for improved performance.
  • Style

    • Removed unused script import from the main template for a cleaner codebase.
  • Bug Fixes

    • Fixed an issue with the search cleanup process in the deployment workflow.

Copy link
Contributor

coderabbitai bot commented Dec 17, 2023

Warning

Rate Limit Exceeded

@CoralPink has exceeded the limit for the number of files or commits that can be reviewed per hour. Please wait 13 minutes and 24 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 1fa773f and 71140bb.

Walkthrough

The project has undergone a significant update, primarily around the search functionality. The elasticlunr library has been removed, and a new search system based on fzf has been implemented. This involved changes to the JavaScript handling search, the service worker's cache version bump, and the removal of elasticlunr references from the GitHub Actions workflow and the main HTML template.

Changes

File Pattern Summary
.github/workflows/gh-pages.yml Removed cleanup step for elasticlunr.min.js.
debug.sh No functional changes.
js/searcher.js Replaced lunrIndex with fzf for search; added storeDocs object and removed searchConfig.
js/serviceworker.js & theme/index.hbs Updated cache version and removed elasticlunr.min.js reference.

🐇✨
In the code warren, deep and vast,
Old search hops away, the fzf is cast.
No more elasticlunr in the script's embrace,
Swift and sleek, the new search takes its place.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ?


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can reply to a review comment made by CodeRabbit.
  • You can tag CodeRabbit on specific lines of code or files in the PR by tagging @coderabbitai in a comment.
  • You can tag @coderabbitai in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 46ecd8b and 22b5153.
Files ignored due to filter (1)
  • book.toml
Files selected for processing (5)
  • .github/workflows/gh-pages.yml (1 hunks)
  • debug.sh (1 hunks)
  • js/searcher.js (4 hunks)
  • js/serviceworker.js (1 hunks)
  • theme/index.hbs (1 hunks)
Files skipped from review due to trivial changes (2)
  • debug.sh
  • js/serviceworker.js
Additional comments: 6
.github/workflows/gh-pages.yml (1)
  • 85-85: The removal of elasticlunr.min.js is consistent with the PR's objective to transition search functionality to fzf-for-js. Ensure that there are no other references to elasticlunr.min.js in the workflow file or other build scripts that might still expect this file to be present.
Verification successful

The shell script output confirms that the only reference to elasticlunr.min.js in the workflow files is the line that removes it, which is in alignment with the PR's objective to remove elasticlunr entirely. There are no other references to this file in the workflow files, which suggests that the cleanup of build artifacts related to elasticlunr has been appropriately handled in the .github/workflows/gh-pages.yml file.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for any remaining references to 'elasticlunr.min.js' in the workflow files.
rg --type yaml 'elasticlunr.min.js' .github/workflows/

Length of output: 128

js/searcher.js (4)
  • 18-20: The addition of fzf and storeDocs is consistent with the PR's objective to transition to fzf-for-js exclusively and remove elasticlunr.

  • 31-44: The new implementation of search results using fzf seems to be logically correct. It fetches results based on the search term, processes them, and displays them accordingly.

  • 92-109: The initialization of storeDocs and fzf is done correctly, and the configuration of fzf is in line with the application's needs. Ensure that the removal of lunrIndex and searchConfig does not affect other parts of the application that might have relied on them.

Verification successful

The verification process has confirmed that there are no remaining references to lunrIndex or searchConfig in the codebase. The removal of these variables from js/searcher.js appears to be clean and should not cause any unresolved dependencies or issues.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for any remaining references to lunrIndex or searchConfig in the codebase.
rg --type js 'lunrIndex|searchConfig'

Length of output: 39



Script:

#!/bin/bash
# Search for any remaining references to lunrIndex or searchConfig in all files within the codebase.
rg 'lunrIndex|searchConfig'

Length of output: 29

* 89-112: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [15-160]

Ensure that the removal of elasticlunr has been fully accounted for and that there are no orphaned references or artifacts left in the project.

Verification successful

The search results indicate that elasticlunr is referenced in a commented line within debug.sh, which seems to be related to cleanup and is not an active code reference. Additionally, elasticlunr is found in Cargo.lock within the mdbook-footnote directory, which is part of the Rust backend and not the JavaScript frontend that was refactored. This suggests that the removal of elasticlunr from the JavaScript codebase has been properly accounted for, and there are no orphaned references or artifacts left in the JavaScript portion of the project.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for any remaining references to elasticlunr in the codebase.
rg --type js 'elasticlunr'

Length of output: 26



Script:

#!/bin/bash
# Search for any remaining references to elasticlunr in the entire codebase.
rg 'elasticlunr'

Length of output: 162

theme/index.hbs (1)
  • 111-116: The changes in the theme/index.hbs file correctly reflect the removal of the elasticlunr.min.js script tag, which is in line with the PR's objective to transition exclusively to fzf-for-js for search functionality. The remaining script tags for book.js and searcher.js suggest that these scripts have been updated to work without elasticlunr. Ensure that the removal of elasticlunr does not impact any other functionality that may have depended on it.
Verification successful

The executed scripts confirm that elasticlunr.min.js is not referenced in the theme/index.hbs file, nor in the JavaScript files book.js and searcher.js. To ensure there are no indirect dependencies on elasticlunr elsewhere in the codebase, I will perform a search across all files.


The search across the codebase found a commented-out reference to elasticlunr in debug.sh and a dependency named elasticlunr-rs in Cargo.lock within the mdbook-footnote directory. The commented-out line in debug.sh is not active code and thus not a concern. The elasticlunr-rs reference in Cargo.lock appears to be a Rust-related dependency and is not directly related to the JavaScript changes being made in the PR. There are no indications of broken references or dependencies in the JavaScript code due to the removal of elasticlunr.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that no other script tags or inline scripts depend on elasticlunr.min.js
rg --type html '<script' theme/index.hbs | grep 'elasticlunr'
# Verify that book.js and searcher.js do not reference elasticlunr
rg --type js 'elasticlunr' js/book.js js/searcher.js

Length of output: 114



Script:

#!/bin/bash
# Search the entire codebase for references to elasticlunr
rg 'elasticlunr'

Length of output: 162

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 22b5153 and 1fa773f.
Files selected for processing (1)
  • .github/workflows/gh-pages.yml (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/gh-pages.yml

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@CoralPink
Copy link
Owner Author

I've also incorporated the comment modification!

I'm going to merge them!

@CoralPink CoralPink merged commit 03cad24 into main Dec 17, 2023
@CoralPink CoralPink deleted the remove-elasticlunr branch December 17, 2023 13:47
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.

1 participant