Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
578 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"presets": [ | ||
"es2015" | ||
], | ||
"plugins": [ | ||
"add-module-exports", | ||
"transform-object-assign", | ||
"es6-promise", | ||
"transform-async-to-generator" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules/ | ||
lib/ | ||
fixture/ | ||
assets/bower_components | ||
assets/build | ||
_site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"extends": "standard", | ||
"env": { | ||
"es6": true, | ||
"jest": true, | ||
"node": true | ||
}, | ||
"globals": { | ||
"GENTLY": true, | ||
"$": true, | ||
"jQuery": true | ||
}, | ||
"rules": { | ||
"no-multi-spaces": 0, | ||
"comma-dangle": [ | ||
"error", | ||
"always-multiline" | ||
], | ||
"key-spacing": [ | ||
"error", | ||
{ | ||
"multiLine": { | ||
"beforeColon": false, | ||
"afterColon": true | ||
}, | ||
"align": { | ||
"beforeColon": false, | ||
"afterColon": true, | ||
"on": "colon", | ||
"mode": "strict" | ||
} | ||
} | ||
] | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const YAML = require('js-yaml') | ||
const fs = require('fs') | ||
const debug = require('depurar')('tusio') | ||
const download = require('download') | ||
|
||
const imageAssetRelDir = process.env.IMAGES_DIR || 'assets/img/images' | ||
const imageAssetDir = `${__dirname}/../${imageAssetRelDir}` | ||
const imageConfigFile = process.env.IMAGES_CFG || `${__dirname}/../_data/logos.yml` | ||
const images = YAML.safeLoad(fs.readFileSync(imageConfigFile, 'utf8')) | ||
|
||
for (let i = 0; i < images.length; i++) { | ||
const image = images[i]; | ||
(({ src, name }, i) => { | ||
if (!src.match(/^https?:\/\//i)) { | ||
return debug(`Skipping already downloaded ${src}`) | ||
} else { | ||
debug(`Downloading ${src}`) | ||
const slug = name.toLowerCase().replace(/[^A-Za-z0-9\-_.]/g, '-') | ||
|
||
download(src).pipe(fs.createWriteStream(`${imageAssetDir}/${slug}`)) | ||
|
||
images[i].src = `/${imageAssetRelDir}/${slug}` | ||
if (i === images.length - 1) { | ||
fs.writeFileSync(imageConfigFile, YAML.safeDump(images)) | ||
return console.log(`Rewritten '${imageConfigFile}' for ${images[i].src}`) | ||
} | ||
} | ||
})(image, i) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
var $ = require('jquery'); | ||
window.jQuery = $; | ||
window.$ = $; | ||
var $ = require('jquery') | ||
window.jQuery = $ | ||
window.$ = $ | ||
|
||
require('./javascripts/app.js') | ||
require('./stylesheets/app.css.less') | ||
|
||
// check if HMR is enabled | ||
if (module.hot) { | ||
module.hot.accept('./javascripts/app.js', function () { | ||
require('./javascripts/app.js'); | ||
}); | ||
require('./javascripts/app.js') | ||
}) | ||
module.hot.accept('./stylesheets/app.css.less', function () { | ||
require('./stylesheets/app.css.less'); | ||
}); | ||
require('./stylesheets/app.css.less') | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
require('jquery-timeago/jquery.timeago.js') | ||
require('on-the-githubs/js/jquery.on-the-githubs.js') | ||
require('./main.js.coffee') | ||
require('./main.js') | ||
require('./upload-demo.js') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// This is just to show that we can use the new jekyl-asset pipeline | ||
// to write CoffeeScript a well, should we so desire. | ||
|
||
($ => { | ||
const Tus = {} | ||
|
||
Tus.navToggler = () => { | ||
const $toggler = $('.header .toggler') | ||
const $navContainer = $('.nav-container') | ||
const toggleClass = 'open' | ||
$toggler.click(() => $navContainer.toggleClass(toggleClass)) | ||
|
||
return $(document).click(() => { | ||
if (!$navContainer.hasClass(toggleClass)) { | ||
return $navContainer.removeClass(toggleClass) | ||
} | ||
}) | ||
} | ||
|
||
return $(document).ready(() => { | ||
Tus.navToggler() | ||
return $('.on-the-githubs').onthegithubs() | ||
}) | ||
})(jQuery) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,135 +1,133 @@ | ||
/* global $, console, tus, alert */ | ||
|
||
$(function () { | ||
'use strict'; | ||
'use strict' | ||
|
||
var tus = require('tus-js-client'); | ||
var tus = require('tus-js-client') | ||
|
||
var upload = null; | ||
var toggleBtn = document.querySelector('#toggle-btn'); | ||
var resumeCheckbox = document.querySelector('#resume'); | ||
var input = document.querySelector('input[type=file]'); | ||
var $progress = $('.progress'); | ||
var $progressBar = $('.progress-bar'); | ||
var alertBox = document.querySelector('#support-alert'); | ||
var uploadList = document.querySelector('.upload-list'); | ||
var upload = null | ||
var toggleBtn = document.querySelector('#toggle-btn') | ||
var resumeCheckbox = document.querySelector('#resume') | ||
var input = document.querySelector('input[type=file]') | ||
var $progress = $('.progress') | ||
var $progressBar = $('.progress-bar') | ||
var alertBox = document.querySelector('#support-alert') | ||
var uploadList = document.querySelector('.upload-list') | ||
|
||
if (!tus.isSupported) { | ||
alertBox.classList.remove('hidden'); | ||
alertBox.classList.remove('hidden') | ||
} | ||
|
||
if (!toggleBtn) { | ||
console.log('Toggle button not found on this page. Aborting upload-demo. '); | ||
return; | ||
console.log('Toggle button not found on this page. Aborting upload-demo. ') | ||
return | ||
} | ||
|
||
toggleBtn.addEventListener('click', function (e) { | ||
e.preventDefault(); | ||
e.preventDefault() | ||
|
||
if (upload) { | ||
upload.abort(); | ||
upload = null; | ||
toggleBtn.textContent = 'resume upload'; | ||
upload.abort() | ||
upload = null | ||
toggleBtn.textContent = 'resume upload' | ||
} else { | ||
if (input.files.length > 0) { | ||
startUpload(); | ||
startUpload() | ||
} else { | ||
input.click(); | ||
input.click() | ||
} | ||
} | ||
}); | ||
}) | ||
|
||
input.addEventListener('change', startUpload); | ||
input.addEventListener('change', startUpload) | ||
|
||
function startUpload() { | ||
var file = input.files[0]; | ||
function startUpload () { | ||
var file = input.files[0] | ||
// Only continue if a file has actually been selected. | ||
// IE will trigger a change event even if we reset the input element | ||
// using reset() and we do not want to blow up later. | ||
if(!file) { | ||
return; | ||
if (!file) { | ||
return | ||
} | ||
|
||
// Use the HTTPS protocol if the site is served over a secure connection, | ||
// in order to prevent the requests from being blocked by the browsers due | ||
// to their mixed-content and security rules. | ||
// In the other cases (including the http: and file: protocols), we simply | ||
// fall back to HTTP. | ||
var protocol = location.protocol === 'https:' ? 'https' : 'http'; | ||
var endpoint = protocol + '://master.tus.io/files/'; | ||
var protocol = window.location.protocol === 'https:' ? 'https' : 'http' | ||
var endpoint = protocol + '://master.tus.io/files/' | ||
|
||
console.log('selected file', file); | ||
console.log('selected file', file) | ||
|
||
toggleBtn.textContent = 'pause upload'; | ||
toggleBtn.textContent = 'pause upload' | ||
|
||
var options = { | ||
endpoint: endpoint, | ||
resume: !resumeCheckbox.checked, | ||
onError: function (error) { | ||
resume : !resumeCheckbox.checked, | ||
onError : function (error) { | ||
if (error.originalRequest) { | ||
if (confirm("Failed because: " + error + "\nDo you want to retry?")) { | ||
options.resume = false; | ||
options.uploadUrl = upload.url; | ||
upload = new tus.Upload(file, options); | ||
upload.start(); | ||
return; | ||
if (window.confirm('Failed because: ' + error + '\nDo you want to retry?')) { | ||
options.resume = false | ||
options.uploadUrl = upload.url | ||
upload = new tus.Upload(file, options) | ||
upload.start() | ||
return | ||
} | ||
} else { | ||
alert("Failed because: " + error); | ||
window.alert('Failed because: ' + error) | ||
} | ||
|
||
reset(); | ||
reset() | ||
}, | ||
onProgress: function (bytesUploaded, bytesTotal) { | ||
var percentage = (bytesUploaded / bytesTotal * 100).toFixed(2); | ||
$progressBar.css({width: percentage + '%'}); | ||
console.log(bytesUploaded, bytesTotal, percentage + '%'); | ||
var percentage = (bytesUploaded / bytesTotal * 100).toFixed(2) | ||
$progressBar.css({width: percentage + '%'}) | ||
console.log(bytesUploaded, bytesTotal, percentage + '%') | ||
}, | ||
onSuccess: function () { | ||
var anchor = document.createElement('a'); | ||
anchor.textContent = 'Download ' + upload.file.name + ' (' + upload.file.size + ' bytes)'; | ||
anchor.href = upload.url; | ||
anchor.className = 'button primary'; | ||
uploadList.appendChild(anchor); | ||
var anchor = document.createElement('a') | ||
anchor.textContent = 'Download ' + upload.file.name + ' (' + upload.file.size + ' bytes)' | ||
anchor.href = upload.url | ||
anchor.className = 'button primary' | ||
uploadList.appendChild(anchor) | ||
|
||
reset(); | ||
reset() | ||
|
||
$("html, body").animate({ | ||
scrollTop: $(uploadList).offset().top | ||
}, 1000); | ||
} | ||
}; | ||
$('html, body').animate({ | ||
scrollTop: $(uploadList).offset().top, | ||
}, 1000) | ||
}, | ||
} | ||
|
||
upload = new tus.Upload(file, options); | ||
upload.start(); | ||
upload = new tus.Upload(file, options) | ||
upload.start() | ||
} | ||
|
||
var animatedOutClass = 'animated flipOutX'; | ||
var animatedInClass = 'animated fadeIn'; | ||
function reset() { | ||
input.value = ''; | ||
toggleBtn.textContent = 'start upload'; | ||
upload = null; | ||
var animatedOutClass = 'animated flipOutX' | ||
var animatedInClass = 'animated fadeIn' | ||
function reset () { | ||
input.value = '' | ||
toggleBtn.textContent = 'start upload' | ||
upload = null | ||
|
||
$progress.removeClass('active'); | ||
$progress.removeClass('active') | ||
|
||
// hide | ||
window.setTimeout(function () { | ||
$progress.addClass(animatedOutClass); | ||
$progressBar.addClass('no-transition'); | ||
$progress.addClass(animatedOutClass) | ||
$progressBar.addClass('no-transition') | ||
|
||
// set to 0 | ||
window.setTimeout(function () { | ||
$progressBar.css({width: 0}); | ||
$progressBar.css({width: 0}) | ||
|
||
// show | ||
window.setTimeout(function () { | ||
$progressBar.removeClass('no-transition'); | ||
$progressBar.removeClass('no-transition') | ||
$progress | ||
.removeClass(animatedOutClass) | ||
.addClass(animatedInClass); | ||
}, 300); | ||
}, 600); | ||
}, 1000); | ||
.addClass(animatedInClass) | ||
}, 300) | ||
}, 600) | ||
}, 1000) | ||
} | ||
}); | ||
}) |
Oops, something went wrong.