Prechádzať zdrojové kódy

Instagram plugin draft, core updated to pass itself to the plugin in .use()

Artur Paikin 9 rokov pred
rodič
commit
2478254510

+ 1 - 1
build/index.html

@@ -69,7 +69,7 @@
 
 <!-- Apply the js client on a selector -->
 <script>
-  var tl = Transloadit("#upload-target");
+  // var tl = Transloadit("#upload-target");
 </script>
 
 <!-- Add the branch name to the <title> and <h1> of this page -->

+ 6 - 5
src/js/lib/transloadit-core.js

@@ -1,12 +1,13 @@
 
 // Using classes internally
 class Transloadit {
-  constructor(opts = {}) {
-    this.opts = opts;
+  constructor(options = {}) {
+    this.options = options;
   }
 
-  use(plugin, opts) {
-    plugin(opts);
+  use(plugin, options) {
+    const transloadit = this;
+    plugin(transloadit, options);
     return this;
   }
 
@@ -16,7 +17,7 @@ class Transloadit {
     return this;
   }
 
-  prepare() {
+  prepare(data) {
     // ...
   }
 

+ 18 - 4
src/js/lib/transloadit-instagram.js

@@ -1,6 +1,20 @@
-// The Dragndrop plugin
+const DATA_FROM_INSTAGRAM = {
+  images: [
+    'https://unsplash.it/600/600?image=921',
+    'https://unsplash.it/600/600?image=870',
+    'https://unsplash.it/600/600?image=823'
+  ]
+};
 
-export default function instagram(options) {
-  console.log(options);
-  console.log('Put a Filter On It (https://youtu.be/iHmLljk2t8M)!');
+function fetchData(apiEndpoint) {
+  return Promise.resolve(DATA_FROM_INSTAGRAM);
+}
+
+export default function transloaditInstagram(core, options) {
+  const userID = options.userID;
+  fetchData('http://transloadit-endpoint/instagram/${userID}')
+    .then(function(data) {
+      console.log(data);
+      core.prepare(data);
+    });
 }

+ 1 - 1
src/js/lib/transloadit-js-client.js

@@ -16,5 +16,5 @@ transloadit()
   .use(dragndrop, {
     selector: '.drop'
   })
-  .use(instagram, {})
+  .use(instagram, {userID: 36177})
   .set({someOption: true});