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.

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