Commit 766717ce authored by Ian Dennis Miller's avatar Ian Dennis Miller

added identicon generation

parent 2fe92eab
......@@ -13,4 +13,7 @@
<div class="controls">
<a id="reveal" href="#" onclick="toggle_appearance('{{ id }}'); return false;">[r]</a>
</div>
<div class="identicon">
<img src="data:image/png;base64,{{ identicon }}">
</div>
</div>
......@@ -4,7 +4,10 @@
import re
import yaml
import rdflib
import base64
import hashlib
import urllib.parse
from pydenticon import Generator
from jinja2 import Environment, PackageLoader, select_autoescape
......@@ -34,6 +37,8 @@ class VisFact:
self.g = rdflib.ConjunctiveGraph()
self.identicon_generator = Generator(rows=8, columns=8, digest=hashlib.sha256)
def load_config(self, yaml_file):
with open(yaml_file, "r") as f:
self.cfg = yaml.load(f.read())
......@@ -65,6 +70,8 @@ class VisFact:
title=title
)
identicon_data = self.identicon_generator.generate(data=quote, width=32, height=32)
if appearance_id not in articles.keys():
articles[appearance_id] = cite
......@@ -84,6 +91,7 @@ class VisFact:
'appearance_year': appearance_year,
'appearance_title': appearance_title,
'appearance_id': appearance_id,
'identicon': base64.b64encode(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