Skip to content
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

Feature request: Search via wikipedia url pasted/drag'n'dropped into the search box #132

Open
davidscotson opened this issue Sep 6, 2023 · 2 comments

Comments

@davidscotson
Copy link

Currently if you paste a Q42 style id into the search box, it'll use that to lookup an entry to match. This is particularly useful for people/things with very common names where the search might get swamped with other items.

I often find myself following a wikipedia link that a site provides to uniquely identify the current item, using the extension to quickly grab the Q-id then pasting it into the extension search box in another window.

It would be nice to skip a step and paste the url directly into the search box. Or drag and drop it into the sidebar.

In theory it's possible to grab links from user selected text too, even multiple ones and check them all, but I'm not sure how that would interact with people just trying to select the text of the link to search. Maybe display any link based match found as an additional search result at the top of the list?

@fuddl
Copy link
Owner

fuddl commented Sep 9, 2023

currently the search box does exactly what the wikidata website search box does. It calls this api endpoint:

https://www.wikidata.org/w/api.php?action=wbsearchentities&format=json&search=Q42&limit=10&errorformat=plaintext&language=en&uselang=en&type=item

If I enter the url into it it won't give me any results:

https://www.wikidata.org/w/api.php?action=wbsearchentities&format=json&search=https://en.wikipedia.org/wiki/Douglas_Adams&limit=10&errorformat=plaintext&language=en&uselang=en&type=item

I wouldn't like makeing it more complicated, then this.

But, as a fallback (when there are no results) and when it is a url, we could simply run all resolvers we usually have. That should have the intended efffect.

@fuddl
Copy link
Owner

fuddl commented Sep 9, 2023

If you want to do this, here are the important parts in the code:

this function resolves a url to a wikidata id:

export const resolve = async (location: LocationLike): Promise<Resolution | null> => {

You could call it here in case there are not results and the input is a url:

async function wikidataAutocomplete(query, lang, scope = 'item') {

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

No branches or pull requests

2 participants