changeset 31:a6b2a09ea413

fix commentary chain visualisation author name display and search by clicking author name.
author casties
date Fri, 11 Dec 2015 17:06:26 -0500
parents cccbcc845d54
children 758a5313baf4
files ismi-python-neo4jrestclient/ismi-vis.py ismi-python-neo4jrestclient/static/commentaries.html ismi-python-neo4jrestclient/static/commentaries_authors2.html
diffstat 3 files changed, 14 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/ismi-python-neo4jrestclient/ismi-vis.py	Fri Dec 11 13:03:04 2015 -0500
+++ b/ismi-python-neo4jrestclient/ismi-vis.py	Fri Dec 11 17:06:26 2015 -0500
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 from json import dumps, loads
-import urllib.request
+import urllib.request, urllib.parse
 
 from flask import Flask, Response, request, send_from_directory
 
@@ -20,7 +20,7 @@
 
 @app.route("/")
 def get_index():
-    return app.send_static_file('commentaries_authors2.html')
+    return app.send_static_file('commentaries.html')
 
 @app.route("/commentaries.html")
 def get_commentaries():
@@ -156,7 +156,8 @@
 def get_search():
     try:
         q = request.args["q"]
-        norm_js = loadJSON(ismi_db_baseurl + "jsonInterface?method=normalize_string&type=arabic_translit&text=%s"%q)
+        qs = urllib.parse.quote(q)
+        norm_js = loadJSON(ismi_db_baseurl + "jsonInterface?method=normalize_string&type=arabic_translit&text=%s"%qs)
         nq = norm_js.get("normalized_text")            
     except KeyError:
         return []
--- a/ismi-python-neo4jrestclient/static/commentaries.html	Fri Dec 11 13:03:04 2015 -0500
+++ b/ismi-python-neo4jrestclient/static/commentaries.html	Fri Dec 11 17:06:26 2015 -0500
@@ -14,7 +14,7 @@
                     <li>
                         <form role="search" class="navbar-form" id="search">
                             <div class="form-group">
-                                <input type="text" value="7437" placeholder="Search for person-id" class="form-control" name="search">
+                                <input type="text" value="jaghmini" placeholder="Search for person name" class="form-control" name="search">
                             </div>
                             <button class="btn btn-default" type="submit">Search for author id</button>
                         </form>
@@ -114,7 +114,7 @@
        $(this).next().slideToggle();
     });
     // provide search and graph
-    backendApiPrefix = "/netvis-ismi";
+    backendApiPrefix = "";
     searchApi = {};
     $(function () {
         function showText(text_id) {
@@ -125,9 +125,10 @@
                         var $list = $("#info").empty();
                         $list.append($("<li>Author: " + data.author.label + " [" + data.author.ismi_id + "]</li>")
                                 .click(function() { 
-                                    search(data.author.ismi_id, true); 
+                                    search(data.author.label, true); 
                                     }));
                         for (var key in data.attrs) {
+                            if (key[0] === "_") continue;
                             var val = data.attrs[key];
                             if (key === "link") {
                                 val = "<a href=\"" + val + "\" target=\"_blank\">" + val + "</a>";
@@ -179,7 +180,7 @@
                             $("#graph .ismi-"+text.ismi_id).each(function(){this.classList.add("marked")});
                         });
                         if (!keep_detail_view) {
-                            // show first title
+                            // show first title in detail view
                             showText(data[0].text.ismi_id);
                         }
                     }, "json");
--- a/ismi-python-neo4jrestclient/static/commentaries_authors2.html	Fri Dec 11 13:03:04 2015 -0500
+++ b/ismi-python-neo4jrestclient/static/commentaries_authors2.html	Fri Dec 11 17:06:26 2015 -0500
@@ -16,7 +16,7 @@
                             <div class="form-group">
                                 <input type="text" value="jaghmini" placeholder="Search for person name" class="form-control" name="search">
                             </div>
-                            <button class="btn btn-default" type="submit">Search for author name</button>
+                            <button class="btn btn-default" type="submit">Search for author id</button>
                         </form>
                     </li>
                 </ul>
@@ -124,8 +124,9 @@
                         if (!data) return;
                         $("#title").text("Title: "+data.title);
                         var $list = $("#info").empty();
-                        $list.append($("<li> author: " + data.author + "</li>"));
+                        $list.append($("<li> author: " + data.author.label + "</li>"));
                         for (var key in data.attrs) {
+                            if (key[0] === "_") continue;
                             var val = data.attrs[key];
                             if (key === "link") {
                                 val = "<a href=\"" + val + "\" target=\"_blank\">" + val + "</a>";
@@ -158,6 +159,7 @@
                         if (!data || data.length == 0) return;
                         // clear all marks
                         $("#graph .marked").each(function(){this.classList.remove("marked")});
+                        // fill list of texts
                         data.forEach(function (row) {
                             var text = row.text;
                             var author = row.author;
@@ -170,6 +172,7 @@
                             // set mark
                             $("#graph .ismi-"+text.ismi_id).each(function(){this.classList.add("marked")});
                         });
+                        // show details of the first text
                         showText(data[0].text.ismi_id);
                     }, "json");
             return false;