Skip to content

Commit

Permalink
make push state work by responding to all routes not prefixed with ap…
Browse files Browse the repository at this point in the history
…i with HTML
  • Loading branch information
joelongstreet committed Feb 22, 2014
1 parent e5fd32d commit 1f3e158
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -3,6 +3,6 @@ node_modules
*.db
bower_components
public/*
!public/index.html
!public/app.html
!public/img/
!public/img/*
6 changes: 3 additions & 3 deletions index.js
Expand Up @@ -5,9 +5,9 @@ var app = express();

app.use(express.static(process.cwd() + '/public'));

app.get('/', routes.getAuthURL);
app.get('/user/authorize', routes.getAuthURL);
app.get('/auth_callback', routes.authCallback);
app.get('/*', routes.ui);
app.get('/api/user/authorize', routes.getAuthURL);
app.get('/api/auth_callback', routes.authCallback);
app.get('/api/:method', routes.makeFlickrRequest);


Expand Down
7 changes: 7 additions & 0 deletions lib/routes.js
@@ -1,3 +1,4 @@
var path = require('path');
var dirty = require('dirty');
var users = dirty('./db/users.db');

Expand All @@ -7,6 +8,12 @@ require('./flickrConnect').createClient(function(client){
});


exports.ui = function(req, res){
var htmlPath = path.join(process.cwd(), 'public/app.html')
res.sendfile(htmlPath);
};


exports.getAuthURL = function(req, res){
res.redirect(flickrClient.getUserAuthURL());
};
Expand Down
3 changes: 1 addition & 2 deletions public/index.html → public/app.html
@@ -1,14 +1,13 @@
<!DOCTYPE html>
<html>
<h
<head>
<meta charset="utf-8">
<title>Flickr Photo Album</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/app.css" />
<script src="/vendor.js"></script>
<script src="/templates.js"></script>
<script src="/app.css"></script>
<script src="/app.js"></script>
</head>
<body><div id="main"></div></body>
Expand Down

0 comments on commit 1f3e158

Please sign in to comment.