mirror of
https://github.com/dariusk/rss-to-activitypub.git
synced 2024-11-22 09:19:19 +02:00
Add profile description field from RSS description
This adds a `summary` field to the `actor` object, populated from the RSS feed's top level <description> element. This makes the <description> content into the profile description.
This commit is contained in:
parent
9957ea6f7f
commit
cf8b1721d9
|
@ -36,6 +36,7 @@ router.get('/convert', function (req, res) {
|
|||
console.log('end!!!!');
|
||||
res.status(200).json(feedData);
|
||||
let displayName = feedData.title;
|
||||
let description = feedData.description;
|
||||
let account = username;
|
||||
// create new user
|
||||
let db = req.app.get('db');
|
||||
|
@ -43,7 +44,7 @@ router.get('/convert', function (req, res) {
|
|||
// create keypair
|
||||
var pair = generateRSAKeypair();
|
||||
getImage(feed, feedData, imageUrl => {
|
||||
let actorRecord = createActor(account, domain, pair.public, displayName, imageUrl);
|
||||
let actorRecord = createActor(account, domain, pair.public, displayName, imageUrl, description);
|
||||
let webfingerRecord = createWebfinger(account, domain);
|
||||
const apikey = crypto.randomBytes(16).toString('hex');
|
||||
db.prepare('insert or replace into accounts(name, actor, apikey, pubkey, privkey, webfinger) values(?, ?, ?, ?, ?, ?)').run( `${account}@${domain}`, JSON.stringify(actorRecord), apikey, pair.public, pair.private, JSON.stringify(webfingerRecord));
|
||||
|
@ -81,7 +82,7 @@ function getImage(feed, feedData, cb) {
|
|||
}
|
||||
}
|
||||
|
||||
function createActor(name, domain, pubkey, displayName, imageUrl) {
|
||||
function createActor(name, domain, pubkey, displayName, imageUrl, description) {
|
||||
displayName = displayName || name;
|
||||
let actor = {
|
||||
'@context': [
|
||||
|
@ -107,6 +108,9 @@ function createActor(name, domain, pubkey, displayName, imageUrl) {
|
|||
'url': imageUrl,
|
||||
};
|
||||
}
|
||||
if (description) {
|
||||
actor.summary = `<p>${description}</p>`;
|
||||
}
|
||||
return actor;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,11 @@ router.get('/:name', function (req, res) {
|
|||
if (actor.icon && actor.icon.url) {
|
||||
imageUrl = actor.icon.url;
|
||||
}
|
||||
res.render('user', { displayName: actor.name, items: feedData.items, accountName: '@'+name, imageUrl: imageUrl });
|
||||
let description = null;
|
||||
if (actor.summary) {
|
||||
description = actor.summary;
|
||||
}
|
||||
res.render('user', { displayName: actor.name, items: feedData.items, accountName: '@'+name, imageUrl: imageUrl, description });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -7,8 +7,9 @@ html
|
|||
body
|
||||
h1= displayName
|
||||
img(src=imageUrl)
|
||||
p.account #{accountName}
|
||||
p What you're looking at is an RSS feed that's been converted into an account that Mastodon (or any other ActivityPub social network) can subscribe to. Put the username above into your user search and you should be able to find this feed and subscribe!
|
||||
h3.account #{accountName}
|
||||
p #{description}
|
||||
p <strong><em>What you're looking at is an RSS feed that's been converted into an account that Mastodon (or any other ActivityPub social network) can subscribe to. Put the username above into your user search and you should be able to find this feed and subscribe!</em></strong>
|
||||
h2 Feed items
|
||||
ul
|
||||
for item in items
|
||||
|
|
Loading…
Reference in New Issue