diff --git a/app/index.js b/app/index.js index bf082004..d3767383 100644 --- a/app/index.js +++ b/app/index.js @@ -1,8 +1,10 @@ var express = require('express'); var app = express(); +var compression = require('compression'); +var serveStatic = require('serve-static'); // Configure ejs engine -app.set('views', __dirname + '/../public'); +app.set('views', __dirname + '/../views'); app.engine('html', require('ejs').renderFile); // Force HTTPS on stackedit.io @@ -15,28 +17,42 @@ app.all('*', function(req, res, next) { }); // Use gzip compression -app.use(express.compress()); +app.use(compression()); // Serve static resources -app.use(express.static(__dirname + '/../public')); - -// Serve editor.html in /viewer -app.get('/editor', function (req, res) { - res.render('editor.html'); -}); - -// Serve viewer.html in /viewer -app.get('/viewer', function (req, res) { - res.render('viewer.html'); -}); +app.use(serveStatic(__dirname + '/../public')); app.post('/pdfExport', require('./pdf').export); app.post('/sshPublish', require('./ssh').publish); app.post('/picasaImportImg', require('./picasa').importImg); app.get('/downloadImport', require('./download').importPublic); -// Error 404 app.use(function(req, res, next) { + res.renderDebug = function(page) { + return res.render(page, { + cache: !req.query.hasOwnProperty('debug') + }); + }; + next(); +}); + +// Serve landing.html in / +app.get('/', function(req, res) { + res.renderDebug('landing.html'); +}); + +// Serve editor.html in /viewer +app.get('/editor', function(req, res) { + res.renderDebug('editor.html'); +}); + +// Serve viewer.html in /viewer +app.get('/viewer', function(req, res) { + res.renderDebug('viewer.html'); +}); + +// Error 404 +app.use(function(req, res) { res.status(404); res.render('error_404.html'); }); diff --git a/public/html/gdrive-action.html b/public/html/gdrive-action.html index f6fce3ee..50f6d711 100644 --- a/public/html/gdrive-action.html +++ b/public/html/gdrive-action.html @@ -3,7 +3,7 @@ + + + + + + diff --git a/views/error_404.html b/views/error_404.html new file mode 100644 index 00000000..0e0f3537 --- /dev/null +++ b/views/error_404.html @@ -0,0 +1,22 @@ + + + + + StackEdit - 404 + + + + + + + + +
+

+ +

+

404 — Page not found

+

Looking for StackEdit recovery?

+ + + diff --git a/views/landing.html b/views/landing.html new file mode 100644 index 00000000..6bd3df00 --- /dev/null +++ b/views/landing.html @@ -0,0 +1,481 @@ + +> + + + StackEdit – In-browser markdown editor + + + + + + + + + + + + + + +
+ + + + + +
+
+ + +
+ + + diff --git a/views/viewer.html b/views/viewer.html new file mode 100644 index 00000000..d0a02279 --- /dev/null +++ b/views/viewer.html @@ -0,0 +1,29 @@ + +> + + + StackEdit Viewer + + + + + + + + + + + + + +