[gnome-books/wip/hadess/better-title] documents: Format title from URI if filename is not available




commit 415a70ff2da7ab0bb4a19a1e6356af982f39a0fd
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Feb 22 18:38:07 2021 +0100

    documents: Format title from URI if filename is not available
    
    This may (ATM, will) be inaccessible data out of the tracker:Documents
    graph. Avoid trying to make up for it in the SPARQL query, and handle
    the title formatting in code if the filename info is missing.

 src/documents.js | 2 ++
 src/query.js     | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/src/documents.js b/src/documents.js
index a2f15c6b..479036c4 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -317,6 +317,8 @@ const DocCommon = new Lang.Class({
             this.name = title;
         else if (this.filename)
             this.name = GdPrivate.filename_strip_extension(this.filename);
+       else if (this.uri)
+           this.name = Gio.File.new_for_uri(this.uri).get_basename()
         else
             this.name = '';
 
diff --git a/src/query.js b/src/query.js
index f753d3ae..1ff96fad 100644
--- a/src/query.js
+++ b/src/query.js
@@ -146,7 +146,7 @@ var QueryBuilder = new Lang.Class({
     _buildQueryInternal: function(global, flags, offsetController, sortBy) {
        let selectClauses =
             '    (nie:isStoredAs(?urn) AS ?uri) ' +
-            '    (COALESCE (nfo:fileName(?file), tracker:string-from-filename(nie:isStoredAs(?urn))) AS 
?filename) ' +
+            '    (nfo:fileName(?file) AS ?filename) ' +
             '    (nie:mimeType(?urn) AS ?mimetype) ' +
             '    (nie:title(?urn) AS ?title) ' +
             '    (tracker:coalesce(nco:fullname(?creator), nco:fullname(?publisher), \'\') AS ?author) ' +


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]