Skip to content

Commit

Permalink
Merge pull request #3490 from manyfold3d/simple-follow-from-search
Browse files Browse the repository at this point in the history
Entering fediverse username in main search redirects to follow page
  • Loading branch information
Floppy authored Jan 27, 2025
2 parents 4f3aa9e + 9551558 commit 8a249e2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
5 changes: 5 additions & 0 deletions app/controllers/models_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class ModelsController < ApplicationController
include ModelListable
include Permittable

before_action :redirect_search, only: [:index], if: -> { params.key?(:q) }
before_action :get_model, except: [:bulk_edit, :bulk_update, :index, :new, :create]
before_action :get_creators_and_collections, only: [:new, :edit, :bulk_edit]
before_action :set_returnable, only: [:bulk_edit, :edit, :new]
Expand Down Expand Up @@ -172,6 +173,10 @@ def destroy

private

def redirect_search
redirect_to new_follow_path(uri: params[:q]) if params[:q]&.match?(/(@|acct:)?([a-z0-9\-_.]+)@(.*)/)
end

def generate_available_tag_list
@available_tags = ActsAsTaggableOn::Tag.where(
id: ActsAsTaggableOn::Tagging.where(
Expand Down
19 changes: 14 additions & 5 deletions app/views/follows/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,20 @@

<h3><%= t(".results") %></h3>
<% if @actor %>
<div class="row">
<div class="col"><%= @actor.name %></div>
<div class="col"><%= @actor.at_address %></div>
<div class="col"><%= render FollowButtonComponent.new(follower: current_user, target: @actor) %></div>
</div>
<table class="table table-striped">
<tr>
<th><%= t(".name") %></th>
<th><%= t(".address") %></th>
<th><%= t(".info") %></th>
<th><%= t(".actions") %></th>
</tr>
<tr class="align-middle">
<td><%= @actor.name %></td>
<td><%= @actor.at_address %></td>
<td class="text-warning"><%= icon("exclamation-triangle-fill", translate(".non_manyfold_account")) if @actor.extensions["f3di:concreteType"].nil? %></td>
<td><%= render FollowButtonComponent.new(follower: current_user, target: @actor) %></td>
</tr>
</table>
<% else %>
<div class="alert alert-info">
<%= icon "person-arms-up", "" %>
Expand Down
5 changes: 5 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,13 @@ en:
follow_remote_actor:
followed: Followed %{actor} successfully
new:
actions: Actions
address: Fediverse Address
help: You can follow public creators, collections or models on another Manyfold server, in fact any public account in the Fediverse! Just enter the account name in the search box!
info: Info
name: Name
no_results: Sorry, couldn't find anything for "%{query}". Is it a valid ActivityPub account or URL?
non_manyfold_account: This is not a Manyfold account; you can follow it, but probably nothing interesting will happen, at least for now.
results: Search Results
search:
placeholder: Enter a Fediverse account or URL, e.g. admin@try.manyfold.app
Expand Down

0 comments on commit 8a249e2

Please sign in to comment.