Show group address in group metadata
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
93728cb9d7
commit
952e592e2c
|
@ -731,7 +731,6 @@
|
||||||
"any distance": "any distance",
|
"any distance": "any distance",
|
||||||
"Group visibility": "Group visibility",
|
"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.",
|
"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",
|
"Group address": "Group address",
|
||||||
"Events tagged with {tag}": "Events tagged with {tag}",
|
"Events tagged with {tag}": "Events tagged with {tag}",
|
||||||
"Explore events": "Explore events",
|
"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.",
|
"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",
|
"No posts found": "No posts found",
|
||||||
"Last sign-in": "Last sign-in",
|
"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."
|
||||||
}
|
}
|
||||||
|
|
|
@ -456,7 +456,6 @@
|
||||||
"Please refresh the page and retry.": "Merci de rafraîchir la page puis réessayer.",
|
"Please refresh the page and retry.": "Merci de rafraîchir la page puis réessayer.",
|
||||||
"Post": "Billet",
|
"Post": "Billet",
|
||||||
"Post a comment": "Ajouter un commentaire",
|
"Post a comment": "Ajouter un commentaire",
|
||||||
"Post a public message": "Poster un message public",
|
|
||||||
"Post a reply": "Envoyer une réponse",
|
"Post a reply": "Envoyer une réponse",
|
||||||
"Postal Code": "Code postal",
|
"Postal Code": "Code postal",
|
||||||
"Posts": "Billets",
|
"Posts": "Billets",
|
||||||
|
@ -634,10 +633,6 @@
|
||||||
"Username": "Pseudo",
|
"Username": "Pseudo",
|
||||||
"Users": "Utilisateur⋅ice⋅s",
|
"Users": "Utilisateur⋅ice⋅s",
|
||||||
"View a reply": "Aucune réponse | Voir une réponse | Voir {totalReplies} réponses",
|
"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 all upcoming events": "Voir tous les événements à venir",
|
||||||
"View event page": "Voir la page de l'évènement",
|
"View event page": "Voir la page de l'évènement",
|
||||||
"View everything": "Voir tout",
|
"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 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 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 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.",
|
"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 successfully deleted": "Votre compte a été supprimé avec succès",
|
||||||
"Your account has been validated": "Votre compte a été validé",
|
"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.",
|
"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é",
|
"No posts found": "Aucun billet trouvé",
|
||||||
"Last sign-in": "Dernière connexion",
|
"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."
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,9 @@
|
||||||
:native-value="GroupVisibility.UNLISTED"
|
:native-value="GroupVisibility.UNLISTED"
|
||||||
>{{ $t("Only accessible through link") }}<br />
|
>{{ $t("Only accessible through link") }}<br />
|
||||||
<small>{{
|
<small>{{
|
||||||
$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."
|
||||||
|
)
|
||||||
}}</small>
|
}}</small>
|
||||||
</b-radio>
|
</b-radio>
|
||||||
<p class="control">
|
<p class="control">
|
||||||
|
|
|
@ -187,7 +187,7 @@ defmodule Mobilizon.Actors do
|
||||||
def get_actor_by_name_with_preload(name, type \\ nil) do
|
def get_actor_by_name_with_preload(name, type \\ nil) do
|
||||||
name
|
name
|
||||||
|> get_actor_by_name(type)
|
|> get_actor_by_name(type)
|
||||||
|> Repo.preload([:organized_events, :user])
|
|> Repo.preload([:organized_events, :user, :physical_address])
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
defimpl Mobilizon.Service.Metadata, for: Mobilizon.Actors.Actor do
|
defimpl Mobilizon.Service.Metadata, for: Mobilizon.Actors.Actor do
|
||||||
|
alias Phoenix.HTML
|
||||||
alias Phoenix.HTML.Tag
|
alias Phoenix.HTML.Tag
|
||||||
alias Mobilizon.Actors.Actor
|
alias Mobilizon.Actors.Actor
|
||||||
|
alias Mobilizon.Web.JsonLD.ObjectView
|
||||||
alias Mobilizon.Web.MediaProxy
|
alias Mobilizon.Web.MediaProxy
|
||||||
|
|
||||||
def build_tags(%Actor{} = actor, _locale \\ "en") do
|
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:title", content: Actor.display_name_and_username(actor)),
|
||||||
Tag.tag(:meta, property: "og:url", content: actor.url),
|
Tag.tag(:meta, property: "og:url", content: actor.url),
|
||||||
Tag.tag(:meta, property: "og:description", content: actor.summary),
|
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: "profile:username", content: actor.preferred_username),
|
||||||
Tag.tag(:meta, property: "twitter:card", content: "summary")
|
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
|
if is_nil(actor.avatar) do
|
||||||
tags
|
tags
|
||||||
else
|
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())]
|
[Tag.tag(:meta, property: "og:image", content: actor.avatar.url |> MediaProxy.url())]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp maybe_add_group_schema(tags, %Actor{type: :Group} = group) do
|
||||||
|
tags ++ [~s{<script type="application/ld+json">#{json(group)}</script>} |> 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
|
end
|
||||||
|
|
2
lib/web/cache/activity_pub.ex
vendored
2
lib/web/cache/activity_pub.ex
vendored
|
@ -23,7 +23,7 @@ defmodule Mobilizon.Web.Cache.ActivityPub do
|
||||||
{:commit, Actor.t()} | {:ignore, nil}
|
{:commit, Actor.t()} | {:ignore, nil}
|
||||||
def get_actor_by_name(name) do
|
def get_actor_by_name(name) do
|
||||||
Cachex.fetch(@cache, "actor_" <> name, fn "actor_" <> name ->
|
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 ->
|
%Actor{} = actor ->
|
||||||
{:commit, actor}
|
{:commit, actor}
|
||||||
|
|
||||||
|
|
|
@ -157,12 +157,7 @@ defmodule Mobilizon.Web.PageController do
|
||||||
defp is_local?(%{local: local}), do: if(local, do: true, else: :remote)
|
defp is_local?(%{local: local}), do: if(local, do: true, else: :remote)
|
||||||
defp is_local?(_), do: false
|
defp is_local?(_), do: false
|
||||||
|
|
||||||
defp maybe_add_noindex_header(conn, %Event{visibility: visibility})
|
defp maybe_add_noindex_header(conn, %{visibility: visibility})
|
||||||
when visibility != :public do
|
|
||||||
put_resp_header(conn, "x-robots-tag", "noindex")
|
|
||||||
end
|
|
||||||
|
|
||||||
defp maybe_add_noindex_header(conn, %Post{visibility: visibility})
|
|
||||||
when visibility != :public do
|
when visibility != :public do
|
||||||
put_resp_header(conn, "x-robots-tag", "noindex")
|
put_resp_header(conn, "x-robots-tag", "noindex")
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,6 +8,16 @@ defmodule Mobilizon.Web.JsonLD.ObjectView do
|
||||||
alias Mobilizon.Web.JsonLD.ObjectView
|
alias Mobilizon.Web.JsonLD.ObjectView
|
||||||
alias Mobilizon.Web.MediaProxy
|
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
|
def render("event.json", %{event: %Event{} = event}) do
|
||||||
organizer = %{
|
organizer = %{
|
||||||
"@type" => if(event.organizer_actor.type == :Group, do: "Organization", else: "Person"),
|
"@type" => if(event.organizer_actor.type == :Group, do: "Organization", else: "Person"),
|
||||||
|
@ -56,14 +66,18 @@ defmodule Mobilizon.Web.JsonLD.ObjectView do
|
||||||
%{
|
%{
|
||||||
"@type" => "Place",
|
"@type" => "Place",
|
||||||
"name" => address.description,
|
"name" => address.description,
|
||||||
"address" => %{
|
"address" => render_one(address, ObjectView, "address.json", as: :address)
|
||||||
"@type" => "PostalAddress",
|
}
|
||||||
"streetAddress" => address.street,
|
end
|
||||||
"addressLocality" => address.locality,
|
|
||||||
"postalCode" => address.postal_code,
|
def render("address.json", %{address: %Address{} = address}) do
|
||||||
"addressRegion" => address.region,
|
%{
|
||||||
"addressCountry" => address.country
|
"@type" => "PostalAddress",
|
||||||
}
|
"streetAddress" => address.street,
|
||||||
|
"addressLocality" => address.locality,
|
||||||
|
"postalCode" => address.postal_code,
|
||||||
|
"addressRegion" => address.region,
|
||||||
|
"addressCountry" => address.country
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -81,7 +95,7 @@ defmodule Mobilizon.Web.JsonLD.ObjectView do
|
||||||
}
|
}
|
||||||
end
|
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)
|
do: render_one(address, ObjectView, "place.json", as: :address)
|
||||||
|
|
||||||
# For now the Virtual Location of an event is it's own URL,
|
# 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
|
"url" => event_url
|
||||||
}
|
}
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue