1
0
Fork 0
mirror of https://framagit.org/framasoft/mobilizon.git synced 2024-12-26 17:59:26 +00:00

Merge branch 'bug/fix-preview' into 'master'

Fix preview

See merge request framasoft/mobilizon!235
This commit is contained in:
Thomas Citharel 2019-10-10 13:22:28 +02:00
commit 739c6c63af
3 changed files with 18 additions and 2 deletions

View file

@ -6,7 +6,6 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>mobilizon</title>
<!--server-generated-meta--> <!--server-generated-meta-->
</head> </head>

View file

@ -474,7 +474,13 @@ export default class Event extends EventMixin {
} }
get emailShareUrl(): string { get emailShareUrl(): string {
return `mailto:?to=&body=${this.event.url}${encodeURIComponent('\n\n')}${this.event.description}&subject=${this.event.title}`; return `mailto:?to=&body=${this.event.url}${encodeURIComponent('\n\n')}${this.textDescription}&subject=${this.event.title}`;
}
get textDescription(): string {
const meta = document.querySelector("meta[property='og:description']");
if (!meta) return '';
return meta.getAttribute('content') || '';
} }
} }

View file

@ -6,7 +6,11 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Events.Event do
alias MobilizonWeb.MediaProxy alias MobilizonWeb.MediaProxy
def build_tags(%Event{} = event) do def build_tags(%Event{} = event) do
event = Map.put(event, :description, process_description(event.description))
tags = [ tags = [
Tag.content_tag(:title, event.title <> " - Mobilizon"),
Tag.tag(:meta, name: "description", content: event.description),
Tag.tag(:meta, property: "og:title", content: event.title), Tag.tag(:meta, property: "og:title", content: event.title),
Tag.tag(:meta, property: "og:url", content: event.url), Tag.tag(:meta, property: "og:url", content: event.url),
Tag.tag(:meta, property: "og:description", content: event.description), Tag.tag(:meta, property: "og:description", content: event.description),
@ -33,6 +37,13 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Events.Event do
] ]
end end
defp process_description(description) do
description
|> HtmlSanitizeEx.strip_tags()
|> String.slice(0..200)
|> (&"#{&1}").()
end
# Insert JSON-LD schema by hand because Tag.content_tag wants to escape it # Insert JSON-LD schema by hand because Tag.content_tag wants to escape it
defp json(%Event{} = event) do defp json(%Event{} = event) do
"event.json" "event.json"