Skip to content

Commit 5520589

Browse files
committed
microsoft academics works
SQUASHED: AUTO-COMMIT-doc-journal-2020-09-11.md-index.md,AUTO-COMMIT-doc-journal-2020-09-11.md-microsoft_academics_result.png,AUTO-COMMIT-doc-journal-2020-09-11.md-microsoft_academic_works.png,AUTO-COMMIT-src-client-bibliography.js,AUTO-COMMIT-src-components-tools-lively-container.js,AUTO-COMMIT-test-bibliography-test.js,
1 parent 5b81690 commit 5520589

File tree

6 files changed

+70
-8
lines changed

6 files changed

+70
-8
lines changed

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

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 2020-09-11
1+
## 2020-09-11 #MicrosoftAcademic for the Win!
22
*Author: @JensLincke*
33

44
Found it by reverse engineering <https://academic.microsoft.com/>... but maybe it is documented?
@@ -14,4 +14,43 @@ fetch("https://academic.microsoft.com/api/search", {
1414
```
1515

1616

17-
![](microsoft_academic_search.png)
17+
![](microsoft_academic_search.png)
18+
19+
20+
### And here we go
21+
22+
```javascript
23+
import moment from "src/external/moment.js";
24+
25+
26+
var json;
27+
28+
(async () => {
29+
json = await fetch("https://academic.microsoft.com/api/search", {
30+
method: "POST",
31+
headers: {
32+
"content-type": "application/json; charset=utf-8"
33+
},
34+
body: JSON.stringify({query: "Jens Lincke", queryExpression: "", filters: [], orderBy: 0, skip: 0, sortAscending: true, take: 10})
35+
}).then(r => r.json())
36+
})()
37+
38+
39+
40+
41+
json.pr.map(ea => ({
42+
authors: ea.paper.a.map(author => author.dn),
43+
title: ea.paper.dn,
44+
microsoftid: ea.paper.id,
45+
year: moment(ea.paper.v.publishedDate).year(),
46+
publisher: ea.paper.v.displayName,
47+
keywords: ea.paper.fos.map(kw => kw.dn),
48+
abstract: ea.paper.d,
49+
}))
50+
```
51+
52+
53+
![](microsoft_academics_result.png)
54+
55+
56+
![](microsoft_academic_works.png)
221 KB
Loading
124 KB
Loading

src/client/bibliography.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Bibliography.cleanTitle("{{This is my Title}}")
108108
// #TODO this method obviously will need a lot of tweaking...
109109
static generateCitationKey(entry) {
110110
if (!entry || !entry.entryTags) return undefined
111-
var firstAuthor = entry.entryTags.author.split("and")[0]
111+
var firstAuthor = entry.entryTags.author.split(/ and /g)[0]
112112
if (firstAuthor.match(",")) {
113113
firstAuthor = firstAuthor.replace(/,.*/,"")
114114
} else {

src/components/tools/lively-container.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,15 +2114,13 @@ export default class Container extends Morph {
21142114
})
21152115
}
21162116

2117-
updateOtherContainers() {
2117+
updateOtherContainers(url="" + this.getURL()) {
21182118
console.warn('updateOtherContainers')
2119-
var url = "" + this.getURL();
21202119
document.body.querySelectorAll('lively-container').forEach(ea => {
21212120
if (ea !== this && !ea.isEditing()
21222121
&& ("" +ea.getURL()).match(url.replace(/\.[^.]+$/,""))) {
21232122
console.log("update container content: " + ea);
2124-
ea.setPath(ea.getURL() + "");
2125-
2123+
ea.setPath(ea.getURL() + "");
21262124
}
21272125
});
21282126

test/bibliography-test.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,31 @@ describe('Bibliography', () => {
2121
it('converts normal prefixed with index number and letter', async function() {
2222
expect(Bibliography.filenameToKey("00C_Winograd_1996_Introduction.pdf")).to.equal("Winograd1996I")
2323
});
24-
2524
})
25+
26+
describe('generateCitationKey', () => {
27+
it('simple', async function() {
28+
expect(Bibliography.generateCitationKey({
29+
entryTags: {
30+
author: "Tom Jones",
31+
year: 1972,
32+
title: "Nothing to See Here!"
33+
}
34+
})).to.equal("Jones1972NSH")
35+
});
36+
37+
it('Name with and in name', async function() {
38+
expect(Bibliography.generateCitationKey({
39+
entryTags: {
40+
author: "Tom Joand and Wilboar Fundi",
41+
year: 1972,
42+
title: "Nothing to See Here Again!"
43+
}
44+
})).to.equal("Joand1972NSH")
45+
});
46+
47+
48+
})
49+
50+
2651
});

0 commit comments

Comments
 (0)