Sfoglia il codice sorgente

add _repo to server-generated _ws object

Benoît Hubert 8 anni fa
parent
commit
e588def6f9
2 ha cambiato i file con 6 aggiunte e 3 eliminazioni
  1. 4 3
      html/index.mustache.html
  2. 2 0
      lib/indexHandlers.js

+ 4 - 3
html/index.mustache.html

@@ -50,7 +50,7 @@
         {{/errorMessage}}
 
             <div class="details-div">
-              <section id="details-repo" class="inline-block" data-slug="{{path}}">
+              <section id="details-repo" class="inline-block">
               {{#repo}}
                   <strong>{{_.collection}} </strong><span>{{title}}</span>
               {{/repo}}
@@ -66,7 +66,7 @@
             </div>
 
             <div>
-              <section id="details-example" class="inline-block" data-slug="{{slug}}">
+              <section id="details-example" class="inline-block">
               {{#example}}
                   <strong>{{_.example}} </strong><span>{{title}}</span>
               {{/example}}
@@ -160,7 +160,8 @@
 <!-- WS scripts -->
 <script id="inline-js-data">
 window._ws = {
-  files: {{{filesJSON}}}
+  files: {{{filesJSON}}},
+  repo: {{{repoJSON}}}
 };
 </script>
 <script src="/js/req-promise.js"></script>

+ 2 - 0
lib/indexHandlers.js

@@ -46,6 +46,7 @@ module.exports = function(exStore, exDir, testMode) {
     // Initialize view data
     let data = {
       menuRepo: exStore.getRepoMenu(),
+      repoJSON: 'null',
       testMode,
       testRun: testMode && req.query.testing,
       appPath: req.path,
@@ -55,6 +56,7 @@ module.exports = function(exStore, exDir, testMode) {
     // Fetch example repository if needed
     if(withRepo) {
       data.repo = exStore.getRepo(repoSlug);
+      data.repoJSON = JSON.stringify(data.repo);
       if(! data.repo) {
         // return res.status(404).send('Repo ' + req.params.repoSlug + ' not found');
         data.errorMessage = translator.getOne(locale, "repoNotFound", [repoSlug]); //'Repo ' + params.repoSlug + ' not found';