-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/spencerwoo/onedrive-vercel-index/CLvL8vbdnsBsED1fXjdvDqG8qZeH |
you can use this for pop up ui: https://headlessui.dev/react/dialog - already present in the dependencies put the search button in the nav bar instead, putting it beside the breadcrumb is not ideal for mobile layouts. |
IMO dropdown (also shipped in headlessui) is closer to input box to show the relationship between them, and has a consistent experience as other search such as search engines. As for dialog, because it can stop users' reading immediately, it is better to be used to ask users for urgent information like credentials. The search query string is not so urgent, so I used dropdown. However, dialog may fit the search consumption better, as it costs fairly a long time to do a searching even with OneDrive provided API. I would be OK to both solutions, and I thought it better you to make the decision. |
pending to wait for decision whether to move search box to dialog and leave a button in navbar
the search in tailwind css documentation site is a pop over, and the search in github documentation site is a slideover, so... oh, and i see you are sending quite a lot of requests when doing a search - basically traversing every subfolder and every file: you know that we have a persistent storage now right ;), we can do some pre-indexing and perform search on the indexed files - just a thought - the idea is basically having a cron job setup every 24 hours that:
and on another api endpoint (serverless function route) such as
i would think that this is the most performant solution for searching without onedrive's own api and with support for cjk. the only caveat is the indexing may take some time for large onedrive storages, which are not ideal as long running jobs (longer than 5 secs), which may be terminated by vercel. another thing is that i do plan on refactoring the project to use edit - shoot, i think we can use github actions for this lol!! |
ok, on the github actions thought:
so, the idea would be:
and so, what we need here:
and voila! |
GitHub Actions ToS says:
And last year GitHub did take some repos (even accounts) down, even they are just doing checkin tasks. So I worry that indexing via GitHub Actions is a little dangerous. Not sure. Anyway indexing via cron job is great, only the runner is a problem. |
closing in favor of #283 being merged |
Close #216
The PR has not been completed and some impl may need discussions IMO
The PR adds search support. For UI it adds a search box with result dropdown on the right of breadcrumb. For utils it adds
getStrSimilarity
anduseClickAwayListener
. For API it adds new query string fieldq
inindex.ts
and handle it likeraw
. For config it adds 2 options intoconfig/site.json
.The searching is done by OneDrive provided API, or builtin string similarity util, according to options. The default policy
ascii-onedrive-else-builtin
is to use OneDrive API when all is ASCII, else builtin.The builtin search relies on
traverseFolder
ofMultiFileDownloader.tsx
to get all files in current folder, and compute string similarity viagetStrSimilarity
ofgetStrSimilarity.ts
, where there is description about the algorithm. ThegetStrSimilarity
should work on all languages including English and Chinese.What have not been completed in the PR are:
It seems that the function to extract path fromFixedwebUrl
to convert ID to path works for me but not for the dev build (the dev buildwebUrl
seems to use ID other than path). Other methods are required.