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

lots of cosmetic fixes, loading icon

parent f9178d0c
......@@ -2,7 +2,7 @@
# visfact (c) Ian Dennis Miller
__project__ = 'visfact'
__version__ = '0.1.1'
__version__ = '0.2.0'
__author__ = 'Ian Dennis Miller'
__email__ = 'ian@iandennismiller.com'
__url__ = 'http://projects.sisrlab.com/idm/visfact'
......
......@@ -2,20 +2,14 @@ var handler = function(e) {
var charCode = (typeof e.which == "number") ? e.which : e.keyCode;
// console.log(charCode);
if (e.ctrlKey && charCode == '65') {
// a: all
e.preventDefault();
e.stopPropagation();
toggle_appearances();
}
else if (e.ctrlKey && charCode == '83') {
if (e.ctrlKey && charCode == '83') {
// s: search
e.preventDefault();
e.stopPropagation();
toggle_search();
}
else if (e.ctrlKey && charCode == '80') {
// p: pick article
else if (e.ctrlKey && charCode == '65') {
// a: article
e.preventDefault();
e.stopPropagation();
toggle_picker();
......@@ -38,12 +32,6 @@ var handler = function(e) {
// escape
toggle_ui();
}
else if (e.ctrlKey && charCode == '68') {
// d: dark
e.preventDefault();
e.stopPropagation();
toggle_dark_mode();
}
else if (e.ctrlKey && charCode == '72') {
// h: help
e.preventDefault();
......
......@@ -22,6 +22,8 @@ function main() {
// init search
init_search();
document.querySelector(".loader").style.display = "none";
}
main();
......@@ -173,11 +173,13 @@ var toggle_appearances = function() {
var close_ui = function() {
var content = document.getElementById("ui-content");
var ui_control = document.getElementById("ui-control");
var ui_elem = document.getElementById("ui");
hide_search();
content.style.display = "none";
ui_control.classList.remove('expanded');
ui_elem.classList.remove('expanded');
// ensure help is closed
var el = document.getElementById("ui-help");
......@@ -189,8 +191,11 @@ var close_ui = function() {
var open_ui = function() {
var content = document.getElementById("ui-content");
var ui_control = document.getElementById("ui-control");
content.style.display = "inline";
var ui_elem = document.getElementById("ui");
content.style.display = "block";
ui_control.classList.add('expanded');
ui_elem.classList.add('expanded');
}
var toggle_ui = function() {
......
......@@ -5,6 +5,8 @@ var cards_content = {};
var hide_search = function() {
var els = document.querySelectorAll('#ui-search');
els[0].style.display = "none";
var ui_control = document.getElementById("ui-control");
ui_control.classList.remove('expanded');
}
var show_search = function() {
......@@ -13,6 +15,9 @@ var show_search = function() {
var els = document.querySelectorAll('#ui-search');
els[0].style.display = "block";
document.querySelector("#ui-query").focus();
var ui_control = document.getElementById("ui-control");
ui_control.classList.add('expanded');
}
var toggle_search = function() {
......
......@@ -18,7 +18,7 @@
<body class="dark">
<div id="container">
<div id="ui">
<a href="#" id="ui-control" class="control expanded" onclick="toggle_ui(); return false;">&gt;</a>
<a href="#" id="ui-control" class="control" onclick="toggle_ui(); return false;">&gt;</a>
<div id="ui-search">
<input id="ui-query" name="query" type="text" onchange="new_search();"></input>
<a href="#" id="ui-search-show-all" onclick="search_show_all(); return false;">[all]</a>
......@@ -37,25 +37,26 @@
<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_dark_mode(); return false;">night mode</a></li>
<li><a href="#" onclick="toggle_help(); return false;">help</a></li>
</ul>
<div id="info"><a href="http://projects.sisrlab.com/idm/visfact">visfact {{ version }}</a></div>
</div>
<div id="ui-help">
<ul>
<li><b>ESC</b>: show/hide UI control</li>
<li><b>ctrl-p</b>: pick article</li>
<li><b>ctrl-a</b>: article picker</li>
<li><b>ctrl-s</b>: search</li>
<li><b>ctrl-d</b>: toggle dark mode</li>
<li><b>ctrl-a</b>: toggle titles (appearance)</li>
<li><b>ctrl-z</b>: zoom cards</li>
<li><b>left/right</b>: previous/next (while zoomed)</li>
<li><b>ctrl-h</b>: show/hide help</li>
</ul>
<div id="info"><a href="http://projects.sisrlab.com/idm/visfact">visfact</a></div>
</div>
</div>
<div class="loader"></div>
{{ quotes }}
</div>
......
......@@ -19,6 +19,8 @@ body.focused {
#info {
text-align: center;
font-family: sans-serif;
font-size: 8pt;
}
#info a {
......@@ -62,6 +64,7 @@ ul {
font-size: 10pt;
margin-top: 0;
margin-bottom: 0.5em;
color: #999;
}
/*.quote { font-weight: bold; }*/
......@@ -77,8 +80,8 @@ a.filtered {
.search ul {
margin: 0.5em 0;
list-style-type: circle;
padding-left: 1em;
list-style-type: disc;
padding-left: 15px;
font-size: 10pt;
}
......@@ -100,7 +103,6 @@ a.filtered {
#ui {
padding: 0.1em;
border: 1px solid #999;
position: fixed;
background: #fff;
max-width: 19em;
......@@ -109,11 +111,28 @@ a.filtered {
top: 0;
}
#ui.expanded {
border: 1px solid #999 !important;
}
#ui.expanded #ui-content {
padding: 0 0.5em 0.5em 0.5em;
}
#ui-content {
display: none;
}
#ui a {
text-decoration: none;
display: block;
}
#ui-config {
margin-top: 0;
margin-bottom: 0.25em;
}
a#ui-control {
font-size: 12pt;
font-weight: bold;
......@@ -173,6 +192,32 @@ body.dark a, body.dark a:visited {
color: #999;
}
/* loader */
.loader {
border: 16px solid #ddd; /* Light grey */
border-top: 16px solid #666; /* Blue */
border-radius: 50%;
width: 120px;
height: 120px;
animation: spin 2s ease infinite;
}
.loader {
position: fixed;
top: 50%;
left: 50%;
margin-top: -60px;
margin-left: -60px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
/* search */
div#ui-search {
display: none;
}
......
......@@ -9,6 +9,7 @@ import hashlib
import urllib.parse
from pydenticon import Generator
from jinja2 import Environment, PackageLoader, select_autoescape
from .__meta__ import __version__
sparql = """
......@@ -54,6 +55,8 @@ class VisFact:
quote_tmpl = self.env.get_template('card.html.j2')
alpha_pattern = re.compile('[\W_]+')
# build facts dictionary
articles = {}
facts = {}
......@@ -79,13 +82,13 @@ class VisFact:
)
quote_identicon_data = self.quote_identicon_generator.generate(
data=quote, width=16, height=16)
data=alpha_pattern.sub('', quote.upper()), width=16, height=16)
appearance_identicon_data = self.source_identicon_generator.generate(
data=appearance_cite, width=16, height=16)
data=alpha_pattern.sub('', appearance_cite.upper()), width=16, height=16)
source_identicon_data = self.source_identicon_generator.generate(
data=cite, width=16, height=16)
data=alpha_pattern.sub('', cite.upper()), width=16, height=16)
if appearance_id not in articles.keys():
articles[appearance_id] = appearance_cite
......@@ -135,7 +138,7 @@ class VisFact:
html_tmpl = self.env.get_template('main.html.j2')
with open(self.cfg["dest"], "wb") as f:
buf = html_tmpl.render(quotes=result, articles=sorted_articles)
buf = html_tmpl.render(quotes=result, articles=sorted_articles, version=__version__)
buf = re.sub(r'file:///.+?#', '', buf)
f.write(buf.encode())
print("visfact: wrote {0}".format(self.cfg["dest"]))
......
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