mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-11-15 01:38:44 +00:00
Remove files changed from incorrect base
This commit is contained in:
+24
-2
@@ -10,7 +10,7 @@ import asyncHandler from 'express-async-handler';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { makePatches, applyPatches, stringifyPatches, parsePatch } from '@sanity/diff-match-patch';
|
||||
import { md5 } from 'hash-wasm';
|
||||
import { splitTextStyleAndMetadata, transformFrontmatter,
|
||||
import { splitTextStyleAndMetadata,
|
||||
brewSnippetsToJSON, debugTextMismatch } from '../shared/helpers.js';
|
||||
import checkClientVersion from './middleware/check-client-version.js';
|
||||
import dbCheck from './middleware/dbCheck.js';
|
||||
@@ -209,7 +209,29 @@ const api = {
|
||||
return res.status(200).send(brew.style);
|
||||
},
|
||||
mergeBrewText : (brew)=>{
|
||||
return transformFrontmatter(brew);
|
||||
let text = brew.text;
|
||||
if(brew.style !== undefined) {
|
||||
text = `\`\`\`css\n` +
|
||||
`${brew.style || ''}\n` +
|
||||
`\`\`\`\n\n` +
|
||||
`${text}`;
|
||||
}
|
||||
const metadata = _.pick(brew, ['title', 'description', 'tags', 'renderer', 'theme']);
|
||||
const snippetsArray = brewSnippetsToJSON('brew_snippets', brew.snippets, null, false).snippets;
|
||||
metadata.snippets = snippetsArray.length > 0 ? snippetsArray : undefined;
|
||||
metadata.bleedSize = { top: brew?.bleedSize?.top, bottom: brew?.bleedSize?.bottom, inner: brew?.bleedSize?.inner, outer: brew?.bleedSize?.outer };
|
||||
metadata.safetySpace = { top: brew?.safetySpace?.top, bottom: brew?.safetySpace?.bottom, outer: brew?.safetySpace?.outer, inner: brew?.safetySpace?.inner };
|
||||
metadata.trimSize = { width: brew?.trimSize?.width, height: brew?.trimSize?.height };
|
||||
metadata.columns = brew?.columns;
|
||||
metadata.columnGutter = brew?.columnGutter;
|
||||
metadata.license = brew?.license;
|
||||
metadata.legalAuthors = brew?.legalAuthors;
|
||||
|
||||
text = `\`\`\`metadata\n` +
|
||||
`${yaml.dump(metadata)}\n` +
|
||||
`\`\`\`\n\n` +
|
||||
`${text}`;
|
||||
return text;
|
||||
},
|
||||
getGoodBrewTitle : (text)=>{
|
||||
const tokens = hbfm.marked.lexer(text);
|
||||
|
||||
@@ -499,6 +499,8 @@ description: this is a description
|
||||
tags:
|
||||
- something
|
||||
- fun
|
||||
renderer: v3
|
||||
theme: phb
|
||||
bleedSize:
|
||||
top: .125in
|
||||
bottom: .125in
|
||||
@@ -516,8 +518,6 @@ columns: '2'
|
||||
columnGutter: .125in
|
||||
license: None
|
||||
legalAuthors: ''
|
||||
renderer: v3
|
||||
theme: phb
|
||||
|
||||
\`\`\`
|
||||
|
||||
@@ -554,7 +554,7 @@ brew`);
|
||||
width : '8.5in',
|
||||
height : '11in',
|
||||
},
|
||||
}, 'hb');
|
||||
});
|
||||
|
||||
expect(result).toEqual(`\`\`\`metadata
|
||||
title: some title
|
||||
@@ -562,6 +562,8 @@ description: this is a description
|
||||
tags:
|
||||
- something
|
||||
- fun
|
||||
renderer: v3
|
||||
theme: phb
|
||||
bleedSize:
|
||||
top: .125in
|
||||
bottom: .125in
|
||||
@@ -579,8 +581,6 @@ columns: '2'
|
||||
columnGutter: .125in
|
||||
license: None
|
||||
legalAuthors: ''
|
||||
renderer: v3
|
||||
theme: phb
|
||||
|
||||
\`\`\`
|
||||
|
||||
|
||||
+3
-13
@@ -15,7 +15,7 @@ import fs from 'fs';
|
||||
import dbCheck from './middleware/dbCheck.js';
|
||||
import sanitizeFilename from 'sanitize-filename';
|
||||
import { DEFAULT_BREW } from './brewDefaults.js';
|
||||
import { splitTextStyleAndMetadata, transformFrontmatter } from '../shared/helpers.js';
|
||||
import { splitTextStyleAndMetadata } from '../shared/helpers.js';
|
||||
import GoogleActions from './googleActions.js';
|
||||
|
||||
import api from './homebrew.api.js';
|
||||
@@ -135,19 +135,9 @@ export default function pageRoutes({
|
||||
});
|
||||
|
||||
//Download brew source page
|
||||
app.get('/download/:format/:id', asyncHandler(getBrew('share')), async (req, res)=>{
|
||||
const markdownFormats = {
|
||||
hb : 'homebrewery',
|
||||
cm : 'commonmark',
|
||||
toml : 'toml',
|
||||
json : 'json'
|
||||
};
|
||||
|
||||
app.get('/download/:id', asyncHandler(getBrew('share')), (req, res)=>{
|
||||
const { brew } = req;
|
||||
|
||||
const lastBrew = brew.text;
|
||||
sanitizeBrew(brew, 'share');
|
||||
brew.text = await transformFrontmatter(brew, req.params.format);
|
||||
const prefix = 'HB - ';
|
||||
|
||||
const encodeRFC3986ValueChars = (str)=>{
|
||||
@@ -162,7 +152,7 @@ export default function pageRoutes({
|
||||
res.set({
|
||||
'Cache-Control' : 'no-cache',
|
||||
'Content-Type' : 'text/plain',
|
||||
'Content-Disposition' : `attachment; filename*=UTF-8''${encodeRFC3986ValueChars(fileName)}.${markdownFormats[req.params.format]}.md`
|
||||
'Content-Disposition' : `attachment; filename*=UTF-8''${encodeRFC3986ValueChars(fileName)}.txt`
|
||||
});
|
||||
res.status(200).send(brew.text);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user