mastofeed-iframe-embed/static/index.html

98 lines
4.1 KiB
HTML
Raw Normal View History

<html lang="en">
2019-11-08 17:46:17 +01:00
<head>
2019-11-08 17:46:17 +01:00
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1">
2022-06-20 15:16:40 +02:00
<title>MaPleFeed - Embed Mastodon or Pleroma Feeds</title>
2019-11-08 17:46:17 +01:00
<link rel="stylesheet" href="./stylesheet.css">
</head>
2019-11-08 17:46:17 +01:00
<body>
<br>
<div>
2022-06-20 15:16:40 +02:00
<h1>MaPleFeed</h1>
<h4>Embed Mastodon or Pleroma profile feeds on any web page.</h4>
2022-06-20 15:36:22 +02:00
<a href="https://github.com/bihlink/maplefeed" target="_blank" class="cta button alt">Source <img
class="link-logo after" src="github-logo.svg" alt="Github Logo" data-reactid="19"></a>
2022-06-20 18:45:36 +02:00
<a href="https://coki.me/donate" target="_blank" class="cta button alt">Donate <img
class="link-logo after" src="ko-fi.svg" alt="Ko-Fi Logo" data-reactid="19"></a><br>
2019-11-08 17:46:17 +01:00
<br>
<hr><br>
<form action="javascript:genUrl()">
<label>Instance URL:<input required type="text" id="urlin" placeholder="mastodon.social"
oninvalid="this.setCustomValidity('Insert your instance URL. Example: mastodon.social')"
2019-11-08 17:46:17 +01:00
oninput="this.setCustomValidity('')"></label>
<br>
<label>Username:<input required type="text" id="usernamein" placeholder="gargron"
2022-06-20 15:36:22 +02:00
oninvalid="this.setCustomValidity('Insert your username. Example: gargron')"
2019-11-08 17:46:17 +01:00
oninput="this.setCustomValidity('')"></label>
<br>
<label>Width (px):<input required type="number" id="width" value="400"
oninvalid="this.setCustomValidity('Insert width of generated feed. Default: 400')"
oninput="this.setCustomValidity('')"></label>
<br>
<label>Height (px):<input required type="number" id="height" value="800"
oninvalid="this.setCustomValidity('Insert height of generated feed. Default: 800')"
oninput="this.setCustomValidity('')"></label>
<br>
<label>UI Scale (percent):<input required type="number" id="size" value="100"
oninvalid="this.setCustomValidity('Insert UI scale. Default: 100')"
oninput="this.setCustomValidity('')"></label>
<br>
<label>Theme:
<select id="theme">
<option value="dark">Dark</option>
<option value="light">Light</option>
<option value="auto">Auto (based on css prefers-color-scheme)</option>
</select>
</label>
<br>
<label>Show Header?<input id="header" type="checkbox" checked="checked"></label>
<br>
<label>Hide replies?<input type="checkbox" id="hidereplies" checked="checked"></label>
<br>
<label>Hide boosts?<input type="checkbox" id="hideboosts" checked="checked"></label>
<br>
<br>
<button value="generate">Generate</button>
</form>
<br><br>
2022-06-20 15:56:44 +02:00
<label>Copy this code and paste to your web page: <br><textarea id="result"
placeholder="result will go here" style="width:100%;"></textarea></label>
2019-11-08 17:46:17 +01:00
<br><br>
<h3>Live Preview:</h3>
<span class="iframe-contain">
2022-06-20 15:36:22 +02:00
<iframe id="frame" allowfullscreen sandbox="allow-top-navigation allow-scripts" width="100%" height="800"
2022-06-20 15:16:40 +02:00
src="/apiv2/feed?userurl=https%3A%2F%2Fabid.cc%2Fusers%2Fbihlink&replies=false&boosts=true"></iframe>
2019-11-08 17:46:17 +01:00
</span>
<br>
</div>
<script>
window.genUrl = function genUrl() {
function val(id) {
return document.getElementById(id).value;
}
2019-11-08 17:46:17 +01:00
var inUrl = 'https://' + val('urlin') + '/users/' + val('usernamein');
2019-11-08 17:46:17 +01:00
var showBoosts = (!document.getElementById('hideboosts').checked).toString();
var showReplies = (!document.getElementById('hidereplies').checked).toString();
var showHeader = document.getElementById('header').checked.toString()
var portStr = (window.location.port && window.location.port != 80) ? (':' + window.location.port) : ''
2019-11-08 17:46:17 +01:00
var iframeUrl = window.location.protocol + '//' + window.location.hostname + portStr
+ "/apiv2/feed?userurl=" + encodeURIComponent(inUrl) + "&theme=" + val('theme') + '&size=' + val('size')
+ "&header=" + showHeader + '&replies=' + showReplies + '&boosts=' + showBoosts;
2019-11-08 17:46:17 +01:00
document.getElementById('result').value = '<iframe allowfullscreen sandbox="allow-top-navigation allow-scripts" width="' + val('width') + '" height="' + val('height') + '" src="' + iframeUrl + '"></iframe>';
2019-11-08 17:46:17 +01:00
var iframe = document.getElementById('frame');
iframe.src = iframeUrl;
iframe.width = val('width');
iframe.height = val('height');
}
</script>
</body>
2019-11-08 17:46:17 +01:00
</html>