0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

Add a page count to User page

This commit is contained in:
G.Ambatte
2021-07-31 17:21:25 +12:00
parent 1885a8d0cc
commit a908c5f5d5
4 changed files with 12 additions and 5 deletions

View File

@@ -107,6 +107,7 @@ const BrewItem = createClass({
<h2>{brew.title}</h2>
<p className='description'>{brew.description}</p>
<hr />
<div className='spacer'></div>
<div className='info'>
<span title={`Authors:\n${brew.authors.join('\n')}`}>

View File

@@ -69,4 +69,7 @@
padding : 0px;
margin : -5px;
}
.spacer {
height : 25px;
}
}

View File

@@ -38,6 +38,7 @@ const newBrew = (req, res)=>{
brew.authors = (req.account) ? [req.account.username] : [];
brew.text = mergeBrewText(brew.text, brew.style);
brew.pageCount = (brew.text.match(/\\page/g) || []).length + 1;
delete brew.editId;
delete brew.shareId;
@@ -66,6 +67,7 @@ const updateBrew = (req, res)=>{
.then((brew)=>{
brew = _.merge(brew, req.body);
brew.text = mergeBrewText(brew.text, brew.style);
brew.pageCount = (brew.text.match(/\\page/g) || []).length + 1;
// Compress brew text to binary before saving
brew.textBin = zlib.deflateRawSync(brew.text);

View File

@@ -4,11 +4,12 @@ const _ = require('lodash');
const zlib = require('zlib');
const HomebrewSchema = mongoose.Schema({
shareId : { type: String, default: ()=>{return nanoid(12);}, index: { unique: true } },
editId : { type: String, default: ()=>{return nanoid(12);}, index: { unique: true } },
title : { type: String, default: '' },
text : { type: String, default: '' },
textBin : { type: Buffer },
shareId : { type: String, default: ()=>{return nanoid(12);}, index: { unique: true } },
editId : { type: String, default: ()=>{return nanoid(12);}, index: { unique: true } },
title : { type: String, default: '' },
text : { type: String, default: '' },
textBin : { type: Buffer },
pageCount : { type: Number, default: 1 },
description : { type: String, default: '' },
tags : { type: String, default: '' },