Skip to content

Commit 54b3f6a

Browse files
committed
[files] new literature overview for
SQUASHED: AUTO-COMMIT-doc-files-all.md,AUTO-COMMIT-doc-files-index.md,AUTO-COMMIT-doc-files-literature.md,AUTO-COMMIT-doc-journal-2020-09-08.md-index.md,AUTO-COMMIT-doc-journal-2020-09-08.md-literature_overview.png,AUTO-COMMIT-src-client-bibliography.js,AUTO-COMMIT-src-client-fileindex.js,AUTO-COMMIT-src-client-files.js,
1 parent f760c6a commit 54b3f6a

File tree

8 files changed

+309
-31
lines changed

8 files changed

+309
-31
lines changed

doc/files/all.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# All Files in FileIndex
2+
3+
<lively-import src="_navigation.html"></lively-import>
4+
5+
<style>
6+
lively-script {
7+
display: inline-block
8+
}
9+
</style>
10+
11+
<script>
12+
import FileIndex from "src/client/fileindex.js"
13+
</script>
14+
15+
<script>
16+
(async (container) => {
17+
var button = document.createElement("button");
18+
button.addEventListener("click", async () => {
19+
await FileIndex.current().addDirectory(lively4url + "/src/client/", 5)
20+
await FileIndex.current().addDirectory(lively4url + "/templates/", 5)
21+
await FileIndex.current().addDirectory(lively4url + "/src/components/", 5)
22+
await FileIndex.current().addDirectory(lively4url + "/src/parts/", 5)
23+
await FileIndex.current().addDirectory(lively4url + "/doc/", 5)
24+
await FileIndex.current().addDirectory(lively4url + "/demos/", 5)
25+
await FileIndex.current().addDirectory(lively4url + "/test/", 5)
26+
27+
// FileIndex.current().addDirectory("https://lively4/thesis/notes", 5)
28+
// FileIndex.current().addDirectory("https://lively4/Notes", 5)
29+
// FileIndex.current().addDirectory("https://lively4/thesis/WriteFirst", 5)
30+
});
31+
button.innerHTML = "update file cache";
32+
return button;
33+
})(this.parentElement)
34+
</script>
35+
36+
37+
<script>
38+
(async (container) => {
39+
var button = document.createElement("button");
40+
button.addEventListener("click", async () => {
41+
await FileIndex.current().update()
42+
lively.show("finished analysis")
43+
});
44+
button.innerHTML = "analyse";
45+
return button;
46+
})(this.parentElement)
47+
</script>
48+
49+
50+
<script>
51+
var markdown = lively.query(this, "lively-markdown");
52+
(async (container) => {
53+
var button = document.createElement("button");
54+
55+
button.addEventListener("click", () => {
56+
var table = markdown.get("#table").get("lively-table")
57+
if (table) {
58+
table.setFromJSO(table.asJSO().sortBy(ea => Number(ea.versions)).reverse())
59+
}
60+
});
61+
button.innerHTML = "sortx";
62+
return button;
63+
})(this.parentElement)
64+
</script>
65+
66+
67+
<script>
68+
var container = lively.query(this, "lively-container");
69+
(async () => {
70+
var table = await lively.create("lively-table")
71+
var files = (await FileIndex.current().db.files.toArray());
72+
73+
var button = document.createElement("button");
74+
75+
button.addEventListener("click", () => {
76+
77+
if (table) {
78+
table.setFromJSO(table.asJSO().sortBy(ea => Number(ea.versions)).reverse())
79+
}
80+
});
81+
button.innerHTML = "sort";
82+
83+
table.setFromJSO(
84+
files
85+
// .filter(ea => ea.url.match(lively4url)) // only show local files...
86+
.map(ea => {
87+
return {
88+
file: ea.url.replace(lively4url, "") + '</a> ',
89+
size: ea.size,
90+
versions: ea.versions && ea.versions.length,
91+
title: ea.title && ea.title.slice(0,100).replace(/</g,"&gt;"),
92+
tags: ea.tags && ea.tags.sort(), // Array.from(new Set(ea.tags))
93+
94+
}
95+
// li.querySelector("a").onclick = (evt) => {
96+
// container.followPath(ea.url)
97+
// evt.preventDefault()
98+
// }
99+
}))
100+
var div = document.createElement("div")
101+
div.appendChild(button)
102+
div.appendChild(table)
103+
return div
104+
})()
105+
</script>

