Browse Source

use `mp-syndicate-to` by default, add setting

* adds setting to choose the property to use for the syndication targets
* all existing users default to the old value `syndicate-to`
* new users default to `mp-syndicate-to`

closes #66
pull/82/head
Aaron Parecki 8 years ago
parent
commit
0e8ee9973a
No known key found for this signature in database GPG Key ID: 276C2817346D6056
8 changed files with 36 additions and 11 deletions
  1. +4
    -0
      controllers/controllers.php
  2. +5
    -0
      schema/migrations/0004.sql
  3. +1
    -0
      schema/mysql.sql
  4. +1
    -0
      schema/sqlite.sql
  5. +1
    -1
      views/docs/note.php
  6. +6
    -6
      views/new-bookmark.php
  7. +2
    -2
      views/new-post.php
  8. +16
    -2
      views/settings.php

+ 4
- 0
controllers/controllers.php View File

@ -115,6 +115,7 @@ $app->get('/bookmark', function() use($app) {
'bookmark_tags' => $tags, 'bookmark_tags' => $tags,
'token' => generate_login_token(), 'token' => generate_login_token(),
'syndication_targets' => json_decode($user->syndication_targets, true), 'syndication_targets' => json_decode($user->syndication_targets, true),
'user' => $user,
'authorizing' => false 'authorizing' => false
)); ));
} }
@ -323,6 +324,9 @@ $app->post('/settings/save', function() use($app) {
if(array_key_exists('slug_field', $params) && $params['slug_field']) if(array_key_exists('slug_field', $params) && $params['slug_field'])
$user->micropub_slug_field = $params['slug_field']; $user->micropub_slug_field = $params['slug_field'];
if(array_key_exists('syndicate_field', $params) && $params['syndicate_field'])
$user->micropub_syndicate_field = $params['syndicate_field'];
$user->save(); $user->save();
$app->response()['Content-type'] = 'application/json'; $app->response()['Content-type'] = 'application/json';
$app->response()->body(json_encode(array( $app->response()->body(json_encode(array(

+ 5
- 0
schema/migrations/0004.sql View File

@ -0,0 +1,5 @@
ALTER TABLE users
ADD COLUMN `micropub_syndicate_field` VARCHAR(255) NOT NULL DEFAULT 'mp-syndicate-to' AFTER `micropub_slug_field`;
UPDATE users
SET micropub_syndicate_field = 'syndicate-to';

+ 1
- 0
schema/mysql.sql View File

@ -9,6 +9,7 @@ CREATE TABLE `users` (
`micropub_scope` varchar(255) DEFAULT NULL, `micropub_scope` varchar(255) DEFAULT NULL,
`micropub_response` text, `micropub_response` text,
`micropub_slug_field` varchar(255) NOT NULL DEFAULT 'mp-slug', `micropub_slug_field` varchar(255) NOT NULL DEFAULT 'mp-slug',
`micropub_syndicate_field` varchar(255) NOT NULL DEFAULT 'mp-syndicate-to',
`micropub_success` tinyint(4) DEFAULT '0', `micropub_success` tinyint(4) DEFAULT '0',
`date_created` datetime DEFAULT NULL, `date_created` datetime DEFAULT NULL,
`last_login` datetime DEFAULT NULL, `last_login` datetime DEFAULT NULL,

+ 1
- 0
schema/sqlite.sql View File

@ -9,6 +9,7 @@ CREATE TABLE users (
micropub_scope TEXT, micropub_scope TEXT,
micropub_response TEXT, micropub_response TEXT,
micropub_slug_field TEXT default 'mp-slug', micropub_slug_field TEXT default 'mp-slug',
micropub_syndicate_field TEXT default 'mp-syndicate-to',
micropub_success INTEGER default 0, micropub_success INTEGER default 0,
date_created datetime, date_created datetime,
last_login datetime, last_login datetime,

+ 1
- 1
views/docs/note.php View File

@ -30,7 +30,7 @@
<li><code>location</code> - If you check the "location" box, then this property will be a Geo URI with the location the browser detected. You will see a preview of the value in the note interface along with a map.</li> <li><code>location</code> - If you check the "location" box, then this property will be a Geo URI with the location the browser detected. You will see a preview of the value in the note interface along with a map.</li>
<li><code>photo</code> or <code>photo[]</code> - If your server supports a Media Endpoint, this will be set to the URL that your endpoint returned when it uploaded the photo. Otherwise, this will be one of the parts in the multipart request with the image file itself.</li> <li><code>photo</code> or <code>photo[]</code> - If your server supports a Media Endpoint, this will be set to the URL that your endpoint returned when it uploaded the photo. Otherwise, this will be one of the parts in the multipart request with the image file itself.</li>
<li><code>mp-slug</code> - If you enter a slug, this will be sent in the request. You can customize the name of this property in settings.</li> <li><code>mp-slug</code> - If you enter a slug, this will be sent in the request. You can customize the name of this property in settings.</li>
<li><code>syndicate-to[]</code> - (Note: this is deprecated and will be replaced with "mp-syndicate-to[]" soon) Each syndication destination selected will be sent in this property. The values will be the <code>uid</code> that your endpoint returns. See <a href="/docs/syndication">Syndication</a> for more details.</li>
<li><code>mp-syndicate-to[]</code> - Each syndication destination selected will be sent in this property. The values will be the <code>uid</code> that your endpoint returns. See <a href="/docs/syndication">Syndication</a> for more details. (If you are using an older Micropub endpoint that expects <code>syndicate-to</code>, you can customize this property in the settings.)</li>
</ul> </ul>
<hr> <hr>

+ 6
- 6
views/new-bookmark.php View File

@ -13,27 +13,27 @@
<form role="form" style="margin-top: 20px;" id="note_form"> <form role="form" style="margin-top: 20px;" id="note_form">
<div class="form-group"> <div class="form-group">
<label for="note_bookmark">Bookmark URL (<code>bookmark-of</code>)</label>
<label for="note_bookmark">Bookmark URL</label>
<input type="text" id="note_bookmark" value="<?= $this->bookmark_url ?>" class="form-control"> <input type="text" id="note_bookmark" value="<?= $this->bookmark_url ?>" class="form-control">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="note_name">Name (<code>name</code>)</label>
<label for="note_name">Name</label>
<input type="text" id="note_name" value="<?= $this->bookmark_name ?>" class="form-control"> <input type="text" id="note_name" value="<?= $this->bookmark_name ?>" class="form-control">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="note_content">Content (<code>content</code>, optional)</label>
<label for="note_content">Content</label>
<textarea id="note_content" value="" class="form-control" style="height: 5em;"><?= $this->bookmark_content ?></textarea> <textarea id="note_content" value="" class="form-control" style="height: 5em;"><?= $this->bookmark_content ?></textarea>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="note_category">Tags (<code>category</code>)</label>
<label for="note_category">Tags</label>
<input type="text" id="note_category" value="<?= $this->bookmark_tags ?>" class="form-control" placeholder="e.g. web, personal"> <input type="text" id="note_category" value="<?= $this->bookmark_tags ?>" class="form-control" placeholder="e.g. web, personal">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="note_syndicate-to">Syndicate (<code>syndicate-to</code>) <a href="javascript:reload_syndications()">refresh</a></label>
<label for="note_syndicate-to">Syndicate <a href="javascript:reload_syndications()">refresh</a></label>
<div id="syndication-container"> <div id="syndication-container">
<?php <?php
if($this->syndication_targets) { if($this->syndication_targets) {
@ -90,7 +90,7 @@ $(function(){
name: $("#note_name").val(), name: $("#note_name").val(),
content: $("#note_content").val(), content: $("#note_content").val(),
category: csv_to_array($("#note_category").val()), category: csv_to_array($("#note_category").val()),
'syndicate-to': syndications
'<?= $this->user->micropub_syndicate_field ?>': syndications
}, function(response){ }, function(response){
if(response.location != false) { if(response.location != false) {

+ 2
- 2
views/new-post.php View File

@ -429,7 +429,7 @@ $(function(){
} }
if(syndications.length > 0) { if(syndications.length > 0) {
for(var i in syndications) { for(var i in syndications) {
formData.append("syndicate-to[]", syndications[i]);
formData.append("<?= $this->user->micropub_syndicate_field ?>[]", syndications[i]);
} }
} }
if(v=$("#note_slug").val()) { if(v=$("#note_slug").val()) {
@ -485,7 +485,7 @@ $(function(){
location: $("#note_location").val(), location: $("#note_location").val(),
category: category, category: category,
slug: $("#note_slug").val(), slug: $("#note_slug").val(),
'syndicate-to': syndications
'<?= $this->user->micropub_syndicate_field ?>': syndications
}, function(data){ }, function(data){
var response = JSON.parse(data); var response = JSON.parse(data);

+ 16
- 2
views/settings.php View File

@ -36,15 +36,23 @@
<p>You can customize some of the properties that are sent in the Micropub request to work with your specific endpoint.</p> <p>You can customize some of the properties that are sent in the Micropub request to work with your specific endpoint.</p>
<table class="table table-condensed">
<table class="table table-condensed" width="100%">
<tr> <tr>
<td>Slug</td> <td>Slug</td>
<td>
<td width="160">
<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> <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>
<div><input type="button" class="btn btn-primary" value="Save" id="save-slug-field"></div> <div><input type="button" class="btn btn-primary" value="Save" id="save-slug-field"></div>
</td> </td>
<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 endpoint is using a custom property or the deprecated <code>slug</code> property.</td> <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 endpoint is using a custom property or the deprecated <code>slug</code> property.</td>
</tr> </tr>
<tr>
<td>Syndication</td>
<td>
<div style="margin-bottom:4px;"><input type="text" id="syndicate-to-field-name" value="<?= $this->user->micropub_syndicate_field ?>" placeholder="mp-syndicate-to" class="form-control"></div>
<div><input type="button" class="btn btn-primary" value="Save" id="save-syndicate-to-field"></div>
</td>
<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 endpoint is using the deprecated <code>syndicate-to</code> property.</td>
</tr>
<tr> <tr>
<td>Send HTML Content</td> <td>Send HTML Content</td>
<td><input type="checkbox" id="send-html-content" <?= $this->user->micropub_optin_html_content ? 'checked="checked"' : '' ?>></td> <td><input type="checkbox" id="send-html-content" <?= $this->user->micropub_optin_html_content ? 'checked="checked"' : '' ?>></td>
@ -91,5 +99,11 @@ $(function(){
}); });
}); });
$("#save-syndicate-to-field").click(function(){
$.post("/settings/save", {
syndicate_field: $("#syndicate-to-field-name").val()
});
});
}); });
</script> </script>

Loading…
Cancel
Save