You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.9 KiB

  1. <?php $this->layout('layout-loggedin', ['title' => $title, 'user' => $user, 'accounts' => $accounts]); ?>
  2. <div class="ui main text container" style="margin-top: 80px; margin-bottom: 40px;">
  3. <h2 class="site-name">Send a Webmention</h2>
  4. <form class="ui form" id="send-webmention-form">
  5. <div class="two fields">
  6. <div class="field"><label>Source URL</label><input type="url" placeholder="Source URL" id="send-source"></div>
  7. <div class="field"><label>Target URL</label><input type="url" placeholder="Target URL" id="send-target"></div>
  8. </div>
  9. <div class="ui error message"></div>
  10. <button class="ui button right floated" id="send-webmention-btn">Send Webmention</button>
  11. <div style="clear:both;"></div>
  12. </form>
  13. <div style="margin-top: 2em;">
  14. <p>Enter a source URL (your post) and target URL (the post you linked to).</p>
  15. <p>Telegraph will discover the Webmention endpoint of the target URL and send the Webmention for you.</p>
  16. <p>You'll be able to see the progress after you click "send".</p>
  17. </div>
  18. </div>
  19. <script>
  20. $(function(){
  21. var csrf = "<?= $csrf ?>";
  22. $("#send-source").focus();
  23. $("#send-webmention-btn").click(function(){
  24. $("#send-webmention-btn").addClass("loading");
  25. $("#send-webmention-form").removeClass("error");
  26. // Send the request to the API now, and then redirect to the status page
  27. $.ajax({
  28. url: "/webmention",
  29. method: "POST",
  30. data: {
  31. _csrf: csrf,
  32. source: $("#send-source").val(),
  33. target: $("#send-target").val()
  34. },
  35. success: function(data){
  36. $("#send-webmention-btn").removeClass("loading");
  37. window.location = data.location+"/details";
  38. },
  39. error: function(data){
  40. $("#send-webmention-btn").removeClass("loading");
  41. $("#send-webmention-form").addClass("error");
  42. $("#send-webmention-form .error.message").text(data.responseJSON.error_description);
  43. }
  44. });
  45. return false;
  46. });
  47. });
  48. </script>