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 6 years ago
parent
commit
1c3b6f50df
No known key found for this signature in database GPG Key ID: 276C2817346D6056
6 changed files with 7 additions and 20 deletions
  1. +1
    -9
      public/editor-files/editor.js
  2. +2
    -7
      public/js/script.js
  3. +1
    -1
      views/event.php
  4. +1
    -1
      views/new-bookmark.php
  5. +1
    -1
      views/new-itinerary.php
  6. +1
    -1
      views/new-post.php

+ 1
- 9
public/editor-files/editor.js View File

@ -72,7 +72,7 @@ $(function() {
$('#publish-in-progress').removeClass('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', {
name: $("#post-name").val(),
@ -149,14 +149,6 @@ function reset_page() {
return localforage.setItem('currentdraft', {});
}
function csv_to_array(val) {
if(val.length > 0) {
return val.split(/[, ]+/);
} else {
return [];
}
}
/* ************************************************ */
/* autosave loop */
var autosaveTimeout = false;

+ 2
- 7
public/js/script.js View File

@ -14,15 +14,10 @@
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(){
// Set the date from JS

+ 1
- 1
views/event.php View File

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

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

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

+ 1
- 1
views/new-itinerary.php View File

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

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

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

Loading…
Cancel
Save