Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions lib/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ im = require('imagemagick-stream'),
common;

module.exports = function(config){
var app = express(),
var router = express.Router();
staticFiles = config.staticFiles,
common = require('./common')(config),
album = require('./album')(config),
photo = require('./photo')(config);


app.set('views', path.join(__dirname, '..', 'views'));
app.set('view engine', 'ejs');


app.get('/gallery.css', function(req, res, next){
router.get('/gallery.css', function(req, res, next){
var fstream = fs.createReadStream(path.join(__dirname, '..', 'css/gallery.css'));
res.type('text/css');
fstream.on('error', function(err){
Expand All @@ -27,7 +24,7 @@ module.exports = function(config){
});

// Photo Page
app.get(/.+(\.(jpg|bmp|jpeg|gif|png|tif)(\?tn=(1|0))?)$/i, function(req, res, next){
router.get(/.+(\.(jpg|bmp|jpeg|gif|png|tif)(\?tn=(1|0))?)$/i, function(req, res, next){
var filePath = path.join(staticFiles, req.path),
fstream;

Expand Down Expand Up @@ -99,9 +96,9 @@ module.exports = function(config){
});

// Photo Pages - anything containing */photo/*
app.get(/(.+\/)?photo\/(.+)/i, photo, common.render);
router.get(/(.+\/)?photo\/(.+)/i, photo, common.render);
// Album Page - everything that doesn't contain the photo string
// regex source http://stackoverflow.com/questions/406230/regular-expression-to-match-string-not-containing-a-word
app.get(/^((?!\/photo\/).)*$/, album, common.render);
return app;
router.get(/^((?!\/photo\/).)*$/, album, common.render);
return router;
}
2 changes: 0 additions & 2 deletions views/album.ejs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<link href="/<%= urlRoot %>/gallery.css" rel="stylesheet" type="text/css">

<% if (!isRoot){ %>
<nav class="breadcrumb">

Expand Down
2 changes: 0 additions & 2 deletions views/photo.ejs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<link href="/<%= urlRoot %>/gallery.css" rel="stylesheet" type="text/css">

<nav class="breadcrumb">
<% for (var i=0; i<breadcrumb.length; i++) { %>

Expand Down