Last active
December 17, 2015 10:49
-
-
Save pvanneau/5598118 to your computer and use it in GitHub Desktop.
Routing tools for webapp (like Backbone)
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
<ifModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_URI} !index | |
RewriteRule (.*) index.html [L] | |
</ifModule> |
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
define([ | |
'jquery', | |
], function($) | |
{ | |
var Helpers = {}; | |
Helpers.preventClick = function(appRouter) | |
{ | |
$(document).on("click", "a[href^='/']", function(event) | |
{ | |
var href, passThrough, url, rel; | |
href = $(event.currentTarget).attr('href'); | |
rel = $(event.currentTarget).attr('rel'); | |
if ( | |
(rel !== "external") && | |
!event.altKey && | |
!event.ctrlKey && | |
!event.metaKey && | |
!event.shiftKey) | |
{ | |
event.preventDefault(); | |
url = href.replace(/^\//, '').replace('\#\!\/', ''); | |
appRouter.navigate(url, { | |
trigger: true | |
}); | |
return false; | |
} | |
}); | |
} | |
return Helpers; | |
}); |
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
var express = require('express'), | |
app = express(); | |
app.use(express.static(__dirname + '/')); | |
app.get(/^(.*)$/, function(req, res) { | |
res.sendfile(__dirname + '/index.html'); | |
}); | |
app.listen(process.env.PORT || 8080); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment