cms/app-client/mirage/config.js
changeset 314 f5690d918358
parent 307 07b44a378ad8
child 318 5564f5065f81
equal deleted inserted replaced
313:706f10bcdc3c 314:f5690d918358
    28     this.get('/documents/:id/transcript',  ({transcripts}, request) => {
    28     this.get('/documents/:id/transcript',  ({transcripts}, request) => {
    29         let id = decodeURIComponent(request.params.id);
    29         let id = decodeURIComponent(request.params.id);
    30         return transcripts.find(id).transcript;
    30         return transcripts.find(id).transcript;
    31     });
    31     });
    32 
    32 
    33     this.get('/languages');
    33     this.get('/stats/languages', 'languages');
    34 
    34 
    35     this.get('/geostats');
    35     this.get('/stats/geostats', 'geostats');
    36 
    36 
    37     this.get('/themes');
    37     this.get('/stats/themes', 'themes');
    38 
    38 
    39     this.get('/discourses');
    39     this.get('/stats/discourses', 'discourses');
    40 
    40 
    41     this.get('/lexvo/:ids', ({lexvos}, request) => {
    41     this.get('/stats/datestats', 'datestats');
       
    42 
       
    43     this.get('/resolvers/lexvo/:ids', ({lexvos}, request) => {
    42         var langIds = decodeURIComponent(request.params.ids);
    44         var langIds = decodeURIComponent(request.params.ids);
    43         var resMap = _.reduce(langIds.split(','), function(res, id) {
    45         var resMap = _.reduce(langIds.split(','), function(res, id) {
    44             var fullId = id;
    46             var fullId = id;
    45             if(!_.startsWith(fullId, constants.LEXVO_BASE_URL)) {
    47             if(!_.startsWith(fullId, constants.LEXVO_BASE_URL)) {
    46                 fullId = constants.LEXVO_BASE_URL + id;
    48                 fullId = constants.LEXVO_BASE_URL + id;
    52         return {
    54         return {
    53             'lexvoids': resMap
    55             'lexvoids': resMap
    54         };
    56         };
    55     });
    57     });
    56 
    58 
    57     this.get('/bnf/:ids', ({ bnfs }, request) => {
    59     this.get('/resolvers/bnf/:ids', ({ bnfs }, request) => {
    58         var bnfIds = decodeURIComponent(request.params.ids);
    60         var bnfIds = decodeURIComponent(request.params.ids);
    59         var resMap = _.reduce(bnfIds.split(','), function(res, id) {
    61         var resMap = _.reduce(bnfIds.split(','), function(res, id) {
    60             var fullId = id;
    62             var fullId = id;
    61             if(_.startsWith(fullId, constants.BNF_BASE_URL)) {
    63             if(_.startsWith(fullId, constants.BNF_BASE_URL)) {
    62                 fullId = fullId.slice(constants.BNF_BASE_URL.length);
    64                 fullId = fullId.slice(constants.BNF_BASE_URL.length);
    72         return {
    74         return {
    73             'bnfids': resMap
    75             'bnfids': resMap
    74         };
    76         };
    75     });
    77     });
    76 
    78 
       
    79     this.get('/resolvers/geonames/:ids', ({ geonames }, request) => {
       
    80         var geonamesIds = decodeURIComponent(request.params.ids);
       
    81         var resMap = _.reduce(geonamesIds.split(','), function(res, id) {
       
    82             var code = id;
       
    83             var m = code.match(constants.GEONAMES_BASE_URLS);
       
    84             if(m) {
       
    85                 code = code.slice(m[0].length);
       
    86             }
       
    87             code = code.replace(/\/+$/, '');
       
    88             var geonamesRes = geonames.find(code);
       
    89             res[id] = geonamesRes?geonamesRes.label:null;
       
    90             return res;
       
    91         }, {});
       
    92         return {
       
    93             'geonamesids': resMap
       
    94         };
       
    95     });
    77 
    96 
    78 }
    97 }