mirror of
https://github.com/dariusk/rss-to-activitypub.git
synced 2024-11-29 20:19:19 +02:00
91 lines
2.9 KiB
HTML
91 lines
2.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Convert an RSS feed to ActivityPub</title>
|
|
<style>
|
|
body {
|
|
font-family: sans-serif;
|
|
max-width: 800px;
|
|
margin: 30px;
|
|
}
|
|
img {
|
|
max-width: 100px;
|
|
}
|
|
li {
|
|
margin-bottom: 0.2em;
|
|
}
|
|
.account {
|
|
}
|
|
input {
|
|
width: 300px;
|
|
font-size: 1.2em;
|
|
}
|
|
.hint {
|
|
font-size: 0.8em;
|
|
}
|
|
button {
|
|
font-size: 1.2em;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Convert an RSS feed to ActivityPub</h1>
|
|
<p><em>by <a href="https://friend.camp/@darius">Darius Kazemi</a>, <a href="https://github.com/dariusk/rss-to-activitypub">source code here</a></em></p>
|
|
<p>Put the full RSS feed URL in here, and pick a username for the account that will track the feed.</p>
|
|
<p>
|
|
<input id="feed" type="text" placeholder="https://example.com/feed.xml"/>
|
|
</p>
|
|
<p>
|
|
<input id="username" type="text" placeholder="username"/><br><span class="hint">only letters, digits, and underscore (_) allowed</span>
|
|
</p>
|
|
<p>Reminder: you won't see any posts on the account until the RSS feed updates at least once!</p>
|
|
<button onclick="submit()">Submit</button>
|
|
<div id="out">
|
|
</div>
|
|
|
|
<script>
|
|
// https://bots.tinysubversions.com/api/convert/?feed=https://toomuchnotenough.site/feed.xml&username=tmne
|
|
function submit() {
|
|
let domain = document.domain;
|
|
let feed = encodeURIComponent(document.querySelector('#feed').value);
|
|
let username = document.querySelector('#username').value;
|
|
let out = document.querySelector('#out');
|
|
fetch(`/api/convert/?feed=${feed}&username=${username}`)
|
|
.then(function(response) {
|
|
return response.json();
|
|
})
|
|
.then(function(myJson) {
|
|
if (myJson.err) {
|
|
out.innerHTML = `<p>Error: ${myJson.err}</p>`;
|
|
return {};
|
|
}
|
|
// a feed exists in the database
|
|
if (myJson.content) {
|
|
// was it a match on feed
|
|
if (myJson.feed === decodeURIComponent(feed)) {
|
|
console.log('feed match!');
|
|
out.innerHTML = `<p>This feed already exists! Follow @${myJson.username}@${domain}.</p>`;
|
|
window.location = `/u/${myJson.username}`;
|
|
}
|
|
// was it a match on username
|
|
else if (myJson.username === username) {
|
|
console.log('username match!');
|
|
out.innerHTML = `<p>This username is already taken for <a href="${myJson.feed}">this feed</a>.</p>`;
|
|
}
|
|
}
|
|
else if (myJson.title) {
|
|
out.innerHTML = `<p>Okay! There is now an ActivityPub actor for ${myJson.title}. You should be able to search for it from your ActivityPub client (Mastodon, Pleroma, etc) using this identifier: @${username}@${domain}. You won't see anything there until the next time the RSS feed updates. You can check out the profile page for this feed at <a href="https://${domain}/u/${username}/">https://${domain}/u/${username}</a> too!</p>`;
|
|
}
|
|
|
|
})
|
|
.catch(error => {
|
|
console.log('!!!',error);
|
|
out.innerHTML = `<p>Error: ${error}</p>`;
|
|
});
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|