Skip to content

Commit 118fc21

Browse files
committed
Merge branch 'gh-pages' of https://github.com/LivelyKernel/lively4-core into gh-pages
2 parents beffd9c + 3a92b68 commit 118fc21

29 files changed

+934
-118
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-04-07.md/index.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

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

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
## Script Augmented Interactive Workflows #ScriptingWorkflows
46+
47+
Using Lively it is possible to hook into very manual workflows and start to script. This is similar to the capabilities of AppleScript, but with Halos it is much easier to actually get the elements that contain the interesting content.
48+
49+
```javascript
50+
import Strings from 'src/client/strings.js'
51+
52+
var input = document.querySelector("lively-dialog").get("input");
53+
54+
55+
var ignore = new Set(["A"]);
56+
57+
input.value = input.value.split(" ").filter(ea => ea.length > 0).map(ea => Strings.toUpperCaseFirst(ea.replace(/[,:;]/,""))).filter(ea => !ignore.has(ea)).join("")
58+
```
59+
60+
![](scriptaugmented_interactive_workflows.png)
61+
158 KB
Loading
581 KB
Loading
400 KB
Loading
1.12 MB
Loading

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
## 2020-09-09
2+
*Author: @JensLincke*
3+
4+
## Browse Google Scholar For current PDF #ScriptingWorkflows
5+
6+
![](browser_scholor_connection_scripting.png)
7+
8+
Replacing copy paste into different window. Next stept would be to use Google Scholar API... if there is one.
9+
10+
An alternative would be the connection of whenever a PDF is browsed the scholar window would notice and show the scholar article to that file.
11+
12+
```javascript
13+
14+
async function googleScholar(queryString) {
15+
const frameId = "googlescholoar"
16+
var iframe = document.body.querySelector("#" + frameId)
17+
18+
if (!iframe) {
19+
iframe = await lively.openComponentInWindow("lively-iframe")
20+
iframe.setAttribute("id", frameId)
21+
iframe.hideMenubar()
22+
}
23+
24+
var query = queryString.replace(/ /g,"+")
25+
iframe.setURL("https://scholar.google.com/scholar?hl=en&as_sdt=0%2C5&btnG=&q=" + query)
26+
27+
}
28+
29+
var container = document.body.querySelector("lively-container");
30+
var query = decodeURI(container.getURL().pathname)
31+
.replace(/.*\//,"")
32+
.replace(/\.pdf$/,"")
33+
.replace(/([a-z])([A-Z])/g,"$1 $2")
34+
.replace(/_/g," ")
35+
36+
googleScholar(query)
37+
```
38+
39+
## Custom URLs for the win!
40+
41+
An literature overview page also links the papers through it's bibtex keys.
42+
43+
![](literature_overview.png)
44+
45+
And then we enter the world of bibliography entries, authors, and keywords:
46+
47+
![](bibliography_navigation.png)
48+
49+
50+

0 commit comments

Comments
 (0)