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.

117 lines
4.5 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 (<code>bookmark-of</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">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">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">Tags (<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">Syndicate (<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>'
  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. $("#btn_post").click(function(){
  58. if($("#note_bookmark").val() == "") {
  59. return false;
  60. }
  61. var syndications = [];
  62. $("#syndication-container button.btn-info").each(function(i,btn){
  63. syndications.push($(btn).data('syndicate-to'));
  64. });
  65. $("#btn_post").addClass("loading disabled").text("Working...");
  66. $.post("/micropub/post", {
  67. 'bookmark-of': $("#note_bookmark").val(),
  68. name: $("#note_name").val(),
  69. content: $("#note_content").val(),
  70. category: csv_to_array($("#note_category").val()),
  71. 'syndicate-to': syndications
  72. }, function(response){
  73. if(response.location != false) {
  74. $("#test_success").removeClass('hidden');
  75. $("#test_error").addClass('hidden');
  76. $("#post_href").attr("href", response.location);
  77. $("#note_form").addClass('hidden');
  78. // $("#note_bookmark").val("");
  79. // $("#note_content").val("");
  80. // $("#note_category").val("");
  81. window.location = response.location;
  82. } else {
  83. $("#test_success").addClass('hidden');
  84. $("#test_error").removeClass('hidden');
  85. $("#btn_post").removeClass("loading disabled").text("Post");
  86. }
  87. });
  88. return false;
  89. });
  90. bind_syndication_buttons();
  91. });
  92. <?= partial('partials/syndication-js') ?>
  93. </script>