Skip to content

Commit

Permalink
Fix trailing slash problem, add status UI, remove webmaker-kits example
Browse files Browse the repository at this point in the history
  • Loading branch information
humphd committed Apr 4, 2014
1 parent 9d70386 commit bce60c2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 17 deletions.
6 changes: 4 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ <h2 class="page-header">Boot Options</h2>
<p>Boot options are passed on the query string. Valid options include:</p>
<ul>
<li><code>?reset</code> (e.g., <a href="?reset">?reset</a> format the current fs, erasing all files)
<li><code>?install={zipfile.zip}</code> (e.g., <a href="?install=webmaker-kits-gh-pages.zip">?install=webmaker-kits-gh-pages.zip</a>, <a href="?install=restaurant-gh-pages.zip">?install=restaurant-gh-pages.zip</a>)
<li><code>?/{path/to/file/in/filesystem}</code> (e.g., serve the file at a given path, <a href="?/webmaker-kits-gh-pages">?/webmaker-kits-gh-pages</a>, <a href="?/restaurant-gh-pages.zip">?/restaurant-gh-pages</a>)
<li><code>?install={zipfile.zip}</code> (e.g., <a href="?install=restaurant-gh-pages.zip">?install=restaurant-gh-pages.zip</a>)
<li><code>?/{path/to/file/in/filesystem}</code> (e.g., serve the file at a given path, <a href="?/restaurant-gh-pages.zip">?/restaurant-gh-pages</a>)
</ul>

<h2 class="page-header">Installing Files</h2>
Expand All @@ -55,6 +55,8 @@ <h2 class="page-header">Installing Files</h2>
</div>
</div>

<div id="status" class="alert alert-success" style="display:none"></div>

</div>
</div>
</body>
Expand Down
45 changes: 30 additions & 15 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,30 @@ requirejs.config({
requirejs(['filer', 'webserver'], function(Filer, WebServer) {
var Path = Filer.Path;

function install(file) {
var status = document.getElementById('status');
status.innerHTML = "Downloading zip file...";
status.style.display = 'block';

WebServer.download(file, function(err, path) {
if(err) {
status.className = "alert alert-danger";
status.innerHTML = "Error downloading zip file!";
return;
}

status.innerHTML = "Extracting zip file...";
WebServer.install(path, function(err) {
if(err) {
status.className = "alert alert-danger";
status.innerHTML = "Error downloading zip file!";
return;
}
window.location = '?/';
});
});
}

function showUI() {
var ui = document.getElementById('ui');
ui.style.display = 'block';
Expand All @@ -17,12 +41,7 @@ requirejs(['filer', 'webserver'], function(Filer, WebServer) {
var upload = document.getElementById('upload');
upload.addEventListener('change', function() {
var file = this.files[0];
WebServer.download(file, function(err, path) {
// XXX deal with err
WebServer.install(path, function() {
window.location = '?/';
});
});
install(file);
}, false);
}

Expand Down Expand Up @@ -61,19 +80,15 @@ requirejs(['filer', 'webserver'], function(Filer, WebServer) {
return;
}
if(option === 'install') {
WebServer.download(value, function(err, path) {
// XXX deal with err
WebServer.install(path, function() {
// Show the web root
window.location = '?/';
});
});
install(value);
return;
}
}

// Case 3: a path was given into the web root, try to serve it
WebServer.serve(option);
// Case 3: a path was given into the web root, try to serve it.
// Strip any server added trailing slash (unless we have '/').
var url = option === '/' ? option : option.replace(/\/$/, '');
WebServer.serve(url);
}

boot();
Expand Down
Binary file removed webmaker-kits-gh-pages.zip
Binary file not shown.

0 comments on commit bce60c2

Please sign in to comment.