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.

108 lines
4.0 KiB

  1. <?php $this->layout('layout-loggedin', ['title' => $title, 'accounts' => $accounts, 'user' => $user]); ?>
  2. <div class="ui main text container" style="margin-top: 80px; margin-bottom: 40px;">
  3. <div class="ui top attached tabular menu">
  4. <a class="item active" data-tab="send-from-source">Find Links</a>
  5. <a class="item" data-tab="send-source-target">Send Webmention</a>
  6. </div>
  7. <div class="ui bottom attached tab segment active" data-tab="send-from-source">
  8. <form action="/dashboard/send" method="get" class="ui form">
  9. <div class="ui fluid action input">
  10. <input type="url" name="url" placeholder="http://example.com/">
  11. <button class="ui button">Find Links</button>
  12. </div>
  13. <input type="hidden" name="account" value="<?= $site->id ?>">
  14. </form>
  15. <div style="padding: 6px;">Enter a URL above to preview and send webmentions from all the links found on the page.</div>
  16. </div>
  17. <div class="ui bottom attached tab segment" data-tab="send-source-target">
  18. <form class="ui form" id="send-webmention-form">
  19. <div class="two fields">
  20. <div class="field"><label>Source URL</label><input type="url" placeholder="Source URL" id="send-source"></div>
  21. <div class="field"><label>Target URL</label><input type="url" placeholder="Target URL" id="send-target"></div>
  22. </div>
  23. <div class="ui error message"></div>
  24. <button class="ui button right floated" id="send-webmention-btn">Send Webmention</button>
  25. <div style="clear:both;"></div>
  26. </form>
  27. </div>
  28. <? if(count($webmentions)): ?>
  29. <table class="ui striped single line table">
  30. <thead>
  31. <th>Status</th>
  32. <th>Date</th>
  33. <th>Source &amp; Target</th>
  34. </thead>
  35. <tbody>
  36. <?php foreach($webmentions as $mention): ?>
  37. <tr<?= $mention['status'] == 'pending' ? ' class="warning"' : '' ?>>
  38. <td>
  39. <div class="popup" data-content="<?= $mention['status'] ?>">
  40. <a href="/webmention/<?= $mention['webmention']->token ?>/details">
  41. <i class="circular inverted <?= $mention['icon'] ?> icon"></i>
  42. </a>
  43. </div>
  44. </td>
  45. <td>
  46. <a href="/webmention/<?= $mention['webmention']->token ?>/details">
  47. <?= date('M j, g:ia', strtotime($mention['webmention']->created_at)) ?>
  48. </a>
  49. </td>
  50. <td>
  51. source=<a href="<?= $this->e($mention['webmention']->source) ?>"><?= $this->e($mention['webmention']->source) ?></a><br>
  52. target=<a href="<?= $this->e($mention['webmention']->target) ?>"><?= $this->e($mention['webmention']->target) ?></a>
  53. </td>
  54. </tr>
  55. <?php endforeach; ?>
  56. </tbody>
  57. </table>
  58. <? else: ?>
  59. <div class="ui message">It looks like you haven't sent any webmentions yet! Try entering one of your post URLs above and send some.</div>
  60. <? endif; ?>
  61. <form class="ui form">
  62. <div class="field">
  63. <label>API Key</label>
  64. <input type="text" readonly="" value="<?= $role->token ?>">
  65. </div>
  66. <p>Use this key when sending webmentions using the <a href="/api">API</a>.</p>
  67. </form>
  68. </div>
  69. <script>
  70. $(function(){
  71. var token = "<?= $role->token ?>";
  72. $(".tabular.menu .item").tab();
  73. $(".popup").popup();
  74. $("#send-webmention-btn").click(function(){
  75. $("#send-webmention-btn").addClass("loading");
  76. $("#send-webmention-form").removeClass("error");
  77. // Send the request to the API now, and then redirect to the status page
  78. $.ajax({
  79. url: "/webmention",
  80. method: "POST",
  81. data: {
  82. token: token,
  83. source: $("#send-source").val(),
  84. target: $("#send-target").val()
  85. },
  86. success: function(data){
  87. $("#send-webmention-btn").removeClass("loading");
  88. window.location = data.location+"/details";
  89. },
  90. error: function(data){
  91. $("#send-webmention-btn").removeClass("loading");
  92. $("#send-webmention-form").addClass("error");
  93. $("#send-webmention-form .error.message").text(data.responseJSON.error_description);
  94. }
  95. });
  96. return false;
  97. });
  98. });
  99. </script>