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.

122 lines
4.4 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">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. <div class="form-group">
  28. <label for="note_syndicate-to">Syndicate <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>'
  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. } else {
  43. ?><div class="bs-callout bs-callout-warning">No syndication targets were found on your site.
  44. You can provide a <a href="/docs#syndication">list of supported syndication targets</a> that will appear as checkboxes here.</div><?php
  45. }
  46. ?>
  47. </div>
  48. </div>
  49. </form>
  50. <hr>
  51. <div style="text-align: right;">
  52. Bookmarklet: <a href="javascript:<?= js_bookmarklet('partials/bookmark-bookmarklet', $this) ?>" class="btn btn-default btn-xs">bookmark</a>
  53. </div>
  54. </div>
  55. <script>
  56. $(function(){
  57. $("#note_category").tokenfield({
  58. createTokensOnBlur: true,
  59. beautify: true
  60. });
  61. $("#btn_post").click(function(){
  62. if($("#note_bookmark").val() == "") {
  63. return false;
  64. }
  65. var syndications = [];
  66. $("#syndication-container button.btn-info").each(function(i,btn){
  67. syndications.push($(btn).data('syndicate-to'));
  68. });
  69. $("#btn_post").addClass("loading disabled").text("Working...");
  70. $.post("/micropub/post", {
  71. 'bookmark-of': $("#note_bookmark").val(),
  72. name: $("#note_name").val(),
  73. content: $("#note_content").val(),
  74. category: tokenfieldToArray("#note_category"),
  75. '<?= $this->user->micropub_syndicate_field ?>': syndications
  76. }, function(response){
  77. if(response.location != false) {
  78. $("#test_success").removeClass('hidden');
  79. $("#test_error").addClass('hidden');
  80. $("#post_href").attr("href", response.location);
  81. $("#note_form").addClass('hidden');
  82. // $("#note_bookmark").val("");
  83. // $("#note_content").val("");
  84. // $("#note_category").val("");
  85. window.location = response.location;
  86. } else {
  87. $("#test_success").addClass('hidden');
  88. $("#test_error").removeClass('hidden');
  89. $("#btn_post").removeClass("loading disabled").text("Post");
  90. }
  91. });
  92. return false;
  93. });
  94. bind_syndication_buttons();
  95. });
  96. <?= partial('partials/syndication-js') ?>
  97. </script>