-
Notifications
You must be signed in to change notification settings - Fork 0
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
Index primary thumbnail id #304
Merged
+227
−29
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7427c50
Extract thumbnail url
eliotjordan 55a1b91
Render large show page thumbnail using thumbnail service url
eliotjordan 49384ff
Handle thumbnail ids that do not correspond to FileSets
eliotjordan 789a43e
Render primary thumbnail first and limit total thumbnails
eliotjordan 6163e52
Guard against nil thumbnail ids
eliotjordan f89ece3
Fix comments
eliotjordan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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 |
---|---|---|
|
@@ -165,7 +165,7 @@ defmodule DpulCollectionsWeb.SearchLive do | |
<div id={"item-#{@item.id}"} class="item"> | ||
<div class="flex flex-wrap gap-5 md:max-h-60 max-h-[22rem] overflow-hidden justify-center md:justify-start relative"> | ||
<.thumbs | ||
:for={{thumb, thumb_num} <- Enum.with_index(@item.image_service_urls)} | ||
:for={{thumb, thumb_num} <- thumbnail_service_urls(5, @item)} | ||
:if={@item.page_count} | ||
thumb={thumb} | ||
thumb_num={thumb_num} | ||
|
@@ -343,4 +343,28 @@ defmodule DpulCollectionsWeb.SearchLive do | |
type == :post -> [{"...", false}, {page, false}] | ||
end | ||
end | ||
|
||
defp thumbnail_service_urls(max_thumbnails, item) do | ||
thumbnail_service_urls( | ||
max_thumbnails, | ||
item.image_service_urls, | ||
item.primary_thumbnail_service_url | ||
) | ||
end | ||
|
||
defp thumbnail_service_urls(max_thumbnails, image_service_urls, nil) do | ||
# Truncate image service urls to max value | ||
image_service_urls | ||
|> Enum.slice(0, max_thumbnails) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😂 Yeah I was wondering about this, were we just putting every thumbnail on the page? I guess it was performing. |
||
|> Enum.with_index() | ||
end | ||
|
||
defp thumbnail_service_urls(max_thumbnails, image_service_urls, primary_thumbnail_service_url) do | ||
# Move thumbnail url to front of list and then truncate to max value | ||
image_service_urls | ||
|> Enum.filter(&(&1 != primary_thumbnail_service_url)) | ||
|> List.insert_at(0, primary_thumbnail_service_url) | ||
|> Enum.slice(0, max_thumbnails) | ||
|> Enum.with_index() | ||
end | ||
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
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if it's more readable, but I wonder if a bunch of these conditionals are pattern matchable?
Like
for the case where there's an id key (this might not be possible, I dunno if you can match like this...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried similar approaches and could not get matches to happen.