Browse Source

disabled the suggestions

master
manetta 6 years ago
parent
commit
e27539f373
  1. 8
      cross-reader.tfidf/readings.py
  2. 9
      cross-reader.tfidf/static/css/stylesheet.css
  3. 7
      cross-reader.tfidf/templates/base.html

8
cross-reader.tfidf/readings.py

@ -33,12 +33,12 @@ def generate_random_rgb():
b = get_random(0, 255)
return r, g, b
def insert_query_highlight(query, sentence, r, g, b):
def insert_query_highlight(query, tfidf, sentence, r, g, b):
pattern = r'[\s\W\_]'+query+r'[\s\W\_]|^'+query+'|'+query+'$'
match = re.search(pattern, sentence, flags=re.IGNORECASE)
if match:
match = match.group()
sentence = re.sub(pattern, ' <strong class="query" style="color:rgba({r},{g},{b},1); background-image: radial-gradient(ellipse, rgba({r},{g},{b},0.4), rgba({r},{g},{b},0.2), transparent, transparent);">{match}</strong> '.format(match=match, r=r, b=b, g=g), sentence, flags=re.IGNORECASE)
match = match.group().replace(' ', '')
sentence = re.sub(pattern, ' <strong class="query" style="font-size:{tfidf}%;color:rgba({r},{g},{b},1); background-image: radial-gradient(ellipse, rgba({r},{g},{b},0.4), rgba({r},{g},{b},0.2), transparent, transparent);">{match}</strong> '.format(tfidf=tfidf, match=match, r=r, b=b, g=g), sentence, flags=re.IGNORECASE)
return sentence
def insert_suggestion_links(query, sentence):
@ -159,7 +159,7 @@ def request_results(query):
results[x]['matches'].append(sentence)
# Transform sentence into an HTML elements
html = insert_query_highlight(query, sentence, r, g, b)
html = insert_query_highlight(query.strip(), 100 + (tfidf * multiplier), sentence, r, g, b)
html = insert_suggestion_links(query, html)
html = Markup(html)
results[x]['html'].append(html)

9
cross-reader.tfidf/static/css/stylesheet.css

@ -154,11 +154,12 @@ a, a:active, a:hover{
margin:0 0 0.7em;
}
#results strong.query{
margin:0 0.2em 0 0;
padding:0.15em 0.25em 0.3em 0.5em;
margin:0;
padding:0;
height: auto;
border:1px dotted magenta;
border-radius: 25px 15px;
/*padding:0.15em 0.25em 0.3em 0.5em;*/
/*border:1px dotted black;*/
/*border-radius: 25px 15px;*/
}
}

7
cross-reader.tfidf/templates/base.html

@ -37,17 +37,14 @@
{% endfor %}
<ul>
</div>
<div id="suggestions">
<!-- <div id="suggestions">
<div>
<p>Cross-reading suggestions:</p>
{% for suggestion in suggestions %}
<div><strong><a href="/?q={{ suggestion.strip() }}">{{ suggestion.strip() }}</a></strong></div>
{% endfor %}
</div>
<div>
</div>
</div>
</div> -->
{% block navwrapper %}
{% endblock %}
</div>

Loading…
Cancel
Save