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.

221 lines
8.2 KiB

4 years ago
  1. <div class="narrow">
  2. <?= partial('partials/header') ?>
  3. <h2>Signed In As</h2>
  4. <table class="table table-condensed">
  5. <tr>
  6. <td>me</td>
  7. <td><code><?= $this->user->url; ?></code> (should be your URL)</td>
  8. </tr>
  9. <?php if(profile('name')) { ?>
  10. <tr>
  11. <td>Name</td>
  12. <td><code><?= profile('name'); ?></code> </td>
  13. </tr>
  14. <?php } ?>
  15. <?php if(profile('photo')) { ?>
  16. <tr>
  17. <td>Photo</td>
  18. <td><code><?= profile('photo'); ?></code> </td>
  19. </tr>
  20. <?php } ?>
  21. <tr>
  22. <td>scope</td>
  23. <td><code><?= $this->user->micropub_scope ?></code> (should be a space-separated list of permissions including "create")</td>
  24. </tr>
  25. <tr>
  26. <td>micropub endpoint</td>
  27. <td><code><?= $this->user->micropub_endpoint ?></code> (should be a URL)</td>
  28. </tr>
  29. <tr>
  30. <td>media endpoint</td>
  31. <td><?= $this->user->micropub_media_endpoint ? '<code>'.$this->user->micropub_media_endpoint.'</code>' : '<a href="https://www.w3.org/TR/micropub/#media-endpoint">no media endpoint</a>' ?></td>
  32. </tr>
  33. <?php if($this->user->supported_post_types): ?>
  34. <tr>
  35. <td>supported post types</td>
  36. <td>
  37. <ul>
  38. <?php
  39. $types = json_decode($this->user->supported_post_types, true);
  40. foreach($types as $type) {
  41. echo '<li>'.htmlspecialchars($type['name']).' ('.$type['type'].')</li>';
  42. }
  43. ?>
  44. </ul>
  45. </td>
  46. </tr>
  47. <?php endif ?>
  48. <tr>
  49. <td width="140">access token</td>
  50. <td><code style="word-break: break-word; white-space: pre-wrap;"><?= $this->user->micropub_access_token ?></code></td>
  51. </tr>
  52. <tr>
  53. <td>
  54. <input type="button" class="btn btn-default" value="Reset Login" id="reset-login">
  55. </td>
  56. <td>
  57. Clicking this button will tell your token endpoint to revoke the token, Quill will forget the access token stored, forget all cached endpoints, and sign you out. If you sign back in, you will start over and see the debugging screens and scope options again.
  58. </td>
  59. </tr>
  60. </table>
  61. <h3>Post Format Settings</h3>
  62. <table class="table table-condensed" width="100%">
  63. <tr>
  64. <td>Weight Unit</td>
  65. <td width="160">
  66. <div style="margin-bottom:4px;"><input type="text" id="weight-unit" value="<?= $this->user->weight_unit ?>" class="form-control"></div>
  67. <div><input type="button" class="btn btn-primary" value="Save" id="save-weight-unit"></div>
  68. </td>
  69. <td>The unit to be used for <a href="/weight">weight posts</a>.</td>
  70. </tr>
  71. </table>
  72. <h3>Syndication Targets</h3>
  73. <div class="form-group">
  74. <label for="note_syndicate-to"><a href="javascript:reload_syndications()">Reload</a></label>
  75. <div id="syndication-container">
  76. <?php
  77. if($this->syndication_targets) {
  78. echo '<ul>';
  79. foreach($this->syndication_targets as $syn) {
  80. echo '<li>'
  81. . '<button data-syndicate-to="'.(isset($syn['uid']) ? htmlspecialchars($syn['uid']) : htmlspecialchars($syn['target'])).'" class="btn btn-default btn-block">'
  82. . ($syn['favicon'] ? '<img src="'.htmlspecialchars($syn['favicon']).'" width="16" height="16"> ' : '')
  83. . htmlspecialchars($syn['target'])
  84. . '</button>'
  85. . '</li>';
  86. }
  87. echo '</ul>';
  88. } else {
  89. ?><div class="bs-callout bs-callout-warning">No syndication targets were found on your site.
  90. Your server can provide a <a href="/docs#syndication">list of supported syndication targets</a> that will appear as checkboxes here.</div><?php
  91. }
  92. ?>
  93. </div>
  94. </div>
  95. <?php if(!Config::$twitterClientID): ?>
  96. <h3>Twitter</h3>
  97. <p>Connecting a Twitter account will automatically "favorite" and "retweet" tweets on Twitter when you favorite and retweet a Twitter URL in Quill.</p>
  98. <input type="button" id="twitter-button" value="Checking" class="btn">
  99. <?php endif ?>
  100. <h3>Backwards Compatibility</h3>
  101. <p>You can customize some of the properties that are sent in the Micropub request to work with older software.</p>
  102. <table class="table table-condensed" width="100%">
  103. <tr>
  104. <td>Slug</td>
  105. <td width="160">
  106. <div style="margin-bottom:4px;"><input type="text" id="slug-field-name" value="<?= $this->user->micropub_slug_field ?>" placeholder="mp-slug" class="form-control"></div>
  107. <div><input type="button" class="btn btn-primary" value="Save" id="save-slug-field"></div>
  108. </td>
  109. <td>Choose the name of the field that the slug will be sent in. This should be set to <code>mp-slug</code> unless your software is using a custom property or the deprecated <code>slug</code> property.</td>
  110. </tr>
  111. <tr>
  112. <td>Syndication</td>
  113. <td>
  114. <div style="margin-bottom:4px;">
  115. <select id="syndicate-to-field-name">
  116. <option value="mp-syndicate-to" <?= $this->user->micropub_syndicate_field == 'mp-syndicate-to' ? 'selected="selected"' : '' ?>>mp-syndicate-to</option>
  117. <option value="syndicate-to" <?= $this->user->micropub_syndicate_field == 'syndicate-to' ? 'selected="selected"' : '' ?>>syndicate-to</option>
  118. </select>
  119. </div>
  120. <div><input type="button" class="btn btn-primary" value="Save" id="save-syndicate-to-field"></div>
  121. </td>
  122. <td>Choose the name of the field that the syndication values will be sent in. This should be set to <code>mp-syndicate-to</code> unless your software is using the deprecated <code>syndicate-to</code> property.</td>
  123. </tr>
  124. <tr>
  125. <td>Send HTML Content</td>
  126. <td><input type="checkbox" id="send-html-content" <?= $this->user->micropub_optin_html_content ? 'checked="checked"' : '' ?>></td>
  127. <td>When checked, content from Quill's HTML editor will be sent in a property called <code>content[html]</code> rather than just <code>content</code>. See the <a href="https://www.w3.org/TR/micropub/#new-article-with-html">Micropub specification</a> for more details.</td>
  128. </tr>
  129. </table>
  130. </div>
  131. <script>
  132. $(function(){
  133. <?php if(!Config::$twitterClientID): ?>
  134. $.getJSON("/auth/twitter", function(data){
  135. // Check if we're already authorized with twitter
  136. if(data && data.result == 'ok') {
  137. $("#twitter-button").val("Connected").addClass("btn-success");
  138. } else if(data && data.url) {
  139. $("#twitter-button").val("Sign In").data("url", data.url).addClass("btn-warning");
  140. } else {
  141. $("#twitter-button").val("Error").addClass("btn-danger");
  142. }
  143. });
  144. $("#twitter-button").click(function(){
  145. if($(this).data('url')) {
  146. window.location = $(this).data('url');
  147. } else {
  148. $.getJSON("/auth/twitter", {login: 1}, function(data){
  149. window.location = data.url;
  150. });
  151. }
  152. });
  153. <?php endif ?>
  154. $("#send-html-content").click(function(){
  155. var enabled = $(this).attr("checked") == "checked";
  156. $.post("/settings/save", {
  157. html_content: (enabled ? 1 : 0)
  158. });
  159. });
  160. $("#save-slug-field").click(function(){
  161. $.post("/settings/save", {
  162. slug_field: $("#slug-field-name").val()
  163. });
  164. });
  165. $("#save-syndicate-to-field").click(function(){
  166. $.post("/settings/save", {
  167. syndicate_field: $("#syndicate-to-field-name").val()
  168. });
  169. });
  170. $("#reset-login").click(function(){
  171. $.post("/auth/reset", function(){
  172. window.location = "/";
  173. });
  174. });
  175. $("#save-weight-unit").click(function(){
  176. $.post("/settings/save", {
  177. weight_unit: $("#weight-unit").val()
  178. });
  179. });
  180. });
  181. function reload_syndications() {
  182. $.getJSON("/micropub/syndications", function(data){
  183. if(data.targets) {
  184. $("#syndication-container").html('<ul></ul>');
  185. for(var i in data.targets) {
  186. var target = data.targets[i].target;
  187. var uid = data.targets[i].uid;
  188. var favicon = data.targets[i].favicon;
  189. $("#syndication-container ul").append('<li><button data-syndicate-to="'+htmlspecialchars(uid ? uid : target)+'" class="btn btn-default btn-block">'+(favicon ? '<img src="'+htmlspecialchars(favicon)+'" width="16" height="16"> ':'')+htmlspecialchars(target)+'</button></li>');
  190. }
  191. bind_syndication_buttons();
  192. } else {
  193. }
  194. console.log(data);
  195. });
  196. }
  197. </script>