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.

106 lines
4.0 KiB

  1. <div class="narrow">
  2. <?= partial('partials/header') ?>
  3. <div style="float: right; margin-top: 6px;">
  4. <button class="btn btn-success" id="btn_post">Save Bookmark</button>
  5. </div>
  6. <div style="clear: both;">
  7. <div class="alert alert-success hidden" id="test_success"><strong>Success! We found a Location header in the response!</strong><br>Your post should be on your website now!<br><a href="" id="post_href">View your post</a></div>
  8. <div class="alert alert-danger hidden" id="test_error"><strong>Your endpoint did not return a Location header.</strong><br>See <a href="/creating-a-micropub-endpoint">Creating a Micropub Endpoint</a> for more information.</div>
  9. </div>
  10. <form role="form" style="margin-top: 20px;" id="note_form">
  11. <div class="form-group">
  12. <label for="note_bookmark"><code>bookmark</code></label>
  13. <input type="text" id="note_bookmark" value="<?= $this->bookmark_url ?>" class="form-control">
  14. </div>
  15. <div class="form-group">
  16. <label for="note_name"><code>name</code></label>
  17. <input type="text" id="note_name" value="<?= $this->bookmark_name ?>" class="form-control">
  18. </div>
  19. <div class="form-group">
  20. <label for="note_content"><code>content</code> (optional)</label>
  21. <textarea id="note_content" value="" class="form-control" style="height: 5em;"><?= $this->bookmark_content ?></textarea>
  22. </div>
  23. <div class="form-group">
  24. <label for="note_category"><code>category</code> (optional, comma-separated list of tags)</label>
  25. <input type="text" id="note_category" value="<?= $this->bookmark_tags ?>" class="form-control" placeholder="e.g. web, personal">
  26. </div>
  27. <div class="form-group">
  28. <label for="note_syndicate-to"><code>syndicate-to</code> <a href="javascript:reload_syndications()">(refresh)</a></label>
  29. <div id="syndication-container">
  30. <?php
  31. if($this->syndication_targets) {
  32. echo '<ul>';
  33. foreach($this->syndication_targets as $syn) {
  34. echo '<li><button data-syndication="'.$syn['target'].'" class="btn btn-default btn-block"><img src="'.$syn['favicon'].'" width="16" height="16"> '.$syn['target'].'</button></li>';
  35. }
  36. echo '</ul>';
  37. } else {
  38. ?><div class="bs-callout bs-callout-warning">No syndication targets were found on your site.
  39. You can provide a <a href="/docs#syndication">list of supported syndication targets</a> that will appear as checkboxes here.</div><?php
  40. }
  41. ?>
  42. </div>
  43. </div>
  44. </form>
  45. <hr>
  46. <div style="text-align: right;">
  47. Bookmarklet: <a href="javascript:<?= js_bookmarklet('partials/bookmark-bookmarklet', $this) ?>" class="btn btn-default btn-xs">bookmark</a>
  48. </div>
  49. </div>
  50. <script>
  51. $(function(){
  52. $("#btn_post").click(function(){
  53. var syndications = [];
  54. $("#syndication-container button.btn-info").each(function(i,btn){
  55. syndications.push($(btn).data('syndication'));
  56. });
  57. $.post("/micropub/post", {
  58. bookmark: $("#note_bookmark").val(),
  59. name: $("#note_name").val(),
  60. content: $("#note_content").val(),
  61. category: $("#note_category").val(),
  62. 'syndicate-to': syndications.join(',')
  63. }, function(data){
  64. var response = JSON.parse(data);
  65. if(response.location != false) {
  66. // $("#test_success").removeClass('hidden');
  67. $("#test_error").addClass('hidden');
  68. // $("#post_href").attr("href", response.location);
  69. // $("#note_bookmark").val("");
  70. // $("#note_content").val("");
  71. // $("#note_category").val("");
  72. window.location = response.location;
  73. } else {
  74. $("#test_success").addClass('hidden');
  75. $("#test_error").removeClass('hidden');
  76. }
  77. });
  78. return false;
  79. });
  80. bind_syndication_buttons();
  81. });
  82. <?= partial('partials/syndication-js') ?>
  83. </script>