Browse Source

split tags using tokenfield instead of comma-separated

this allows tag values to contain spaces, which is up to your own micropub server to handle appropriately.

closes #95 and replaces #96
pull/108/head
Aaron Parecki 7 years ago
parent
commit
1c3b6f50df
No known key found for this signature in database GPG Key ID: 276C2817346D6056
  1. 10
      public/editor-files/editor.js
  2. 9
      public/js/script.js
  3. 2
      views/event.php
  4. 2
      views/new-bookmark.php
  5. 2
      views/new-itinerary.php
  6. 2
      views/new-post.php

10
public/editor-files/editor.js

@ -72,7 +72,7 @@ $(function() {
$('#publish-in-progress').removeClass('hidden'); $('#publish-in-progress').removeClass('hidden');
$('#publish-fields').addClass('hidden'); $('#publish-fields').addClass('hidden');
var category = csv_to_array($("#post-tags").tokenfield('getTokensList'));
var category = $("#note_category").tokenfield("getTokens").map(function(t){ return t.value});
$.post('/editor/publish', { $.post('/editor/publish', {
name: $("#post-name").val(), name: $("#post-name").val(),
@ -149,14 +149,6 @@ function reset_page() {
return localforage.setItem('currentdraft', {}); return localforage.setItem('currentdraft', {});
} }
function csv_to_array(val) {
if(val.length > 0) {
return val.split(/[, ]+/);
} else {
return [];
}
}
/* ************************************************ */ /* ************************************************ */
/* autosave loop */ /* autosave loop */
var autosaveTimeout = false; var autosaveTimeout = false;

9
public/js/script.js

@ -14,14 +14,9 @@
return num; return num;
} }
function csv_to_array(val) {
if(val.length > 0) {
return val.split(/[, ]+/);
} else {
return [];
function tokenfieldToArray(sel) {
return $(sel).tokenfield("getTokens").map(function(t){ return t.value});
} }
}
$(function(){ $(function(){

2
views/event.php

@ -73,7 +73,7 @@
name: $("#event_name").val(), name: $("#event_name").val(),
start: event_start, start: event_start,
location: $("#event_location").val(), location: $("#event_location").val(),
category: csv_to_array($("#note_category").val())
category: tokenfieldToArray("#note_category")
}; };
if(event_end) { if(event_end) {

2
views/new-bookmark.php

@ -89,7 +89,7 @@ $(function(){
'bookmark-of': $("#note_bookmark").val(), 'bookmark-of': $("#note_bookmark").val(),
name: $("#note_name").val(), name: $("#note_name").val(),
content: $("#note_content").val(), content: $("#note_content").val(),
category: csv_to_array($("#note_category").val()),
category: tokenfieldToArray("#note_category"),
'<?= $this->user->micropub_syndicate_field ?>': syndications '<?= $this->user->micropub_syndicate_field ?>': syndications
}, function(response){ }, function(response){
if(response.location != false) { if(response.location != false) {

2
views/new-itinerary.php

@ -180,7 +180,7 @@ $(function(){
}); });
}); });
var category = csv_to_array($("#note_category").val());
var category = tokenfieldToArray("#note_category");
properties = { properties = {
itinerary: itinerary itinerary: itinerary

2
views/new-post.php

@ -689,7 +689,7 @@ $(function(){
syndications.push($(btn).data('syndicate-to')); syndications.push($(btn).data('syndicate-to'));
}); });
var category = csv_to_array($("#note_category").val());
var category = tokenfieldToArray("#note_category");
var formData = new FormData(); var formData = new FormData();
var entry = {}; var entry = {};

Loading…
Cancel
Save