From a43dbcc189336adc9cdf321751e7ca71371da4b9 Mon Sep 17 00:00:00 2001 From: wouterkool Date: Fri, 24 Apr 2020 12:18:38 +0200 Subject: [PATCH 1/7] Created page IlikeCLR --- main.py | 8 + templates/pages/paper_like.html | 262 ++++++++++++++++++++++++++++++++ templates/pages/papers.html | 5 + templates/pages/papers_vis.html | 8 +- 4 files changed, 281 insertions(+), 2 deletions(-) create mode 100644 templates/pages/paper_like.html diff --git a/main.py b/main.py index a4510829a..b2e2fbc38 100644 --- a/main.py +++ b/main.py @@ -187,6 +187,14 @@ def paperVis(): return render_template('pages/papers_vis.html') +@app.route('/paper_like.html') +def paperLike(): + data = {"keyword": "all", + "page": "papers", + "openreviews": site_data["papers"].values()} + return render_template('pages/paper_like.html', **data) + + @app.route('/recs.html') def recommendations(): data = {"choices": site_data["author_recs"].keys(), diff --git a/templates/pages/paper_like.html b/templates/pages/paper_like.html new file mode 100644 index 000000000..d637530bf --- /dev/null +++ b/templates/pages/paper_like.html @@ -0,0 +1,262 @@ + + + {% set page_title = "ICLR 2020" %} + {% include 'pages/head.html' %} + + + + + {% set active_page = "I♥CLR" %} + {% include 'pages/header.html' %} +
+ + +
+ +
+ + + + {% include 'pages/footer.html' %} + + \ No newline at end of file diff --git a/templates/pages/papers.html b/templates/pages/papers.html index 6fcf0cbc0..1169282a2 100644 --- a/templates/pages/papers.html +++ b/templates/pages/papers.html @@ -21,6 +21,11 @@ Visualization + +
-
+
@@ -61,6 +73,9 @@
+
+ +
+
+ +
+ +
+ + + + + +
+
+ + + + + + +
+ +
+ +
@@ -270,6 +354,7 @@
+ #} From 104640d463bfa7dbe69603da4b6af16c86c32f7f Mon Sep 17 00:00:00 2001 From: wouterkool Date: Thu, 7 May 2020 12:24:48 +0200 Subject: [PATCH 7/7] Improved search with exact match on typeahead and explicit filtering of small words --- static/js/paper_like.js | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/static/js/paper_like.js b/static/js/paper_like.js index a1171e804..6baf300f8 100644 --- a/static/js/paper_like.js +++ b/static/js/paper_like.js @@ -161,7 +161,14 @@ const setSession = (day, num) => { } } -const doSearch = it => { +const doExactSearch = it => { + return doSearch(it, true) + // Disabled since it somehow gets overridden by the typahead script + // Todo some other way to indicate that we perform an exact search? + // return doSearch((it.charAt(0) == '"' ? '' : '"') + it + (it.charAt(it.length -1) == '"' ? '' : '"')) +} + +const doSearch = (it, exact) => { $('.typeahead_all').val(it); setQueryStringParameter("search", encodeURIComponent(it)); @@ -169,10 +176,14 @@ const doSearch = it => { const gridItems = $grid.find('.grid-item'); // TODO improve search functionality - - if (it.length > 0){ - itarr = it.toLowerCase().split(" "); - itarr = jQuery(itarr).filter((i, el) => { return el.length >= 4 }) + const query = it.trim().toLowerCase(); + if (query.length > 0){ + // const exact = (query.charAt(0) == '"' && query.charAt(query.length - 1) == '"') + let itarr = ( + exact ? + jQuery([query.substring(query.charAt(0) == '"' ? 1 : 0, query.length - (query.charAt(query.length - 1) == '"' ? 1 : 0))]) : + jQuery(query.split(" ")).filter((i, el) => { return ['and', 'or', 'on', 'of', 'for', 'by', 'with', 'via', 'in', 'to', 'a', 'an', 'the'].indexOf(el) < 0 }) + ); gridItems.each((i, el) => { el = jQuery(el) const haystack = el.text(); @@ -289,8 +300,8 @@ const start = () => { proj_dict = {}; jQuery.each(allProj, (i, el) => { proj_dict[el['id']] = el['pos']}); calcAllKeys(allPapers, allKeys); - const allKeysCombined = allKeys['authors'].concat(allKeys['keywords'], allKeys['titles']) - initTypeAhead(allKeysCombined, '.typeahead_all', 'ilike', (el, it) => { doSearch(it) }); + const allKeysCombined = allKeys['authors'].concat(allKeys['keywords'], allKeys['titles']); + initTypeAhead(allKeysCombined, '.typeahead_all', 'ilike', (el, it) => { allKeysCombined.indexOf(it) >= 0 ? doExactSearch(it) : doSearch(it) }); updateCards(allPapers) @@ -308,7 +319,7 @@ const start = () => { jQuery('.pp-card .keywords').on('click', 'a', function(){ - doSearch(jQuery(this).text()); + doExactSearch(jQuery(this).text()); return false; }); @@ -352,7 +363,8 @@ const start = () => { const sessionNumber = decodeURIComponent(getUrlParameter("session_number")) || 'all'; setSession(sessionDay, sessionNumber); if (urlSearch !== '') { - doSearch(urlSearch) + let it = urlSearch; + allKeysCombined.indexOf(it) >= 0 ? doExactSearch(it) : doSearch(it) } // setSessionDay(sessionDay) // setSessionNumber(sessionNumber)