Bladeren bron

add a category for each example

Benoît Hubert 8 jaren geleden
bovenliggende
commit
81f3b78d0b

+ 2 - 1
exemples/jquery/ajax-donnees-page-produit/config.json

@@ -4,5 +4,6 @@
   "js": [ "script.js" ],
   "css": [],
   "libsCss": [ "styles.css" ],
-  "libsJs": [ "jquery-3.2.1.min.js" ]
+  "libsJs": [ "jquery-3.2.1.min.js" ],
+  "category": "misc"
 }

+ 2 - 1
exemples/jquery/ajax-envoi-formulaire-par-get/config.json

@@ -4,5 +4,6 @@
   "js": [ "script.js" ],
   "css": [],
   "libsCss": [ "styles.css" ],
-  "libsJs": [ "jquery-3.2.1.min.js" ]
+  "libsJs": [ "jquery-3.2.1.min.js" ],
+  "category": "misc"
 }

+ 2 - 1
exemples/jquery/ajax-envoi-formulaire-par-post/config.json

@@ -4,5 +4,6 @@
   "js": [ "script.js" ],
   "css": [],
   "libsCss": [ "styles.css" ],
-  "libsJs": [ "jquery-3.2.1.min.js" ]
+  "libsJs": [ "jquery-3.2.1.min.js" ],
+  "category": "misc"
 }

+ 2 - 1
exemples/jquery/ajax-exemple-simple/config.json

@@ -4,5 +4,6 @@
   "js": [ "script.js" ],
   "css": [],
   "libsCss": [ "styles.css" ],
-  "libsJs": [ "jquery-3.2.1.min.js" ]
+  "libsJs": [ "jquery-3.2.1.min.js" ],
+  "category": "misc"
 }

+ 2 - 1
exemples/jquery/ajax-requete-randomuserme/config.json

@@ -4,5 +4,6 @@
   "js": [ "script.js" ],
   "css": [],
   "libsCss": [ "styles.css" ],
-  "libsJs": [ "jquery-3.2.1.min.js" ]
+  "libsJs": [ "jquery-3.2.1.min.js" ],
+  "category": "misc"
 }

+ 2 - 1
exemples/jquery/ajax-requete-themoviedborg/config.json

@@ -4,5 +4,6 @@
   "js": [ "script.js" ],
   "css": [],
   "libsCss": [ "styles.css" ],
-  "libsJs": [ "jquery-3.2.1.min.js" ]
+  "libsJs": [ "jquery-3.2.1.min.js" ],
+  "category": "misc"
 }

+ 2 - 1
exemples/jquery/cibler-un-element-enfant/config.json

@@ -4,5 +4,6 @@
   "js": [ "script.js" ],
   "css": [],
   "libsCss": [ "styles.css" ],
-  "libsJs": [ "jquery-3.2.1.min.js" ]
+  "libsJs": [ "jquery-3.2.1.min.js" ],
+  "category": "misc"
 }

+ 2 - 1
exemples/jquery/evenements-1-click-submit/config.json

@@ -4,5 +4,6 @@
   "js": [ "script.js" ],
   "css": [],
   "libsCss": [ "styles.css" ],
-  "libsJs": [ "jquery-3.2.1.min.js" ]
+  "libsJs": [ "jquery-3.2.1.min.js" ],
+  "category": "misc"
 }

+ 2 - 1
exemples/jquery/evenements-2-change/config.json

@@ -4,5 +4,6 @@
   "js": [ "script.js" ],
   "css": [],
   "libsCss": [ "styles.css" ],
-  "libsJs": [ "jquery-3.2.1.min.js" ]
+  "libsJs": [ "jquery-3.2.1.min.js" ],
+  "category": "misc"
 }

+ 2 - 1
exemples/jquery/evenements-3-keyup/config.json

@@ -4,5 +4,6 @@
   "js": [ "script.js" ],
   "css": [],
   "libsCss": [ "styles.css" ],
-  "libsJs": [ "jquery-3.2.1.min.js" ]
+  "libsJs": [ "jquery-3.2.1.min.js" ],
+  "category": "misc"
 }

+ 2 - 1
exemples/jquery/exercice-1-verifier-un-formulaire/config.json

@@ -4,5 +4,6 @@
   "js": [ "script.js" ],
   "css": [],
   "libsCss": [ "styles.css" ],
-  "libsJs": [ "jquery-3.2.1.min.js" ]
+  "libsJs": [ "jquery-3.2.1.min.js" ],
+  "category": "misc"
 }

+ 2 - 1
exemples/jquery/onglets/config.json

@@ -4,5 +4,6 @@
   "js": [ "script.js" ],
   "css": [],
   "libsCss": [ "styles.css" ],
-  "libsJs": [ "jquery-3.2.1.min.js" ]
+  "libsJs": [ "jquery-3.2.1.min.js" ],
+  "category": "misc"
 }

