diff --git a/js/src/i18n/en_US.json b/js/src/i18n/en_US.json
index fa34de2a..1ca56418 100644
--- a/js/src/i18n/en_US.json
+++ b/js/src/i18n/en_US.json
@@ -731,7 +731,6 @@
"any distance": "any distance",
"Group visibility": "Group visibility",
"The group will be publicly listed in search results and may be suggested in the explore section. Only public informations will be shown on it's page.": "The group will be publicly listed in search results and may be suggested in the explore section. Only public informations will be shown on it's page.",
- "You'll need to transmit the group URL so people may access the group's profile.": "You'll need to transmit the group URL so people may access the group's profile.",
"Group address": "Group address",
"Events tagged with {tag}": "Events tagged with {tag}",
"Explore events": "Explore events",
@@ -793,5 +792,6 @@
"A place to publish something to the whole world, your community or just your group members.": "A place to publish something to the whole world, your community or just your group members.",
"No posts found": "No posts found",
"Last sign-in": "Last sign-in",
- "Last IP adress": "Last IP adress"
+ "Last IP adress": "Last IP adress",
+ "You'll need to transmit the group URL so people may access the group's profile. The group won't be findable in Mobilizon's search or regular search engines.": "You'll need to transmit the group URL so people may access the group's profile. The group won't be findable in Mobilizon's search or regular search engines."
}
diff --git a/js/src/i18n/fr_FR.json b/js/src/i18n/fr_FR.json
index 28595f16..20e064ce 100644
--- a/js/src/i18n/fr_FR.json
+++ b/js/src/i18n/fr_FR.json
@@ -456,7 +456,6 @@
"Please refresh the page and retry.": "Merci de rafraîchir la page puis réessayer.",
"Post": "Billet",
"Post a comment": "Ajouter un commentaire",
- "Post a public message": "Poster un message public",
"Post a reply": "Envoyer une réponse",
"Postal Code": "Code postal",
"Posts": "Billets",
@@ -634,10 +633,6 @@
"Username": "Pseudo",
"Users": "Utilisateur⋅ice⋅s",
"View a reply": "Aucune réponse | Voir une réponse | Voir {totalReplies} réponses",
- "View all discussions": "Voir toutes les discussions",
- "View all events": "Voir tous les événements",
- "View all resources": "Voir toutes les resources",
- "View all todos": "Voir tous les todos",
"View all upcoming events": "Voir tous les événements à venir",
"View event page": "Voir la page de l'évènement",
"View everything": "Voir tout",
@@ -684,7 +679,6 @@
"You will be redirected to the original instance": "Vous allez être redirigé⋅e vers l'instance d'origine",
"You wish to participate to the following event": "Vous souhaitez participer à l'événement suivant",
"You'll get a weekly recap every Monday for upcoming events, if you have any.": "Vous recevrez un récapitulatif hebdomadaire chaque lundi pour les événements de la semaine, si vous en avez.",
- "You'll need to transmit the group URL so people may access the group's profile.": "Vous aurez besoin de transmettre l'URL du groupe pour que d'autres personnes accèdent au profil du groupe.",
"You'll receive a confirmation email.": "Vous recevrez un email de confirmation.",
"Your account has been successfully deleted": "Votre compte a été supprimé avec succès",
"Your account has been validated": "Votre compte a été validé",
@@ -798,5 +792,6 @@
"A place to publish something to the whole world, your community or just your group members.": "Un endroit pour publier quelque chose à l'intention du monde entier, de votre communauté ou simplement des membres de votre groupe.",
"No posts found": "Aucun billet trouvé",
"Last sign-in": "Dernière connexion",
- "Last IP adress": "Dernière addresse IP"
+ "Last IP adress": "Dernière addresse IP",
+ "You'll need to transmit the group URL so people may access the group's profile. The group won't be findable in Mobilizon's search or regular search engines.": "Vous aurez besoin de transmettre l'URL du groupe pour que d'autres personnes accèdent au profil du groupe. Le groupe ne sera pas trouvable dans la recherche de Mobilizon ni dans les moteurs de recherche habituels."
}
diff --git a/js/src/views/Group/GroupSettings.vue b/js/src/views/Group/GroupSettings.vue
index 4d207e60..084557e4 100644
--- a/js/src/views/Group/GroupSettings.vue
+++ b/js/src/views/Group/GroupSettings.vue
@@ -61,7 +61,9 @@
:native-value="GroupVisibility.UNLISTED"
>{{ $t("Only accessible through link") }}
{{
- $t("You'll need to transmit the group URL so people may access the group's profile.")
+ $t(
+ "You'll need to transmit the group URL so people may access the group's profile. The group won't be findable in Mobilizon's search or regular search engines."
+ )
}}
diff --git a/lib/mobilizon/actors/actors.ex b/lib/mobilizon/actors/actors.ex index 0584d364..8e1e1a75 100644 --- a/lib/mobilizon/actors/actors.ex +++ b/lib/mobilizon/actors/actors.ex @@ -187,7 +187,7 @@ defmodule Mobilizon.Actors do def get_actor_by_name_with_preload(name, type \\ nil) do name |> get_actor_by_name(type) - |> Repo.preload([:organized_events, :user]) + |> Repo.preload([:organized_events, :user, :physical_address]) end @doc """ diff --git a/lib/service/metadata/actor.ex b/lib/service/metadata/actor.ex index 00b14415..5677edf8 100644 --- a/lib/service/metadata/actor.ex +++ b/lib/service/metadata/actor.ex @@ -1,10 +1,12 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Actors.Actor do + alias Phoenix.HTML alias Phoenix.HTML.Tag alias Mobilizon.Actors.Actor + alias Mobilizon.Web.JsonLD.ObjectView alias Mobilizon.Web.MediaProxy def build_tags(%Actor{} = actor, _locale \\ "en") do - tags = [ + [ Tag.tag(:meta, property: "og:title", content: Actor.display_name_and_username(actor)), Tag.tag(:meta, property: "og:url", content: actor.url), Tag.tag(:meta, property: "og:description", content: actor.summary), @@ -12,7 +14,12 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Actors.Actor do Tag.tag(:meta, property: "profile:username", content: actor.preferred_username), Tag.tag(:meta, property: "twitter:card", content: "summary") ] + |> maybe_add_avatar(actor) + |> maybe_add_group_schema(actor) + end + @spec maybe_add_avatar(list(Tag.t()), Actor.t()) :: list(Tag.t()) + defp maybe_add_avatar(tags, actor) do if is_nil(actor.avatar) do tags else @@ -20,4 +27,17 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Actors.Actor do [Tag.tag(:meta, property: "og:image", content: actor.avatar.url |> MediaProxy.url())] end end + + defp maybe_add_group_schema(tags, %Actor{type: :Group} = group) do + tags ++ [~s{} |> HTML.raw()] + end + + defp maybe_add_group_schema(tags, _), do: tags + + # Insert JSON-LD schema by hand because Tag.content_tag wants to escape it + defp json(%Actor{} = group) do + "group.json" + |> ObjectView.render(%{group: group}) + |> Jason.encode!() + end end diff --git a/lib/web/cache/activity_pub.ex b/lib/web/cache/activity_pub.ex index bb9df1e4..f32cf598 100644 --- a/lib/web/cache/activity_pub.ex +++ b/lib/web/cache/activity_pub.ex @@ -23,7 +23,7 @@ defmodule Mobilizon.Web.Cache.ActivityPub do {:commit, Actor.t()} | {:ignore, nil} def get_actor_by_name(name) do Cachex.fetch(@cache, "actor_" <> name, fn "actor_" <> name -> - case Actors.get_actor_by_name(name) do + case Actors.get_actor_by_name_with_preload(name) do %Actor{} = actor -> {:commit, actor} diff --git a/lib/web/controllers/page_controller.ex b/lib/web/controllers/page_controller.ex index 6c026a22..64bef0b8 100644 --- a/lib/web/controllers/page_controller.ex +++ b/lib/web/controllers/page_controller.ex @@ -157,12 +157,7 @@ defmodule Mobilizon.Web.PageController do defp is_local?(%{local: local}), do: if(local, do: true, else: :remote) defp is_local?(_), do: false - defp maybe_add_noindex_header(conn, %Event{visibility: visibility}) - when visibility != :public do - put_resp_header(conn, "x-robots-tag", "noindex") - end - - defp maybe_add_noindex_header(conn, %Post{visibility: visibility}) + defp maybe_add_noindex_header(conn, %{visibility: visibility}) when visibility != :public do put_resp_header(conn, "x-robots-tag", "noindex") end diff --git a/lib/web/views/json_ld/object_view.ex b/lib/web/views/json_ld/object_view.ex index 59e69976..7db4a393 100644 --- a/lib/web/views/json_ld/object_view.ex +++ b/lib/web/views/json_ld/object_view.ex @@ -8,6 +8,16 @@ defmodule Mobilizon.Web.JsonLD.ObjectView do alias Mobilizon.Web.JsonLD.ObjectView alias Mobilizon.Web.MediaProxy + def render("group.json", %{group: %Actor{} = group}) do + %{ + "@context" => "http://schema.org", + "@type" => "Organization", + "url" => group.url, + "name" => group.name || group.preferred_username, + "address" => render_address(group) + } + end + def render("event.json", %{event: %Event{} = event}) do organizer = %{ "@type" => if(event.organizer_actor.type == :Group, do: "Organization", else: "Person"), @@ -56,14 +66,18 @@ defmodule Mobilizon.Web.JsonLD.ObjectView do %{ "@type" => "Place", "name" => address.description, - "address" => %{ - "@type" => "PostalAddress", - "streetAddress" => address.street, - "addressLocality" => address.locality, - "postalCode" => address.postal_code, - "addressRegion" => address.region, - "addressCountry" => address.country - } + "address" => render_one(address, ObjectView, "address.json", as: :address) + } + end + + def render("address.json", %{address: %Address{} = address}) do + %{ + "@type" => "PostalAddress", + "streetAddress" => address.street, + "addressLocality" => address.locality, + "postalCode" => address.postal_code, + "addressRegion" => address.region, + "addressCountry" => address.country } end @@ -81,7 +95,7 @@ defmodule Mobilizon.Web.JsonLD.ObjectView do } end - defp render_location(%Event{physical_address: %Address{} = address}), + defp render_location(%{physical_address: %Address{} = address}), do: render_one(address, ObjectView, "place.json", as: :address) # For now the Virtual Location of an event is it's own URL, @@ -92,4 +106,11 @@ defmodule Mobilizon.Web.JsonLD.ObjectView do "url" => event_url } end + + defp render_location(_), do: nil + + defp render_address(%{physical_address: %Address{} = address}), + do: render_one(address, ObjectView, "address.json", as: :address) + + defp render_address(_), do: nil end