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.

120 lines
4.0 KiB

7 years ago
  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! </strong><a href="" id="post_href">View your post</a></div>
  8. <div class="alert alert-danger hidden" id="test_error"><strong>Something went wrong!</strong><br>Your Micropub endpoint indicated that something went wrong creating the post.</div>
  9. </div>
  10. <form role="form" style="margin-top: 20px;" id="note_form">
  11. <div class="form-group">
  12. <label for="note_bookmark">Bookmark URL</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">Name</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">Content</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">Tags</label>
  25. <input type="text" id="note_category" value="<?= $this->bookmark_tags ?>" class="form-control" placeholder="e.g. web, personal">
  26. </div>
  27. <?php if($this->syndication_targets): ?>
  28. <div class="form-group">
  29. <label for="note_syndicate-to">Syndicate <a href="javascript:reload_syndications()">refresh</a></label>
  30. <div id="syndication-container">
  31. <?php
  32. echo '<ul>';
  33. foreach($this->syndication_targets as $syn) {
  34. echo '<li>'
  35. . '<button data-syndicate-to="'.(isset($syn['uid']) ? htmlspecialchars($syn['uid']) : htmlspecialchars($syn['target'])).'" class="btn btn-default btn-block">'
  36. . ($syn['favicon'] ? '<img src="'.htmlspecialchars($syn['favicon']).'" width="16" height="16"> ' : '')
  37. . htmlspecialchars($syn['target'])
  38. . '</button>'
  39. . '</li>';
  40. }
  41. echo '</ul>';
  42. ?>
  43. </div>
  44. </div>
  45. <?php endif ?>
  46. </form>
  47. <hr>
  48. <div style="text-align: right;">
  49. Bookmarklet: <a href="javascript:<?= js_bookmarklet('partials/bookmark-bookmarklet', $this) ?>" class="btn btn-default btn-xs">bookmark</a>
  50. </div>
  51. </div>
  52. <script>
  53. $(function(){
  54. $("#note_category").tokenfield({
  55. createTokensOnBlur: true,
  56. beautify: true
  57. });
  58. $("#btn_post").click(function(){
  59. if($("#note_bookmark").val() == "") {
  60. return false;
  61. }
  62. var syndications = [];
  63. $("#syndication-container button.btn-info").each(function(i,btn){
  64. syndications.push($(btn).data('syndicate-to'));
  65. });
  66. $("#btn_post").addClass("loading disabled").text("Working...");
  67. $.post("/micropub/post", {
  68. 'bookmark-of': $("#note_bookmark").val(),
  69. name: $("#note_name").val(),
  70. content: $("#note_content").val(),
  71. category: tokenfieldToArray("#note_category"),
  72. '<?= $this->user->micropub_syndicate_field ?>': syndications
  73. }, function(response){
  74. if(response.location != false) {
  75. $("#test_success").removeClass('hidden');
  76. $("#test_error").addClass('hidden');
  77. $("#post_href").attr("href", response.location);
  78. $("#note_form").addClass('hidden');
  79. // $("#note_bookmark").val("");
  80. // $("#note_content").val("");
  81. // $("#note_category").val("");
  82. window.location = response.location;
  83. } else {
  84. $("#test_success").addClass('hidden');
  85. $("#test_error").removeClass('hidden');
  86. $("#btn_post").removeClass("loading disabled").text("Post");
  87. }
  88. });
  89. return false;
  90. });
  91. bind_syndication_buttons();
  92. });
  93. <?= partial('partials/syndication-js') ?>
  94. </script>