Browse Source

Structure is directly under core now

Kevin van Zonneveld 9 years ago
parent
commit
2f0ddbcd38

+ 1 - 1
bin/builder

@@ -51,7 +51,7 @@ else
 fi
 
 # Install into examples
-for path in $(find examples -type d -maxdepth 1 -mindepth 1); do
+for path in $(find examples -maxdepth 1 -mindepth 1 -type d); do
   exampleProject="$(basename "${path}")"
   rsync \
     -ai \

+ 0 - 49
src/js/core/Transloadit.js

@@ -1,49 +0,0 @@
-export default class Transloadit {
-  constructor(opts) {
-    // Dictates in what order different plugin types are ran:
-    this.types = [ 'presetter', 'selecter', 'uploader' ];
-
-    // Container for different types of plugins
-    this.plugins = {};
-  }
-
-  use(Plugin, opts) {
-    // Instantiate
-    var plugin = new Plugin(this, opts);
-
-    // Save in plugin container
-    if (!this.plugins[plugin.type]) {
-      this.plugins[plugin.type] = [];
-    }
-    this.plugins[plugin.type].push(plugin);
-
-    return this;
-  }
-
-  setProgress(plugin, percentage) {
-    // Any plugin can call this via `this.core.setProgress(this, precentage)`
-    console.log(plugin.type + ' plugin ' + plugin.name + ' set the progress to ' + percentage);
-
-    return this;
-  }
-
-  run() {
-    // Walk over plugins in the order as defined by this.types.
-    var files = []
-    for (var j in this.types) {
-      var type = this.types[j];
-      // Walk over all plugins of this type, passing & modifying the files array as we go
-      for (var i in this.plugins[type]) {
-        var plugin = this.plugins[type][i];
-        console.log('--> Now running ' + plugin.type + ' plugin ' + plugin.name + ': ');
-        files = plugin.run(files);
-        console.dir(files);
-        console.log('');
-      }
-    }
-
-    // core.run is the final step and retuns the results (vs every other method, returning `this`)
-    // for chainability
-    return files;
-  }
-}

+ 0 - 5
src/js/core/Transloadit.scss

@@ -1,5 +0,0 @@
-.transloadit-js-client {
-  font-family: "Comic Sans MS";
-  color: purple;
-  border: 1px dashed pink;
-  font-size: 32px; }

+ 0 - 15
src/js/plugins/DragDrop.js

@@ -1,15 +0,0 @@
-import TransloaditPlugin from '../plugins/TransloaditPlugin';
-export default class DragDrop extends TransloaditPlugin {
-  constructor(core, opts) {
-    super(core, opts);
-    this.type = 'selecter';
-  }
-
-  run(files) {
-    this.core.setProgress(this, 0);
-    var selected = [ {name: 'lolcat.jpeg'} ]
-    this.core.setProgress(this, 100);
-
-    return selected;
-  }
-}

+ 0 - 9
src/js/plugins/TransloaditBasic.js

@@ -1,9 +0,0 @@
-class TransloaditBasic extends TransloaditPlugin {
-  constructor(core, opts) {
-    super(core, opts);
-    this.type = 'presetter';
-    this.core
-      .use(DragDrop, {modal: true, wait: true})
-      .use(Tus10, {endpoint: 'http://master.tus.io:8080'})
-  }
-}

+ 0 - 14
src/js/plugins/TransloaditPlugin.js

@@ -1,14 +0,0 @@
-export default class TransloaditPlugin {
-  // This contains boilerplate that all TransloaditPlugins share - and should not be used
-  // directly. It also shows which methods final plugins should implement/override,
-  // this deciding on structure.
-  constructor(core, opts) {
-    this.core = core;
-    this.opts = opts;
-    this.name = this.constructor.name;
-  }
-
-  run(files) {
-    return files;
-  }
-}

+ 0 - 21
src/js/plugins/Tus10.js

@@ -1,21 +0,0 @@
-import TransloaditPlugin from '../plugins/TransloaditPlugin';
-export default class Tus10 extends TransloaditPlugin {
-  constructor(core, opts) {
-    super(core, opts);
-    this.type = 'uploader';
-  }
-
-  run(files) {
-    this.core.setProgress(this, 0);
-    var uploaded = [];
-    for (var i in files) {
-      var file = files[i];
-      this.core.setProgress(this, (i * 1) + 1);
-      uploaded[i]     = file;
-      uploaded[i].url = this.opts.endpoint + '/uploaded/' + file.name;
-    }
-    this.core.setProgress(this, 100);
-
-    return uploaded;
-  }
-}