Merge pull request 'Add OpenGraph meta tags for rich embeds' (#311) from redmt/teddit:add_opengraph_meta_tags_for_embeds into main

Reviewed-on: https://codeberg.org/teddit/teddit/pulls/311
This commit is contained in:
teddit 2022-06-10 19:14:31 +02:00
commit 1c9b125b70
18 changed files with 83 additions and 0 deletions

View File

@ -155,6 +155,7 @@ async function processJsonPost(json, parsed, user_preferences) {
images: null,
crosspost: false,
selftext: unescape(post.selftext_html),
selftext_preview: post.selftext.substr(0, 120).replace(/\n/g, ' '),
poll_data: post.poll_data,
link_flair:
user_preferences.flairs != 'false' ? await formatLinkFlair(post) : '',

BIN
static/logo512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View File

@ -2,6 +2,9 @@ doctype html
html
head
title about - teddit
meta(property='og:title', content='about - teddit')
include includes/meta_default.pug
include includes/meta_description.pug
include includes/head.pug
body(class=""+ (user_preferences.theme === 'auto' ? 'dark' : user_preferences.theme) + "")
include includes/topbar.pug

View File

@ -6,6 +6,7 @@ if(user_preferences.theme === 'sepia')
link(rel="stylesheet", type="text/css", href="/css/sepia.css")
link(rel="stylesheet", type="text/css", href="/css/styles.css")
link(rel="icon", type="image/png", sizes="32x32", href="/favicon.png")
meta(property='og:site_name', content='teddit')
meta(name="viewport", content="width=device-width, initial-scale=1.0")
-
if(!user_preferences)

View File

@ -0,0 +1,3 @@
meta(property='og:type', content='website')
meta(name='twitter:card', content='summary')
include meta_logo.pug

View File

@ -0,0 +1 @@
meta(property='og:description', content='Teddit is a free and open source alternative Reddit front-end focused on privacy. Teddit doesn\'t require you to have JavaScript enabled in your browser.')

View File

@ -0,0 +1,4 @@
meta(property='og:image', content='/logo512.png')
meta(property='og:image:width', content='128')
meta(property='og:image:height', content='128')
meta(property='og:author_name', content='')

View File

@ -0,0 +1,43 @@
meta(property='og:title', content=cleanTitle(post.title) + ' : r/' + subreddit)
meta(property='og:description', content='' + post.selftext_preview)
meta(property='og:author_name', content='u/' + post.author)
if !post.has_media
if post.gallery
meta(property='twitter:card', content='summary_large_image')
meta(property='og:type', content='image')
each item in post.gallery_items
meta(property='og:image', content='' + item.large)
else
if post.images
meta(property='twitter:card', content='summary_large_image')
meta(property='og:type', content='image')
meta(property='og:image', content='' + post.images.source)
meta(property='og:image:url', content='' + post.images.source)
else
include meta_logo.pug
else
if post.media
if post.media.not_hosted_in_reddit
if post.media.source === 'YouTube'
meta(property='twitter:card', content='player')
meta(property='og:type', content='video')
meta(property='og:video', content='' + post.media.embed_src)
else
if post.media.source === 'external'
if post.images
meta(name='twitter:card', content='summary_large_image')
meta(property='og:type', content='image')
meta(property='og:image', content='' + post.images.source)
meta(property='og:image:src', content='' + post.images.source)
else
meta(name='twitter:card', content='summary_large_image')
meta(property='og:type', content='image')
meta(property='og:image', content='' + post.media.source)
meta(property='og:image:url', content='' + post.media.source)
else
meta(property='twitter:card', content='player')
meta(property='og:type', content='video')
meta(property='og:video', content='' + post.media.source)
meta(property='og:video:type', content='video/mp4')
else
include meta_logo.pug

View File

@ -2,6 +2,9 @@ doctype html
html
head
title teddit
meta(property='og:title', content='frontpage : teddit')
include includes/meta_default.pug
include includes/meta_description.pug
include includes/head.pug
body(class=""+ (user_preferences.theme === 'auto' ? 'dark' : user_preferences.theme) + "")
include includes/topbar.pug

View File

@ -2,6 +2,7 @@ doctype html
html
head
title #{cleanTitle(post.title)} : #{subreddit}
include includes/meta_post.pug
include includes/head.pug
body(class=""+ (user_preferences.theme === 'auto' ? 'dark' : user_preferences.theme) + "")
include includes/topbar.pug

View File

@ -2,6 +2,9 @@ doctype html
html
head
title preferences - teddit
meta(property='og:title', content='preferences - teddit')
include includes/meta_default.pug
include includes/meta_description.pug
include includes/head.pug
body(class=""+ (user_preferences.theme === 'auto' ? 'dark' : user_preferences.theme) + "")
include includes/topbar.pug

View File

@ -2,6 +2,9 @@ doctype html
html
head
title privacy policy - teddit
meta(property='og:title', content='privacy policy - teddit')
include includes/meta_default.pug
include includes/meta_description.pug
include includes/head.pug
body(class=""+ (user_preferences.theme === 'auto' ? 'dark' : user_preferences.theme) + "")
include includes/topbar.pug

View File

@ -2,6 +2,9 @@ doctype html
html
head
title saved
meta(property='og:title', content='saved - teddit')
include includes/meta_default.pug
include includes/meta_description.pug
include includes/head.pug
body(class=""+ (user_preferences.theme === 'auto' ? 'dark' : user_preferences.theme) + "")
include includes/topbar.pug

View File

@ -3,8 +3,12 @@ html
head
if no_query
title search teddit
meta(property='og:title', content='search - teddit')
else
title search results for #{q}
meta(property='og:title', content='search results for ' + q + ' - teddit')
include includes/meta_default.pug
include includes/meta_description.pug
include includes/head.pug
body(class=""+ (user_preferences.theme === 'auto' ? 'dark' : user_preferences.theme) + "")
include includes/topbar.pug

View File

@ -2,6 +2,9 @@ doctype html
html
head
title /r/#{subreddit}
meta(property='og:title', content='/r/' + subreddit)
meta(property='og:description', content='' + unescape(subreddit_about.public_description_html, user_preferences))
include includes/meta_default.pug
include includes/head.pug
body(class=""+ (user_preferences.theme === 'auto' ? 'dark' : user_preferences.theme) + "")
include includes/topbar.pug

View File

@ -2,6 +2,8 @@ doctype html
html
head
title wiki /r/#{subreddit}
meta(property='og:title', content='wiki /r/' + subreddit)
include includes/meta_default.pug
include includes/head.pug
body(class=""+ (user_preferences.theme === 'auto' ? 'dark' : user_preferences.theme) + "")
include includes/topbar.pug

View File

@ -2,6 +2,9 @@ doctype html
html
head
title subreddits - explore
meta(property='og:title', content='explore subreddits - teddit')
include includes/meta_default.pug
include includes/meta_description.pug
include includes/head.pug
body(class=""+ (user_preferences.theme === 'auto' ? 'dark' : user_preferences.theme) + "")
include includes/topbar.pug

View File

@ -2,6 +2,8 @@ doctype html
html
head
title overview for #{data.username}
meta(property='og:title', content='u/' + data.username + ' - teddit')
include includes/meta_default.pug
include includes/head.pug
body(class=""+ (user_preferences.theme === 'auto' ? 'dark' : user_preferences.theme) + "")
include includes/topbar.pug