mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-17 01:32:45 +00:00
js files
This commit is contained in:
@@ -53,7 +53,7 @@ fs.emptyDirSync('./build');
|
|||||||
const themes = { Legacy: {}, V3: {} };
|
const themes = { Legacy: {}, V3: {} };
|
||||||
|
|
||||||
let themeFiles = fs.readdirSync('./themes/Legacy');
|
let themeFiles = fs.readdirSync('./themes/Legacy');
|
||||||
for (let dir of themeFiles) {
|
for (const dir of themeFiles) {
|
||||||
const themeData = JSON.parse(fs.readFileSync(`./themes/Legacy/${dir}/settings.json`).toString());
|
const themeData = JSON.parse(fs.readFileSync(`./themes/Legacy/${dir}/settings.json`).toString());
|
||||||
themeData.path = dir;
|
themeData.path = dir;
|
||||||
themes.Legacy[dir] = (themeData);
|
themes.Legacy[dir] = (themeData);
|
||||||
@@ -70,7 +70,7 @@ fs.emptyDirSync('./build');
|
|||||||
}
|
}
|
||||||
|
|
||||||
themeFiles = fs.readdirSync('./themes/V3');
|
themeFiles = fs.readdirSync('./themes/V3');
|
||||||
for (let dir of themeFiles) {
|
for (const dir of themeFiles) {
|
||||||
const themeData = JSON.parse(fs.readFileSync(`./themes/V3/${dir}/settings.json`).toString());
|
const themeData = JSON.parse(fs.readFileSync(`./themes/V3/${dir}/settings.json`).toString());
|
||||||
themeData.path = dir;
|
themeData.path = dir;
|
||||||
themes.V3[dir] = (themeData);
|
themes.V3[dir] = (themeData);
|
||||||
@@ -113,7 +113,7 @@ fs.emptyDirSync('./build');
|
|||||||
const stream = fs.createWriteStream(editorThemeFile, { flags: 'a' });
|
const stream = fs.createWriteStream(editorThemeFile, { flags: 'a' });
|
||||||
stream.write('[\n"default"');
|
stream.write('[\n"default"');
|
||||||
|
|
||||||
for (let themeFile of editorThemeFiles) {
|
for (const themeFile of editorThemeFiles) {
|
||||||
stream.write(`,\n"${themeFile.slice(0, -4)}"`);
|
stream.write(`,\n"${themeFile.slice(0, -4)}"`);
|
||||||
}
|
}
|
||||||
stream.write('\n]\n');
|
stream.write('\n]\n');
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ describe('Tests for admin api', ()=>{
|
|||||||
|
|
||||||
const response = await app
|
const response = await app
|
||||||
.post('/admin/notification/add')
|
.post('/admin/notification/add')
|
||||||
.set('Authorization', 'Basic ' + Buffer.from('admin:password3').toString('base64'))
|
.set('Authorization', `Basic ${Buffer.from('admin:password3').toString('base64')}`)
|
||||||
.send(inputNotification);
|
.send(inputNotification);
|
||||||
|
|
||||||
expect(response.status).toBe(500);
|
expect(response.status).toBe(500);
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ const version = packageJSON.version;
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import jwt from 'jwt-simple';
|
import jwt from 'jwt-simple';
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import yaml from 'js-yaml';
|
|
||||||
import config from './config.js';
|
import config from './config.js';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
|
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ const api = {
|
|||||||
`${text}`;
|
`${text}`;
|
||||||
return text;
|
return text;
|
||||||
},
|
},
|
||||||
|
|
||||||
getGoodBrewTitle : (text)=>{
|
getGoodBrewTitle : (text)=>{
|
||||||
const tokens = Markdown.marked.lexer(text);
|
const tokens = Markdown.marked.lexer(text);
|
||||||
return (tokens.find((token)=>token.type === 'heading' || token.type === 'paragraph')?.text || 'No Title')
|
return (tokens.find((token)=>token.type === 'heading' || token.type === 'paragraph')?.text || 'No Title')
|
||||||
@@ -294,7 +295,7 @@ const api = {
|
|||||||
|
|
||||||
currentTheme = req.brew;
|
currentTheme = req.brew;
|
||||||
splitTextStyleAndMetadata(currentTheme);
|
splitTextStyleAndMetadata(currentTheme);
|
||||||
if(!currentTheme.tags.some(tag => tag === "meta:theme" || tag === "meta:Theme"))
|
if(!currentTheme.tags.some((tag)=>tag === 'meta:theme' || tag === 'meta:Theme'))
|
||||||
throw { brewId: req.params.id, name: 'Invalid Theme Selected', message: 'Selected theme does not have the meta:theme tag', status: 422, HBErrorCode: '10' };
|
throw { brewId: req.params.id, name: 'Invalid Theme Selected', message: 'Selected theme does not have the meta:theme tag', status: 422, HBErrorCode: '10' };
|
||||||
themeName ??= currentTheme.title;
|
themeName ??= currentTheme.title;
|
||||||
themeAuthor ??= currentTheme.authors?.[0];
|
themeAuthor ??= currentTheme.authors?.[0];
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ renderer.paragraph = function(token){
|
|||||||
//Fix local links in the Preview iFrame to link inside the frame
|
//Fix local links in the Preview iFrame to link inside the frame
|
||||||
renderer.link = function (token) {
|
renderer.link = function (token) {
|
||||||
let { href, title, tokens } = token;
|
let { href, title, tokens } = token;
|
||||||
const text = this.parser.parseInline(tokens)
|
const text = this.parser.parseInline(tokens);
|
||||||
let self = false;
|
let self = false;
|
||||||
if(href[0] == '#') {
|
if(href[0] == '#') {
|
||||||
self = true;
|
self = true;
|
||||||
@@ -110,7 +110,7 @@ renderer.link = function (token) {
|
|||||||
|
|
||||||
// Expose `src` attribute as `--HB_src` to make the URL accessible via CSS
|
// Expose `src` attribute as `--HB_src` to make the URL accessible via CSS
|
||||||
renderer.image = function (token) {
|
renderer.image = function (token) {
|
||||||
let {href, title, text} = token;
|
const { href, title, text } = token;
|
||||||
if(href === null)
|
if(href === null)
|
||||||
return text;
|
return text;
|
||||||
|
|
||||||
@@ -873,7 +873,7 @@ const extractHTMLStyleTags = (htmlString)=>{
|
|||||||
?.filter((attr)=>!attr.startsWith('class="') && !attr.startsWith('style="') && !attr.startsWith('id="'))
|
?.filter((attr)=>!attr.startsWith('class="') && !attr.startsWith('style="') && !attr.startsWith('id="'))
|
||||||
.reduce((obj, attr)=>{
|
.reduce((obj, attr)=>{
|
||||||
const index = attr.indexOf('=');
|
const index = attr.indexOf('=');
|
||||||
let [key, value] = [attr.substring(0, index), attr.substring(index + 1)];
|
const [key, value] = [attr.substring(0, index), attr.substring(index + 1)];
|
||||||
obj[key.trim()] = value.replace(/"/g, '');
|
obj[key.trim()] = value.replace(/"/g, '');
|
||||||
return obj;
|
return obj;
|
||||||
}, {}) || null;
|
}, {}) || null;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* eslint-disable max-lines */
|
|
||||||
|
|
||||||
import Markdown from 'naturalcrit/markdown.js';
|
import Markdown from 'naturalcrit/markdown.js';
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* eslint-disable max-lines */
|
|
||||||
|
|
||||||
import Markdown from 'naturalcrit/markdown.js';
|
import Markdown from 'naturalcrit/markdown.js';
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* eslint-disable max-lines */
|
|
||||||
|
|
||||||
import Markdown from 'naturalcrit/markdown.js';
|
import Markdown from 'naturalcrit/markdown.js';
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* eslint-disable max-lines */
|
|
||||||
|
|
||||||
module.exports = [
|
module.exports = [
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* eslint-disable max-lines */
|
|
||||||
|
|
||||||
module.exports = [
|
module.exports = [
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable max-lines */
|
||||||
|
|
||||||
const fontAwesome = {
|
const fontAwesome = {
|
||||||
// FONT-AWESOME SOLID
|
// FONT-AWESOME SOLID
|
||||||
'fas_0' : 'fas fa-0',
|
'fas_0' : 'fas fa-0',
|
||||||
|
|||||||
Reference in New Issue
Block a user