1
0
mirror of https://github.com/stolksdorf/homebrewery.git synced 2025-12-13 16:25:57 +00:00

Added a print page route, allowing for easy image and pdf grabs

This commit is contained in:
Scott Tolksdorf
2016-01-13 15:14:13 -05:00
parent dab29762c6
commit db5d12992a
3 changed files with 154 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
@import (less) 'shared/naturalCrit/styles/reset.less';
@import (less) './client/homebrew/phbStyle/phb.fonts.css';
@import (less) './client/homebrew/phbStyle/phb.assets.less';
//Colors
@@ -24,8 +24,8 @@
z-index : 15;
box-sizing : border-box;
overflow : hidden;
height : 27.5cm;
width : 21cm;
height : 279.4mm;
width : 215.9mm;
padding : 1.0cm 1.7cm;
column-count : 2;
column-fill : auto;

View File

@@ -1,3 +1,126 @@
/* Eric Meyer's Reset CSS v2.0 - http://cssreset.com */
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
margin: 0;
padding: 0;
}
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
display: block;
}
body {
line-height: 1;
}
ol,
ul {
list-style: none;
}
blockquote,
q {
quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
/* Main Font */
@font-face {
font-family: BookSanity;
@@ -55,8 +178,8 @@
z-index: 15;
box-sizing: border-box;
overflow: hidden;
height: 27.5cm;
width: 21cm;
height: 279.4mm;
width: 215.9mm;
padding: 1.0cm 1.7cm;
column-count: 2;
column-fill: auto;

View File

@@ -1,3 +1,4 @@
var _ = require('lodash');
var vitreumRender = require('vitreum/render');
var HomebrewModel = require('./homebrew.model.js').model;
@@ -97,6 +98,31 @@ module.exports = function(app){
})
});
//Print Page
var Markdown = require('marked');
var PHBStyle = '<style>' + require('fs').readFileSync('./phb.standalone.css', 'utf8') + '</style>'
app.get('/homebrew/print/: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>'
return res.send(page)
})
});