1
0
mirror of https://github.com/stolksdorf/homebrewery.git synced 2025-12-18 13:21:28 +00:00

Added @page css rule to auto turn off margins in Chrome when printing

This commit is contained in:
Scott
2016-02-16 14:10:11 -05:00
parent c8b3a0f183
commit 2231dc3684
4 changed files with 82 additions and 67 deletions

View File

@@ -2,8 +2,23 @@ var _ = require('lodash');
var vitreumRender = require('vitreum/render');
var HomebrewModel = require('./homebrew.model.js').model;
var getTopBrews = function(cb){
HomebrewModel.find().sort({views: -1}).limit(5).exec(function(err, brews) {
cb(brews);
});
}
module.exports = function(app){
app.get('/homebrew/top', function(req, res){
getTopBrews(function(topBrews){
return res.json(topBrews);
});
})
app.get('/homebrew/new', function(req, res){
var newHomebrew = new HomebrewModel();
@@ -43,8 +58,6 @@ module.exports = function(app){
});
//Edit Page
app.get('/homebrew/edit/:id', function(req, res){
HomebrewModel.find({editId : req.params.id}, function(err, objs){
@@ -122,52 +135,9 @@ module.exports = function(app){
var page = '<html><head>' + title + PHBStyle + '</head><body>' + content +'</body></html>'
return res.send(page)
})
});
});
//PDF download
/*
var pdf = require('html-pdf');
app.get('/homebrew/pdf/:id', function(req, res){
HomebrewModel.find({shareId : req.params.id}, function(err, objs){
if(err) return res.status(404).send();
var resObj = null;
var errObj = {text: "# oops\nCould not find the homebrew."}
if(objs.length){
resObj = objs[0];
}
var content = _.map(resObj.text.split('\\page'), function(pageText){
return '<div class="phb">' + Markdown(pageText) + '</div>';
}).join('\n');
var title = '<title>' + resObj.text.split('\n')[0] + '</title>';
var page = '<html><head>' + title + PHBStyle + '</head><body>' + content +'</body></html>'
var config = {
"height": (279.4 - 56) + "mm",
"width": (215.9 - 43) + "mm",
"border": "0",
}
pdf.create(page, config).toStream(function(err, stream){
res.attachment('pdfname.pdf');
return stream.pipe(res);
});
})
});
*/
//Home and 404, etc.
var welcomeText = require('fs').readFileSync('./client/homebrew/homePage/welcome_msg.txt', 'utf8');