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

search within a work #1785

Open
saracarl opened this issue Jun 22, 2020 · 6 comments
Open

search within a work #1785

saracarl opened this issue Jun 22, 2020 · 6 comments
Assignees
Labels

Comments

@saracarl
Copy link
Collaborator

We have a lot of searches, but not one for within a work

@isabelabarton
Copy link
Collaborator

isabelabarton commented Jul 23, 2020

@saracarl I feel like once I find the right place it could look something like this. (including the lines below this line)

=form_tag({:controller => 'dashboard', :action => 'landing_page'}, method: :get, enforce_utf8: false, class: 'collection-search') do

Where specifically should there be a search bar? Because there are already search bars in these two spots.
Screen Shot 2020-07-23 at 1 37 36 PM
Screen Shot 2020-07-23 at 1 37 44 PM

I could, however add one on an actual page, but would it be looking for specific words?
Screen Shot 2020-07-23 at 1 37 56 PM

@isabelabarton isabelabarton self-assigned this Jul 23, 2020
@benwbrum
Copy link
Owner

I think the most logical place to put this particular search bar is on the screen that users see when they click on a work name, like https://fromthepage.com/benwbrum/jeremiah-white-graves-diaries/jeremiah-white-graves-diary-volume-2-book-13

That's probably somewhere like app/views/display/read_work.

@isabelabarton
Copy link
Collaborator

isabelabarton commented Jul 23, 2020

@benwbrum If theres is already a search bar looking in the collection in that spot, what would the new one be looking for?

@benwbrum
Copy link
Owner

benwbrum commented Jul 23, 2020 via email

@isabelabarton
Copy link
Collaborator

isabelabarton commented Jul 23, 2020

@benwbrum supply 103

else
@search_string = CGI::escapeHTML(params[:search_string])
# convert 'natural' search strings unless they're precise
unless @search_string.match(/["+-]/)
@search_string.gsub!(/(\S+)/, '+\1*')
end
# restrict to pages that include that subject
@pages = Page.order('work_id, position').joins(:work).where(work_id: @collection.works.ids).where("MATCH(search_text) AGAINST(? IN BOOLEAN MODE)", @search_string).paginate(page: params[:page])
end

@benwbrum
Copy link
Owner

benwbrum commented Aug 4, 2020

It looks like all we need to do is replace work_id: @collection.works.ids with work_id: @work.id, as in this:

Page.order('work_id, position').joins(:work).where(work_id: @work.id).where("MATCH(search_text) AGAINST(? IN BOOLEAN MODE)", @search_string).paginate(page: params[:page])

@isabelabarton isabelabarton removed their assignment Aug 5, 2020
benwbrum added a commit that referenced this issue Jun 22, 2023
#1785-Added Search within a Work Functionality
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants