Forráskód Böngészése

Merge pull request #27 from transloadit/feature-examples

Examples Folder
Kevin van Zonneveld 9 éve
szülő
commit
f1aa1072d5

+ 1 - 0
.gitignore

@@ -1,3 +1,4 @@
 node_modules
 build/transloadit-js-client.*
 npm-debug.log
+examples/playground/static/js/app.js

+ 5 - 3
.travis.yml

@@ -3,17 +3,19 @@ language: node_js
 node_js:
   - 4.2.2
 
-before_script:
+script:
   - "npm run-script build"
+  - "npm run-script build:examples"
+  - "cp build/transloadit-js-client.js examples/playground/static/js/transloadit-js-client.js"
 
-script:
+after_script:
   - "echo 'Tested :)'"
 
 deploy:
   acl              : public_read
   bucket           : hackathon.transloadit.com
   cache_control    : no-cache
-  local-dir        : build
+  local-dir        : examples/playground
   provider         : s3
   skip_cleanup     : true
   upload-dir       : transloadit-js-client/$TRAVIS_BRANCH

+ 1 - 1
bin/scripts

@@ -1,6 +1,6 @@
 #!/bin/bash
 
-ENTRY=src/js/lib/transloadit-js-client.js
+ENTRY=src/js/core/transloadit-core.js
 OUTPUT=build/transloadit-js-client.js
 TRANSFORMS="[ babelify ]"
 

+ 1 - 0
examples/buildAll

@@ -0,0 +1 @@
+./node_modules/.bin/browserify examples/playground/src/js/app.js -o examples/playground/static/js/app.js

+ 85 - 0
examples/playground/index.html

@@ -0,0 +1,85 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+
+  <!-- Basic Page Needs
+  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
+  <meta charset="utf-8">
+  <title>Loading...</title>
+  <meta name="description" content="">
+  <meta name="author" content="">
+
+  <!-- Mobile Specific Metas
+  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
+  <meta name="viewport" content="width=device-width, initial-scale=1">
+
+  <!-- FONT
+  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
+  <link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
+
+  <!-- CSS
+  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
+  <link rel="stylesheet" href="static/css/normalize.css">
+  <link rel="stylesheet" href="static/css/skeleton.css">
+
+  <!-- Favicon
+  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
+  <link rel="icon" type="image/png" href="static/images/favicon.png">
+
+
+  <link rel="stylesheet" href="static/css/style.css" type="text/css" />
+</head>
+<body>
+
+  <!-- Primary Page Layout
+  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
+  <div class="container">
+    <div class="row">
+      <div class="twelve columns" style="margin-top: 10%">
+        <h1>
+          Loading..
+        </h1>
+
+        <h4>transloadit-js-client</h4>
+        <p>
+          With this file we can easily test the built js client locally (via <code>npm run preview</code>)
+          and online.
+        </p>
+
+        <div id="upload-target">
+          Loading..
+        </div>
+
+      </div>
+    </div>
+  </div>
+
+  <footer>
+    <hr />
+    <ul>
+      <li><a href="https://travis-ci.org/transloadit/transloadit-js-client">Travis</a></li>
+      <li><a href="https://github.com/transloadit/transloadit-js-client">GitHub</a></li>
+    </ul>
+  </footer>
+
+</body>
+
+<!-- Include the built js client -->
+<script src="static/js/transloadit-js-client.js"></script>
+<script src="static/js/app.js"></script>
+
+<!-- Apply the js client on a selector -->
+<script>
+  var tl = Transloadit("#upload-target");
+</script>
+
+<!-- Add the branch name to the <title> and <h1> of this page -->
+<script>
+  var branch        = location.pathname.split('/')[2] || 'local-unknown';
+  var elTitle       = document.querySelector('title');
+  var elH1          = document.querySelector('h1');
+  var title         = 'You are reviewing branch: ' + branch;
+  elTitle.innerHTML = title;
+  elH1.innerHTML    = title;
+</script>
+</html>

+ 13 - 0
examples/playground/package.json

@@ -0,0 +1,13 @@
+{
+  "name": "playground",
+  "version": "1.0.0",
+  "description": "",
+  "main": "index.js",
+  "scripts": {
+    "build": "../../node_modules/.bin/browserify src/js/app.js -o static/js/app.js",
+    "watch": "../../node_modules/.bin/watchify src/js/app.js -o static/js/app.js",
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "author": "",
+  "license": "ISC"
+}

+ 0 - 0
examples/playground/src/js/app.js


+ 0 - 0
build/css/normalize.css → examples/playground/static/css/normalize.css


+ 0 - 0
build/css/skeleton.css → examples/playground/static/css/skeleton.css


+ 0 - 0
examples/playground/static/css/style.css


+ 0 - 0
build/images/favicon.png → examples/playground/static/images/favicon.png


+ 3 - 0
examples/playground/static/js/app.js

@@ -0,0 +1,3 @@
+(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
+
+},{}]},{},[1]);

+ 4 - 3
package.json

@@ -5,15 +5,16 @@
   "main": "index.js",
   "scripts": {
     "browser-sync": "browser-sync start --config bs-config.js",
-    "build": "npm run build:js & npm run build:css",
+    "build": "npm run build:js && npm run build:css",
     "build:css": "bin/styles",
     "build:js": "bin/scripts node_modules/.bin/browserify",
-    "clean": "rm -rf build/*.js & rm -rf build/*.css",
+    "build:examples": "examples/buildAll",
+    "clean": "rm -rf build/*.js && rm -rf build/*.css",
     "lint": "eslint src/js/lib/**/*.js",
     "phantom-test": "zuul test/spec/upload.js --phantom",
     "preview": "npm run watch & npm run browser-sync",
     "test": "bin/test",
-    "watch": "npm run watch:css & npm run watch:js",
+    "watch": "npm run watch:css && npm run watch:js",
     "watch:css": "nodemon -e scss -x \"npm run build:css\"",
     "watch:js": "bin/scripts node_modules/.bin/watchify"
   },