forked from pulibrary/plum
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added code from ocracoke for search api
- Loading branch information
Andy Smith
committed
Jun 8, 2017
1 parent
65576bf
commit 37af9e2
Showing
4 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
json.set! '@type', 'search:Hit' | ||
json.annotations do | ||
# This is the way we trick UV to show the number of hits | ||
urls = [] | ||
doc[:hit_number].times do |time| | ||
urls << annotation_url(doc['id'], doc['resource'], time) | ||
end | ||
json.array! urls | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
json.set! "@id", annotation_url(doc[:id], doc[:resource], doc[:time]) | ||
json.set! '@type', 'oa:Annotation' | ||
json.motivation 'sc:painting' | ||
|
||
json.resource do | ||
json.set! '@type', "cnt:ContentAsText" | ||
json.chars doc[:word] | ||
end | ||
|
||
page_word_list = @pages_json[doc[:id]] | ||
xywh = if !@pages_json[doc[:id]] || page_word_list[doc[:word]].nil? | ||
"0,0,0,0" | ||
else | ||
word_bounds = page_word_list[doc[:word]].shift | ||
# FIXME: This is the wrong place to set all of these to integers | ||
if word_bounds | ||
x = word_bounds["x0"].to_i | ||
y = word_bounds["y0"].to_i | ||
w = word_bounds["x1"].to_i - word_bounds["x0"].to_i | ||
h = word_bounds["y1"].to_i - word_bounds["y0"].to_i | ||
"#{x},#{y},#{w},#{h}" | ||
else | ||
"0,0,0,0" | ||
end | ||
end | ||
|
||
# FIXME: How to make this so it is possible to have different canvas URLs to | ||
# match each institution's own URLs to canvases as found in their | ||
# Presentation manifests? | ||
json.on manifest_canvas_on_xywh(doc[:id], xywh) #manifest_canvas_id(doc[:id]) + "#xywh=#{xywh}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters