Compare commits

..

No commits in common. "6c80f3977a211a4070ab19d2ed043acde6882a68" and "17b1d023ccfc81f7cac63468591928657274b22a" have entirely different histories.

10 changed files with 394 additions and 600 deletions

3
.gitignore vendored
View File

@ -8,5 +8,4 @@ dev/
config.json config.json
*.sqlite* *.sqlite*
*.db *.db
.dbversion .dbversion
.DS_Store

View File

@ -16,6 +16,7 @@ export const searchView = (state, emit, i18n) => {
} }
// Returning an array in a view allows non-shared parent HTML elements. // Returning an array in a view allows non-shared parent HTML elements.
// This one doesn't have the problem right now, but it's good to remember.
return [ return [
html`<h1 class="title">${__('search.header')}</h1>`, html`<h1 class="title">${__('search.header')}</h1>`,
@ -44,7 +45,7 @@ export const searchView = (state, emit, i18n) => {
// Search Options Section // Search Options Section
html`<section class="flex one two-700"> html`<section class="flex one two-700">
${/*<div> <div>
${modal('searchSourceInfo', controller, [ ${modal('searchSourceInfo', controller, [
html`<p> html`<p>
${__('search.search_source.help.text')} ${__('search.search_source.help.text')}
@ -90,8 +91,7 @@ export const searchView = (state, emit, i18n) => {
</option> </option>
</select> </select>
</label> </label>
</div>*/'' // Temporarily comment out the source chooser so I can focus on just Inventaire </div>
}
<div> <div>
${__('search.search_by.label')}<br> ${__('search.search_by.label')}<br>

View File

@ -8,28 +8,21 @@ export const resultDetails = (searchController, result, emit = () => {}) => {
const { __ } = searchController.i18n; const { __ } = searchController.i18n;
const modalId = `result_${result.uri}`; const modalId = `result_${result.uri}`;
const hasReviews = typeof result.averageRating !== 'undefined' && typeof result.numberOfReviews !== 'undefined';
const buttonHTML = html`<label for=${modalId} class="pseudo button"> const buttonHTML = html`<label for=${modalId} class="pseudo button">
${!hasReviews <span data-tooltip="${__('interaction.average_rating')}: ${result.averageRating}">
? __('search.no_reviews') ${starRating(result.averageRating)}
: html`<span data-tooltip="${__('interaction.average_rating')}: ${result.averageRating}"> </span>
${starRating(result.averageRating)} <span style="margin-left:10px;" data-tooltip=${__('interaction.reviews_written')}>
</span> <span style="margin-right:8px;"><i class="icon-chat"></i></span>
<span style="margin-left:10px;" data-tooltip=${__('interaction.reviews_written')}> <span>${result.numberOfReviews}</span>
<span style="margin-right:8px;"><i class="icon-chat"></i></span> </span>
<span>${result.numberOfReviews}</span>
</span>`
}
<br />
<small>${__('search.click_for_details')}</small>
</label>`; </label>`;
const tabNames = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']; const tabNames = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty'];
const modalContent = html`<article class="flex"> const modalContent = html`<article class="flex">
<div class="sixth-700" style="text-align:center;"> <div class="sixth-700" style="text-align:center;">
<h4>${__('search.covers')}</h4> <h4>Covers</h4>
${typeof result.covers === 'undefined' ${typeof result.covers === 'undefined'
? html`<span style="font-size:3em;"><i class="icon-loading animate-spin"></i></span>` ? html`<span style="font-size:3em;"><i class="icon-loading animate-spin"></i></span>`
: html`<div class="tabs ${typeof tabNames[result.covers.length - 1] !== 'undefined' ? tabNames[result.covers.length - 1] : null}"> : html`<div class="tabs ${typeof tabNames[result.covers.length - 1] !== 'undefined' ? tabNames[result.covers.length - 1] : null}">
@ -62,33 +55,32 @@ export const resultDetails = (searchController, result, emit = () => {}) => {
} }
</div> </div>
<div class="two-third-700"> <div class="two-third-700">
${!hasReviews <h4>${__('interaction.average_rating')}</h4>
? html`<h4>${__('search.no_reviews')}</h4>` <span data-tooltip="${result.averageRating}">${starRating(result.averageRating)}</span>
: html`<h4>${__('interaction.average_rating')}</h4>
<span data-tooltip="${result.averageRating}">${starRating(result.averageRating)}</span>
<div class="flex"> <div class="flex">
<div> <div>
<h4>Top Reviews</h4> <h4>Top Reviews</h4>
</div>
<div>
<a href="/book/${result.uri}" class="small button">
<span style="margin-right:8px;"><i class="icon-chat"></i></span>
<span>${result.numberOfReviews}</span>
<span>${__('search.see_interaction_details')}</span>
</a>
</div>
</div> </div>
${(typeof result.reviews !== 'undefined' && Array.isArray(result.reviews) ? result.reviews : []).map(review => { <div>
return reviewCard(searchController, review); <a href="/book/${result.uri}" class="small button">
})}` <span style="margin-right:8px;"><i class="icon-chat"></i></span>
} <span>${result.numberOfReviews}</span>
<span>${__('search.see_interaction_details')}</span>
</a>
</div>
</div>
${result.reviews.map(review => {
return reviewCard(searchController, review);
})}
</div> </div>
<div class="sixth-700"> <div class="sixth-700">
<p> <p>
<button class="success"> <span data-tooltip=${__('interaction.add')}>
<i class="icon-plus"></i> <span>${__('interaction.add')}</span> <button class="success">
</button> <i class="icon-plus"></i>
</button>
</span>
</p> </p>
<p> <p>
<a class="small button" href=${result.link} target="_blank"> <a class="small button" href=${result.link} target="_blank">

View File

@ -7,10 +7,9 @@
"author": "Robbie Antenesse <dev@alamantus.com>", "author": "Robbie Antenesse <dev@alamantus.com>",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"dev": "concurrently --kill-others \"npm run watch-app\" \"npm run watch-server\"", "dev": "concurrently --kill-others \"npm run watch-js\" \"npm run serve\"",
"start": "npm run build && cross-env NODE_ENV=production npm run serve", "start": "npm run build && cross-env NODE_ENV=production npm run serve",
"watch-app": "parcel watch app/index.html --out-dir public --no-hmr --no-cache", "watch-js": "parcel watch app/index.html --out-dir public --no-hmr --no-cache",
"watch-server": "onchange -i -k \"server/**/*.js*\" -- npm run serve",
"serve": "node server/index.js", "serve": "node server/index.js",
"build": "npm run process-images && npm run bundle", "build": "npm run process-images && npm run bundle",
"bundle": "parcel build app/index.html --out-dir public --no-source-maps --no-cache", "bundle": "parcel build app/index.html --out-dir public --no-source-maps --no-cache",
@ -22,7 +21,6 @@
"choo-devtools": "^3.0.3", "choo-devtools": "^3.0.3",
"concurrently": "^5.1.0", "concurrently": "^5.1.0",
"faker": "^4.1.0", "faker": "^4.1.0",
"onchange": "^7.0.2",
"rimraf": "^3.0.1", "rimraf": "^3.0.1",
"sequelize-erd": "https://github.com/Alamantus/sequelize-erd.git" "sequelize-erd": "https://github.com/Alamantus/sequelize-erd.git"
}, },
@ -40,18 +38,18 @@
"fastify-plugin": "^1.6.0", "fastify-plugin": "^1.6.0",
"fastify-static": "^2.6.0", "fastify-static": "^2.6.0",
"make-promises-safe": "^5.1.0", "make-promises-safe": "^5.1.0",
"marked": "^1.1.0", "marked": "^0.8.0",
"mysql2": "^2.1.0", "mysql2": "^2.1.0",
"node-fetch": "^2.6.0", "node-fetch": "^2.6.0",
"nodemailer": "^6.4.2", "nodemailer": "^6.4.2",
"parcel-bundler": "^1.12.4", "parcel-bundler": "^1.12.4",
"parcel-plugin-goodie-bag": "^2.0.0", "parcel-plugin-goodie-bag": "^2.0.0",
"pg": "^8.2.1", "pg": "^7.18.1",
"pg-hstore": "^2.3.3", "pg-hstore": "^2.3.3",
"picnic": "^6.5.2", "picnic": "^6.5.2",
"sass": "^1.25.0", "sass": "^1.25.0",
"sequelize": "^5.21.3", "sequelize": "^5.21.3",
"sharp": "^0.25.4", "sharp": "^0.24.0",
"sqlite3": "^4.2.0" "sqlite": "^3.0.3"
} }
} }

