matrix-art

An image gallery for Matrix
git clone git://archive.git.mtrnord.blog/MTRNord/matrix-art.git
Log | Files | Refs | README | LICENSE

commit 29c42033cce4eae8fd281dc836651393181d26bb
parent 057ada1c4420c70eaa6cc102bcbf63bdcf302d8b
Author: MTRNord <mtrnord1@gmail.com>
Date:   Fri, 14 Jan 2022 20:58:18 +0100

Add mediarss support

Diffstat:
Mpackage-lock.json | 11+++++------
Mpackage.json | 5+++--
Mpages/api/posts/feed.rss.ts | 74+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 81 insertions(+), 9 deletions(-)

diff --git a/package-lock.json b/package-lock.json @@ -7,7 +7,7 @@ "name": "matrix-art", "dependencies": { "cors": "^2.8.5", - "feed": "^4.2.2", + "feed": "yshrsmz/feed#custom-elements", "lightgallery": "^2.3.0", "meilisearch": "^0.23.0", "next": "12.0.7", @@ -4468,8 +4468,8 @@ }, "node_modules/feed": { "version": "4.2.2", - "resolved": "https://registry.npmjs.org/feed/-/feed-4.2.2.tgz", - "integrity": "sha512-u5/sxGfiMfZNtJ3OvQpXcvotFpYkL0n9u9mM2vkui2nGo8b4wvDkJ8gAkYqbA8QpGyFCv3RK0Z+Iv+9veCS9bQ==", + "resolved": "git+ssh://git@github.com/yshrsmz/feed.git#86dffd1837c088fa5077675c8214397dc5284395", + "license": "MIT", "dependencies": { "xml-js": "^1.6.11" }, @@ -11988,9 +11988,8 @@ } }, "feed": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/feed/-/feed-4.2.2.tgz", - "integrity": "sha512-u5/sxGfiMfZNtJ3OvQpXcvotFpYkL0n9u9mM2vkui2nGo8b4wvDkJ8gAkYqbA8QpGyFCv3RK0Z+Iv+9veCS9bQ==", + "version": "git+ssh://git@github.com/yshrsmz/feed.git#86dffd1837c088fa5077675c8214397dc5284395", + "from": "feed@yshrsmz/feed#custom-elements", "requires": { "xml-js": "^1.6.11" } diff --git a/package.json b/package.json @@ -17,7 +17,7 @@ }, "dependencies": { "cors": "^2.8.5", - "feed": "^4.2.2", + "feed": "yshrsmz/feed#custom-elements", "lightgallery": "^2.3.0", "meilisearch": "^0.23.0", "next": "12.0.7", @@ -45,4 +45,4 @@ "tailwindcss": "^3.0.11", "typescript": "4.5.4" } -} +} +\ No newline at end of file diff --git a/pages/api/posts/feed.rss.ts b/pages/api/posts/feed.rss.ts @@ -32,7 +32,11 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) link: "https://" + (req.headers.host || "art.midnightthoughts.space"), language: "en", copyright: "", - feed: "https://" + (req.headers.host || "art.midnightthoughts.space") + "/posts.rss" + feed: "https://" + (req.headers.host || "art.midnightthoughts.space") + "/posts.rss", + namespaces: { + "xmlns:creativeCommons": "http://backend.userland.com/creativeCommonsRssModule", + "xmlns:media": "https://search.yahoo.com/mrss/" + } }); try { @@ -96,6 +100,40 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) url: client?.downloadLink(image["m.file"].url)!, type: image["m.file"].mimetype, length: image["m.file"].size + }, + extra: { + 'media:content': { + _attributes: { + url: client?.downloadLink(image["m.file"].url)!, + type: image["m.file"].mimetype, + medium: 'image', + height: image["m.image"].height, + width: image["m.image"].width, + }, + 'media:credit': { + _attributes: { + role: "author", + scheme: "urn:ebu" + }, + _text: imageEvent.content.displayname, + } + }, + 'media:keywords': image["matrixart.tags"].join(", "), + 'media:rating': "nonadult", + 'media:title': { + _attributes: { + type: "plain" + }, + _text: image["m.text"], + }, + 'creativeCommons:license': "https://creativecommons.org/licenses/by-nc-nd/4.0/", + 'media:license': { + _attributes: { + href: "https://creativecommons.org/licenses/by-nc-nd/4.0/", + type: "text/html" + }, + _text: "Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)" + } } }); } @@ -117,6 +155,40 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) url: client?.downloadLink(imageEvent.content["m.file"].url)!, type: imageEvent.content["m.file"].mimetype, length: imageEvent.content["m.file"].size + }, + extra: { + 'media:content': { + _attributes: { + url: client?.downloadLink(imageEvent.content["m.file"].url)!, + type: imageEvent.content["m.file"].mimetype, + medium: 'image', + height: imageEvent.content["m.image"].height, + width: imageEvent.content["m.image"].width, + }, + 'media:credit': { + _attributes: { + role: "author", + scheme: "urn:ebu" + }, + _text: imageEvent.content.displayname, + } + }, + 'media:keywords': imageEvent.content["matrixart.tags"].join(", "), + 'media:rating': "nonadult", + 'media:title': { + _attributes: { + type: "plain" + }, + _text: imageEvent.content["m.text"], + }, + 'creativeCommons:license': "https://creativecommons.org/licenses/by-nc-nd/4.0/", + 'media:license': { + _attributes: { + href: "https://creativecommons.org/licenses/by-nc-nd/4.0/", + type: "text/html" + }, + _text: "Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)" + } } }); }