summaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
authorAaron Parecki <aaron@parecki.com>2014-07-06 18:28:18 -0700
committerAaron Parecki <aaron@parecki.com>2014-07-06 18:28:18 -0700
commit592eac5d8dc4c704bfb34915c0703fc2aecc6d46 (patch)
treea9875ed88b33674da0571c0ad8007c01eda07f23 /views
parentb2337158a38b7dfda6d5c4e3c5f0dd4ae9f4845d (diff)
Adds support for querying your micropub endpoint to check for syndication targets.
This changes the value of "in-reply-to" to use hyphens instead of underscore separators!! Also shows you the full request made to your micropub endpoint.
Diffstat (limited to 'views')
-rw-r--r--views/dashboard.php87
-rw-r--r--views/docs.php33
2 files changed, 114 insertions, 6 deletions
diff --git a/views/dashboard.php b/views/dashboard.php
index cabeedc..d88a59c 100644
--- a/views/dashboard.php
+++ b/views/dashboard.php
@@ -24,6 +24,24 @@
</div>
<div class="form-group">
+ <label for="note_syndicate-to"><code>syndicate-to</code> <a href="javascript:reload_syndications()">(refresh)</a></label>
+ <div id="syndication-container">
+ <?php
+ if($this->syndication_targets) {
+ echo '<ul>';
+ foreach($this->syndication_targets as $syn) {
+ 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>';
+ }
+ echo '</ul>';
+ } else {
+ ?><div class="bs-callout bs-callout-warning">No syndication targets were found on your site.
+ You can provide a <a href="/docs#syndication">list of supported syndication targets</a> that will appear as checkboxes here.</div><?php
+ }
+ ?>
+ </div>
+ </div>
+
+ <div class="form-group">
<label for="note_location"><code>location</code></label>
<input type="checkbox" id="note_location_chk" value="">
<img src="/images/spinner.gif" id="note_location_loading" style="display: none;">
@@ -45,6 +63,11 @@
<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>
+ <div id="last_request_container" style="display: none;">
+ <h4>Request made to your Micropub endpoint</h4>
+ <pre id="test_request" style="width: 100%; min-height: 140px;"></pre>
+ </div>
+
<?php if($this->test_response): ?>
<h4>Last response from your Micropub endpoint <span id="last_response_date">(<?= relative_time($this->response_date) ?>)</span></h4>
<?php endif; ?>
@@ -80,17 +103,26 @@
$(function(){
$("#btn_post").click(function(){
+
+ var syndications = [];
+ $("#syndication-container button.btn-info").each(function(i,btn){
+ syndications.push($(btn).data('syndication'));
+ });
+
$.post("/micropub/post", {
content: $("#note_content").val(),
- in_reply_to: $("#note_in_reply_to").val(),
+ 'in-reply-to': $("#note_in_reply_to").val(),
location: $("#note_location").val(),
category: $("#note_category").val(),
- slug: $("#note_slug").val()
+ slug: $("#note_slug").val(),
+ 'syndicate-to': syndications.join(',')
}, function(data){
var response = JSON.parse(data);
if(response.location != false) {
- $("#note_form").slideUp();
+ $("#note_form").slideUp(200, function(){
+ $(window).scrollTop($("#test_success").position().top);
+ });
$("#test_success").removeClass('hidden');
$("#test_error").addClass('hidden');
@@ -107,8 +139,11 @@ $(function(){
}
$("#last_response_date").html("(just now)");
+ $("#test_request").html(response.request);
+ $("#last_request_container").show();
$("#test_response").html(response.response);
- })
+ });
+ return false;
});
function location_error(msg) {
@@ -174,10 +209,54 @@ $(function(){
fetch_location();
}
+ bind_syndication_buttons();
});
+
+function reload_syndications() {
+ $.getJSON("/micropub/syndications", function(data){
+ if(data.targets) {
+ $("#syndication-container").html('<ul></ul>');
+ for(var i in data.targets) {
+ var target = data.targets[i].target;
+ var favicon = data.targets[i].favicon;
+ $("#syndication-container ul").append('<li><button data-syndication="'+target+'" class="btn btn-default btn-block"><img src="'+favicon+'" width="16" height="16"> '+target+'</button></li>');
+ }
+ bind_syndication_buttons();
+ } else {
+
+ }
+ console.log(data);
+ });
+}
+
+function bind_syndication_buttons() {
+ $("#syndication-container button").unbind("click").click(function(){
+ $(this).toggleClass('btn-info');
+ return false;
+ });
+}
+
</script>
<style type="text/css">
+ #syndication-container ul {
+ list-style-type: none;
+ margin: 0;
+ padding: 10px;
+ }
+ #syndication-container li {
+ padding: 0;
+ margin-bottom: 6px;
+ }
+ #syndication-container button {
+ max-width: 240px;
+ text-shadow: none;
+ }
+ #syndication-container button img {
+ float: left;
+ margin-left: 10px;
+ }
+
#last_response_date {
font-size: 80%;
font-weight: normal;
diff --git a/views/docs.php b/views/docs.php
index 48fd0d8..94856a1 100644
--- a/views/docs.php
+++ b/views/docs.php
@@ -1,7 +1,7 @@
<div class="narrow">
<?= partial('partials/header') ?>
- <h2>Introduction</h2>
+ <h2 id="introduction">Introduction</h2>
<div class="col-xs-6 col-md-4" style="float: right;">
<span class="thumbnail"><img src="/images/quill-ui.png"></span>
@@ -15,7 +15,9 @@
<p>Once you've signed in, you'll see an interface like the one shown which you can use to
write a post. Clicking "post" will make a Micropub request to your endpoint.<p>
- <h2>Configuring Endpoints</h2>
+
+
+ <h2 id="endpoints">Configuring Endpoints</h2>
<h3>Authorization Endpoint</h3>
<?= partial('partials/auth-endpoint-help') ?>
@@ -28,4 +30,31 @@
<p>The <a href="/creating-a-micropub-endpoint">Creating a Micropub Endpoint</a> tutorial will walk you through how to handle incoming POST requests from apps like this.</p>
+
+
+ <h2 id="syndication">Syndication Targets</h2>
+
+ <p>You can provide a list of supported syndication targets that will appear as checkboxes when you are creating a new post.</p>
+
+ <p>To do this, your Micropub endpoint will need to respond to a GET request containing a query string of <code>q=syndicate-to</code>. This request will be made with the access token that was generated for this app, so you can choose which syndication targets you want to allow this app to use.</p>
+
+ <p>Below is the request and expected response that Quill looks for.</p>
+
+ <pre><code>GET /micropub?q=syndicate-to HTTP/1.1
+Authorization: Bearer xxxxxxxxxx
+
+HTTP/1.1 200 OK
+Content-type: application/x-www-form-urlencoded
+
+syndicate-to=syndicate-to=twitter.com%2Faaronpk%2Cfacebook.com%2Faaronpk
+</code></pre>
+
+ <p>The response should be a form-encoded reply with a single field, <code>syndicate-to</code>. The value is a comma-separated list of syndication targets. The actual values are up to your Micropub endpoint, but a good convention is to use the domain name of the service (e.g. twitter.com), or domain name and username (e.g. twitter.com/aaronpk).</p>
+
+ <p>If you do include the domain name, Quill will be able to show icons for recognized services next to the checkboxes.</p>
+
+ <p>Quill will check for your supported syndication targets when you sign in, but there is also a link on the new post screen to manually re-check if you'd like.</p>
+
+
+
</div> \ No newline at end of file