View File

@ -76,8 +76,7 @@ class SearchController {
let extraReferences = []; let extraReferences = [];
if (urisToCheck.length > 0) { if (urisToCheck.length > 0) {
// Need to figure this out extraReferences = await this.searchReferencesBySourceCodes(source, urisToCheck);
// extraReferences = await this.searchReferencesBySourceCodes(source, urisToCheck);
} }
return [ return [
...bookReferences, ...bookReferences,

View File

@ -26,13 +26,11 @@ const fastifyNodemailer = (fastify, options, next) => {
try { try {
transporter = createTransport(options); transporter = createTransport(options);
} catch (err) { } catch (err) {
fastify.decorate('canEmail', false);
return next(err); return next(err);
} }
fastify fastify
.decorate('nodemailer', transporter) .decorate('nodemailer', transporter)
.decorate('canEmail', true)
.addHook('onClose', close); .addHook('onClose', close);
next(); next();

View File

@ -21,14 +21,13 @@ const fp = require('fastify-plugin');
const Sequelize = require('sequelize'); const Sequelize = require('sequelize');
function plugin (fastify, options) { function plugin (fastify, options) {
const { config, registerModels } = options; const instance = options.instance || 'sequelize';
const instance = config.instance || 'sequelize'; const autoConnect = options.autoConnect || true;
const autoConnect = config.autoConnect || true;
delete config.instance; delete options.instance;
delete config.autoConnect; delete options.autoConnect;
const sequelize = new Sequelize(config); const sequelize = new Sequelize(options);
if (autoConnect) { if (autoConnect) {
return sequelize.authenticate().then(decorate); return sequelize.authenticate().then(decorate);
@ -40,7 +39,6 @@ function plugin (fastify, options) {
function decorate () { function decorate () {
fastify.decorate(instance, sequelize); fastify.decorate(instance, sequelize);
fastify.decorate('models', registerModels(sequelize));
fastify.addHook('onClose', (fastifyInstance, done) => { fastify.addHook('onClose', (fastifyInstance, done) => {
sequelize.close() sequelize.close()
.then(done) .then(done)

View File

@ -72,14 +72,11 @@
"author": "Author" "author": "Author"
}, },
"loading": "Loading...", "loading": "Loading...",
"no_reviews": "No Reviews yet",
"click_for_details": "Show Book Details",
"no_results": "None Found", "no_results": "None Found",
"no_results_suggestion": "If you're expecting book data, go and help fill out the Inventaire database!", "no_results_suggestion": "If you're expecting book data, go and help fill out the Inventaire database!",
"people_header": "People", "people_header": "People",
"series_header": "Series", "series_header": "Series",
"books_header": "Books", "books_header": "Books",
"covers": "Covers",
"see_interaction_details": "See All Interactions", "see_interaction_details": "See All Interactions",
"see_book_details": "See Book Details" "see_book_details": "See Book Details"
}, },

View File

@ -45,14 +45,10 @@ switch (fastify.siteConfig.db_engine) {
sequelizeConfig.password = fastify.siteConfig.db_password; sequelizeConfig.password = fastify.siteConfig.db_password;
} }
} }
fastify.register(require('./fastify-plugins/fastify-sequelize'), { fastify.register(require('./fastify-plugins/fastify-sequelize'), sequelizeConfig);
config: sequelizeConfig,
registerModels: require('./sequelize/models'),
});
if (!fastify.siteConfig.email_host || !fastify.siteConfig.email_username) { if (!fastify.siteConfig.email_host || !fastify.siteConfig.email_username) {
console.warn('###\nNo email server set up. You will not be able to send emails without entering your email configuration.\n###'); console.warn('###\nNo email server set up. You will not be able to send emails without entering your email configuration.\n###');
fastify.decorate('canEmail', false);
} else { } else {
fastify.register(require('./fastify-plugins/fastify-nodemailer'), { fastify.register(require('./fastify-plugins/fastify-nodemailer'), {
pool: true, pool: true,
@ -107,4 +103,7 @@ fastify.listen(fastify.siteConfig.port, function (err, address) {
fastify.log.error(err); fastify.log.error(err);
process.exit(1); process.exit(1);
} }
fastify.decorate('canEmail', typeof fastify.nodemailer !== 'undefined');
fastify.decorate('models', require('./sequelize/models')(fastify.sequelize));
}); });

876
yarn.lock

File diff suppressed because it is too large Load Diff