Skip to content

Commit d99522d

Browse files
committed
Merge branch 'gh-pages' of https://github.com/LivelyKernel/lively4-core into gh-pages
2 parents 7dde635 + c6de46d commit d99522d

19 files changed

+707
-126
lines changed
523 KB
Loading

doc/journal/2021-02-24.md/index.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
## 2021-02-24
2+
*Author: @JensLincke*
3+
4+
5+
![](generate_drawio_content.png)
6+
7+
### Reverse Engineering
8+
9+
Copy some drawio content and past it into a workspace...
10+
11+
```javascript
12+
import XML from "src/client/xml.js"
13+
14+
lively.get("#drawiosource").value = XML.prettify(decodeURIComponent(
15+
lively.get("#drawiocode").value))
16+
```
17+
18+
That produces some source... and copy and pasting it back into drawio produced actual graphical content.
19+
20+
```javascript
21+
<mxGraphModel>
22+
<root>
23+
<mxCell id="0"/>
24+
<mxCell id="1" parent="0"/>
25+
<UserObject label="[@Olsen2007EUI]" id="2">
26+
<mxCell style="text;whiteSpace=wrap;html=1;fontSize=12;fontColor=#000000;" vertex="1" parent="1">
27+
<mxGeometry x="240" y="220" width="100" height="30" as="geometry"/>
28+
</mxCell>
29+
</UserObject>
30+
<UserObject label="[@Hoho]" id="3">
31+
<mxCell style="text;whiteSpace=wrap;html=1;fontSize=12;fontColor=#000000;" vertex="1" parent="1">
32+
<mxGeometry x="250" y="270" width="100" height="30" as="geometry"/>
33+
</mxCell>
34+
</UserObject>
35+
</root>
36+
</mxGraphModel>
37+
```
38+
39+
### Generating Draw.io Content
40+
41+
So, we can actually generate content
42+
43+
44+
```javascript
45+
46+
var source = `<mxGraphModel>
47+
<root>
48+
<mxCell id="0"/>
49+
<mxCell id="1" parent="0"/>`
50+
51+
var idCounter = 3;
52+
that.childNodes.forEach((ea,index) => {
53+
source += `<UserObject label="[@${ea.key}] ${ea.getAuthors()[0]} ${ea.year}. ${ea.title} " id="${idCounter++}">
54+
<mxCell style="text;whiteSpace=wrap;html=1;fontSize=12;fontColor=#000000;" vertex="1" parent="1">
55+
<mxGeometry x="250" y="${30 *index}" width="600" height="40" as="geometry"/>
56+
</mxCell>
57+
</UserObject>`
58+
59+
})
60+
61+
source += ` </root>
62+
</mxGraphModel>`
63+
64+
65+
```

src/client/fileindex.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,8 @@ export default class FileIndex {
770770
}).then(r => r.clone().json())
771771

772772
if (!stats.error) {
773-
await this.addFile(url, stats.name, stats.type, stats.size, stats.modified)
773+
let name = url.replace(/.*\//,"")
774+
await this.addFile(url, name, stats.type, stats.size, stats.modified)
774775
}
775776
}
776777

src/client/html.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,13 @@ export default class HTML {
216216
if (node.getAttribute) {
217217

218218
var href = node.getAttribute("href")
219+
if (!href) {
220+
href = node.getAttribute("xlink:href")
221+
if (href) {
222+
var isXLink = true;
223+
}
224+
}
225+
219226
if (href) {
220227
// console.log("FIX LINK ", href)
221228
// #TODO load inplace....

src/client/protocols/bib.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ export class BibScheme extends BibliographyScheme {
2121
var entry = entries[0] || {authors: undefined, keywords: undefined, title: ""}
2222
var key = query
2323
var files = await FileIndex.current().db.files.where("bibkey").equals(key).toArray()
24+
var literatureNotes = await FileIndex.current().db.files
25+
.filter( ea => ea.name.match(key + ".md")).toArray()
26+
2427

2528
var papers = await Literature.db.papers.where("key").equals(key).toArray()
2629

@@ -43,7 +46,7 @@ export class BibScheme extends BibliographyScheme {
4346
if (entry.source) {
4447
content += "<pre>" + entry.source+ "</pre>"
4548
}
46-
content += "<h3>Documents</h3><ul>" + files.map(ea => {
49+
content += "<h3>Documents</h3><ul>" + (files.concat(literatureNotes)).map(ea => {
4750
return `<li><a href="${ea.url}">${ea.name}</a></li>`
4851
}).join("\n") + "</ul>"
4952

src/components/tools/file-chooser.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ import Bindings from "src/client/bindings.js"
55
import {promisedEvent} from "src/client/utils.js"
66

77

8+
/*MD # File Chooser
9+
10+
![](file-chooser.png){width=300px}
11+
12+
MD*/
13+
814
export default class FileChooser extends Morph {
915
async initialize() {
1016
this.registerAttributes(["root"]);
45.1 KB
Loading
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<template id="literature-graph" >
2+
<style data-src="/src/external/font-awesome/css/font-awesome.css"></style>
3+
<style data-src="/templates/livelystyle.css"></style>
4+
<style>
5+
:host {
6+
7+
}
8+
9+
10+
#details {
11+
width: 600px;
12+
padding: 20px;
13+
background-color: rgba(240,240,250,0.9);
14+
border: 1px solid rgba(200,200,250,0.9);
15+
border-radius: 10px;
16+
}
17+
18+
</style>
19+
<div id="content">
20+
</div>
21+
<slot></slot>
22+
</template>
23+

0 commit comments

Comments
 (0)