rss-to-activitypub/public/convert/index.html

91 lines
2.9 KiB
HTML
Raw Permalink Normal View History

2018-10-15 07:18:10 +03:00
<!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;
2018-10-15 07:18:10 +03:00
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>
2018-10-15 07:18:10 +03:00
<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>
2019-02-24 08:26:24 +02:00
<p>Reminder: you won't see any posts on the account until the RSS feed updates at least once!</p>
2018-10-15 07:18:10 +03:00
<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() {
2018-11-06 19:45:33 +02:00
let domain = document.domain;
let feed = encodeURIComponent(document.querySelector('#feed').value);
2018-10-15 07:18:10 +03:00
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 {};
}
2018-10-15 07:18:10 +03:00
// a feed exists in the database
if (myJson.content) {
// was it a match on feed
if (myJson.feed === feed) {
console.log('feed match!');
2018-11-06 19:45:33 +02:00
out.innerHTML = `<p>This feed already exists! Follow @${myJson.username}@${domain}.</p>`;
2018-10-15 07:18:10 +03:00
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) {
2018-11-06 19:45:33 +02:00
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>`;
2018-10-15 07:18:10 +03:00
}
})
.catch(error => {
console.log('!!!',error);
out.innerHTML = `<p>Error: ${error}</p>`;
});
}
</script>
</body>
</html>