63 lines
2.2 KiB
HTML
63 lines
2.2 KiB
HTML
<script type="text/javascript">
|
|
RED.nodes.registerType('indieauth', {
|
|
category: 'config',
|
|
defaults: {
|
|
client_id: {value: ""},
|
|
me: {value: ""}
|
|
},
|
|
credentials: {
|
|
micropub_endpoint: {value: "", required: false},
|
|
token_endpoint: {value: "", required: false},
|
|
auth_token: {value: "", required: false}
|
|
},
|
|
label: function () {
|
|
return this.me || 'indieauth';
|
|
},
|
|
|
|
exportable: false,
|
|
|
|
oneditprepare: function () {
|
|
var id = this.id;
|
|
|
|
var pathname = document.location.pathname;
|
|
if (pathname.slice(-1) != "/") {
|
|
pathname += "/";
|
|
}
|
|
|
|
var callback = location.protocol + "//" +
|
|
location.hostname +
|
|
(location.port?":"+location.port:"")+
|
|
pathname + "indieauth/auth/callback";
|
|
|
|
$('#node-config-start-auth').mousedown(function () {
|
|
var clientId = $("#node-config-input-client_id").val();
|
|
var me = $("#node-config-input-me").val();
|
|
var url = 'indieauth/auth?id=' + id + '&client_id=' + clientId + "&me=" + me + "&callback=" + encodeURIComponent(callback);
|
|
$(this).attr("href", url);
|
|
});
|
|
}
|
|
})
|
|
</script>
|
|
|
|
<script type="text/x-red" data-template-name="indieauth">
|
|
<div class="form-tips" id="node-config-indieauth-tooltip">
|
|
Fill in your Client ID, Me url and click Web Sign In. You will be redirect to your authorization endpoint. When authorization is complete you can close the new tab and
|
|
click Done.
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<label for="node-config-input-client_id"><i class="icon-bookmark"></i> Client ID</label>
|
|
<input type="text" id="node-config-input-client_id">
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<label for="node-config-input-me"><i class="icon-bookmark"></i> me</label>
|
|
<input type="text" id="node-config-input-me">
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<label> </label>
|
|
<a class="btn" id="node-config-start-auth" href="#" target="_blank"><span>Web Sign In</span></a>
|
|
</div>
|
|
</script>
|