Commit dc3a8132 authored by Ian Dennis Miller's avatar Ian Dennis Miller

identicons for appearance and sources

parent 162b157b
<div class="card" id="{{ id }}" about="#{{ appearance_id }}">
<div class="appearance">
<div class="identicon">
<img src="data:image/png;base64,{{ identicon }}">
<img src="data:image/png;base64,{{ appearance_identicon }}">
</div>
{{ appearance_authors }}. ({{ appearance_year }}). {{ appearance_title }}
</div>
<div class="quote">{{ quote }}</div>
<div class="quote">
<div class="identicon">
<img src="data:image/png;base64,{{ quote_identicon }}">
</div>
{{ quote }}
</div>
<div class="search">
<ul>
{% for source in sources %}
<li>
<div class="identicon">
<img src="data:image/png;base64,{{ source.identicon }}">
</div>
<a href="https://scholar.google.ca/scholar?hl=en&as_sdt=0%2C5&q={{ source.query }}&btnG=" target="_blank">{{ source.cite }}</a>
</li>
{% endfor %}
......
......@@ -89,8 +89,8 @@ var highlight_keyword = function(id, keyword) {
var card = document.querySelector('#' + id);
var quote_el = card.querySelector(".quote");
var original_content = quote_el.textContent;
var search = quote_el.textContent;
var original_content = quote_el.innerHTML;
var search = quote_el.innerHTML;
var re = new RegExp(keyword, 'ig');
if (search.length > 0)
......
......@@ -30,12 +30,12 @@
</ul>
<ul id="ui-config">
<li><a href="#" onclick="toggle_picker(); return false;">[ctrl-p] pick article</a></li>
<li><a href="#" onclick="toggle_search(); return false;">[ctrl-s] search</a></li>
<li><a href="#" onclick="toggle_focus(); return false;">[ctrl-z] zoom</a></li>
<li><a href="#" onclick="toggle_appearances(); return false;">[ctrl-a] appearances</a></li>
<li><a href="#" onclick="toggle_dark_mode(); return false;">[ctrl-d] dark mode</a></li>
<li><a href="#" onclick="toggle_help(); return false;">[ctrl-h] help</a></li>
<li><a href="#" onclick="toggle_picker(); return false;">pick article</a></li>
<li><a href="#" onclick="toggle_search(); return false;">search</a></li>
<li><a href="#" onclick="toggle_focus(); return false;">zoom cards</a></li>
<li><a href="#" onclick="toggle_appearances(); return false;">appearances</a></li>
<li><a href="#" onclick="toggle_dark_mode(); return false;">dark mode</a></li>
<li><a href="#" onclick="toggle_help(); return false;">help</a></li>
</ul>
</div>
<div id="ui-help">
......
......@@ -38,6 +38,7 @@ body.focused {
.identicon {
float: right;
margin-left: 0.5em;
clear: both;
}
ul {
......
......@@ -37,7 +37,9 @@ class VisFact:
self.g = rdflib.ConjunctiveGraph()
self.identicon_generator = Generator(rows=8, columns=8, digest=hashlib.sha512)
self.quote_identicon_generator = Generator(rows=8, columns=8, digest=hashlib.sha512)
self.source_identicon_generator = Generator(rows=8, columns=8, digest=hashlib.sha512,
background="#999999")
def load_config(self, yaml_file):
with open(yaml_file, "r") as f:
......@@ -76,7 +78,14 @@ class VisFact:
title=appearance_title
)
identicon_data = self.identicon_generator.generate(data=quote, width=24, height=24)
quote_identicon_data = self.quote_identicon_generator.generate(
data=quote, width=16, height=16)
appearance_identicon_data = self.source_identicon_generator.generate(
data=appearance_cite, width=16, height=16)
source_identicon_data = self.source_identicon_generator.generate(
data=cite, width=16, height=16)
if appearance_id not in articles.keys():
articles[appearance_id] = appearance_cite
......@@ -86,6 +95,7 @@ class VisFact:
'year': year,
'title': title,
'cite': cite.replace('..', '.'),
'identicon': base64.b64encode(source_identicon_data).decode(),
'query': urllib.parse.quote_plus(', '.join([authors, year, title])),
}
......@@ -97,7 +107,8 @@ class VisFact:
'appearance_year': appearance_year,
'appearance_title': appearance_title,
'appearance_id': appearance_id,
'identicon': base64.b64encode(identicon_data).decode(),
'quote_identicon': base64.b64encode(quote_identicon_data).decode(),
'appearance_identicon': base64.b64encode(appearance_identicon_data).decode(),
'sources': [source],
}
else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment