# Description > If this is a code change, please include a summary of what you've coded, and link to the issue(s) it closes/implements. > > If this is a documentation change, please briefly describe what you've changed and why. More dicking about with opengraph meta stuff. This one preserves whitespace and newlines and indentation and stuff inside of ogmeta description tags. Should make multi-line posts look a LOT better when linked in discord etc.  Also closes https://codeberg.org/superseriousbusiness/gotosocial/issues/2452 for all intents + purposes, since text inside description tags is now converted to text, and go templating escapes them instead of them being escaped and *then* truncated. ## Checklist Please put an x inside each checkbox to indicate that you've read and followed it: `[ ]` -> `[x]` If this is a documentation change, only the first two checkboxes must be filled (you can delete the others if you want). - [x] I/we have read the [GoToSocial contribution guidelines](https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/CONTRIBUTING.md). - [x] I/we have not used so-called 'AI' to create the proposed changes. - [x] I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat. - [x] I/we have performed a self-review of added code. - [x] I/we have written code that is legible and maintainable by others. - [x] I/we have commented the added code, particularly in hard-to-understand areas. - [x] I/we have made any necessary changes to documentation. - [x] I/we have added tests that cover new code. - [x] I/we have run tests and they pass locally with the changes. - [x] I/we have run `go fmt ./...` and `golangci-lint run`. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4658 Co-authored-by: tobi <tobi.smethurst@protonmail.com> Co-committed-by: tobi <tobi.smethurst@protonmail.com>
80 lines
3.0 KiB
Cheetah
80 lines
3.0 KiB
Cheetah
{{- /*
|
|
// GoToSocial
|
|
// Copyright (C) GoToSocial Authors admin@gotosocial.org
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Affero General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/ -}}
|
|
|
|
{{- /*
|
|
OPEN GRAPH META TAGS
|
|
To enable fancy previews of links to GtS posts/profiles shared via instant
|
|
messaging, or other social media, parse out provided Open Graph meta tags.
|
|
*/ -}}
|
|
|
|
{{- with .ogMeta }}
|
|
{{- if .Locale }}
|
|
<meta property="og:locale" content="{{- .Locale -}}">
|
|
{{- else }}
|
|
{{- end }}
|
|
<meta property="og:type" content="{{- .Type -}}">
|
|
<meta property="og:title" content="{{- demojify .Title | noescape -}}">
|
|
<meta property="og:url" content="{{- .URL -}}">
|
|
<meta property="og:site_name" content="{{- .SiteName -}}">
|
|
<meta property="og:description" content="{{- .Description -}}">
|
|
<meta name="description" content="{{- .Description -}}">
|
|
{{- if .ArticlePublisher }}
|
|
<meta property="og:article:publisher" content="{{ .ArticlePublisher }}">
|
|
<meta property="og:article:author" content="{{ .ArticleAuthor }}">
|
|
<meta property="og:modified_time" content="{{ .ArticleModifiedTime }}">
|
|
<meta property="og:article:modified_time" content="{{ .ArticleModifiedTime }}">
|
|
<meta property="og:published_time" content="{{ .ArticlePublishedTime }}">
|
|
<meta property="og:article:published_time" content="{{ .ArticlePublishedTime }}">
|
|
{{- else }}
|
|
{{- end }}
|
|
{{- if .ProfileUsername }}
|
|
<meta property="og:profile:username" content="{{- .ProfileUsername -}}">
|
|
{{- else }}
|
|
{{- end }}
|
|
{{- range $i, $m := .Media }}
|
|
<meta property="og:{{- $m.OGType -}}" content="{{- $m.URL -}}">
|
|
{{- if or (eq $m.OGType "video") (eq $m.OGType "audio") }}
|
|
<meta property="og:{{- $m.OGType -}}:secure_url" content="{{- $m.URL -}}">
|
|
{{- else }}
|
|
{{- end }}
|
|
{{- if $m.MIMEType }}
|
|
<meta property="og:{{- $m.OGType -}}:type" content="{{ $m.MIMEType }}">
|
|
{{- else }}
|
|
{{- end }}
|
|
{{- if $m.Width }}
|
|
<meta property="og:{{- $m.OGType -}}:width" content="{{ $m.Width }}">
|
|
<meta property="og:{{- $m.OGType -}}:height" content="{{ $m.Height }}">
|
|
{{- else }}
|
|
{{- end }}
|
|
{{- if $m.Alt }}
|
|
<meta property="og:{{- $m.OGType -}}:alt" content="{{ $m.Alt }}">
|
|
{{- else }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- if .TwitterSummaryLargeImage }}
|
|
<meta name="twitter:card" content="summary_large_image">
|
|
<meta name="twitter:image" content="{{- .TwitterSummaryLargeImage -}}">
|
|
{{- if .TwitterImageAlt }}
|
|
<meta name="twitter:image:alt" content="{{- .TwitterImageAlt -}}">
|
|
{{- else }}
|
|
{{- end }}
|
|
{{- else }}
|
|
<meta name="twitter:card" content="summary">
|
|
{{- end }}
|
|
{{- end }} |