MuckRock / documentcloud-frontend

DocumentCloud's front end source code - Please report bugs, issues and feature requests to info@documentcloud.org
https://www.documentcloud.org
GNU Affero General Public License v3.0
15 stars 5 forks source link

Search highlights #501

Open eyeseast opened 3 months ago

eyeseast commented 3 months ago

Current version: https://www.documentcloud.org/app?q=boston

API: https://api.www.documentcloud.org/api/documents/search/?q=boston&hl=true&expand=user,organization

Highlights are both pages and notes.

eyeseast commented 3 months ago

Solr is already marking text for us as <em> tags: https://github.com/MuckRock/documentcloud/blob/master/config/solr/solrconfig.xml#L1331-L1339

Might be nice to switch those to <mark> since that's more semantic.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/mark

eyeseast commented 3 months ago

A big chunk of src/structure/document.js is concerned with transforming highlights. I wonder if we actually need all of that or if we can rely on what Solr gives us.

eyeseast commented 2 months ago

Here's what highlights look like: https://api.www.documentcloud.org/api/documents/search/?q=boston&hl=true&expand=user,organization

eyeseast commented 2 months ago

We currently show page thumbnails (smaller than main document thumbnails) for each text highlight, and we link to the relevant page:

Screenshot 2024-04-19 at 10 27 17 AM

For note highlights, we link to the relevant note:

Screenshot 2024-04-19 at 10 27 31 AM
eyeseast commented 1 month ago

Need to represent the in-document search results, too:

Screenshot 2024-05-14 at 10 17 49 AM Screenshot 2024-05-14 at 10 18 43 AM

API response: https://api.www.documentcloud.org/api/documents/24438447/search/?q=%22Los%20Angeles%22

allanlasser commented 1 month ago

screenshot-grammar@2x

Just saw this screenshot and really liked its approach to providing inline highlights as a list of results. https://ulysses.app/