Skip to content

Commit

Permalink
The rubygem partial displays the latest release date
Browse files Browse the repository at this point in the history
  • Loading branch information
heyapricot committed Feb 22, 2024
1 parent 0c48ef3 commit 3941c33
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/modules/gems.css
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
float: right;
text-align: right; } }

.gems__gem__version {
.gems__gem__version, .gems__gem__latest__release__date {
margin-left: 10px;
font-style: italic;
font-weight: 300;
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/searches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ class SearchesController < ApplicationController

def show
return unless params[:query].is_a?(String)
@error_msg, @gems = ElasticSearcher.new(params[:query], page: @page).search
@error_msg, @elastic_results = ElasticSearcher.new(params[:query], page: @page).search

return unless @gems
return unless @elastic_results
@gems = Rubygem.where(id: @elastic_results.map(&:id)).with_versions
set_total_pages if @gems.total_count > Gemcutter::SEARCH_MAX_PAGES * Rubygem.default_per_page
exact_match = Rubygem.name_is(params[:query]).first
@yanked_gem = exact_match unless exact_match&.indexed_versions?
Expand Down
7 changes: 6 additions & 1 deletion app/views/rubygems/_rubygem.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
<span class="gems__gem__info">
<h2 class="gems__gem__name">
<%= rubygem.name %>
<span class="gems__gem__version"><%= latest_version_number(rubygem) %></span>
<span class="gems__gem__version">
<%= latest_version_number(rubygem) %>
</span>
<span class="gems__gem__latest__release__date">
<%= version_date_tag(rubygem.latest_version) %>
</span>
</h2>
<p class="gems__gem__desc t-text"><%= short_info(rubygem) %></p>
</span>
Expand Down
4 changes: 2 additions & 2 deletions app/views/searches/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<% @subtitle = t('.subtitle', :query => content_tag(:em, h(params[:query]))) %>

<header class="gems__header push--s">
<p class="gems__meter"><%= page_entries_info(@gems, :entry_name => 'gem').html_safe %></p>
<p class="gems__meter"><%= page_entries_info(@elastic_results, :entry_name => 'gem').html_safe %></p>
</header>

<%= render partial: 'aggregations', locals: { gems: @gems } %>
Expand All @@ -44,7 +44,7 @@
<% if @gems.present? %>
<%= render partial: 'rubygems/rubygem', collection: @gems %>
<%= paginate @gems %>
<%= paginate @elastic_results %>
<% end %>
<% end %>
<% end %>

0 comments on commit 3941c33

Please sign in to comment.