Mirror of Quill
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.

113 lines
4.1 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. // ctrl-s to save
  53. $(window).on('keydown', function(e){
  54. if(e.keyCode == 83 && e.ctrlKey){
  55. $("#btn_post").click();
  56. }
  57. });
  58. $("#btn_post").click(function(){
  59. var syndications = [];
  60. $("#syndication-container button.btn-info").each(function(i,btn){
  61. syndications.push($(btn).data('syndication'));
  62. });
  63. $.post("/micropub/post", {
  64. bookmark: $("#note_bookmark").val(),
  65. name: $("#note_name").val(),
  66. content: $("#note_content").val(),
  67. category: $("#note_category").val(),
  68. 'syndicate-to': syndications.join(',')
  69. }, function(data){
  70. var response = JSON.parse(data);
  71. if(response.location != false) {
  72. // $("#test_success").removeClass('hidden');
  73. $("#test_error").addClass('hidden');
  74. // $("#post_href").attr("href", response.location);
  75. // $("#note_bookmark").val("");
  76. // $("#note_content").val("");
  77. // $("#note_category").val("");
  78. window.location = response.location;
  79. } else {
  80. $("#test_success").addClass('hidden');
  81. $("#test_error").removeClass('hidden');
  82. }
  83. });
  84. return false;
  85. });
  86. bind_syndication_buttons();
  87. });
  88. <?= partial('partials/syndication-js') ?>
  89. </script>