+ 2 - 1
exemples/jquery/selecteurs-basiques/config.json

@@ -4,5 +4,6 @@
   "js": [ "script.js" ],
   "css": [],
   "libsCss": [ "styles.css" ],
-  "libsJs": [ "jquery-3.2.1.min.js" ]
+  "libsJs": [ "jquery-3.2.1.min.js" ],
+  "category": "misc"
 }

+ 2 - 1
exemples/jquery/selecteurs-filtres-2/config.json

@@ -4,5 +4,6 @@
   "js": [ "script.js" ],
   "css": [],
   "libsCss": [ "styles.css" ],
-  "libsJs": [ "jquery-3.2.1.min.js" ]
+  "libsJs": [ "jquery-3.2.1.min.js" ],
+  "category": "misc"
 }

+ 2 - 1
exemples/jquery/selecteurs-filtres/config.json

@@ -4,5 +4,6 @@
   "js": [ "script.js" ],
   "css": [],
   "libsCss": [ "styles.css" ],
-  "libsJs": [ "jquery-3.2.1.min.js" ]
+  "libsJs": [ "jquery-3.2.1.min.js" ],
+  "category": "misc"
 }

+ 2 - 1
exemples/jquery/selecteurs-multiples/config.json

@@ -4,5 +4,6 @@
   "js": [ "script.js" ],
   "css": [],
   "libsCss": [ "styles.css" ],
-  "libsJs": [ "jquery-3.2.1.min.js" ]
+  "libsJs": [ "jquery-3.2.1.min.js" ],
+  "category": "misc"
 }

+ 2 - 1
exemples/jquery/validation-de-formulaires-bootstrap/config.json

@@ -4,5 +4,6 @@
   "js": [ "script.js" ],
   "css": [],
   "libsCss": [ "styles.css" ],
-  "libsJs": [ "jquery-3.2.1.min.js" ]
+  "libsJs": [ "jquery-3.2.1.min.js" ],
+  "category": "misc"
 }

+ 5 - 3
sandboxApp.js

@@ -54,6 +54,7 @@ ExampleStore.prototype.loadRepository = function(repoPath) {
   const repoDescriptor = {
     title: repoConfig.title,
     path: repoPath,
+    fullPath,
     examples: []
   };
   this.repos.push(repoDescriptor);
@@ -61,11 +62,12 @@ ExampleStore.prototype.loadRepository = function(repoPath) {
   .then(examples => Promise.map(
     examples, example => loadExample(repoDescriptor, example)
   ))
+  .then(() => console.log(this.repos[0]))
 };
 
-ExampleStore.prototype.loadExample = function(repo, example) {
-  var exampleConfig = require(repo.path + '/' + example + '/config.json');
-  
+ExampleStore.prototype.loadExample = function(repo, slug) {
+  const exampleConfig = require(repo.fullPath + '/' + slug + '/config.json');
+  repo.examples.push(Object.assign({ slug }, exampleConfig));
 };
 
 var es = new ExampleStore(__dirname + '/exemples');

+ 26 - 12
utils/migrate_old.js

@@ -66,22 +66,36 @@ function gitMvAsync(src, dst) {
 // )
 // .catch(console.error);
 
-function writeExampleConfig(example) {
+function writeExampleConfig(slug) {
+  var config = require(examplesDir + '/' + slug + '/config.json');
+  config.category = "misc";
+  // console.log(exampleConfig)
   // return new Promise((resolve, reject) => {
-    const { slug, title } = example;
-    const config = {
-      title,
-      html: ['example.html'],
-      js: ['script.js'],
-      css: [],
-      libsCss: ['styles.css'],
-      libsJs: ['jquery-3.2.1.min.js']
-    };
+  //   const { slug, title } = example;
+  //   const config = {
+  //     title,
+  //     html: ['example.html'],
+  //     js: ['script.js'],
+  //     css: [],
+  //     libsCss: ['styles.css'],
+  //     libsJs: ['jquery-3.2.1.min.js']
+  //   };
     const configJson = beautify(config, null, 2, 100);
-    // resolve(configJson);
+  //   // resolve(configJson);
   return fs.writeFileAsync(examplesDir + '/' + slug + '/config.json', configJson);
   // });
 }
 
-Promise.map(listJson, writeExampleConfig)
+fs.readdirAsync(examplesDir)
+.then(dirContent => {
+  var excludes = ['liste.json', '.gitkeep', 'repo-config.json'];
+  excludes.forEach(file => {
+    var idxInContent = dirContent.indexOf(file);
+    if(idxInContent !== -1) {
+      dirContent.splice(idxInContent, 1);
+    }
+  });
+  return dirContent;
+})
+.then(exampleList => Promise.map(exampleList, writeExampleConfig))
 .then(filesPerExample => console.log(filesPerExample));