# HG changeset patch
# User arussell
# Date 1450534665 18000
# Node ID 758a5313baf4999c678f69b236c27e04bb9590a7
# Parent acc60a20582c5404664dc57e63958e9c13cb79fe# Parent a6b2a09ea4134e4911d1798d41c780eaee00d6be
Changes merged.
diff -r acc60a20582c -r 758a5313baf4 ismi-python-neo4jrestclient/ismi-vis.py
--- a/ismi-python-neo4jrestclient/ismi-vis.py Sat Dec 19 09:15:43 2015 -0500
+++ b/ismi-python-neo4jrestclient/ismi-vis.py Sat Dec 19 09:17:45 2015 -0500
@@ -1,5 +1,6 @@
#!/usr/bin/env python
-from json import dumps
+from json import dumps, loads
+import urllib.request, urllib.parse
from flask import Flask, Response, request, send_from_directory
@@ -8,6 +9,13 @@
app = Flask(__name__, static_url_path='/static/')
app.debug = True
gdb = GraphDatabase("http://localhost:7474", username="neo4j", password="neo5j")
+ismi_db_baseurl = "http://localhost:18080/ismi-richfaces/"
+
+def loadJSON(url):
+ #print("JSON loading %s"%url)
+ wsh=urllib.request.urlopen(url)
+ txt = wsh.read()
+ return loads(txt.decode("utf-8"))
@app.route("/")
@@ -148,15 +156,21 @@
def get_search():
try:
q = request.args["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 []
else:
- query = ("MATCH (t:TEXT)-[:was_created_by]->(p:PERSON {ismi_id: {id}})"
+ #query = ("MATCH (t:TEXT)-[:was_created_by]->(p:PERSON {ismi_id: {id}})"
+ # " RETURN t,p,exists((t)-[:is_commentary_on]->()),exists(()-[:is_commentary_on]->(t))")
+ query = ("MATCH (t:TEXT)-[:was_created_by]->(p:PERSON)"
+ " WHERE p._n_label =~ {name}"
" RETURN t,p,exists((t)-[:is_commentary_on]->()),exists(()-[:is_commentary_on]->(t))")
results = gdb.query(
query,
returns=(Node,Node,bool,bool),
- params={"id": int(q)}
+ params={"name": ".*%s.*"%nq.lower()}
)
# {"name": "(?i).*" + q + ".*"}
print("search for %s returned %s results"%(repr(q),len(results)))
diff -r acc60a20582c -r 758a5313baf4 ismi-python-neo4jrestclient/static/commentaries.html
--- a/ismi-python-neo4jrestclient/static/commentaries.html Sat Dec 19 09:15:43 2015 -0500
+++ b/ismi-python-neo4jrestclient/static/commentaries.html Sat Dec 19 09:17:45 2015 -0500
@@ -14,7 +14,7 @@
@@ -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($("Author: " + data.author.label + " [" + data.author.ismi_id + "]")
.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 = "" + val + "";
@@ -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");
diff -r acc60a20582c -r 758a5313baf4 ismi-python-neo4jrestclient/static/commentaries_authors2.html
--- a/ismi-python-neo4jrestclient/static/commentaries_authors2.html Sat Dec 19 09:15:43 2015 -0500
+++ b/ismi-python-neo4jrestclient/static/commentaries_authors2.html Sat Dec 19 09:17:45 2015 -0500
@@ -14,7 +14,7 @@
@@ -100,7 +100,8 @@
.node.TEXT { fill: #888; }
.node.TEXT.marked { stroke: red; }
.node.TEXT.selected { fill: red; }
- .link { stroke: #999; stroke-opacity: .6; stroke-width: 1px; }
+ .link { stroke: #999; stroke-opacity: .6; stroke-width: 2px; }
+ .arrowHead { fill: #999 }
tr.marked {border: 2px solid red;}
@@ -123,8 +124,9 @@
if (!data) return;
$("#title").text("Title: "+data.title);
var $list = $("#info").empty();
- $list.append($(" author: " + data.author + ""));
+ $list.append($(" author: " + data.author.label + ""));
for (var key in data.attrs) {
+ if (key[0] === "_") continue;
var val = data.attrs[key];
if (key === "link") {
val = "" + val + "";
@@ -157,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;
@@ -169,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;
@@ -187,13 +191,30 @@
var force = d3.layout.force()
.charge(-100) // -200
- .linkDistance(15) // 30
+ .linkDistance(20) // 30
.size([width, height]);
var svg = d3.select("#graph").append("svg")
.attr("width", "1400px").attr("height", "1400px")
.attr("pointer-events", "all");
+ // arrow head marker
+ var defs = svg.append("defs").append("marker")
+ .attr({
+ "id":"arrow",
+ "markerUnits": "strokeWidth",
+ "viewBox":"0 -5 10 10",
+ "refX": 20, // 5
+ "refY":0,
+ "markerWidth":4,
+ "markerHeight":4,
+ "orient":"auto"
+ })
+ .append("path")
+ .attr("d", "M0,-5 L10,0 L0,5")
+ .attr("class","arrowHead");
+
+ // load graph
d3.json(backendApiPrefix+"/graph?limit=1000", function(error, graph) {
if (error) return;
@@ -201,7 +222,10 @@
var link = svg.selectAll(".link")
.data(graph.links).enter()
- .append("line").attr("class", "link");
+ .append("line").attr({
+ "class": "link",
+ "marker-end": "url(#arrow)"
+ });
var node = svg.selectAll(".node")
.data(graph.nodes).enter()