author | Chloe Laisne <chloe.laisne@gmail.com> |
Thu, 22 Sep 2016 15:34:10 +0200 | |
changeset 278 | f2c2c80a49f7 |
parent 274 | 53a6985443f8 |
child 304 | 20071981ba2a |
permissions | -rw-r--r-- |
173 | 1 |
import ENV from 'app-client/config/environment'; |
2 |
import _ from 'lodash/lodash'; |
|
3 |
import * as constants from 'corpus-common-addon/utils/constants'; |
|
4 |
||
5 |
export default function() { |
|
6 |
||
7 |
// These comments are here to help you get started. Feel free to delete them. |
|
8 |
||
9 |
/* |
|
10 |
Config (with defaults). |
|
11 |
||
12 |
Note: these only affect routes defined *after* them! |
|
13 |
*/ |
|
14 |
// this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server |
|
15 |
// this.namespace = ''; // make this `api`, for example, if your API is namespaced |
|
261
02e2396bcbbc
Migrate to ember 2.7 + correct jquery null context error + declare shim for popcorn (instead of silencing the JSHint error)
ymh <ymh.work@gmail.com>
parents:
245
diff
changeset
|
16 |
this.namespace = ENV.rootURL.replace(/\/$/,'')+'/api/v1'; |
173 | 17 |
// this.timing = 400; // delay for each request, automatically set to 0 during testing |
18 |
||
19 |
this.get('/documents', function({ documents }) { |
|
20 |
return this.serialize(documents.all(), 'sparse-document'); |
|
21 |
}); |
|
245
c9dd78a43b07
Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents:
173
diff
changeset
|
22 |
|
173 | 23 |
this.get('/documents/:id', ({documents}, request) => { |
24 |
let id = decodeURIComponent(request.params.id); |
|
25 |
return documents.find(id); |
|
26 |
}); |
|
27 |
||
28 |
this.get('/documents/:id/transcript', ({transcripts}, request) => { |
|
29 |
let id = decodeURIComponent(request.params.id); |
|
30 |
return transcripts.find(id).transcript; |
|
31 |
}); |
|
32 |
||
33 |
this.get('/languages'); |
|
34 |
||
278
f2c2c80a49f7
Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents:
274
diff
changeset
|
35 |
this.get('/geostats'); |
274
53a6985443f8
geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents:
261
diff
changeset
|
36 |
|
173 | 37 |
this.get('/themes'); |
38 |
||
39 |
this.get('/discourses'); |
|
40 |
||
41 |
this.get('/lexvo/:ids', ({lexvos}, request) => { |
|
42 |
var langIds = decodeURIComponent(request.params.ids); |
|
43 |
var resMap = _.reduce(langIds.split(','), function(res, id) { |
|
44 |
var fullId = id; |
|
45 |
if(!_.startsWith(fullId, constants.LEXVO_BASE_URL)) { |
|
46 |
fullId = constants.LEXVO_BASE_URL + id; |
|
47 |
} |
|
48 |
var lexvoRes = lexvos.find(fullId); |
|
49 |
res[id] = lexvoRes?lexvoRes.name:null; |
|
50 |
return res; |
|
51 |
}, {}); |
|
52 |
return { |
|
53 |
'lexvoids': resMap |
|
54 |
}; |
|
55 |
}); |
|
56 |
||
57 |
this.get('/bnf/:ids', ({ bnfs }, request) => { |
|
58 |
var bnfIds = decodeURIComponent(request.params.ids); |
|
59 |
var resMap = _.reduce(bnfIds.split(','), function(res, id) { |
|
60 |
var fullId = id; |
|
61 |
if(_.startsWith(fullId, constants.BNF_BASE_URL)) { |
|
62 |
fullId = fullId.slice(constants.BNF_BASE_URL.length); |
|
63 |
} else if (_.startsWith(fullId, constants.BNF_ARK_BASE_URL)) { |
|
64 |
fullId = fullId.slice(constants.BNF_ARK_BASE_URL.length); |
|
65 |
} else if (!_.startsWith(fullId, constants.BNF_ARK_BASE_ID)) { |
|
66 |
fullId = constants.BNF_ARK_BASE_ID + fullId; |
|
67 |
} |
|
68 |
var bnfRes = bnfs.find(fullId); |
|
69 |
res[id] = bnfRes?bnfRes.label:null; |
|
70 |
return res; |
|
71 |
}, {}); |
|
72 |
return { |
|
73 |
'bnfids': resMap |
|
74 |
}; |
|
75 |
}); |
|
76 |
||
77 |
||
78 |
} |