diff options
-rw-r--r-- | strus/document.ana | 1 | ||||
-rw-r--r-- | themes/new_theme/layouts/partials/ranklist.html | 30 |
2 files changed, 26 insertions, 5 deletions
diff --git a/strus/document.ana b/strus/document.ana index c6b0dd1..8fbcf3e 100644 --- a/strus/document.ana +++ b/strus/document.ana @@ -13,6 +13,7 @@ [SearchIndex] word = lc:convdia(en):stem(en):lc regex("([A-Za-z']+)") /posts/post/meta()/title(); word = lc:convdia(en):stem(en):lc regex("([A-Za-z']+)") /posts/post/body//para(); + sentence = empty punctuation("en") /posts/post/body//para(); [ForwardIndex] title = orig split /posts/post/meta()/title(); diff --git a/themes/new_theme/layouts/partials/ranklist.html b/themes/new_theme/layouts/partials/ranklist.html index 9ed4877..47982d7 100644 --- a/themes/new_theme/layouts/partials/ranklist.html +++ b/themes/new_theme/layouts/partials/ranklist.html @@ -94,15 +94,17 @@ } else if( attribute.key == 'docid' ) { docid = attribute.value; } else if( attribute.key == 'text' ) { - abstract += ' ' + attribute.value; + abstract += ' ' + escapeHtml( attribute.value ); } } if( title == '' ) { title = title_attribute; } + title = title.replaceAll( /#SMARK#/, "<i>" ).replaceAll( /#EMARK#/, "</i>" ); html += "<div class='title'>" html += "<a href=\"" + docid + "\">" + title + "</a></div>"; if( abstract != '' ) { + abstract = abstract.replaceAll( /#SMARK#/, "<b>" ).replaceAll( /#EMARK#/, "</b>" ); html += "<div class='abstract'>" + abstract + "</div>"; } html += "</li>"; @@ -111,11 +113,20 @@ return html; } + String.prototype.replaceAll = function(search, replacement) { + var target = this; + return target.replace(new RegExp(search, 'g'), replacement); + }; + + function escapeHtml( text ) { + return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">" ); + } + function executeQuery( query ) { var request = { query: { first_rank: 0, - nof_ranks: 10, + nof_ranks: 100, features: get_features( query ), select: [ "sel" @@ -189,7 +200,7 @@ }, { key: "mark", - value: "<font color='black'>%1%</font>" + value: "#SMARK#%1%#EMARK#" } ], resultnames: [ @@ -219,13 +230,21 @@ key: "add_dots", value: 1 }, + //~ { + //~ key: "sentence", + //~ value: "sentence" + //~ }, + //~ { + //~ key: "nof_sentences", + //~ value: 3 + //~ }, { key: "start_first_match", - value: 0 + value: 1 }, { key: "mark", - value: "<b>%1%</b>" + value: "#SMARK#%1%#EMARK#" } ], resultnames: [ @@ -259,6 +278,7 @@ } else { msg = t; } + msg = escapeHtml( msg ); html = "<pre><font color='red'>There was an error communicating to the strusWebService, reason: " + msg + "</font></pre>\n"; $( '#ranklist' ).html( html ); |