summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Parecki <aaron@parecki.com>2017-01-17 09:24:41 -0800
committerAaron Parecki <aaron@parecki.com>2017-01-17 09:24:41 -0800
commit0e8ee9973a550a3ab0a2069d9a12b683651b7d9b (patch)
treea6f5449d8dd09e815ad659396a1aaa350354215e
parent3bdcd009c8817df5275041d5c4d72c716d660456 (diff)
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
-rw-r--r--controllers/controllers.php4
-rw-r--r--schema/migrations/0004.sql5
-rw-r--r--schema/mysql.sql1
-rw-r--r--schema/sqlite.sql1
-rw-r--r--views/docs/note.php2
-rw-r--r--views/new-bookmark.php12
-rw-r--r--views/new-post.php4
-rw-r--r--views/settings.php18
8 files changed, 36 insertions, 11 deletions
diff --git a/controllers/controllers.php b/controllers/controllers.php
index 505589f..3f95147 100644
--- a/controllers/controllers.php
+++ b/controllers/controllers.php
@@ -115,6 +115,7 @@ $app->get('/bookmark', function() use($app) {
'bookmark_tags' => $tags,
'token' => generate_login_token(),
'syndication_targets' => json_decode($user->syndication_targets, true),
+ 'user' => $user,
'authorizing' => false
));
}
@@ -323,6 +324,9 @@ $app->post('/settings/save', function() use($app) {
if(array_key_exists('slug_field', $params) && $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();
$app->response()['Content-type'] = 'application/json';
$app->response()->body(json_encode(array(
diff --git a/schema/migrations/0004.sql b/schema/migrations/0004.sql
new file mode 100644
index 0000000..8b74018
--- /dev/null
+++ b/schema/migrations/0004.sql
@@ -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';
diff --git a/schema/mysql.sql b/schema/mysql.sql
index 31f10fd..9796b5d 100644
--- a/schema/mysql.sql
+++ b/schema/mysql.sql
@@ -9,6 +9,7 @@ CREATE TABLE `users` (
`micropub_scope` varchar(255) DEFAULT NULL,
`micropub_response` text,
`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',
`date_created` datetime DEFAULT NULL,
`last_login` datetime DEFAULT NULL,
diff --git a/schema/sqlite.sql b/schema/sqlite.sql
index 1dced77..00e5f1c 100644
--- a/schema/sqlite.sql
+++ b/schema/sqlite.sql
@@ -9,6 +9,7 @@ CREATE TABLE users (
micropub_scope TEXT,
micropub_response TEXT,
micropub_slug_field TEXT default 'mp-slug',
+ micropub_syndicate_field TEXT default 'mp-syndicate-to',
micropub_success INTEGER default 0,
date_created datetime,
last_login datetime,
diff --git a/views/docs/note.php b/views/docs/note.php
index 654c478..737e811 100644
--- a/views/docs/note.php
+++ b/views/docs/note.php
@@ -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>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>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>
<hr>
diff --git a/views/new-bookmark.php b/views/new-bookmark.php
index 32e9043..068422f 100644
--- a/views/new-bookmark.php
+++ b/views/new-bookmark.php
@@ -13,27 +13,27 @@
<form role="form" style="margin-top: 20px;" id="note_form">
<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">
</div>
<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">
</div>
<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>
</div>
<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">
</div>
<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">
<?php
if($this->syndication_targets) {
@@ -90,7 +90,7 @@ $(function(){
name: $("#note_name").val(),
content: $("#note_content").val(),
category: csv_to_array($("#note_category").val()),
- 'syndicate-to': syndications
+ '<?= $this->user->micropub_syndicate_field ?>': syndications
}, function(response){
if(response.location != false) {
diff --git a/views/new-post.php b/views/new-post.php
index 7059c5e..57a2ffa 100644
--- a/views/new-post.php
+++ b/views/new-post.php
@@ -429,7 +429,7 @@ $(function(){
}
if(syndications.length > 0) {
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()) {
@@ -485,7 +485,7 @@ $(function(){
location: $("#note_location").val(),
category: category,
slug: $("#note_slug").val(),
- 'syndicate-to': syndications
+ '<?= $this->user->micropub_syndicate_field ?>': syndications
}, function(data){
var response = JSON.parse(data);
diff --git a/views/settings.php b/views/settings.php
index 2662eb0..5895718 100644
--- a/views/settings.php
+++ b/views/settings.php
@@ -36,16 +36,24 @@
<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>
<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><input type="button" class="btn btn-primary" value="Save" id="save-slug-field"></div>
</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>
+ <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>
<td>Send HTML Content</td>
<td><input type="checkbox" id="send-html-content" <?= $this->user->micropub_optin_html_content ? 'checked="checked"' : '' ?>></td>
<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>
@@ -91,5 +99,11 @@ $(function(){
});
});
+ $("#save-syndicate-to-field").click(function(){
+ $.post("/settings/save", {
+ syndicate_field: $("#syndicate-to-field-name").val()
+ });
+ });
+
});
</script>