Skip to content

TagSpaces is an offline, open source, document manager with tagging support

Introduced new file list properties

Borislav Sapundzhiev5a3d659aa0e2
diff --git a/data/ext/perspectiveGrid/perspectiveUI.js b/data/ext/perspectiveGrid/perspectiveUI.js
index 6d10f7205..700f65755 100644
--- a/data/ext/perspectiveGrid/perspectiveUI.js
+++ b/data/ext/perspectiveGrid/perspectiveUI.js
@@ -68,7 +68,7 @@ define(function(require, exports, module) {
<button class="btn btn-link fileTileSelector" filepath="{{filepath}}"><i class="fa {{selected}} fa-lg"></i></button></p></li>');
var fileTileTmbTmpl = Handlebars.compile('<li title="{{filepath}}" filepath="{{filepath}}" class="fileTile">\
- <span><img class="thumbImgTile" filepath="{{tmbpath}}" style="max-width: 200px; max-height: 200px;" src=""></span>\
+ <span><img class="thumbImgTile" filepath="{{tmbpath}}" style="max-width: 200px; max-height: 200px;" src="{{thumbPath}}"></span>\
<p class="titleInFileTile">{{title}}</p><span class="tagsInFileTile">\
{{#each tags}}\
<button class="btn btn-sm tagButton fileTagsTile" tag="{{tag}}" filepath="{{filepath}}" style="{{style}}">{{tag}} <span class="caret"></span></button>\
@@ -76,7 +76,7 @@ define(function(require, exports, module) {
</span><span class="fileExtTile">{{fileext}}</span>\
<button class="btn btn-link fileTileSelector" filepath="{{filepath}}"><i class="fa {{selected}} fa-lg"></i></button></p></li>');
- ExtUI.prototype.createFileTile = function(title, filePath, fileExt, fileTags, isSelected) {
+ ExtUI.prototype.createFileTile = function(title, filePath, fileExt, fileTags, isSelected, metaObj) {
//TODO minimize platform specific calls
var tmbPath;
if (isCordova || isWeb) {
@@ -84,16 +84,17 @@ define(function(require, exports, module) {
} else {
tmbPath = "file:///" + filePath;
}
-
+ var metaObj = metaObj || { thumbnailPath : ""};
var context = {
filepath: filePath,
tmbpath: tmbPath,
fileext: fileExt,
title: title,
tags: [],
- selected: isSelected ? "fa-check-square-o" : "fa-square-o"
+ selected: isSelected ? "fa-check-square-o" : "fa-square-o",
+ thumbPath: metaObj.thumbnailPath
};
-
+
if (fileTags.length > 0) {
var tagString = "" + fileTags;
var tags = tagString.split(",");
@@ -279,7 +280,7 @@ define(function(require, exports, module) {
$("#" + this.extensionID + "IncreaseThumbsButton").prop('disabled', false);
TSCORE.showLoadingAnimation();
var $tiltleElem = $("#" + this.extensionID + "Container .thumbImgTile");
- $tiltleElem.each(function(index) {
+ /*$tiltleElem.each(function(index) {
var $element = $(this);
if (TSPRO.available) {
TSPRO.getThumbnailURL($element.attr('filepath'), function(dataURL) {
@@ -310,7 +311,7 @@ define(function(require, exports, module) {
}
}
$element.attr('style', "");
- });
+ });*/
$('.thumbImgTile').css({
"max-width": TMB_SIZES[this.currentTmbSize],
"max-height": TMB_SIZES[this.currentTmbSize]
@@ -581,7 +582,9 @@ define(function(require, exports, module) {
value[j][TSCORE.fileListTITLE],
value[j][TSCORE.fileListFILEPATH],
value[j][TSCORE.fileListFILEEXT],
- value[j][TSCORE.fileListTAGS]
+ value[j][TSCORE.fileListTAGS],
+ false,
+ value[j][TSCORE.fileListMETA]
));
}
diff --git a/data/js/core.api.js b/data/js/core.api.js
index fa777ba58..39f84f669 100644
--- a/data/js/core.api.js
+++ b/data/js/core.api.js
@@ -659,6 +659,7 @@ define(function(require, exports, module) {
exports.fileListFILELMDT = 4;
exports.fileListFILEPATH = 5;
exports.fileListFILENAME = 6;
+ exports.fileListMETA = 7;
//document events
exports.createDocumentEvent = createDocumentEvent;
exports.fireDocumentEvent = fireDocumentEvent;
diff --git a/data/js/perspective.manager.js b/data/js/perspective.manager.js
index 8baf30c02..799ac229e 100644
--- a/data/js/perspective.manager.js
+++ b/data/js/perspective.manager.js
@@ -6,6 +6,7 @@ define(function(require, exports, module) {
console.log('Loading perspective.manager.js ...');
var perspectives;
var TSCORE = require('tscore');
+ var TSPRO = require("tspro");
var initPerspectives = function() {
perspectives = [];
@@ -176,6 +177,7 @@ define(function(require, exports, module) {
var updateFileBrowserData = function(dirList) {
console.log('Updating the file browser data...');
TSCORE.fileList = [];
+ var workers = [];
var tags, ext, title, fileSize, fileLMDT, path, filename, entry;
for (var i = 0; i < dirList.length; i++) {
// Considering Unix HiddenEntries (. in the beginning of the filename)
@@ -195,6 +197,10 @@ define(function(require, exports, module) {
if (fileLMDT === undefined) {
fileLMDT = '';
}
+ var metaObj = {
+ thumbnailPath: "",
+ metaData: null
+ };
entry = [
ext,
title,
@@ -202,9 +208,11 @@ define(function(require, exports, module) {
fileSize,
fileLMDT,
path,
- filename
+ filename,
+ metaObj
];
TSCORE.fileList.push(entry);
+ workers.push(loadMetaDataFromFile(path,entry));
} else {
entry = [
path,
@@ -215,8 +223,41 @@ define(function(require, exports, module) {
}
}
changePerspective(TSCORE.currentPerspectiveID);
+
+ Promise.all(workers).then(function(result) {
+ //TSCORE.fileList = result;
+ //refreshFileListContainer();
+ }).catch(function(error) {
+ console.log("MetaData Error: " + error);
+ });
};
+ function loadMetaDataFromFile(filePath, entry) {
+
+ var promise = new Promise(function(resolve, reject) {
+ if (TSPRO.available) {
+ TSPRO.getThumbnailURL(filePath, function(dataURL) {
+ entry[TSCORE.fileListMETA].thumbnailPath = dataURL;
+ resolve(entry);
+ }, reject);
+ } else {
+ var metaFilePath = TSCORE.findMetaFilebyPath(filePath, "png");
+ if (metaFilePath) {
+ entry[TSCORE.fileListMETA].thumbnailPath = metaFilePath;
+ }
+ var metaFileJson = TSCORE.findMetaFilebyPath(filePath, "json");
+ if(metaFileJson) {
+ TSCORE.IO.getFileContent(metaFileJson, function(result) {
+ var str = String.fromCharCode.apply(null, new Uint8Array(result));
+ entry[TSCORE.fileListMETA].metaData = JSON.parse(str);
+ }, reject);
+ }
+ resolve(entry);
+ }
+ });
+ return promise;
+ }
+
var refreshFileListContainer = function() {
// TODO consider search view
TSCORE.IO.listDirectory(TSCORE.currentPath);