# HG changeset patch # User casties # Date 1454603750 -3600 # Node ID 7b5dcd3238d2b05d24e3078332aff8054a43d37c # Parent 810ea40a9ef87e6d01ad15864e7ae8f0bfaa181a search field also accepts ismi_ids. display list of authors in head. display author name in title list. diff -r 810ea40a9ef8 -r 7b5dcd3238d2 ismi-python-neo4jrestclient/ismi-vis.py --- a/ismi-python-neo4jrestclient/ismi-vis.py Thu Feb 04 15:50:08 2016 +0100 +++ b/ismi-python-neo4jrestclient/ismi-vis.py Thu Feb 04 17:35:50 2016 +0100 @@ -153,20 +153,27 @@ 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}})" - # " 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))") + if qs.isdigit(): + 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))") + param = {"id": int(qs)} + + else: + 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))") + param = {"name": ".*%s.*"%nq.lower()} + results = gdb.query( query, returns=(Node,Node,bool,bool), - params={"name": ".*%s.*"%nq.lower()} + params=param ) # {"name": "(?i).*" + q + ".*"} print("search for %s returned %s results"%(repr(q),len(results))) diff -r 810ea40a9ef8 -r 7b5dcd3238d2 ismi-python-neo4jrestclient/static/commentaries.html --- a/ismi-python-neo4jrestclient/static/commentaries.html Thu Feb 04 15:50:08 2016 +0100 +++ b/ismi-python-neo4jrestclient/static/commentaries.html Thu Feb 04 17:35:50 2016 +0100 @@ -16,7 +16,7 @@
- + @@ -46,6 +46,7 @@ + @@ -166,12 +167,14 @@ // clear all marks $("#graph .marked").each(function(){this.classList.remove("marked")}); // fill table of titles + var authors = {}; data.forEach(function (row) { var text = row.text; var author = row.author; - $("#author").text("Titles by Author: "+author.label+" ["+author.ismi_id+"]"); + // collect authors + authors[author.ismi_id] = author; 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"); @@ -179,6 +182,11 @@ // set mark $("#graph .ismi-"+text.ismi_id).each(function(){this.classList.add("marked")}); }); + var authorlist = ""; + for (var a in authors) { + authorlist += (authorlist ? ", " : "") + authors[a].label + " ["+authors[a].ismi_id+"]"; + } + $("#author").text("Titles by: "+authorlist); if (!keep_detail_view) { // show first title in detail view showText(data[0].text.ismi_id);
Author Title (translit) Title (arabic) ismi_id
" + text.label + "" + text.full_title + "" + text.ismi_id + "
" + author.label + "" + text.label + "" + text.full_title + "" + text.ismi_id + "