TagSpaces is an offline, open source, document manager with tagging support
Enhancing tag suggestion with ui improvements and suggestions from the containing directory name
uggrock042f02b6a4a5
diff --git a/data/js/fileopener.js b/data/js/fileopener.jsindex dcfaece84..99403fc40 100644--- a/data/js/fileopener.js+++ b/data/js/fileopener.js@@ -201,7 +201,7 @@ define(function(require, exports, module) {$("#filetoolbox").append('<button id="nextFileButton" class="btn" title="Go to the next file"><i class="icon-circle-arrow-right"></i></button>');$("#filetoolbox").append('<button id="editDocument" class="btn" title="Edit File"><i class="icon-pencil"></i></button>');//$("#filetoolbox").append('<button id="openInNewWindow" class="btn" title="Go to the previous file"><i class="icon-circle-arrow-left"></i></button>');- $("#filetoolbox").append('<button id="openTagSuggestionMenu" class="btn" title="Tag Suggestions"><i class="icon-tags"></i> <b class="caret"></b></button>');+ $("#filetoolbox").append('<button id="openTagSuggestionMenu" class="btn" title="Tag File"><i class="icon-tag"></i> <b class="caret"></b></button>');//$("#filetoolbox").append('<button id="startFullscreen" class="btn" title="Open file in full screen"><i class="icon-fullscreen"></i></b></button>');$("#filetoolbox").append('<button id="openFileActionsMenu" data-dropdown="#fileActionsMenu" class="btn" title="Opens a menu with additional file actions"><i class="icon-th-list"></i> <b class="caret"></b></button>');$("#filetoolbox").append('<button id="closeOpenedFile" class="btn" title="Close file"><i class="icon-remove-sign"></i></button>');@@ -240,6 +240,7 @@ define(function(require, exports, module) {})));$( "#tagSuggestionsMenu" ).append($('<li>', {class: "divider"}));+ $( "#tagSuggestionsMenu" ).append($('<li>').append($('<a>', {text: " Tag Suggestion" })))// Adding context menu entries for creating tags according to the suggested tagsfor (var i=0; i < suggTags.length; i++) {@@ -249,9 +250,13 @@ define(function(require, exports, module) {title: "Add tag "+suggTags[i]+" to current file",tagname: suggTags[i],filepath: filePath,- text: " Tag with '"+suggTags[i]+"'",+ //text: " Tag with '"+suggTags[i]+"'",})- .prepend("<i class='icon-tag'></i>")+ .append($('<button>', {+ title: "Tag with "+suggTags[i],+ "class": "btn btn-small btn-success tagButton",+ text: suggTags[i]+ })).click(function() {var tagName = $(this).attr( "tagname" );var filePath = $(this).attr( "filepath" );diff --git a/data/js/tagutils.js b/data/js/tagutils.jsindex 139e23530..ba8d7edc4 100644--- a/data/js/tagutils.js+++ b/data/js/tagutils.js@@ -25,6 +25,11 @@ define(function(require, exports, module) {return filePath.substring(0, filePath.lastIndexOf(DIR_SEPARATOR));}+ function extractContainingDirectoryName(filePath) {+ var tmpStr = filePath.substring(0, filePath.lastIndexOf(DIR_SEPARATOR));+ return tmpStr.substring(tmpStr.lastIndexOf(DIR_SEPARATOR)+1,tmpStr.length);+ }+function extractFileExtension(filePath) {var ext = filePath.substring(filePath.lastIndexOf(".") + 1, filePath.length).toLowerCase().trim();if (filePath.lastIndexOf(".") < 0) { ext = ""; }@@ -90,10 +95,11 @@ define(function(require, exports, module) {console.log("Filename does not contains tags. Aborting extraction.");return tags;}+ var cleanedTags = [];+var tagContainer = fileName.slice(beginTagContainer+1,endTagContainer).trim();tags = tagContainer.split(TAG_DELIMITER);- var cleanedTags = [];for (var i=0; i < tags.length; i++) {if(tags[i].trim().length > 1) {cleanedTags.push(tags[i]);@@ -101,7 +107,6 @@ define(function(require, exports, module) {}console.log("Extracting finished ");-return cleanedTags;}@@ -123,6 +128,18 @@ define(function(require, exports, module) {tags = tagContainer.split(/[\s,+_-]+/);var cleanedTags = [];++ // Extracting tags from the name of the containing directory+ var tagsFromDirName = [];+ tagsFromDirName = extractContainingDirectoryName(filePath).trim().split(/[\s,+_-]+/);++ for (var i=0; i < tagsFromDirName.length; i++) {+ if(tagsFromDirName[i].trim().length > 1) {+ cleanedTags.push(tagsFromDirName[i]);+ }+ }++ // Cleaning the tags from filenamefor (var i=0; i < tags.length; i++) {if(tags[i].trim().length > 1) {cleanedTags.push(tags[i]);@@ -270,6 +287,7 @@ define(function(require, exports, module) {exports.isWindows = isWindows;exports.extractFileName = extractFileName;exports.extractContainingDirectoryPath = extractContainingDirectoryPath;+ exports.extractContainingDirectoryName = extractContainingDirectoryName;exports.extractFileExtension = extractFileExtension;exports.extractTitle = extractTitle;exports.formatFileSize = formatFileSize;