Skip to content

Commit

Permalink
chore: rename library to fusty flow
Browse files Browse the repository at this point in the history
  • Loading branch information
AidasK committed Oct 4, 2013
1 parent 98bea3d commit e679b3c
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 105 deletions.
20 changes: 10 additions & 10 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = function (grunt) {
options: {
banner: '/*' +
' * MIT Licensed' +
' * http://github.com/resumable2/maybe-resumable.js' +
' * http://github.com/flowjs/fusty-flow.js' +
' * Aidas Klimas' +
' */',
compress: {
Expand All @@ -34,21 +34,21 @@ module.exports = function (grunt) {
}
},
files: {
'build/maybe-resumable.min.js': [
'bower_components/resumable.js/src/resumable.js',
'src/maybe-resumable.js',
'src/not-resumable.js'
'build/fusty-flow.min.js': [
'bower_components/flow.js/src/flow.js',
'src/fusty-flow-factory.js',
'src/fusty-flow.js'
]
}
}
},
concat: {
resumable: {
flow: {
files: {
'build/maybe-resumable.js': [
'bower_components/resumable.js/src/resumable.js',
'src/maybe-resumable.js',
'src/not-resumable.js'
'build/fusty-flow.js': [
'bower_components/flow.js/src/flow.js',
'src/fusty-flow-factory.js',
'src/fusty-flow.js'
]
}
}
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
## What is Maybe-Resumable.js ?
## What is Fusty-Flow.js ?

A JavaScript library which extends Resumable.js and allows to use not resumable uploads for older browsers, such as IE7, IE8 and IE9.
A JavaScript library which extends Flow.js and allows to use not resumable uploads for older browsers, such as IE7, IE8 and IE9.

This library is written in the same style as Resumable.js and follows same api. This means that with
minimal effort we can have both: awesome [Resumable.js](https://github.com/resumable2/resumable.js) features and support for older browsers.
This library is written in the same style as Flow.js and follows same api. This means that with
minimal effort we can have both: awesome [Flow.js](https://github.com/flowjs/flow.js) features and support for older browsers.


## How can I use it?

Same as Resumable.js, except of calling Resumable constructor we call maybeResumable function.
This function automatically checks if Resumable.js is supported.
Same as Flow.js, except of calling Flow constructor we call fustyFlowFactory function.
This function automatically checks if Flow.js is supported.

var uploader = maybeResumable({
var uploader = fustyFlowFactory({
target:'/api/photo/redeem-upload-token',
query:{upload_token:'my_token'}
});

`uploader` is going to be instance of `Resumable` if it is supported, otherwise instance of `NotResumable` will be returned.
`uploader` is going to be instance of `Flow` if it is supported, otherwise instance of `FustyFlow` will be returned.

## NotResumable
## FustyFlow

This library has same methods and properties as `Resumable` except it handles not resumable uploads.
This library has same methods and properties as `Flow` except it handles not resumable uploads.
Additional options:
* matchJSON - removes html from returned response on fileSuccess event. Default false.

## NotResumableFile
## FustyFlowFile

File is instance of `NotResumableFile`. It has same methods and properties as `ResumableFile`.
File is instance of `FustyFlowFile`. It has same methods and properties as `FlowFile`.

Differences in properties:
* size - undefined
Expand All @@ -44,6 +44,6 @@ Differences in methods:

To create your own build, clone this repository and run `grunt build`.

Command will concat and minify resumable.js, not-resumable.js and maybe-resumable.js files. Look for maybe-resumable.js and maybe-resumable.min.js in build directory.
Command will concat and minify flow.js, fusty-flow.js and fusty-flow-factory.js files. Look for fusty-flow.js and fusty-flow.min.js in build directory.

Minified library size is about 18kb, which is much less then other alternative libraries with IE7+ support.
8 changes: 4 additions & 4 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "maybe-resumable.js",
"version": "1.0.0-alpha",
"main": "src/maybe-resumable.js",
"name": "fusty-flow.js",
"version": "1.0.0-beta",
"main": "src/fusty-flow.js",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"tests"
],
"dependencies": {
"resumable.js": "~2"
"flow.js": "~2"
}
}
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{
"name": "maybe-resumable.js",
"version": "1.0.0-alpha",
"description": "Resumable.js html5 file upload support for older browsers",
"main": "src/maybe-resumable.js",
"name": "fusty-flow.js",
"version": "1.0.0-beta",
"description": "Flow.js html5 file upload support for older browsers based on iframe upload.",
"main": "src/fusty-flow-factory.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git://github.com/resumable2/maybe-resumable.js.git"
"url": "git://github.com/flowjs/fusty-flow.js.git"
},
"keywords": [
"flow",
"flow.js",
"resumable",
"resumable.js",
"uploader",
Expand Down
38 changes: 19 additions & 19 deletions samples/frontend.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<head>
<title></title>
<script>var module = {};</script>
<script src="../bower_components/resumable.js/src/resumable.js"></script>
<script src="../src/maybe-resumable.js"></script>
<script src="../src/not-resumable.js"></script>
<script src="../bower_components/flow.js/src/flow.js"></script>
<script src="../src/fusty-flow-factory.js"></script>
<script src="../src/fusty-flow.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<style>
.list {
Expand Down Expand Up @@ -37,41 +37,41 @@
</head>
<body>
<div class="span6">
<p>Resumable</p>
<input id="resumableUploader" type="file">
<p>Flow</p>
<input id="flowUploader" type="file">
<a href="#" onclick="resume.upload()">Upload</a>
<a href="#" onclick="resume.pause()">Pause</a>
<a href="#" onclick="resume.cancel()">Cancel</a>
<ul id="resumableList" class="list">
<ul id="flowList" class="list">

</ul>
</div>

<div class="span6">
<p>Not Resumable</p>
<input id="notResumableUploader" type="file">
<p>Not Flow</p>
<input id="notFlowUploader" type="file">
<a href="#" onclick="noresume.upload()">Upload</a>
<a href="#" onclick="noresume.pause()">Pause</a>
<a href="#" onclick="noresume.cancel()">Cancel</a>
<ul id="notResumableList" class="list">
<ul id="notFlowList" class="list">

</ul>
</div>

<script>
function init(resumable) {
function init(flow) {
var opts = {
target: 'server.php',
query: function () { return {'Hello':'hi', 'resumable': resumable}},
query: function () { return {'Hello':'hi', 'flow': flow}},
simultaneousUploads: 4,
chunkSize: 1024 * 1024,
throttleProgressCallbacks: 0
};
var r = resumable ? new Resumable(opts) : new NotResumable(opts);
if (resumable && !r.support) {
var r = flow ? new Flow(opts) : new FustyFlow(opts);
if (flow && !r.support) {
return ;
}
r.assignBrowse(document.getElementById(resumable ? 'resumableUploader' : 'notResumableUploader'));
r.assignBrowse(document.getElementById(flow ? 'flowUploader' : 'notFlowUploader'));
r.on('catchall', function () {
console.log(arguments[0], arguments);
});
Expand Down Expand Up @@ -112,7 +112,7 @@

});

function ResumableList(element) {
function FlowList(element) {
var $ = this;
$.element = element;
$.files = {};
Expand All @@ -122,14 +122,14 @@
$.add = function (file) {
var element = document.createElement('li');
$.element.appendChild(element);
$.files[file.uniqueIdentifier] = new ResumableListRow(element, file);
$.files[file.uniqueIdentifier] = new FlowListRow(element, file);
};
$.update = function (file, message) {
$.files[file.uniqueIdentifier] && $.files[file.uniqueIdentifier].update(file, message);
};
$.init();
}
function ResumableListRow(element, file) {
function FlowListRow(element, file) {
var $ = this;
$.element = element;
$.file = file;
Expand Down Expand Up @@ -202,8 +202,8 @@
$.init();
}

var element = document.getElementById(resumable ? 'resumableList' : 'notResumableList');
var list = new ResumableList(element);
var element = document.getElementById(flow ? 'flowList' : 'notFlowList');
var list = new FlowList(element);
return r;
}
var resume = init(true);
Expand Down
14 changes: 7 additions & 7 deletions samples/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
mkdir($tempDir);
}
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$chunkDir = $tempDir . DIRECTORY_SEPARATOR . $_GET['resumableIdentifier'];
$chunkFile = $chunkDir.'/chunk.part'.$_GET['resumableChunkNumber'];
$chunkDir = $tempDir . DIRECTORY_SEPARATOR . $_GET['flowIdentifier'];
$chunkFile = $chunkDir.'/chunk.part'.$_GET['flowChunkNumber'];
if (file_exists($chunkFile)) {
header("HTTP/1.0 200 Ok");
} else {
Expand All @@ -18,9 +18,9 @@
'get' => $_GET,
'post' => $_POST,
//optional
'resumableTotalSize' => isset($_FILES['file']) ? $_FILES['file']['size'] : $_GET['resumableTotalSize'],
'resumableIdentifier' => isset($_FILES['file']) ? $_FILES['file']['name'] . '-' . $_FILES['file']['size']
: $_GET['resumableIdentifier'],
'resumableFilename' => isset($_FILES['file']) ? $_FILES['file']['name'] : $_GET['resumableFilename'],
'resumableRelativePath' => isset($_FILES['file']) ? $_FILES['file']['tmp_name'] : $_GET['resumableRelativePath']
'flowTotalSize' => isset($_FILES['file']) ? $_FILES['file']['size'] : $_GET['flowTotalSize'],
'flowIdentifier' => isset($_FILES['file']) ? $_FILES['file']['name'] . '-' . $_FILES['file']['size']
: $_GET['flowIdentifier'],
'flowFilename' => isset($_FILES['file']) ? $_FILES['file']['name'] : $_GET['flowFilename'],
'flowRelativePath' => isset($_FILES['file']) ? $_FILES['file']['tmp_name'] : $_GET['flowRelativePath']
]);
11 changes: 11 additions & 0 deletions src/fusty-flow-factory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function fustyFlowFactory(opts) {
var flow = new Flow(opts);
if (flow.support) {
return flow;
}
return new FustyFlow(opts);
}
// Node.js-style export for Node and Component
if(typeof module != 'undefined') {
module.exports = fustyFlowFactory;
}
Loading

0 comments on commit e679b3c

Please sign in to comment.