Added Open Graph/Twitter tags to podcast, apps, v4v, search, and stats pages
This commit is contained in:
5 files changed
+184
-11
No files matched your search
@@ -23,6 +23,7 @@
|
||||
"dompurify": "^2.4.3",
|
||||
"dotenv": "^8.2.0",
|
||||
"dotenv-webpack": "^8.0.1",
|
||||
"ejs": "^3.1.9",
|
||||
"express": "^4.17.1",
|
||||
"history": "^4.10.1",
|
||||
"moment": "^2.29.0",
|
||||
|
||||
+83
-1
@@ -5,6 +5,7 @@ const app = express() // create express app
|
||||
const { makeThreadcap, InMemoryCache, updateThreadcap, makeRateLimitedFetcher } = require('threadcap');
|
||||
const fetch = require('node-fetch');
|
||||
const packageJson = require('../package.json');
|
||||
const ejs = require('ejs')
|
||||
|
||||
// Gets the .env variables
|
||||
require('dotenv').config()
|
||||
@@ -23,6 +24,9 @@ const apiAdd = require('podcast-index-api')(
|
||||
process.env.API_ADD_SECRET
|
||||
)
|
||||
|
||||
app.set("view engine", "ejs")
|
||||
app.set("views", "./server/views")
|
||||
|
||||
app.use((req, res, next) => {
|
||||
|
||||
const { rawHeaders, httpVersion, method, socket, url } = req;
|
||||
@@ -258,12 +262,90 @@ app.use('/api/apps', async (req, res) => {
|
||||
|
||||
app.use('/api/images', express.static('./server/assets'))
|
||||
|
||||
// ------------------------------------------------
|
||||
// ---------- Pages with Open Graph tags ----------
|
||||
// ------------------------------------------------
|
||||
|
||||
app.use('/apps', (req, res) => {
|
||||
res.render('index', {
|
||||
'title': 'Apps',
|
||||
'path': req.originalUrl,
|
||||
})
|
||||
})
|
||||
|
||||
app.use('/add', (req, res) => {
|
||||
res.render('index', {
|
||||
'title': 'Add Feed',
|
||||
'path': req.originalUrl,
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
app.use('/podcast/value4value', (req, res) => {
|
||||
res.render('index', {
|
||||
'title': 'Value 4 Value Podcasts',
|
||||
'description': 'These podcasts are set up to receive Bitcoin payments in real-time over the Lightning network using compatible Podcasting 2.0 apps.',
|
||||
'path': req.originalUrl,
|
||||
})
|
||||
})
|
||||
|
||||
app.use('/podcast/:podcastid(\\d+)', async (req, res) => {
|
||||
const params = {
|
||||
'title': 'Podcast', // default title
|
||||
'path': req.originalUrl,
|
||||
}
|
||||
|
||||
if (req.query.episode) { // /podcast/41504?episode=15576217793
|
||||
const response = await api.episodesById(req.query.episode)
|
||||
|
||||
if (response?.episode?.id) {
|
||||
const { feedTitle, title, description, image } = response.episode
|
||||
const textDescription = description.replaceAll(/<\/?[^>]+(>|$)/gi, '').replaceAll(/[\r\n]/g, ' ')
|
||||
|
||||
params.title = feedTitle + ' | ' + title
|
||||
params.description = textDescription
|
||||
params.image = image
|
||||
}
|
||||
}
|
||||
else if (req.params.podcastid) { // /podcast/41504
|
||||
const response = await api.podcastsByFeedId(req.params.podcastid)
|
||||
|
||||
if (response?.feed?.id) {
|
||||
const { title, description, image } = response.feed
|
||||
const textDescription = description.replaceAll(/<\/?[^>]+(>|$)/gi, '').replaceAll(/[\r\n]/g, ' ')
|
||||
|
||||
params.title = title
|
||||
params.description = textDescription
|
||||
params.image = image
|
||||
}
|
||||
}
|
||||
|
||||
res.render('index', params)
|
||||
})
|
||||
|
||||
app.use('/search', (req, res) => {
|
||||
res.render('index', {
|
||||
'title': 'Search',
|
||||
'path': req.originalUrl,
|
||||
})
|
||||
})
|
||||
|
||||
app.use('/stats', (req, res) => {
|
||||
res.render('index', {
|
||||
'title': 'Stats',
|
||||
'path': req.originalUrl,
|
||||
})
|
||||
})
|
||||
|
||||
// ------------------------------------------------
|
||||
// ---------- Static content for client -----------
|
||||
// ------------------------------------------------
|
||||
|
||||
app.use(express.static('./server/www'))
|
||||
app.get('*', (req, res) => res.sendFile(path.resolve('server', 'www', 'index.html')))
|
||||
|
||||
app.get('*', (req, res) => {
|
||||
res.render('index', {})
|
||||
})
|
||||
|
||||
// ------------------------------------------------
|
||||
|
||||
|
||||
@@ -1,20 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<!--
|
||||
//
|
||||
// This file is used by Webpack to generate the actual EJS template in `views/index.ejs`
|
||||
//
|
||||
-->
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<!-- Style dependencies -->
|
||||
<!-- <link href="https://unpkg.com/normalize.css@^7.0.0" rel="stylesheet" /> -->
|
||||
<title>Podcastindex.org</title>
|
||||
<meta name="title" content="Podcastindex.org">
|
||||
<meta name="description" content="The Podcast Index is here to preserve, protect and extend the open, independent podcasting ecosystem.">
|
||||
<title><%= (locals.title ? locals.title + ' | ' : '') + 'Podcastindex.org' %></title>
|
||||
|
||||
<meta name="title" content="<%= (locals.title ? locals.title + ' | ' : '') + 'Podcastindex.org' %>">
|
||||
<meta name="description" content="<%= (locals.description || 'The Podcast Index is here to preserve, protect and extend the open, independent podcasting ecosystem.') %>">
|
||||
|
||||
<meta name="twitter:title" content="<%= (locals.title ? locals.title + ' | ' : '') + 'Podcastindex.org' %>">
|
||||
<meta name="twitter:description" content="<%= (locals.description || 'The Podcast Index is here to preserve, protect and extend the open, independent podcasting ecosystem.') %>">
|
||||
<meta name="twitter:site" content="@PodcastindexOrg">
|
||||
<meta name="twitter:url" content="https://podcastindex.org<%= (locals.path || '/') %>">
|
||||
<meta name="twitter:image" content="<%= locals.image || 'https://podcastindex.org/android-chrome-256x256.png' %>">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
|
||||
<meta property="og:title" content="<%= (locals.title ? locals.title + ' | ' : '') + 'Podcastindex.org' %>">
|
||||
<meta property="og:description" content="<%= (locals.description || 'The Podcast Index is here to preserve, protect and extend the open, independent podcasting ecosystem.') %>">
|
||||
<meta property="og:site_name" content="Podcastindex.org">
|
||||
<meta property="og:url" content="https://podcastindex.org<%= (locals.path || '/') %>">
|
||||
<meta property="og:image" content="<%= locals.image || 'https://podcastindex.org/android-chrome-256x256.png' %>">
|
||||
<meta property="og:image:width" content="256">
|
||||
<meta property="og:image:height" content="256">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:url" content="https://podcastindex.org/">
|
||||
<meta property="og:title" content="Podcastindex.org">
|
||||
<meta property="og:description" content="The Podcast Index is here to preserve, protect and extend the open, independent podcasting ecosystem.">
|
||||
<meta property="twitter:url" content="https://podcastindex.org/">
|
||||
<meta property="twitter:title" content="Podcastindex.org">
|
||||
<meta property="twitter:description" content="The Podcast Index is here to preserve, protect and extend the open, independent podcasting ecosystem.">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
+15
-1
@@ -13,6 +13,11 @@ module.exports = env => ({
|
||||
port: 9001,
|
||||
historyApiFallback: true,
|
||||
proxy: {
|
||||
'/': {
|
||||
changeOrigin: true,
|
||||
target: 'http://localhost:5001',
|
||||
pathRewrite: { '^/': '/' },
|
||||
},
|
||||
'/api': {
|
||||
changeOrigin: true,
|
||||
target: 'http://localhost:5001',
|
||||
@@ -22,8 +27,16 @@ module.exports = env => ({
|
||||
changeOrigin: true,
|
||||
target: 'http://localhost:5001',
|
||||
pathRewrite: { '^/namespace': '/namespace' },
|
||||
},
|
||||
'/podcast': {
|
||||
changeOrigin: true,
|
||||
target: 'http://localhost:5001',
|
||||
pathRewrite: { '^/podcast': '/podcast' },
|
||||
}
|
||||
},
|
||||
writeToDisk: (filePath) => {
|
||||
return /\.html$|\.ejs$/.test(filePath);
|
||||
}
|
||||
},
|
||||
entry: './ui/src/index.tsx',
|
||||
output: {
|
||||
@@ -101,7 +114,8 @@ module.exports = env => ({
|
||||
},
|
||||
plugins: [
|
||||
new HtmlWebpackPlugin({
|
||||
template: path.resolve(__dirname, './ui/public', 'index.html'),
|
||||
template: path.resolve(__dirname, './ui/public', 'index.ejs.html'),
|
||||
filename: path.resolve(__dirname, './server/views', 'index.ejs'),
|
||||
minify: {
|
||||
removeComments: true,
|
||||
removeRedundantAttributes: true,
|
||||
|
||||
@@ -5502,6 +5502,13 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"async@npm:^3.2.3":
|
||||
version: 3.2.4
|
||||
resolution: "async@npm:3.2.4"
|
||||
checksum: 43d07459a4e1d09b84a20772414aa684ff4de085cbcaec6eea3c7a8f8150e8c62aa6cd4e699fe8ee93c3a5b324e777d34642531875a0817a35697522c1b02e89
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"asynckit@npm:^0.4.0":
|
||||
version: 0.4.0
|
||||
resolution: "asynckit@npm:0.4.0"
|
||||
@@ -6954,6 +6961,16 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"chalk@npm:^4.0.2":
|
||||
version: 4.1.2
|
||||
resolution: "chalk@npm:4.1.2"
|
||||
dependencies:
|
||||
ansi-styles: ^4.1.0
|
||||
supports-color: ^7.1.0
|
||||
checksum: fe75c9d5c76a7a98d45495b91b2172fa3b7a09e0cc9370e5c8feb1c567b85c4288e2b3fded7cfdd7359ac28d6b3844feb8b82b8686842e93d23c827c417e83fc
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"character-entities-legacy@npm:^1.0.0":
|
||||
version: 1.1.4
|
||||
resolution: "character-entities-legacy@npm:1.1.4"
|
||||
@@ -8816,6 +8833,17 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"ejs@npm:^3.1.9":
|
||||
version: 3.1.9
|
||||
resolution: "ejs@npm:3.1.9"
|
||||
dependencies:
|
||||
jake: ^10.8.5
|
||||
bin:
|
||||
ejs: bin/cli.js
|
||||
checksum: af6f10eb815885ff8a8cfacc42c6b6cf87daf97a4884f87a30e0c3271fedd85d76a3a297d9c33a70e735b97ee632887f85e32854b9cdd3a2d97edf931519a35f
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"electron-to-chromium@npm:^1.3.247, electron-to-chromium@npm:^1.3.378, electron-to-chromium@npm:^1.3.571":
|
||||
version: 1.3.582
|
||||
resolution: "electron-to-chromium@npm:1.3.582"
|
||||
@@ -9957,6 +9985,15 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"filelist@npm:^1.0.4":
|
||||
version: 1.0.4
|
||||
resolution: "filelist@npm:1.0.4"
|
||||
dependencies:
|
||||
minimatch: ^5.0.1
|
||||
checksum: a303573b0821e17f2d5e9783688ab6fbfce5d52aaac842790ae85e704a6f5e4e3538660a63183d6453834dedf1e0f19a9dadcebfa3e926c72397694ea11f5160
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"filesize@npm:3.6.1":
|
||||
version: 3.6.1
|
||||
resolution: "filesize@npm:3.6.1"
|
||||
@@ -12605,6 +12642,20 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"jake@npm:^10.8.5":
|
||||
version: 10.8.7
|
||||
resolution: "jake@npm:10.8.7"
|
||||
dependencies:
|
||||
async: ^3.2.3
|
||||
chalk: ^4.0.2
|
||||
filelist: ^1.0.4
|
||||
minimatch: ^3.1.2
|
||||
bin:
|
||||
jake: bin/cli.js
|
||||
checksum: a23fd2273fb13f0d0d845502d02c791fd55ef5c6a2d207df72f72d8e1eac6d2b8ffa6caf660bc8006b3242e0daaa88a3ecc600194d72b5c6016ad56e9cd43553
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"jest-changed-files@npm:^24.9.0":
|
||||
version: 24.9.0
|
||||
resolution: "jest-changed-files@npm:24.9.0"
|
||||
@@ -14393,6 +14444,15 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"minimatch@npm:^3.1.2":
|
||||
version: 3.1.2
|
||||
resolution: "minimatch@npm:3.1.2"
|
||||
dependencies:
|
||||
brace-expansion: ^1.1.7
|
||||
checksum: c154e566406683e7bcb746e000b84d74465b3a832c45d59912b9b55cd50dee66e5c4b1e5566dba26154040e51672f9aa450a9aef0c97cfc7336b78b7afb9540a
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"minimatch@npm:^5.0.1":
|
||||
version: 5.1.6
|
||||
resolution: "minimatch@npm:5.1.6"
|
||||
@@ -16063,6 +16123,7 @@ __metadata:
|
||||
dompurify: ^2.4.3
|
||||
dotenv: ^8.2.0
|
||||
dotenv-webpack: ^8.0.1
|
||||
ejs: ^3.1.9
|
||||
express: ^4.17.1
|
||||
favicons-webpack-plugin: ^4.2.0
|
||||
file-loader: ^6.1.0
|
||||
|
||||
Reference in new issue
Block a user