TagSpaces is an offline, open source, document manager with tagging support
add geo smart tags
kristiyanddcad18f66daa3
diff --git a/data/js/core.ui.js b/data/js/core.ui.jsindex 270bb432b..478c5b6b6 100644--- a/data/js/core.ui.js+++ b/data/js/core.ui.js@@ -738,7 +738,7 @@ define(function(require, exports, module) {var dateTimeRegExp = /^\d\d\d\d-(00|[0-9]|1[0-9]|2[0-3]):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9])$/g;var dateTimeWinRegExp = /^(([0-1]?[0-9])|([2][0-3]))!([0-5]?[0-9])(!([0-5]?[0-9]))?$/g;var dateRangeRegExp = /^([0]?[1-9]|[1|2][0-9]|[3][0|1])[-]([0]?[1-9]|[1][0-2])$/g;-+ var geoTag = 'geoTag';var currentCoordinate;var currentDateTime = dataTag;@@ -771,7 +771,7 @@ define(function(require, exports, module) {currentDateTime.match(dateTimeWinRegExp) ||year || month || date;- if (geoLocationRegExp.exec(currentCoordinate)) {+ if (geoLocationRegExp.exec(currentCoordinate) || geoTag === dataTag) {$('.nav-tabs a[href="#geoLocation"]').tab('show');} else if (dateRegExp) {$('.nav-tabs a[href="#dateTimeTab"]').tab('show');@@ -1253,4 +1253,5 @@ define(function(require, exports, module) {exports.reportIssues = reportIssues;exports.whatsNew = whatsNew;exports.showDocumentation = showDocumentation;+ exports.tagRecognition = tagRecognition;});diff --git a/data/js/map.ui.js b/data/js/map.ui.jsindex e2a70f5de..9c4f6b569 100644--- a/data/js/map.ui.js+++ b/data/js/map.ui.js@@ -71,8 +71,13 @@ define(function(require, exports, module) {return parseFloat(currentLat) + "," + parseFloat(currentLong);}+ function showViewLocation() {+ tagSpacesMap.setView(new L.LatLng(54.5259614, +15.2551187), 5);+ }++function showGeoLocation(coordinate) {- tagSpacesMap.setView(new L.LatLng(54.5259614, -15.2551187), 5);+ showViewLocation();tileLayer.addTo(tagSpacesMap);var regExp = /^([-+]?)([\d]{1,2})(((\.)(\d+)(,)))(\s*)(([-+]?)([\d]{1,3})((\.)(\d+))?)$/g;@@ -82,6 +87,11 @@ define(function(require, exports, module) {} else if (coordinate.lastIndexOf('-') !== -1) {currentCoordinate = splitValue(coordinate, coordinate.lastIndexOf('-'));}+ var geoTag = TSCORE.selectedTag === 'geoTag';++ if (geoTag) {+ showViewLocation();+ }if (regExp.exec(currentCoordinate)) {tagSpacesMap.setView([currentLat, currentLong], 13);@@ -89,7 +99,8 @@ define(function(require, exports, module) {draggable: true}).addTo(tagSpacesMap).bindPopup('Tag', {showOnMouseOver: true});} else {- tagSpacesMap.setView([54.5259614, +15.2551187], 5);+ showViewLocation();+ //tagSpacesMap.setView([54.5259614, +15.2551187], 5);}}@@ -163,7 +174,11 @@ define(function(require, exports, module) {});$('#dialogEditTag').on('hidden.bs.modal', function() {- removeMarker();+ //removeMarker();+ if (TSCORE.selectedTag === 'geoTag') {+ TSCORE.TagUtils.removeTag(TSCORE.selectedFiles[0], TSCORE.selectedTag);+ removeMarker();+ }});}});diff --git a/data/js/settings.default.js b/data/js/settings.default.jsindex 1e83310d9..4caaf11cc 100644--- a/data/js/settings.default.js+++ b/data/js/settings.default.js@@ -249,6 +249,14 @@ define(function (require, exports, module) {"desciption": "Adds the current year as tag","color": "#4986e7","textcolor": "#ffffff"+ },+ {+ "type": "smart",+ "title": "geoTag",+ "functionality": "geoLocation",+ "desciption": "Adds the current geo location as tag",+ "color": "#4986e7",+ "textcolor": "#ffffff"}]},diff --git a/data/js/tags.ui.js b/data/js/tags.ui.jsindex c7f55e99f..21145b872 100644--- a/data/js/tags.ui.js+++ b/data/js/tags.ui.js@@ -17,45 +17,46 @@ define(function(require, exports, module) {var TSCORE = require('tscore');var tagGroupsTmpl = Handlebars.compile(- '{{#each tagGroups}}' +- '<div class="accordion-group disableTextSelection tagGroupContainer">' +- '<div class="accordion-heading btn-group ui-droppable tagGroupContainerHeading flexLayout" key="{{key}}">' +- '<button class="btn btn-link btn-lg tagGroupIcon" data-toggle="collapse" data-target="#tagButtons{{@index}}" data-i18n="[title]ns.common:toggleTagGroup" title="{{../toggleTagGroup}}">' +- '<i class="fa fa-tags fa-fw"></i>' +- '</button>' +- '<button class="btn btn-link tagGroupTitle flexMaxWidth" data-toggle="collapse" data-target="#tagButtons{{@index}}" key="{{key}}">{{title}} ' +- '<sup><span class="badge" style="font-size: 9px;" data-i18n="[title]ns.common:tagGroupTagsCount">{{children.length}}</span></sup></button>' +- '<button class="btn btn-link btn-lg tagGroupActions" key="{{key}}" data-i18n="[title]ns.common:tagGroupOperations" title="{{../tagGroupOperations}}">' +- '<b class="fa fa-ellipsis-v"></b>' +- '</button>' +- '</div>' +- '{{#if collapse}}' ++ '{{#each tagGroups}}' ++ '<div class="accordion-group disableTextSelection tagGroupContainer">' ++ '<div class="accordion-heading btn-group ui-droppable tagGroupContainerHeading flexLayout" key="{{key}}">' ++ '<button class="btn btn-link btn-lg tagGroupIcon" data-toggle="collapse" data-target="#tagButtons{{@index}}" data-i18n="[title]ns.common:toggleTagGroup" title="{{../toggleTagGroup}}">' ++ '<i class="fa fa-tags fa-fw"></i>' ++ '</button>' ++ '<button class="btn btn-link tagGroupTitle flexMaxWidth" data-toggle="collapse" data-target="#tagButtons{{@index}}" key="{{key}}">{{title}} ' ++ '<sup><span class="badge" style="font-size: 9px;" data-i18n="[title]ns.common:tagGroupTagsCount">{{children.length}}</span></sup></button>' ++ '<button class="btn btn-link btn-lg tagGroupActions" key="{{key}}" data-i18n="[title]ns.common:tagGroupOperations" title="{{../tagGroupOperations}}">' ++ '<b class="fa fa-ellipsis-v"></b>' ++ '</button>' ++ '</div>' ++ '{{#if collapse}}' +'<div class="accordion-body collapse" id="tagButtons{{@index}}">' +- '{{else}}' ++ '{{else}}' +'<div class="accordion-body collapse in" id="tagButtons{{@index}}">' +- '{{/if}}' +- '<div class="accordion-inner" id="tagButtonsContent{{@index}}" style="padding: 2px;">' +- '<div>' +- '{{#each children}}' +- '<a class="btn btn-sm tagButton" tag="{{title}}" parentkey="{{../key}}" style="{{style}}" title="{{description}}" >' +- '<span class="{{icon}}" /> ' +- '{{title}}' +- '{{#if count}} <span class="badge" style="font-size: 9px; background-color: rgba(187, 187, 187, 0.26);" data-i18n="[title]ns.common:tagGroupTagsCount1">{{count}}</span>{{/if}}' +- ' <span class="fa fa-ellipsis-v"></span>' +- '</a>' +- '{{/each}}' +- '</div>' +- '</div>' +- '</div>' +- '</div>' +- '{{/each}}'+ '{{/if}}' ++ '<div class="accordion-inner" id="tagButtonsContent{{@index}}" style="padding: 2px;">' ++ '<div>' ++ '{{#each children}}' ++ '<a class="btn btn-sm tagButton" tag="{{title}}" parentkey="{{../key}}" style="{{style}}" title="{{description}}" >' ++ '<span class="{{icon}}" /> ' ++ '{{title}}' ++ '{{#if count}} <span class="badge" style="font-size: 9px; background-color: rgba(187, 187, 187, 0.26);" data-i18n="[title]ns.common:tagGroupTagsCount1">{{count}}</span>{{/if}}' ++ ' <span class="fa fa-ellipsis-v"></span>' ++ '</a>' ++ '{{/each}}' ++ '</div>' ++ '</div>' ++ '</div>' ++ '</div>' ++ '{{/each}}');var tagButtonTmpl = Handlebars.compile('{{#each tags}} <button class="btn btn-sm tagButton" tag="{{tag}}" ' + 'filepath="{{filepath}}" style="{{style}}">{{tag}} <span class="fa fa-ellipsis-v dropDownIcon"></span></button>{{/each}}');function initUI() {- $('#extMenuAddTagAsFilter').click(function() {});+ $('#extMenuAddTagAsFilter').click(function() {+ });// Context menu for the tags in the file table and the file viewer$('#tagMenuAddTagAsFilter').click(function() {TSCORE.searchForTag(TSCORE.selectedTag);@@ -100,7 +101,7 @@ define(function(require, exports, module) {console.log("tagGroupMenuImportTags");$('#jsonImportFileInput').click();$('#jsonImportFileInput').on('change', function(selection) {-+var file = selection.currentTarget.files[0];//addFileInputName = decodeURIComponent(file.name);var reader = new FileReader();@@ -242,6 +243,9 @@ define(function(require, exports, module) {tag.icon = '';if (tag.type === 'smart') {tag.icon = 'fa fa-flask';+ if (tag.title === 'geoTag') {+ tag.icon = 'fa fa-map-marker';+ }}// Add keybinding to tagsif (tag.keyBinding && tag.keyBinding.length > 0) {@@ -348,39 +352,36 @@ define(function(require, exports, module) {var d;if (tagData.type === 'smart') {switch (tagData.functionality) {- case 'here': {- /* window.onload = function() {- if (navigator.geolocation) {- navigator.geolocation.getCurrentPosition(function(position) {- var lat = position.coords.latitude;- var lng = position.coords.longitude;- alert("Current position: " + lat + " " + lng);- }, function(error) {- alert('Error occurred. Error code: ' + error.code);- },{timeout:50000});- }else{- alert('no geolocation support');- }- };*/+ case 'geoLocation':+ {+ $('#viewContainers').on('drop dragend', function(event) {+ event.preventDefault();+ //tagValue = TSCORE.showTagEditDialog();+ tagValue = TSCORE.TagUtils.formatGeoTag();+ });break;}- case 'today': {+ case 'today':+ {tagValue = TSCORE.TagUtils.formatDateTime4Tag(new Date(), false);break;}- case 'tomorrow': {+ case 'tomorrow':+ {d = new Date();d.setDate(d.getDate() + 1);tagValue = TSCORE.TagUtils.formatDateTime4Tag(d, false);break;}- case 'yesterday': {+ case 'yesterday':+ {d = new Date();d.setDate(d.getDate() - 1);tagValue = TSCORE.TagUtils.formatDateTime4Tag(d, false);break;}- case 'currentMonth': {+ case 'currentMonth':+ {var cMonth = '' + (new Date().getMonth() + 1);if (cMonth.length === 1) {cMonth = '0' + cMonth;@@ -388,15 +389,18 @@ define(function(require, exports, module) {tagValue = '' + new Date().getFullYear() + cMonth;break;}- case 'currentYear': {+ case 'currentYear':+ {tagValue = '' + new Date().getFullYear();break;}- case 'now': {+ case 'now':+ {tagValue = TSCORE.TagUtils.formatDateTime4Tag(new Date(), true);break;}- default: {+ default:+ {break;}}@@ -481,15 +485,15 @@ define(function(require, exports, module) {}function showImportTagsDialog(tagGroups) {-+require(['text!templates/ImportTagsDialog.html'], function(uiTPL) {if ($('#dialogImportTags').length < 1) {var uiTemplate = Handlebars.compile(uiTPL);- $('body').append(uiTemplate({objects:tagGroups}));+ $('body').append(uiTemplate({objects: tagGroups}));$('#importTagsButton').on('click', function() {-+tagGroups.forEach(function(value) {TSCORE.Config.addTagGroup(value);});@@ -631,7 +635,7 @@ define(function(require, exports, module) {selectOnBlur: true,formatSelectionCssClass: function(tag, container) {var style = generateTagStyle(TSCORE.Config.findTag(tag.text));- if (style) {+ if (style) {$(container).parent().attr("style", style);}}diff --git a/data/js/tagutils.js b/data/js/tagutils.jsindex 4ecbc64bc..ce796a565 100644--- a/data/js/tagutils.js+++ b/data/js/tagutils.js@@ -101,7 +101,7 @@ define(function(require, exports, module) {// cases like "asd ] asd ["else if (beginTagContainer > endTagContainer) {// case: [ not found in the filename- else if ( beginTagContainer < 0 )+ else if ( beginTagContainer < 0 )else if ( endTagContainer < 0 ) */if (beginTagContainer >= 0 && beginTagContainer < endTagContainer) {if (beginTagContainer === 0 && endTagContainer === fileName.trim().length) {@@ -189,6 +189,10 @@ define(function(require, exports, module) {return cYear + '.' + cMonth + '.' + cDate + time;}+ //function geoTag(dataTag){+ // return TSCORE.tagRecognition(dataTag)+ //}+function formatDateTime4Tag(date, includeTime, includeMS) {if (date === undefined || date === '') {return '';@@ -223,15 +227,19 @@ define(function(require, exports, module) {}var time = '';if (includeTime) {- time = '-' + cHour + '' + cMinute + '' + cSecond;+ time = '~' + cHour + '' + cMinute + '' + cSecond;}var milliseconds = '';if (includeMS) {- milliseconds = '-' + d.getMilliseconds();+ milliseconds = '~' + d.getMilliseconds();}return cYear + '' + cMonth + '' + cDate + time + milliseconds;}+ function formatGeoTag(){+ TSCORE.showTagEditDialog();+ }+function convertStringToDate(dateString) {if (dateString === undefined || dateString === '') {return false;@@ -574,6 +582,7 @@ define(function(require, exports, module) {exports.formatFileSize = formatFileSize;exports.formatDateTime = formatDateTime;exports.formatDateTime4Tag = formatDateTime4Tag;+ exports.formatGeoTag = formatGeoTag;exports.convertStringToDate = convertStringToDate;exports.extractTags = extractTags;exports.suggestTags = suggestTags;