diff --git a/inc/processJsonPost.js b/inc/processJsonPost.js index f382ee5..b3cd784 100644 --- a/inc/processJsonPost.js +++ b/inc/processJsonPost.js @@ -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) : '', diff --git a/static/logo512.png b/static/logo512.png new file mode 100644 index 0000000..fcb5afe Binary files /dev/null and b/static/logo512.png differ diff --git a/views/about.pug b/views/about.pug index 74cce84..b4d8432 100644 --- a/views/about.pug +++ b/views/about.pug @@ -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 diff --git a/views/includes/head.pug b/views/includes/head.pug index 2bf6ee8..8761b3c 100644 --- a/views/includes/head.pug +++ b/views/includes/head.pug @@ -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) diff --git a/views/includes/meta_default.pug b/views/includes/meta_default.pug new file mode 100644 index 0000000..1f8e8c2 --- /dev/null +++ b/views/includes/meta_default.pug @@ -0,0 +1,3 @@ +meta(property='og:type', content='website') +meta(name='twitter:card', content='summary') +include meta_logo.pug diff --git a/views/includes/meta_description.pug b/views/includes/meta_description.pug new file mode 100644 index 0000000..921dafe --- /dev/null +++ b/views/includes/meta_description.pug @@ -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.') diff --git a/views/includes/meta_logo.pug b/views/includes/meta_logo.pug new file mode 100644 index 0000000..876358d --- /dev/null +++ b/views/includes/meta_logo.pug @@ -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='') diff --git a/views/includes/meta_post.pug b/views/includes/meta_post.pug new file mode 100644 index 0000000..1577ab5 --- /dev/null +++ b/views/includes/meta_post.pug @@ -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 diff --git a/views/index.pug b/views/index.pug index 841ef48..ad973b7 100644 --- a/views/index.pug +++ b/views/index.pug @@ -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 diff --git a/views/post.pug b/views/post.pug index 4030147..cd607bc 100644 --- a/views/post.pug +++ b/views/post.pug @@ -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 diff --git a/views/preferences.pug b/views/preferences.pug index 1292510..47a857f 100644 --- a/views/preferences.pug +++ b/views/preferences.pug @@ -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 diff --git a/views/privacypolicy.pug b/views/privacypolicy.pug index 20bf2f9..7ca4e85 100644 --- a/views/privacypolicy.pug +++ b/views/privacypolicy.pug @@ -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 diff --git a/views/saved.pug b/views/saved.pug index d31f4b6..5c4c244 100644 --- a/views/saved.pug +++ b/views/saved.pug @@ -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 diff --git a/views/search.pug b/views/search.pug index 8957a4f..f93a557 100644 --- a/views/search.pug +++ b/views/search.pug @@ -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 diff --git a/views/subreddit.pug b/views/subreddit.pug index e0de866..89afd18 100644 --- a/views/subreddit.pug +++ b/views/subreddit.pug @@ -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 diff --git a/views/subreddit_wiki.pug b/views/subreddit_wiki.pug index bd09710..46a158f 100644 --- a/views/subreddit_wiki.pug +++ b/views/subreddit_wiki.pug @@ -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 diff --git a/views/subreddits_explore.pug b/views/subreddits_explore.pug index 55fa309..6d8a455 100644 --- a/views/subreddits_explore.pug +++ b/views/subreddits_explore.pug @@ -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 diff --git a/views/user.pug b/views/user.pug index fe67d8e..9471e8c 100644 --- a/views/user.pug +++ b/views/user.pug @@ -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