-
Notifications
You must be signed in to change notification settings - Fork 4
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
offline search for mirror drives #1175
Conversation
Netlify Deployments: |
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.
Device | URL |
---|---|
mobile | https://ocw-hugo-themes-www-pr-1175--ocw-next.netlify.app/ |
Device | URL |
---|---|
mobile | https://ocw-hugo-themes-www-pr-1175--ocw-next.netlify.app/search/ |
Device | URL |
---|---|
mobile | https://ocw-hugo-themes-course-v2-pr-1175--ocw-next.netlify.app/ |
Not what you expected? Are your scores flaky? GitHub runners could be the cause.
Try running on Foo instead
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.
This makes sense, works as described, and is super cool 👍
Some things I noticed... I think that at least the first two are worth addressing:
- I think we should change
minMatchCharLength: 5
to something significantly lower. Currently, OCW has no math courses (joking...):
-
When there are no matches, the page is very blank. I think we should say "No results found". Or perhaps always show the count.
-
(Fixed)
Sometimes the titles contain invalid characters on the search page. For example,3.034-fall-2005
has an ampersand in its title:
And, as mentioned in slack: We may want to move some/all of the JS to a file that gets processed by webpack. JS in template files do not. The arrow functions will make IE mad. See also #1075
aria-label="Search" | ||
placeholder="Search OpenCourseWare" | ||
/> | ||
<button id="search-button" type="submit" class="py-2 px-3">Search</button> |
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.
<button id="search-button" type="submit" class="py-2 px-3">Search</button> | |
<button id="search-button" type="button" class="py-2 px-3">Search</button> |
Then you won't need to prevent default down below.
@ChristopherChudzicki all set for another look |
What are the relevant tickets?
Closes #1174
Description (What does it do?)
This PR adds the Fuse.js library to the project and utilizes it to provide offline search functionality in the
www-offline
theme, used as the home page of mirror drives. The search icon is now displayed in the header on pages that aren't the search page, linking to a newsearch.html
page at the root. In mitodl/ocw-studio#1705, we set upocw-studio
to publish a file undercontent/websites
for each website that has been published live at least once inside the root website,ocw-www
. This content is currently being used to generate a paginated list of sites at the root when using thewww-offline
theme inindex.html
. Insearch.html
, we put that same list into an array in Javascript and feed it into Fuse.js as a data source, indexing onprimary_course_number
andtitle
. The search page mostly replicates a basic version of the online search without any facets or resource search, providing links to sites relative to the root of the mirror drive in the same way the paginated index does. Everything is done in raw Javascript right in a script tag on the page to avoid any issues with CORS when viewing the page without a web server offline.Screenshots (if appropriate):
How can this be tested?
ocw-hugo-themes
on this branch as well as https://github.mit.edu/ocw-content-rc/ocw-www andocw-hugo-projects
on thecg/www-offline-enable-section
branchocw-hugo-themes
, runyarn install
to make sure you install the latest dependenciesocw-hugo-themes
, runyarn build /path/to/ocw-content-rc/ocw-www/ /path/to/ocw-hugo-projects/ocw-www/config-offline.yaml
ocw-content-rc/ocw-www/dist
folder and double click onindex.html
file://path/to/ocw-content-rc/ocw-www/dist/courses/course-name
courses
folder underdist
and extract it there to a folder matching the courses
name` propertyRelease process
mitodl/ocw-hugo-projects#255 should be merged and released before this PR