# HG changeset patch # User casties # Date 1444395680 -7200 # Node ID d964d9a238377cc8b65bf0d588b6a70f6626796b # Parent d8bbf6d5920b478c4de3f6d93c142140387ac8f4 now with clickable author names in detail panel. diff -r d8bbf6d5920b -r d964d9a23837 ismi-python-neo4jrestclient/ismi-vis.py --- a/ismi-python-neo4jrestclient/ismi-vis.py Fri Oct 09 12:54:39 2015 +0200 +++ b/ismi-python-neo4jrestclient/ismi-vis.py Fri Oct 09 15:01:20 2015 +0200 @@ -188,9 +188,9 @@ " optional match (s)-[:was_created_by]->(sa:PERSON)" " optional match (t)<-[:is_commentary_on]-(c:TEXT)" " optional match (c)-[:was_created_by]->(ca:PERSON)" - " return t,a.label,s.label,s.ismi_id,sa.label,c.label,c.ismi_id,ca.label") + " return t,a.label,a.ismi_id,s.label,s.ismi_id,sa.label,c.label,c.ismi_id,ca.label") print("query:%s"%query) - results = gdb.query(query, returns=(Node,str,str,str,str,str,str,str), + results = gdb.query(query, returns=(Node,str,str,str,str,str,str,str,str), params={"text_id": int(text_id)}) print("result:%s"%results) @@ -198,9 +198,10 @@ author = None scs = {} cs = {} - for [t,a_label,s_label,s_id,sa_label,c_label,c_id,ca_label] in results: + for [t,a_label,a_id,s_label,s_id,sa_label,c_label,c_id,ca_label] in results: text = t author = a_label + author_id = a_id if s_id is not None and s_id != "None": scs[int(s_id)] = {"title": s_label, "author":sa_label} @@ -209,7 +210,7 @@ print("text:%s scs:%s cs:%s"%(text, scs, cs)) return Response(dumps({"title": text['label'], "attrs": text.properties, - "author": author, + "author": {"label": author, "ismi_id": author_id}, "commenting": scs, "commentaries": cs}), mimetype="application/json") diff -r d8bbf6d5920b -r d964d9a23837 ismi-python-neo4jrestclient/static/commentaries_authors3.html --- a/ismi-python-neo4jrestclient/static/commentaries_authors3.html Fri Oct 09 12:54:39 2015 +0200 +++ b/ismi-python-neo4jrestclient/static/commentaries_authors3.html Fri Oct 09 15:01:20 2015 +0200 @@ -39,14 +39,13 @@
- Texts by this author + Titles by this author (click to hide)
- @@ -124,7 +123,10 @@ if (!data) return; $("#title").text("Title: "+data.title); var $list = $("#info").empty(); - $list.append($("
  • author: " + data.author + "
  • ")); + $list.append($("
  • Author: " + data.author.label + "
  • ") + .click(function() { + search(data.author.ismi_id, true); + })); for (var key in data.attrs) { var val = data.attrs[key]; if (key === "link") { @@ -135,6 +137,7 @@ // re-set selected $("#graph .selected").each(function(){this.classList.remove("selected")}); $("#graph .ismi-"+data.attrs.ismi_id).each(function(){this.classList.add("selected")}); + // add commentaries var $commentaries = $("#commentaries").empty(); for (var key in data.commentaries) { var val = data.commentaries[key]; @@ -150,19 +153,23 @@ }, "json"); return false; } - function search() { - var query=$("#search").find("input[name=search]").val(); + function search(query, keep_detail_view) { + if (query == null) { + query=$("#search").find("input[name=search]").val(); + } $.get(backendApiPrefix+"/search?q=" + encodeURIComponent(query), function (data) { var t = $("table#results tbody").empty(); if (!data || data.length == 0) return; // clear all marks $("#graph .marked").each(function(){this.classList.remove("marked")}); + // fill table of titles data.forEach(function (row) { var text = row.text; var author = row.author; + $("#author").text("Titles by Author: "+author.label+" ["+author.ismi_id+"]"); var comm = row.is_commentary || row.has_commentaries; - var $row = $("").appendTo(t) + var $row = $("").appendTo(t) .click(function() { showText($(this).find("td.text_id").text());}); if (comm) { $row.addClass("marked"); @@ -170,7 +177,10 @@ // set mark $("#graph .ismi-"+text.ismi_id).each(function(){this.classList.add("marked")}); }); - showText(data[0].text.ismi_id); + if (!keep_detail_view) { + // show first title + showText(data[0].text.ismi_id); + } }, "json"); return false; } @@ -212,7 +222,7 @@ .attr("class","arrowHead"); // load graph - d3.json(backendApiPrefix+"/graph?limit=1000", function(error, graph) { + d3.json(backendApiPrefix+"/graph?limit=10", function(error, graph) { if (error) return; force.nodes(graph.nodes).links(graph.links).start(); @@ -231,7 +241,6 @@ .attr("r", 8) // 10 .attr("data-ismi_id", function(d) {return d.ismi_id}) .on("click", function() { - console.log("click on ", this); var id = this.getAttribute("data-ismi_id"); searchApi.showText(id); })
    Author (translit) Title (translit) Title (arabic) ismi_id
    " + author.label + "" + text.label + "" + text.full_title + "" + text.ismi_id + "
    " + text.label + "" + text.full_title + "" + text.ismi_id + "