0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-05-07 18:48:39 +00:00

Revert "Embed Endpoint"

This commit is contained in:
Trevor Buckner
2026-04-04 21:15:57 -04:00
committed by GitHub
parent 13f3df529a
commit 67b4d3b760
13 changed files with 102 additions and 397 deletions
+2 -45
View File
@@ -1,14 +1,6 @@
/* eslint-disable max-lines */
import _ from 'lodash';
import yaml from 'js-yaml';
import request from '../client/homebrew/utils/request-middleware.js';
import Markdown from '../shared/markdown.js';
import packageJSON from '../package.json' with { type: 'json' };
const PAGEBREAK_REGEX_V3 = /^(?=\\page(?:break)?(?: *{[^\n{}]*})?$)/m;
const PAGEBREAK_REGEX_LEGACY = /\\page(?:break)?/m;
const COLUMNBREAK_REGEX_LEGACY = /\\column(:?break)?/m;
// Convert the templates from a brew to a Snippets Structure.
const brewSnippetsToJSON = (menuTitle, userBrewSnippets, themeBundleSnippets=null, full=true)=>{
@@ -138,7 +130,7 @@ const fetchThemeBundle = async (setError, setThemeBundle, renderer, theme)=>{
const themeBundle = res.body;
themeBundle.joinedStyles = themeBundle.styles.map((style)=>`<style>${style}</style>`).join('\n\n');
setThemeBundle(themeBundle);
if(setError) { setError(null); }
setError(null);
};
const debugTextMismatch = (clientTextRaw, serverTextRaw, label)=>{
@@ -176,45 +168,10 @@ const debugTextMismatch = (clientTextRaw, serverTextRaw, label)=>{
}
};
const scrapeBrew = ()=>{
const htmlBody = `<html>\n${window.frames['BrewRenderer'].contentDocument.documentElement.innerHTML}\n</html>`;
return htmlBody;
};
const downloadBlob = (brewHtml, fileName)=>{
const blob = new Blob([brewHtml], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = fileName || 'download';
const clickHandler = ()=>{
setTimeout(()=>{
URL.revokeObjectURL(url);
removeEventListener('click', clickHandler);
}, 150);
};
a.addEventListener('click', clickHandler, false);
a.click();
};
const scrapeBrewZip = ()=>{
const htmlBody = scrapeBrew();
// DO STUFF!
};
const scrapeBrewHTML = ()=>{
const htmlBody = scrapeBrew();
// Manipulate the body to change all relative path references to full URLs
downloadBlob(htmlBody, 'testDownload.html');
};
export {
splitTextStyleAndMetadata,
printCurrentBrew,
fetchThemeBundle,
brewSnippetsToJSON,
debugTextMismatch,
scrapeBrewHTML,
scrapeBrewZip,
debugTextMismatch
};