Skip to content

Commit c3b69dd

Browse files
authored
Merge pull request #4729 from manyfold3d/link-other-searches
Link to other search types from search results (including fediverse and offsite)
2 parents 5d55823 + f4494ec commit c3b69dd

File tree

6 files changed

+26
-0
lines changed

6 files changed

+26
-0
lines changed

app/controllers/models_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class ModelsController < ApplicationController
2121

2222
def index
2323
@models = @filter.models(policy_scope(Model))
24+
@search = params[:q].presence
2425
prepare_model_list
2526
set_indexable @models
2627
respond_to do |format|

app/models/site_settings.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ def self.ignored_file?(pathname)
9595
end
9696
end
9797

98+
def self.fasp_data_sharing_enabled?
99+
federation_enabled? && FaspClient::Provider.any? { |it| it.has_capability? :account_search }
100+
end
101+
98102
module UserDefaults
99103
RENDERER = ActiveSupport::HashWithIndifferentAccess.new(
100104
grid_width: 200,

app/views/models/_list.html.erb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
<div class="alert alert-info">
44
<%= icon "person-arms-up", "" %>
55
<%= signed_in? ? t(".no_results_html") : t(".no_results_signed_out_html", link: new_user_session_path) %>
6+
<% if @search %>
7+
<%= t ".search.or_other_sites" %>
8+
<%= render "search_links" %>
9+
<% end %>
610
</div>
711
<% else %>
812
<div class="skip-link-container">
@@ -19,6 +23,13 @@
1923
<% if pagination_settings["models"] %>
2024
<%= paginate @models %>
2125
<% end %>
26+
<% if @search %>
27+
<div class="alert alert-info">
28+
<%= icon "search", "" %>
29+
<%= t ".search.other_sites" %>
30+
<%= render "search_links" %>
31+
</div>
32+
<% end %>
2233
</div>
2334
<% end %>
2435
<% end %>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<% html_class = "ms-3" %>
2+
<div class="mt-2">
3+
<%= link_to t("sites.fediverse"), new_follow_path(uri: @search), class: html_class if SiteSettings.fasp_data_sharing_enabled? %>
4+
<%= link_to t("sites.thangs"), "https://thangs.com/search/#{ERB::Util.url_encode(@search)}?searchScope=all&view=list", class: html_class, target: "manyfold_thangs_search", rel: "noreferrer" %>
5+
<%= link_to t("sites.yeggi"), "https://yeggi.com/q/#{ERB::Util.url_encode(@search)}/", target: "manyfold_yeggi_search", class: html_class, rel: "noreferrer" %>
6+
</div>

config/locales/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ en:
821821
cgtrader: CGTrader
822822
comicsgamesandthings: Comics, Games, and Things
823823
cults3d: Cults3D
824+
fediverse: The Fediverse
824825
github: GitHub
825826
makerworld: MakerWorld
826827
manyfold: Manyfold

config/locales/models/en.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ en:
5555
bulk_edit: Edit All Models
5656
no_results_html: Sorry, we couldn't find anything to show you! Try changing your filters or search terms, or uploading some models.
5757
no_results_signed_out_html: Sorry, we couldn't find anything to show you! There might be more to see if you <a href="%{link}">sign in</a>.
58+
search:
59+
or_other_sites: 'Or, try searching elsewhere:'
60+
other_sites: 'Can''t find what you want? Try searching elsewhere:'
5861
skip_models: Skip model list
5962
merge:
6063
success: Models merged successfully.

0 commit comments

Comments
 (0)