cms/app-client/mirage/config.js
changeset 314 f5690d918358
parent 307 07b44a378ad8
child 318 5564f5065f81
--- a/cms/app-client/mirage/config.js	Sun Oct 02 19:11:06 2016 +0200
+++ b/cms/app-client/mirage/config.js	Sun Oct 02 19:14:07 2016 +0200
@@ -30,15 +30,17 @@
         return transcripts.find(id).transcript;
     });
 
-    this.get('/languages');
+    this.get('/stats/languages', 'languages');
 
-    this.get('/geostats');
+    this.get('/stats/geostats', 'geostats');
+
+    this.get('/stats/themes', 'themes');
 
-    this.get('/themes');
+    this.get('/stats/discourses', 'discourses');
 
-    this.get('/discourses');
+    this.get('/stats/datestats', 'datestats');
 
-    this.get('/lexvo/:ids', ({lexvos}, request) => {
+    this.get('/resolvers/lexvo/:ids', ({lexvos}, request) => {
         var langIds = decodeURIComponent(request.params.ids);
         var resMap = _.reduce(langIds.split(','), function(res, id) {
             var fullId = id;
@@ -54,7 +56,7 @@
         };
     });
 
-    this.get('/bnf/:ids', ({ bnfs }, request) => {
+    this.get('/resolvers/bnf/:ids', ({ bnfs }, request) => {
         var bnfIds = decodeURIComponent(request.params.ids);
         var resMap = _.reduce(bnfIds.split(','), function(res, id) {
             var fullId = id;
@@ -74,5 +76,22 @@
         };
     });
 
+    this.get('/resolvers/geonames/:ids', ({ geonames }, request) => {
+        var geonamesIds = decodeURIComponent(request.params.ids);
+        var resMap = _.reduce(geonamesIds.split(','), function(res, id) {
+            var code = id;
+            var m = code.match(constants.GEONAMES_BASE_URLS);
+            if(m) {
+                code = code.slice(m[0].length);
+            }
+            code = code.replace(/\/+$/, '');
+            var geonamesRes = geonames.find(code);
+            res[id] = geonamesRes?geonamesRes.label:null;
+            return res;
+        }, {});
+        return {
+            'geonamesids': resMap
+        };
+    });
 
 }