0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-20 14:02:45 +00:00
This commit is contained in:
Trevor Buckner
2024-09-04 01:06:56 -04:00
parent 4f39222724
commit d7d690a9d1
5 changed files with 132 additions and 133 deletions

View File

@@ -5,11 +5,11 @@ const Nav = require('naturalcrit/nav/nav.jsx');
module.exports = function (props) {
return (
<Nav.item
color="purple"
icon="fas fa-dungeon"
href="/vault"
color='purple'
icon='fas fa-dungeon'
href='/vault'
newTab={false}
rel="noopener noreferrer"
rel='noopener noreferrer'
>
Vault
</Nav.item>

View File

@@ -116,7 +116,7 @@ const VaultPage = (props) => {
const renderNavItems = ()=>(
<Navbar>
<Nav.section>
<Nav.item className="brewTitle">
<Nav.item className='brewTitle'>
Vault: Search for brews
</Nav.item>
</Nav.section>
@@ -145,24 +145,24 @@ const VaultPage = (props) => {
};
const renderForm = ()=>(
<div className="brewLookup">
<h2 className="formTitle">Brew Lookup</h2>
<div className="formContents">
<div className='brewLookup'>
<h2 className='formTitle'>Brew Lookup</h2>
<div className='formContents'>
<label>
Title of the brew
<input
ref={titleRef}
type="text"
name="title"
type='text'
name='title'
defaultValue={props.query.title || ''}
onKeyUp={disableSubmitIfFormInvalid}
pattern=".{3,}"
title="At least 3 characters"
pattern='.{3,}'
title='At least 3 characters'
onKeyDown={(e)=>{
if(e.key === 'Enter' && !submitButtonRef.current.disabled)
loadPage(1, true);
}}
placeholder="v3 Reference Document"
placeholder='v3 Reference Document'
/>
</label>
@@ -170,34 +170,34 @@ const VaultPage = (props) => {
Author of the brew
<input
ref={authorRef}
type="text"
name="author"
pattern=".{1,}"
type='text'
name='author'
pattern='.{1,}'
defaultValue={props.query.author || ''}
onKeyUp={disableSubmitIfFormInvalid}
onKeyDown={(e)=>{
if(e.key === 'Enter' && !submitButtonRef.current.disabled)
loadPage(1, true);
}}
placeholder="Username"
placeholder='Username'
/>
</label>
<label>
Results per page
<select ref={countRef} name="count" defaultValue={props.query.count || 20}>
<option value="10">10</option>
<option value="20">20</option>
<option value="40">40</option>
<option value="60">60</option>
<select ref={countRef} name='count' defaultValue={props.query.count || 20}>
<option value='10'>10</option>
<option value='20'>20</option>
<option value='40'>40</option>
<option value='60'>60</option>
</select>
</label>
<label>
<input
className="renderer"
className='renderer'
ref={v3Ref}
type="checkbox"
type='checkbox'
defaultChecked={props.query.v3 !== 'false'}
onChange={disableSubmitIfFormInvalid}
/>
@@ -206,9 +206,9 @@ const VaultPage = (props) => {
<label>
<input
className="renderer"
className='renderer'
ref={legacyRef}
type="checkbox"
type='checkbox'
defaultChecked={props.query.legacy !== 'false'}
onChange={disableSubmitIfFormInvalid}
/>
@@ -216,7 +216,7 @@ const VaultPage = (props) => {
</label>
<button
id="searchButton"
id='searchButton'
ref={submitButtonRef}
onClick={()=>{
loadPage(1, true);
@@ -244,7 +244,7 @@ const VaultPage = (props) => {
<li>
Some common words like "a", "after", "through", "itself", "here", etc.,
are ignored in searches. The full list can be found &nbsp;
<a href="https://github.com/mongodb/mongo/blob/0e3b3ca8480ddddf5d0105d11a94bd4698335312/src/mongo/db/fts/stop_words_english.txt">
<a href='https://github.com/mongodb/mongo/blob/0e3b3ca8480ddddf5d0105d11a94bd4698335312/src/mongo/db/fts/stop_words_english.txt'>
here
</a>
</li>
@@ -286,18 +286,18 @@ const VaultPage = (props) => {
));
return (
<div className="paginationControls">
<div className='paginationControls'>
<button
className="previousPage"
className='previousPage'
onClick={()=>loadPage(pageState - 1, false)}
disabled={pageState === startPage}
>
<i className="fa-solid fa-chevron-left"></i>
<i className='fa-solid fa-chevron-left'></i>
</button>
<ol className="pages">
<ol className='pages'>
{startPage > 1 && (
<a
className="pageNumber firstPage"
className='pageNumber firstPage'
onClick={()=>loadPage(1, false)}
>
1 ...
@@ -306,7 +306,7 @@ const VaultPage = (props) => {
{pagesAroundCurrent}
{endPage < totalPages && (
<a
className="pageNumber lastPage"
className='pageNumber lastPage'
onClick={()=>loadPage(totalPages, false)}
>
... {totalPages}
@@ -314,11 +314,11 @@ const VaultPage = (props) => {
)}
</ol>
<button
className="nextPage"
className='nextPage'
onClick={()=>loadPage(pageState + 1, false)}
disabled={pageState === totalPages}
>
<i className="fa-solid fa-chevron-right"></i>
<i className='fa-solid fa-chevron-right'></i>
</button>
</div>
);
@@ -327,8 +327,8 @@ const VaultPage = (props) => {
const renderFoundBrews = ()=>{
if(searching) {
return (
<div className="foundBrews searching">
<h3 className="searchAnim">Searching</h3>
<div className='foundBrews searching'>
<h3 className='searchAnim'>Searching</h3>
</div>
);
}
@@ -338,7 +338,7 @@ const VaultPage = (props) => {
console.log('render Error: ', error);
return (
<div className="foundBrews noBrews">
<div className='foundBrews noBrews'>
<h3>Error: {errorText}</h3>
</div>
);
@@ -346,7 +346,7 @@ const VaultPage = (props) => {
if(!brewCollection) {
return (
<div className="foundBrews noBrews">
<div className='foundBrews noBrews'>
<h3>No search yet</h3>
</div>
);
@@ -354,15 +354,15 @@ const VaultPage = (props) => {
if(brewCollection.length === 0) {
return (
<div className="foundBrews noBrews">
<div className='foundBrews noBrews'>
<h3>No brews found</h3>
</div>
);
}
return (
<div className="foundBrews">
<span className="totalBrews">
<div className='foundBrews'>
<span className='totalBrews'>
{`Brews found: `}
<span>{totalBrews}</span>
</span>
@@ -381,15 +381,15 @@ const VaultPage = (props) => {
};
return (
<div className="vaultPage">
<link href="/themes/V3/Blank/style.css" rel="stylesheet" />
<link href="/themes/V3/5ePHB/style.css" rel="stylesheet" />
<div className='vaultPage'>
<link href='/themes/V3/Blank/style.css' rel='stylesheet' />
<link href='/themes/V3/5ePHB/style.css' rel='stylesheet' />
{renderNavItems()}
<div className="content">
<div className='content'>
<SplitPane hideMoveArrows>
<div className="form dataGroup">{renderForm()}</div>
<div className='form dataGroup'>{renderForm()}</div>
<div className="resultsContainer dataGroup">
<div className='resultsContainer dataGroup'>
{renderFoundBrews()}
</div>
</SplitPane>

View File

@@ -62,15 +62,14 @@ const findBrews = async (req, res) => {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
const processedBrews = brews.map((brew)=>{
brew.authors = brew.authors.map(author =>
emailRegex.test(author) ? 'hidden' : author
brew.authors = brew.authors.map((author)=>emailRegex.test(author) ? 'hidden' : author
);
return brew;
});
res.json({ brews: processedBrews, page });
})
.catch((error)=>{
throw {...error, message: "Error finding brews in Vault search", HBErrorCode: 90};
throw { ...error, message: 'Error finding brews in Vault search', HBErrorCode: 90 };
});
};
@@ -93,7 +92,7 @@ const findTotal = async (req, res) => {
res.json({ totalBrews });
})
.catch((error)=>{
throw {...error, message: "Error finding brews in Vault search findTotal function", HBErrorCode: 91};
throw { ...error, message: 'Error finding brews in Vault search findTotal function', HBErrorCode: 91 };
});
};