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

Merge branch 'master' of projects.sisrlab.com:idm/visfact

parents 8972ab99 ced23995
......@@ -18,7 +18,7 @@ pip install -e git+https://projects.sisrlab.com/idm/visfact.git#egg=visfact
## Usage
```sh
visfact-make.py example/visfact.yaml
visfact-make.py visfact.yaml
open output.html
```
......@@ -28,6 +28,60 @@ Arrow keys are used to navigate the fact cards:
- up: show all cards
- down: hide all cards but the current one
## Authoring
This authoring workflow creates a new file for capturing citations from one article.
Snippets must be installed in your text editor.
*Sublime Text 3* and *VS Code* are supported.
### Workflow
1. Create a blank file in the argument path: `touch argument-1/author-2019.ttl`
2. Open `.ttl` file in text editor
3. Type `article` and tab-complete to activate the **article** snippet
4. Enter the DOI, title, authors, and year.
5. Use `cite`, `self`, and `src` to populate the rest of the file with quotes.
### Config
1. Create a blank config file: `touch visfact.yaml`
2. Open `visfact.yaml` in the text editor
3. Type `config` and tab-complete to activate the **configuration** snippet
4. provide the path to the `.ttl` files
### Running
```sh
visfact-make.py visfact.yaml
open argument-1.html
```
## Snippets
Use snippets to reduce repetitive typing and to generally go faster.
Snippets are text macros that expand to produce the necessary Turtle for adding quotes.
Snippets are provided for some text editors.
### Sublime Text 3
The following snippets are provided:
- **self**: self-citation
- **cite**: a quote with one or more external sources
- **vcite**: a verbatim quote (no automatic removal of citations)
- **src**: an extra source for a particular quote
The following will install snippets to the User Packages directory.
`make snippets-sublime-text-3`
### VS Code
1. Open [snippets/vscode/turtle.json](https://projects.sisrlab.com/idm/visfact/raw/master/snippets/vscode/turtle.json)
2. In VS Code, **File -- Preferences -- User Snippets**
3. Choose Turtle (`turtle.json`)
4. Copy-paste contents of `turtle.json`
## Configuration
A YAML file is used to control visfact.
......@@ -57,6 +111,7 @@ The following Turtle corresponds to `example/argument-1/article-1.ttl`, which is
a thesis:article ;
dc:title "The Major Work" ;
dc:authors "Author Y & Author Z" ;
dc:url "https://doi.org/" ;
dc:year 2019 .
[ a thesis:claim ;
......@@ -80,29 +135,3 @@ The following Turtle corresponds to `example/argument-1/article-1.ttl`, which is
] ;
] .
```
## Snippets
Use snippets to reduce repetitive typing and to generally go faster.
Snippets are text macros that expand to produce the necessary Turtle for adding quotes.
Snippets are provided for some text editors.
### Sublime Text 3
The following snippets are provided:
- **self**: self-citation
- **cite**: a quote with one or more external sources
- **vcite**: a verbatim quote (no automatic removal of citations)
- **src**: an extra source for a particular quote
The following will install snippets to the User Packages directory.
`make snippets-sublime-text-3`
### VS Code
1. Open [snippets/vscode/turtle.json](https://projects.sisrlab.com/idm/visfact/raw/master/snippets/vscode/turtle.json)
2. In VS Code, **File -- Preferences -- User Snippets**
3. Choose Turtle (`turtle.json`)
4. Copy-paste contents of `turtle.json`
......@@ -14,10 +14,7 @@ $0] .
]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>cite</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>source.ttl</scope>
<!-- Optional: Description to show in the menu -->
<description>Article-citation Snippet</description>
</snippet>
<snippet>
<content><![CDATA[
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns/> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix thesis: <https://projects.sisrlab.com/idm/visfact/raw/master/thesis.rdf#> .
<#${TM_FILENAME/.ttl//}>
a thesis:Article ;
dc:url "https://doi.org/$1" ;
dc:title "$2" ;
dc:authors "$3" ;
dc:year $4 .
]]></content>
<tabTrigger>article</tabTrigger>
<scope>source.ttl</scope>
<description>Base Article Snippet</description>
</snippet>
<snippet>
<content><![CDATA[
---
files:
- "${1:argument}/article-1.ttl"
dest: "$1.html"
rdf: "$1.rdf"
]]></content>
<tabTrigger>config</tabTrigger>
<scope>source.ttl</scope>
<description>visfact configuration</description>
</snippet>
......@@ -7,10 +7,7 @@
]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>self</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>source.ttl</scope>
<!-- Optional: Description to show in the menu -->
<description>Self-citation Snippet</description>
</snippet>
......@@ -7,10 +7,7 @@
dc:year ${1/.*(\d\d\d\d).*/\1/} ;
] ;
$0]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>src</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>source.ttl</scope>
<!-- Optional: Description to show in the menu -->
<description>Source mini Snippet</description>
</snippet>
......@@ -13,10 +13,7 @@ $0] .
]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>vcite</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>source.ttl</scope>
<!-- Optional: Description to show in the menu -->
<description>Verbatim Article-citation Snippet</description>
</snippet>
......@@ -3,13 +3,13 @@
"prefix": "cite",
"body": [
"[ a thesis:Claim ;",
" thesis:appearance <#${TM_FILENAME/.ttl//}> ;",
" thesis:quote \"$1\" ;",
" thesis:source [ a thesis:Article ;",
" dc:authors \"$2\" ;",
" dc:title \"$3\" ;",
" dc:year $4 ;",
" ] ;",
"\tthesis:appearance <#${TM_FILENAME/.ttl//}> ;",
"\tthesis:quote \"$1\" ;",
"\tthesis:source [ a thesis:Article ;",
"\t\tdc:authors \"$2\" ;",
"\t\tdc:title \"$3\" ;",
"\t\tdc:year $4 ;",
"\t] ;",
"$0",
"] .",
"",
......@@ -21,9 +21,9 @@
"prefix": "self",
"body": [
"[ a thesis:Claim ;",
" thesis:appearance <#${TM_FILENAME/.ttl//}> ;",
" thesis:quote \"$1\" ;",
" thesis:source <#${TM_FILENAME/.ttl//}> ;",
"\tthesis:appearance <#${TM_FILENAME/.ttl//}> ;",
"\tthesis:quote \"$1\" ;",
"\tthesis:source <#${TM_FILENAME/.ttl//}> ;",
"] .",
"",
"",
......@@ -38,8 +38,38 @@
"\t\tdc:title \"$2\" ;",
"\t\tdc:year $3 ;",
"\t] ;",
"$0"
""
],
"description": "Source mini Snippet"
}
}
\ No newline at end of file
"Article_Base": {
"prefix": "article",
"body": [
"@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns/> .",
"@prefix dc: <http://purl.org/dc/elements/1.1/> .",
"@prefix thesis: <https://projects.sisrlab.com/idm/visfact/raw/master/thesis.rdf#> .",
"",
"<#${TM_FILENAME/.ttl//}>",
" a thesis:Article ;",
" dc:url \"https://doi.org/$1\" ;",
" dc:title \"$2\" ;",
" dc:authors \"$3\" ;",
" dc:year $4 .",
"",
""
],
"description": "Article Base Snippet"
},
"Configuration": {
"prefix": "config",
"body": [
"---",
"files:",
" - \"${1:argument}/article-1.ttl\"",
"dest: \"$1.html\"",
"rdf: \"$1.rdf\"",
""
],
"description": "Visfact Configuration"
}
}
......@@ -33,14 +33,14 @@
<ul id="ui-config">
<li><a href="#" onclick="toggle_help(); return false;">[h]elp</a></li>
<li><a href="#" onclick="hide_all(); return false;">[f]ocus mode</a></li>
<li><a href="#" onclick="show_all(); return false;">show [a]ll</a></li>
<li><a href="#" onclick="toggle_focus(); return false;">toggle [f]ocus</a></li>
<li><a href="#" onclick="toggle_appearances(); return false;">toggle [a]ppearances</a></li>
<li><a href="#" onclick="toggle_dark_mode(); return false;">[d]ark mode</a></li>
</ul>
</div>
<div id="ui-help">
<ul>
<li><b>A</b>: show all cards</li>
<li><b>A</b>: toggle appearance (title)</li>
<li><b>F</b>: focus on card</li>
<li><b>left/right</b>: previous/next (in focus mode)</li>
<li><b>D</b>: toggle dark mode</li>
......
......@@ -3,6 +3,17 @@ var counter = 0;
var filtered = false;
var focused = true;
var filter_id = "";
var appearances = "visible";
var toggle_focus = function() {
if (focused) {
show_all();
}
else {
hide_all();
}
}
var hide_all = function() {
for (var i = 0; i < divs.length; i++){
......@@ -128,6 +139,31 @@ var toggle_appearance = function(id) {
}
}
var hide_appearances = function() {
var els = document.querySelectorAll('.appearance');
for (var i = 0; i < els.length; i++){
els[i].style.display = "none";
}
appearances = "hidden";
}
var show_appearances = function() {
var els = document.querySelectorAll('.appearance');
for (var i = 0; i < els.length; i++){
els[i].style.display = "block";
}
appearances = "visible";
}
var toggle_appearances = function() {
if (appearances == "hidden") {
show_appearances();
}
else {
hide_appearances();
}
}
var close_ui = function() {
var content = document.getElementById("ui-content");
var ui_control = document.getElementById("ui-control");
......@@ -183,7 +219,7 @@ var handler = function(e) {
if (e.ctrlKey && charCode == '65') {
// a: all
show_all();
toggle_appearances();
}
else if (e.ctrlKey && charCode == '70') {
// s: search
......@@ -191,7 +227,7 @@ var handler = function(e) {
}
else if (e.ctrlKey && charCode == '70') {
// f: focus
hide_all();
toggle_focus();
}
else if (charCode == '37') {
// left arrow
......
......@@ -56,15 +56,15 @@ class VisFact:
if m:
fact_id = "claim-{0:0>2}-{1:0>4}".format(m.group(1), m.group(2))
if appearance_id not in articles.keys():
articles[appearance_id] = appearance
cite = "{authors}. ({year}). {title}.".format(
authors=authors,
year=year,
title=title
)
if appearance_id not in articles.keys():
articles[appearance_id] = cite
source = {
'authors': authors,
'year': year,
......
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