Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
|
acafbe4670 | 3 years ago |
|
8392cf0c60 | 3 years ago |
@ -0,0 +1,4 @@ |
||||
{ |
||||
"typescript.tsdk": "node_modules/typescript/lib", |
||||
"typescript.enablePromptUseWorkspaceTsdk": true |
||||
} |
@ -1,91 +1,137 @@ |
||||
import Image from 'next/image' |
||||
import { Inter } from '@next/font/google' |
||||
import styles from './page.module.css' |
||||
"use client"; |
||||
|
||||
const inter = Inter({ subsets: ['latin'] }) |
||||
import React, { useState, useEffect} from 'react'; |
||||
import { |
||||
Container, |
||||
Grid, |
||||
Header, |
||||
List, |
||||
Segment, |
||||
Label, |
||||
} from 'semantic-ui-react'; |
||||
import { Item } from 'semantic-ui-react'; |
||||
import 'semantic-ui-css/semantic.min.css'; |
||||
import AudioPlayer from 'react-h5-audio-player'; |
||||
|
||||
export default function Home() { |
||||
return ( |
||||
<main className={styles.main}> |
||||
<div className={styles.description}> |
||||
<p> |
||||
Get started by editing |
||||
<code className={styles.code}>src/app/page.tsx</code> |
||||
</p> |
||||
<div> |
||||
<a |
||||
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app" |
||||
target="_blank" |
||||
rel="noopener noreferrer" |
||||
> |
||||
By{' '} |
||||
<Image |
||||
src="/vercel.svg" |
||||
alt="Vercel Logo" |
||||
className={styles.vercelLogo} |
||||
width={100} |
||||
height={24} |
||||
priority |
||||
/> |
||||
</a> |
||||
</div> |
||||
</div> |
||||
type Props = { |
||||
id: number; |
||||
audio: string; |
||||
description: string; |
||||
urlImg: string; |
||||
title: string; |
||||
children: Node; |
||||
} |
||||
|
||||
<div className={styles.center}> |
||||
<Image |
||||
className={styles.logo} |
||||
src="/next.svg" |
||||
alt="Next.js Logo" |
||||
width={180} |
||||
height={37} |
||||
priority |
||||
|
||||
const PodcastBlocks: React.FC<Props> = ({id, audio, description, urlImg, title}) => ( |
||||
<> |
||||
<Item> |
||||
<Item.Image size='medium' src={'img/'+urlImg} /> |
||||
<Item.Content> |
||||
<Item.Header as='a'>{title}</Item.Header> |
||||
<Item.Meta> |
||||
<span className='cinema'></span> |
||||
</Item.Meta> |
||||
<Item.Description> |
||||
{description} |
||||
</Item.Description> |
||||
<AudioPlayer |
||||
src={"audio/"+audio} |
||||
onPlay={e => console.log(id)} |
||||
// other props here
|
||||
/> |
||||
<div className={styles.thirteen}> |
||||
<Image src="/thirteen.svg" alt="13" width={40} height={31} priority /> |
||||
</div> |
||||
</div> |
||||
<Item.Extra> |
||||
<Label icon='globe' content='-' /> |
||||
</Item.Extra> |
||||
</Item.Content> |
||||
</Item> |
||||
</> |
||||
) |
||||
|
||||
|
||||
export default function Home() { |
||||
interface IUser { |
||||
[x: string]: any; |
||||
name: string; |
||||
}; |
||||
const [data, setData] = useState<IUser>(); |
||||
const [isLoading, setLoading] = useState(false) |
||||
|
||||
|
||||
useEffect(() => { |
||||
setLoading(true) |
||||
fetch('/api/podcasts/all') |
||||
.then((res) => res.json()) |
||||
.then((data) => { |
||||
setData(data); |
||||
setLoading(false); |
||||
}) |
||||
}, []) |
||||
|
||||
<div className={styles.grid}> |
||||
<a |
||||
href="https://beta.nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app" |
||||
className={styles.card} |
||||
target="_blank" |
||||
rel="noopener noreferrer" |
||||
> |
||||
<h2 className={inter.className}> |
||||
Docs <span>-></span> |
||||
</h2> |
||||
<p className={inter.className}> |
||||
Find in-depth information about Next.js features and API. |
||||
</p> |
||||
</a> |
||||
if (isLoading) return <p>Загрузка...</p> |
||||
if (!data) return <p>Нет интернета</p> |
||||
|
||||
<a |
||||
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app" |
||||
className={styles.card} |
||||
target="_blank" |
||||
rel="noopener noreferrer" |
||||
> |
||||
<h2 className={inter.className}> |
||||
Templates <span>-></span> |
||||
</h2> |
||||
<p className={inter.className}>Explore the Next.js 13 playground.</p> |
||||
</a> |
||||
const podcasts = data.map((obj: JSX.IntrinsicAttributes & Props, index: React.Key | null | undefined) => <PodcastBlocks key={index} {...obj}/> ); |
||||
|
||||
<a |
||||
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app" |
||||
className={styles.card} |
||||
target="_blank" |
||||
rel="noopener noreferrer" |
||||
> |
||||
<h2 className={inter.className}> |
||||
Deploy <span>-></span> |
||||
</h2> |
||||
<p className={inter.className}> |
||||
Instantly deploy your Next.js site to a shareable URL with Vercel. |
||||
</p> |
||||
</a> |
||||
</div> |
||||
</main> |
||||
return ( |
||||
<> |
||||
<Segment style={{ padding: '8em 0em' }} vertical> |
||||
<Grid container stackable verticalAlign='middle'> |
||||
<Grid.Row> |
||||
<Grid.Column width={8} textAlign='center'> |
||||
<Header as='h3' style={{ fontSize: '4em' }}> |
||||
BlogBaster |
||||
</Header> |
||||
<Header as='h3' style={{ fontSize: '2em' }}> |
||||
Увлечены. Качественно. |
||||
За новое звучание. |
||||
</Header> |
||||
<p style={{ fontSize: '1.33em' }}> |
||||
Если вы хотите стать нашим партнером или рекламодателем — пишите на podcast@blogbaster.xyz |
||||
</p> |
||||
</Grid.Column> |
||||
</Grid.Row> |
||||
</Grid> |
||||
</Segment> |
||||
<Segment style={{ padding: '8em 0em' }} vertical> |
||||
<Container textAlign='left'> |
||||
<Item.Group> |
||||
{podcasts} |
||||
</Item.Group> |
||||
</Container> |
||||
</Segment> |
||||
|
||||
<Segment inverted vertical style={{ padding: '5em 0em' }}> |
||||
<Container> |
||||
<Grid divided inverted stackable> |
||||
<Grid.Row> |
||||
<Grid.Column width={3}> |
||||
<Header inverted as='h4' content='Социальные сети' /> |
||||
<List link inverted> |
||||
<List.Item as='a'>Вконтакте</List.Item> |
||||
<List.Item as='a'>Telegram</List.Item> |
||||
</List> |
||||
</Grid.Column> |
||||
<Grid.Column width={3}> |
||||
<Header inverted as='h4' content='Платформы' /> |
||||
<List link inverted> |
||||
<List.Item as='a'>Яндекс музыка</List.Item> |
||||
<List.Item as='a'>Google подкасты</List.Item> |
||||
<List.Item as='a'>Apple подкасты</List.Item> |
||||
</List> |
||||
</Grid.Column> |
||||
<Grid.Column width={7}> |
||||
<Header as='h4' inverted> |
||||
О нас |
||||
</Header> |
||||
<p> |
||||
BlogBaster 2022 |
||||
</p> |
||||
</Grid.Column> |
||||
</Grid.Row> |
||||
</Grid> |
||||
</Container> |
||||
</Segment> |
||||
</> |
||||
) |
||||
} |
||||
} |
@ -0,0 +1,29 @@ |
||||
import { writeFileSync } from "fs"; |
||||
import { getAllPosts } from "./posts"; |
||||
import RSS from "rss"; |
||||
const post = [{title:'ddee', url:'dfdf', date:'12.12.22', description:'dfdf dfdf dfdf'}] |
||||
export default async function getRSS() { |
||||
const siteURL = "https://yourdomain.com"; |
||||
const allBlogs = getAllPosts(); |
||||
|
||||
const feed = new RSS({ |
||||
title: "Your Name", |
||||
description: "your description", |
||||
site_url: siteURL, |
||||
feed_url: `${siteURL}/feed.xml`, |
||||
language: "en", |
||||
pubDate: new Date(), |
||||
copyright: `All rights reserved ${new Date().getFullYear()}, Your Name`, |
||||
}); |
||||
|
||||
post.map((post) => { |
||||
feed.item({ |
||||
title: post.title, |
||||
url: `${siteURL}/blogs/${post.slug}`, |
||||
date: post.date, |
||||
description: post.excerpt, |
||||
}); |
||||
}); |
||||
|
||||
writeFileSync("../../public/feed.xml", feed.xml({ indent: true })); |
||||
} |
@ -0,0 +1,13 @@ |
||||
export function getAllPosts() { |
||||
const posts = getSlugs() |
||||
.map((slug) => { |
||||
return getFrontMatter(slug); |
||||
}) |
||||
.filter((post) => post != null || post != undefined) // Filter post if it is not published
|
||||
.sort((a, b) => { |
||||
if (new Date(a.date) > new Date(b.date)) return -1; |
||||
if (new Date(a.date) < new Date(b.date)) return 1; |
||||
return 0; |
||||
}); |
||||
return posts; |
||||
} |
@ -1,13 +0,0 @@ |
||||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
||||
import type { NextApiRequest, NextApiResponse } from 'next' |
||||
|
||||
type Data = { |
||||
name: string |
||||
} |
||||
|
||||
export default function handler( |
||||
req: NextApiRequest, |
||||
res: NextApiResponse<Data> |
||||
) { |
||||
res.status(200).json({ name: 'John Doe' }) |
||||
} |
@ -0,0 +1,13 @@ |
||||
import Select from "../../../server/db/select"; |
||||
import type { NextApiRequest, NextApiResponse } from 'next'; |
||||
|
||||
const sql = "SELECT * FROM podcasts WHERE status=1"; |
||||
|
||||
export default function handler( |
||||
req: NextApiRequest, |
||||
res: NextApiResponse |
||||
) { |
||||
Select(sql, function(data){ |
||||
res.status(200).json(data); |
||||
}) |
||||
} |
@ -0,0 +1,35 @@ |
||||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
||||
import type { NextApiRequest, NextApiResponse } from 'next' |
||||
import Select from "../../../../../server/db/select"; |
||||
import Insert from "../../../../../server/db/insert"; |
||||
import { getRssXml, Items } from '../../../../../сomponents/podcasts'; |
||||
|
||||
const id = 1; |
||||
|
||||
const sql_company = "SELECT * FROM podcasts, company WHERE podcasts.id="+id; |
||||
const sql_items = "SELECT * FROM `podcasts`, items, company WHERE podcasts.id=items.id_podcasts and podcasts.id="+id; |
||||
|
||||
const sql_userAgent = "INSERT INTO views (id_podcasts, userAgent,ip) VALUES (?,?,?)"; |
||||
|
||||
export default function handler( |
||||
req: NextApiRequest, |
||||
res: NextApiResponse |
||||
) { |
||||
const views = [id, req.headers['user-agent'], req.socket.remoteAddress] |
||||
console.log(views); |
||||
Select(sql_company, function(data_company : any){ |
||||
Select(sql_items, function(data_items : any){ |
||||
res.setHeader('Content-Type', 'text/xml'); |
||||
res.status(200).send(getRssXml(data_company[0])+data_items.map((rows : any) => Items(rows))+'</channel> </rss>'); |
||||
}) |
||||
|
||||
}) |
||||
Insert(sql_userAgent, views as string[], function(message){ |
||||
console.log(message); |
||||
}) |
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,117 @@ |
||||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
||||
import type { NextApiRequest, NextApiResponse } from 'next' |
||||
import Select from "../../../../../server/db/select"; |
||||
|
||||
|
||||
const sql = "SELECT * FROM podcasts WHERE status=1 and podcasts='Поуехали'"; |
||||
|
||||
const title ='Поуехали'; |
||||
const atom_link = 'https://blogbaster.xyz/api/podcasts/lets-go/'; |
||||
const email = 'crapsh@gmail.com'; |
||||
const nameCompanies= 'BlogBaster'; |
||||
const description = 'Интервью с людьми, которые переехали за границу на ПМЖ. Аргентина, Америка, Турция, Грузия, Израиль… зачем, сколько и почему?'; |
||||
const webSite = 'https://blogbaster.xyz'; |
||||
const urlImg = 'https://blogbaster.xyz/img/poyexali.jpg'; |
||||
const lastBuildDate = 'Fri, 06 May 2022 15:30:47 +0000'; |
||||
|
||||
interface Rows { |
||||
episode: number; |
||||
podcasts: string; |
||||
title: string; |
||||
description: string; |
||||
guid: string; |
||||
pubDate: string; |
||||
duration: number; |
||||
urlImg: string; |
||||
fileSize: number; |
||||
audio: string; |
||||
} |
||||
|
||||
const item = (data: Rows) => { |
||||
let items =` |
||||
<item> |
||||
<itunes:episodeType>full</itunes:episodeType> |
||||
<itunes:episode>`+data.episode+`</itunes:episode> |
||||
<itunes:season>1</itunes:season> |
||||
<title><![CDATA[`+data.podcasts+': '+data.title+`]]></title> |
||||
<description><![CDATA[`+data.description+`]]></description> |
||||
<googleplay:description>`+data.description+`</googleplay:description> |
||||
<itunes:summary>`+data.description+`</itunes:summary> |
||||
<guid isPermaLink="false">`+data.guid+`</guid> |
||||
<pubDate>`+data.pubDate+`</pubDate> |
||||
<itunes:duration>`+data.duration+`</itunes:duration> |
||||
<link>`+webSite+'/podcast/'+data.guid+`</link> |
||||
<googleplay:image href="/img/`+data.urlImg+`"/> |
||||
<itunes:image href="/img/`+data.urlImg+`"/> |
||||
<googleplay:explicit>no</googleplay:explicit> |
||||
<itunes:explicit>false</itunes:explicit> |
||||
<enclosure url="'https://blogbaster.xyz/audio/`+data.audio+`" length="`+data.fileSize+`" type="audio/mpeg"/> |
||||
<media:title>`+data.podcasts+': '+data.title+`</media:title> |
||||
<media:content url="https://blogbaster.xyz/audio/`+data.audio+`" fileSize="`+data.fileSize+`" type="audio/mpeg" medium="audio" isDefault="true" expression="full" bitrate="320" channels="2" duration="`+data.duration+`" lang="ru"/> |
||||
<media:thumbnail url="/img/`+data.urlImg+`" width="150" height="150"/> |
||||
<media:copyright url="`+webSite+`">© 2022 `+nameCompanies+`</media:copyright> |
||||
<creativeCommons:license>https://creativecommons.org/licenses/by/4.0/</creativeCommons:license>
|
||||
</item>`;
|
||||
return(items) |
||||
} |
||||
|
||||
const getRssXml = (data: Array<string>) =>
|
||||
`<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0" |
||||
xmlns:atom="http://www.w3.org/2005/Atom" |
||||
xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0/play-podcasts.xsd" |
||||
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" |
||||
xmlns:content="http://purl.org/rss/1.0/modules/content/" |
||||
xmlns:media="http://search.yahoo.com/mrss/" |
||||
xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" |
||||
> |
||||
<channel> |
||||
<title>`+title+`</title> |
||||
<atom:link href="`+atom_link+`" rel="self" type="application/rss+xml"/> |
||||
<googleplay:owner>`+email+`</googleplay:owner> |
||||
<itunes:owner> |
||||
<itunes:name>`+nameCompanies+`</itunes:name> |
||||
<itunes:email>`+email+`</itunes:email> |
||||
</itunes:owner> |
||||
<googleplay:author>`+nameCompanies+`</googleplay:author> |
||||
<itunes:author>`+nameCompanies+`</itunes:author> |
||||
<description>`+description+`</description> |
||||
<googleplay:description>`+description+`</googleplay:description> |
||||
<itunes:summary>`+description+`</itunes:summary> |
||||
<image> |
||||
<link>`+webSite+`</link> |
||||
<title>`+nameCompanies+`</title> |
||||
<url>`+urlImg+`</url> |
||||
</image> |
||||
<googleplay:image href="`+urlImg+`"/> |
||||
<itunes:image href="`+urlImg+`"/> |
||||
<itunes:category text="Society & Culture"> |
||||
<itunes:category text="Places & Travel"/> |
||||
</itunes:category> |
||||
<itunes:category text="Science"> |
||||
<itunes:category text="Social Sciences"/> |
||||
</itunes:category> |
||||
<language>ru</language> |
||||
<link>`+webSite+`</link> |
||||
<copyright>© 2023 `+nameCompanies+`</copyright> |
||||
<itunes:type>episodic</itunes:type> |
||||
<googleplay:explicit>no</googleplay:explicit> |
||||
<itunes:explicit>no</itunes:explicit> |
||||
<lastBuildDate>`+lastBuildDate+`</lastBuildDate> |
||||
<googleplay:block>yes</googleplay:block> |
||||
`+data.map((rows : any) => item(rows))+` |
||||
</channel> |
||||
</rss>`;
|
||||
|
||||
export default function handler( |
||||
req: NextApiRequest, |
||||
res: NextApiResponse |
||||
) { |
||||
const userAgent = req.headers['user-agent']; |
||||
console.log(userAgent); |
||||
Select(sql, function(data : any){ |
||||
res.setHeader('Content-Type', 'text/xml'); |
||||
res.status(200).send(getRssXml(data)); |
||||
}) |
||||
|
||||
} |
@ -0,0 +1,117 @@ |
||||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
||||
import type { NextApiRequest, NextApiResponse } from 'next' |
||||
import Select from "../../../../../server/db/select"; |
||||
|
||||
|
||||
const sql = "SELECT * FROM podcasts WHERE status=1 and podcasts='Нравится слушать'"; |
||||
|
||||
const title ='Нравится слушать'; |
||||
const atom_link = 'https://blogbaster.xyz/api/podcasts/like-to-listen/'; |
||||
const email = 'crapsh@gmail.com'; |
||||
const nameCompanies= 'BlogBaster'; |
||||
const description = 'Мы молодая команда из Краснодара, создаем подкасты для молодежи'; |
||||
const webSite = 'https://blogbaster.xyz'; |
||||
const urlImg = 'https://blogbaster.xyz/img/Like-to-listen.jpg'; |
||||
const lastBuildDate = 'Fri, 06 May 2022 15:30:47 +0000'; |
||||
|
||||
interface Rows { |
||||
episode: number; |
||||
podcasts: string; |
||||
title: string; |
||||
description: string; |
||||
guid: string; |
||||
pubDate: string; |
||||
duration: number; |
||||
urlImg: string; |
||||
fileSize: number; |
||||
audio: string; |
||||
} |
||||
|
||||
const item = (data: Rows) => { |
||||
let items =` |
||||
<item> |
||||
<itunes:episodeType>full</itunes:episodeType> |
||||
<itunes:episode>`+data.episode+`</itunes:episode> |
||||
<itunes:season>1</itunes:season> |
||||
<title>`+data.podcasts+': '+data.title+`</title> |
||||
<description>`+data.description+`</description> |
||||
<googleplay:description>`+data.description+`</googleplay:description> |
||||
<itunes:summary>`+data.description+`</itunes:summary> |
||||
<guid isPermaLink="false">`+data.guid+`</guid> |
||||
<pubDate>`+data.pubDate+`</pubDate> |
||||
<itunes:duration>`+data.duration+`</itunes:duration> |
||||
<link>`+webSite+'/podcast/'+data.guid+`</link> |
||||
<googleplay:image href="/img/`+data.urlImg+`"/> |
||||
<itunes:image href="/img/`+data.urlImg+`"/> |
||||
<googleplay:explicit>no</googleplay:explicit> |
||||
<itunes:explicit>false</itunes:explicit> |
||||
<enclosure url="'https://blogbaster.xyz/audio/`+data.audio+`" length="`+data.fileSize+`" type="audio/mpeg"/> |
||||
<media:title>`+data.podcasts+': '+data.title+`</media:title> |
||||
<media:content url="https://blogbaster.xyz/audio/`+data.audio+`" fileSize="`+data.fileSize+`" type="audio/mpeg" medium="audio" isDefault="true" expression="full" bitrate="320" channels="2" duration="`+data.duration+`" lang="ru"/> |
||||
<media:thumbnail url="/img/`+data.urlImg+`" width="150" height="150"/> |
||||
<media:copyright url="`+webSite+`">© 2022 `+nameCompanies+`</media:copyright> |
||||
<creativeCommons:license>https://creativecommons.org/licenses/by/4.0/</creativeCommons:license>
|
||||
</item>`;
|
||||
return(items) |
||||
} |
||||
|
||||
const getRssXml = (data: Array<string>) =>
|
||||
`<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0" |
||||
xmlns:atom="http://www.w3.org/2005/Atom" |
||||
xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0/play-podcasts.xsd" |
||||
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" |
||||
xmlns:content="http://purl.org/rss/1.0/modules/content/" |
||||
xmlns:media="http://search.yahoo.com/mrss/" |
||||
xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" |
||||
> |
||||
<channel> |
||||
<title>`+title+`</title> |
||||
<atom:link href="`+atom_link+`" rel="self" type="application/rss+xml"/> |
||||
<googleplay:owner>`+email+`</googleplay:owner> |
||||
<itunes:owner> |
||||
<itunes:name>`+nameCompanies+`</itunes:name> |
||||
<itunes:email>`+email+`</itunes:email> |
||||
</itunes:owner> |
||||
<googleplay:author>`+nameCompanies+`</googleplay:author> |
||||
<itunes:author>`+nameCompanies+`</itunes:author> |
||||
<description>`+description+`</description> |
||||
<googleplay:description>`+description+`</googleplay:description> |
||||
<itunes:summary>`+description+`</itunes:summary> |
||||
<image> |
||||
<link>`+webSite+'/'+webSite+`</link> |
||||
<title>`+nameCompanies+`</title> |
||||
<url>`+webSite+'/'+urlImg+`</url> |
||||
</image> |
||||
<googleplay:image href="`+webSite+'/'+urlImg+`"/> |
||||
<itunes:image href="`+webSite+'/'+urlImg+`"/> |
||||
<itunes:category text="Society & Culture"> |
||||
<itunes:category text="Places & Travel"/> |
||||
</itunes:category> |
||||
<itunes:category text="Science"> |
||||
<itunes:category text="Social Sciences"/> |
||||
</itunes:category> |
||||
<language>ru</language> |
||||
<link>`+webSite+`</link> |
||||
<copyright>© 2022 `+nameCompanies+`</copyright> |
||||
<itunes:type>episodic</itunes:type> |
||||
<googleplay:explicit>no</googleplay:explicit> |
||||
<itunes:explicit>no</itunes:explicit> |
||||
<lastBuildDate>`+lastBuildDate+`</lastBuildDate> |
||||
<googleplay:block>yes</googleplay:block> |
||||
`+data.map((rows : any) => item(rows))+` |
||||
</channel> |
||||
</rss>`;
|
||||
|
||||
export default function handler( |
||||
req: NextApiRequest, |
||||
res: NextApiResponse |
||||
) { |
||||
const userAgent = req.headers['user-agent']; |
||||
console.log(userAgent); |
||||
Select(sql, function(data : any){ |
||||
res.setHeader('Content-Type', 'text/xml'); |
||||
res.status(200).send(getRssXml(data)); |
||||
}) |
||||
|
||||
} |
@ -0,0 +1,13 @@ |
||||
import mysql from "mysql2"; |
||||
|
||||
const pool = mysql.createPool({ |
||||
host: process.env.HOST, |
||||
user: process.env.DATABASE, |
||||
database: process.env.DATABASE, |
||||
password: process.env.PASSWORD, |
||||
waitForConnections: true, |
||||
connectionLimit: 10, |
||||
queueLimit: 0 |
||||
}); |
||||
|
||||
module.exports = pool; |
@ -0,0 +1,14 @@ |
||||
const pool = require("./connect"); |
||||
import {QueryError} from 'mysql2'; |
||||
|
||||
interface definitionInterface{ |
||||
(message:string):void; |
||||
} |
||||
export default function Insert(sql: string, argument: string[], callback: definitionInterface) { |
||||
pool.query(sql, argument, (err: QueryError, rows: string) => { |
||||
if (err) { |
||||
return console.error(err.message); |
||||
} |
||||
pool.releaseConnection(pool); |
||||
}); |
||||
} |
@ -0,0 +1,12 @@ |
||||
const pool = require("./connect"); |
||||
import {QueryError} from 'mysql2'; |
||||
|
||||
interface definitionInterface{ |
||||
(message:string):void; |
||||
} |
||||
export default function Select(sql: string, callback: definitionInterface) { |
||||
pool.query(sql, (err: QueryError, rows: string) => { |
||||
callback(rows); |
||||
pool.releaseConnection(pool); |
||||
}); |
||||
} |
@ -0,0 +1,42 @@ |
||||
interface Props { |
||||
episode: number; |
||||
title: string; |
||||
title_items : string; |
||||
description: string; |
||||
guid: string; |
||||
pubDate: string; |
||||
duration: number; |
||||
urlImg: string; |
||||
fileSize: number; |
||||
audio: string; |
||||
webSite: string; |
||||
nameCompanies: string; |
||||
} |
||||
|
||||
export const Items = (data: Props) => { |
||||
let item =` |
||||
<item> |
||||
<itunes:episodeType>full</itunes:episodeType> |
||||
<itunes:episode>`+data.episode+`</itunes:episode> |
||||
<itunes:season>1</itunes:season> |
||||
<title><![CDATA[`+data.title+': '+data.title_items +`]]></title> |
||||
<description><![CDATA[`+data.description+`]]></description> |
||||
<googleplay:description>`+data.description+`</googleplay:description> |
||||
<itunes:summary>`+data.description+`</itunes:summary> |
||||
<guid isPermaLink="false">`+data.guid+`</guid> |
||||
<pubDate>`+data.pubDate+`</pubDate> |
||||
<itunes:duration>`+data.duration+`</itunes:duration> |
||||
<link>`+data.webSite+'/podcast/'+data.guid+`</link> |
||||
<googleplay:image href="`+data.webSite+'/img/'+data.urlImg+`"/> |
||||
<itunes:image href="`+data.webSite+'/img/'+data.urlImg+`"/> |
||||
<googleplay:explicit>no</googleplay:explicit> |
||||
<itunes:explicit>false</itunes:explicit> |
||||
<enclosure url="`+data.webSite+'/audio/'+data.audio+`" length="`+data.fileSize+`" type="audio/mpeg"/> |
||||
<media:title>`+data.title+': '+data.title_items +`</media:title> |
||||
<media:content url="`+data.webSite+'/audio/'+data.audio+`" fileSize="`+data.fileSize+`" type="audio/mpeg" medium="audio" isDefault="true" expression="full" bitrate="320" channels="2" duration="`+data.duration+`" lang="ru"/> |
||||
<media:thumbnail url="`+data.webSite+'/img/'+data.urlImg+`" width="150" height="150"/> |
||||
<media:copyright url="`+data.webSite+`">© 2022 `+data.nameCompanies+`</media:copyright> |
||||
<creativeCommons:license>https://creativecommons.org/licenses/by/4.0/</creativeCommons:license>
|
||||
</item>`;
|
||||
return(item) |
||||
}; |
@ -0,0 +1,61 @@ |
||||
import { Items } from './Item' |
||||
|
||||
interface Props { |
||||
map(arg0: (rows: any) => string): unknown; |
||||
title: string, |
||||
atom_link: string, |
||||
email: string, |
||||
nameCompanies: string, |
||||
description: string, |
||||
webSite: string, |
||||
urlImg: string, |
||||
lastBuildDate: string |
||||
} |
||||
|
||||
export const getRssXml = (data: Props) => { |
||||
let item =` |
||||
<rss version="2.0" |
||||
xmlns:atom="http://www.w3.org/2005/Atom" |
||||
xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0/play-podcasts.xsd" |
||||
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" |
||||
xmlns:content="http://purl.org/rss/1.0/modules/content/" |
||||
xmlns:media="http://search.yahoo.com/mrss/" |
||||
xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" |
||||
> |
||||
<channel> |
||||
<title>`+data.title+`</title> |
||||
<atom:link href="`+data.atom_link+`" rel="self" type="application/rss+xml"/> |
||||
<googleplay:owner>`+data.email+`</googleplay:owner> |
||||
<itunes:owner> |
||||
<itunes:name>`+data.nameCompanies+`</itunes:name> |
||||
<itunes:email>`+data.email+`</itunes:email> |
||||
</itunes:owner> |
||||
<googleplay:author>`+data.nameCompanies+`</googleplay:author> |
||||
<itunes:author>`+data.nameCompanies+`</itunes:author> |
||||
<description>`+data.description+`</description> |
||||
<googleplay:description>`+data.description+`</googleplay:description> |
||||
<itunes:summary>`+data.description+`</itunes:summary> |
||||
<image> |
||||
<link>`+data.webSite+`</link> |
||||
<title>`+data.nameCompanies+`</title> |
||||
<url>`+data.webSite+'/'+data.urlImg+`</url> |
||||
</image> |
||||
<googleplay:image href="`+data.webSite+'/'+data.urlImg+`"/> |
||||
<itunes:image href="`+data.webSite+'/'+data.urlImg+`"/> |
||||
<itunes:category text="Society & Culture"> |
||||
<itunes:category text="Places & Travel"/> |
||||
</itunes:category> |
||||
<itunes:category text="Science"> |
||||
<itunes:category text="Social Sciences"/> |
||||
</itunes:category> |
||||
<language>ru</language> |
||||
<link>`+data.webSite+`</link> |
||||
<copyright>© 2022 `+data.nameCompanies+`</copyright> |
||||
<itunes:type>episodic</itunes:type> |
||||
<googleplay:explicit>no</googleplay:explicit> |
||||
<itunes:explicit>no</itunes:explicit> |
||||
<lastBuildDate>`+data.lastBuildDate+`</lastBuildDate> |
||||
<googleplay:block>yes</googleplay:block>`; |
||||
return(item) |
||||
}; |
||||
|
@ -0,0 +1,2 @@ |
||||
export * from './Item' |
||||
export * from './getRssXml' |
Loading…
Reference in new issue