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.

114 lines
4.3 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. <p class="help-block">Note: This will be changing to <code>bookmark-of</code> in the near future. It is best for your code to accept both for now.</p>
  15. </div>
  16. <div class="form-group">
  17. <label for="note_name"><code>name</code></label>
  18. <input type="text" id="note_name" value="<?= $this->bookmark_name ?>" class="form-control">
  19. </div>
  20. <div class="form-group">
  21. <label for="note_content"><code>content</code> (optional)</label>
  22. <textarea id="note_content" value="" class="form-control" style="height: 5em;"><?= $this->bookmark_content ?></textarea>
  23. </div>
  24. <div class="form-group">
  25. <label for="note_category"><code>category</code> (optional, comma-separated list of tags)</label>
  26. <input type="text" id="note_category" value="<?= $this->bookmark_tags ?>" class="form-control" placeholder="e.g. web, personal">
  27. </div>
  28. <div class="form-group">
  29. <label for="note_syndicate-to"><code>syndicate-to</code> <a href="javascript:reload_syndications()">(refresh)</a></label>
  30. <div id="syndication-container">
  31. <?php
  32. if($this->syndication_targets) {
  33. echo '<ul>';
  34. foreach($this->syndication_targets as $syn) {
  35. 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>';
  36. }
  37. echo '</ul>';
  38. } else {
  39. ?><div class="bs-callout bs-callout-warning">No syndication targets were found on your site.
  40. You can provide a <a href="/docs#syndication">list of supported syndication targets</a> that will appear as checkboxes here.</div><?php
  41. }
  42. ?>
  43. </div>
  44. </div>
  45. </form>
  46. <hr>
  47. <div style="text-align: right;">
  48. Bookmarklet: <a href="javascript:<?= js_bookmarklet('partials/bookmark-bookmarklet', $this) ?>" class="btn btn-default btn-xs">bookmark</a>
  49. </div>
  50. </div>
  51. <script>
  52. $(function(){
  53. // ctrl-s to save
  54. $(window).on('keydown', function(e){
  55. if(e.keyCode == 83 && e.ctrlKey){
  56. $("#btn_post").click();
  57. }
  58. });
  59. $("#btn_post").click(function(){
  60. var syndications = [];
  61. $("#syndication-container button.btn-info").each(function(i,btn){
  62. syndications.push($(btn).data('syndication'));
  63. });
  64. $.post("/micropub/post", {
  65. bookmark: $("#note_bookmark").val(),
  66. name: $("#note_name").val(),
  67. content: $("#note_content").val(),
  68. category: $("#note_category").val(),
  69. 'syndicate-to': syndications.join(',')
  70. }, function(data){
  71. var response = JSON.parse(data);
  72. if(response.location != false) {
  73. $("#test_success").removeClass('hidden');
  74. $("#test_error").addClass('hidden');
  75. $("#post_href").attr("href", response.location);
  76. // $("#note_bookmark").val("");
  77. // $("#note_content").val("");
  78. // $("#note_category").val("");
  79. window.location = response.location;
  80. } else {
  81. $("#test_success").addClass('hidden');
  82. $("#test_error").removeClass('hidden');
  83. }
  84. });
  85. return false;
  86. });
  87. bind_syndication_buttons();
  88. });
  89. <?= partial('partials/syndication-js') ?>
  90. </script>