-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnamespaces.js
More file actions
107 lines (82 loc) · 2.42 KB
/
Copy pathnamespaces.js
File metadata and controls
107 lines (82 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
var u = require('util');
function prefix(nid) {
return u.format('urn:hg:%s:', nid);
}
module.exports = {
geonames: {
baseUrl: 'http://sws.geonames.org/',
urlMatch: function(url) {
var alternativeBaseUrl = 'http://www.geonames.org/';
return url.toLowerCase().indexOf(this.baseUrl) === 0 || url.toLowerCase().indexOf(alternativeBaseUrl) === 0;
},
baseUrlRegex: /http:\/\/(sws|www)\.geonames\.org\//,
URLtoURN: function(url) {
var match = /.*?(\d+).*/.exec(url);
return prefix('geonames') + match[1];
},
URNtoURL: function(nid, nss) {
return this.baseUrl + nss + '/';
}
},
tgn: {
baseUrl: 'http://vocab.getty.edu/tgn/',
URLtoURN: function(url) {
var match = /.*?(term)?\/?(\d+).*/i.exec(url);
var nss = [match[1], match[2]].filter(function(part) { return part; }).join(':');
return prefix('tgn') + nss;
},
URNtoURL: function(nid, nss) {
return this.baseUrl + nss.split(':').join('/');
}
},
dbpedia: {
baseUrl: 'http://dbpedia.org/',
URLtoURN: function(url) {
var match = /(resource|page)\/(.*)$/i.exec(url);
return prefix('dbpedia') + match[2];
},
URNtoURL: function(nid, nss) {
return this.baseUrl + 'resource/' + nss;
}
},
wikidata: {
baseUrl: 'http://www.wikidata.org/',
URLtoURN: function(url) {
var match = /(wiki|entity)\/(.*)$/i.exec(url);
return prefix('wikidata') + match[2];
},
URNtoURL: function(nid, nss) {
return this.baseUrl + 'entity/' + nss;
}
},
pleiades: {
baseUrl: 'http://pleiades.stoa.org/',
URLtoURN: function(url) {
var match = /places\/(.*)$/i.exec(url);
return prefix('pleiades') + match[1];
},
URNtoURL: function(nid, nss) {
return this.baseUrl + 'places/' + nss;
}
},
gemeentegeschiedenis: {
baseUrl: 'http://www.gemeentegeschiedenis.nl/',
URLtoURN: function(url) {
var match = /gemeentenaam\/(.*)$/i.exec(url);
return prefix('gemeentegeschiedenis') + match[1];
},
URNtoURL: function(nid, nss) {
return this.baseUrl + 'gemeentenaam/' + nss;
}
},
kloeke: {
baseUrl: 'http://www.meertens.knaw.nl/kloeke/',
URLtoURN: function(url) {
var match = /kloekenummer=(.*)$/i.exec(url);
return prefix('kloeke') + match[1];
},
URNtoURL: function(nid, nss) {
return this.baseUrl + 'index.php?kloekenummer=' + nss;
}
}
};