doc/files/index.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@
99
</style>
1010

1111
<script>
12-
import FileCache from "src/client/fileindex.js"
12+
import FileIndex from "src/client/fileindex.js"
1313
</script>
1414

1515
<script>
1616
(async (container) => {
1717
var button = document.createElement("button");
1818
button.addEventListener("click", async () => {
19-
await FileCache.current().addDirectory(lively4url + "/src/client/", 5)
20-
await FileCache.current().addDirectory(lively4url + "/templates/", 5)
21-
await FileCache.current().addDirectory(lively4url + "/src/components/", 5)
22-
await FileCache.current().addDirectory(lively4url + "/src/parts/", 5)
23-
await FileCache.current().addDirectory(lively4url + "/doc/", 5)
24-
await FileCache.current().addDirectory(lively4url + "/demos/", 5)
25-
await FileCache.current().addDirectory(lively4url + "/test/", 5)
19+
await FileIndex.current().addDirectory(lively4url + "/src/client/", 5)
20+
await FileIndex.current().addDirectory(lively4url + "/templates/", 5)
21+
await FileIndex.current().addDirectory(lively4url + "/src/components/", 5)
22+
await FileIndex.current().addDirectory(lively4url + "/src/parts/", 5)
23+
await FileIndex.current().addDirectory(lively4url + "/doc/", 5)
24+
await FileIndex.current().addDirectory(lively4url + "/demos/", 5)
25+
await FileIndex.current().addDirectory(lively4url + "/test/", 5)
2626

27-
// FileCache.current().addDirectory("https://lively4/thesis/notes", 5)
28-
// FileCache.current().addDirectory("https://lively4/Notes", 5)
29-
// FileCache.current().addDirectory("https://lively4/thesis/WriteFirst", 5)
27+
// FileIndex.current().addDirectory("https://lively4/thesis/notes", 5)
28+
// FileIndex.current().addDirectory("https://lively4/Notes", 5)
29+
// FileIndex.current().addDirectory("https://lively4/thesis/WriteFirst", 5)
3030
});
3131
button.innerHTML = "update file cache";
3232
return button;
@@ -38,7 +38,7 @@
3838
(async (container) => {
3939
var button = document.createElement("button");
4040
button.addEventListener("click", async () => {
41-
await FileCache.current().update()
41+
await FileIndex.current().update()
4242
lively.show("finished analysis")
4343
});
4444
button.innerHTML = "analyse";
@@ -68,7 +68,7 @@
6868
var container = lively.query(this, "lively-container");
6969
(async () => {
7070
var table = await lively.create("lively-table")
71-
var files = (await FileCache.current().db.files.toArray());
71+
var files = (await FileIndex.current().db.files.toArray());
7272

7373
var button = document.createElement("button");
7474

doc/files/literature.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Literature
2+
3+
4+
## Papers
5+
6+
<script>
7+
import FileCache from "src/client/fileindex.js"
8+
9+
(async () => {
10+
var files = await FileCache.current().db.files
11+
.filter(ea => ea.bibkey && ea.name.match(/\.pdf$/)).toArray();
12+
13+
var entries = await FileCache.current().db.bibliography
14+
.filter(ea => ea.key).toArray();
15+
16+
var keys = new Set()
17+
18+
files.forEach(ea => keys.add(ea.key))
19+
entries.forEach(ea => keys.add(ea.key))
20+
21+
function printCollection(collection) {
22+
return <ul>{...
23+
collection.map(paper => {
24+
if (paper.file) {
25+
var filelink = <a style="color:gray" click={(evt) => {
26+
if (evt.shiftKey) {
27+
lively.openInspector(paper) // #Example #ExplorationPattern #ForMarcel build way into object inspector into UI
28+
} else {
29+
if (paper.file) lively.openBrowser(paper.file.url)
30+
}
31+
}
32+
}>{paper.file.name}</a>
33+
}
34+
if (paper.entry && paper.entry.keywords) {
35+
var keywords = <span class="keywords">{... paper.entry.keywords.map(ea => ea + " ")}</span>
36+
}
37+
38+
return <li>
39+
<a click={() => lively.openBrowser("bib://" + paper.key)}>{
40+
"[" + paper.key + "]" }</a>
41+
{filelink || ""} {keywords || ""}
42+
</li>
43+
}) }</ul>
44+
}
45+
46+
47+
48+
function printYear(year) {
49+
return <div>
50+
<h3>{year}</h3>
51+
{printCollection(papersByYear[year])}
52+
</div>
53+
}
54+
55+
let style = document.createElement("style")
56+
style.textContent = `
57+
.keywords {
58+
font-size: 9pt;
59+
color: lightgray;
60+
}
61+
`
62+
63+
let papersByYear = Array.from(keys).map(key => {
64+
let file = files.find(ea => ea.bibkey == key)
65+
let entry = entries.find(ea => ea.key == key)
66+
return {key, file, entry}
67+
}).groupBy(file => file.entry && file.entry.year)
68+
69+
return <div>{style}
70+
<h2>By Year</h2>
71+
{... Object.keys(papersByYear).map(year => printYear(year) )}
72+
</div>
73+
})()
74+
</script>
75+
76+
77+
78+
## Bibliographies
79+
80+
<script>
81+
import FileCache from "src/client/fileindex.js"
82+
83+
(async () => {
84+
var files = await FileCache.current().db.files
85+
.filter(ea => ea.name.match(/\.bib$/)).toArray();
86+
return <ul>{... files.map(ea => {
87+
return <li>
88+
<a style="color:gray" click={(evt) => {
89+
if (evt.shiftKey) {
90+
lively.openInspector(ea) // #Example #ExplorationPattern #ForMarcel build way into object inspector into UI
91+
} else {
92+
lively.openBrowser(ea.url)
93+
}
94+
}
95+
}>{ea.name}</a>
96+
</li>
97+
}) }</ul>
98+
})()
99+
</script>

doc/journal/2020-09-08.md/index.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## 2020-09-08 #Lively4Server MOVE allows renaming
2+
*Author: @JensLincke*
3+
4+
5+
So it can be used in scripts....
6+
7+
```javascript
8+
fetch("http://localhost:9006/test/b", {
9+
method: "MOVE",
10+
headers: {
11+
destination: "http://localhost:9006/test/c"
12+
}
13+
}).then(r => r.text())
14+
```
15+
16+
## Some Files Cleanup #Delete
17+
18+
```javascript
19+
var files;
20+
var base = "http://localhost:9005/Dropbox/Thesis/Literature/";
21+
fetch(base, {
22+
method: "OPTIONS",
23+
headers: {
24+
"filelist": true
25+
}
26+
}).then(r => r.json()).then(obj => files=obj.contents)
27+
28+
var toDelete = files.filter(ea => ea.name.match(/\.note$/)).sortBy(ea => ea.size).filter(ea => ea.size == 1).map(ea => base + ea.name)
29+
30+
var value;
31+
(async () => {
32+
for(var ea of toDelete) {
33+
await fetch(ea, {method: "DELETE"})
34+
lively.notify("deleted " + ea)
35+
}
36+
})()
37+
```
38+
39+
## New Literature Overview Page
40+
41+
Given, that the lively4 FileIndex contains bibliographies and PDF files, those are now printed nicely on <browse://doc/files/literature.md>:
42+
43+
![](literature_overview.png)
44+
45+
158 KB
Loading

src/client/bibliography.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ Bibliography.cleanTitle("{{This is my Title}}")
9595
import Bibliography from 'src/client/bibliography.js';
9696
var start = performance.now();
9797
var result = eval(this.parentElement.querySelector("code").textContent);
98-
var time = performance.now() - start;
99-
<div>{result} <i>({time} ms)</i></div>
98+
// var time = performance.now() - start;
99+
<div>{result} </div> // <i>({time} ms)</i>
100100
</script>
101101
MD*/
102102

0 commit comments

Comments
 (0)