11const express = require ( 'express' ) ;
22
3- const marked = require ( 'marked' ) ;
4-
53const qr = require ( 'qr-image' ) ;
64
7- const { loadDatabase, searchDatabase } = require ( './googleSpreadsheet' ) ;
5+ const {
6+ loadDatabase,
7+ searchDatabase,
8+ addMarkdown,
9+ addSimilarItems,
10+ } = require ( './googleSpreadsheet' ) ;
811
912const app = express ( ) ;
1013
@@ -24,16 +27,6 @@ function logScanned(uuid, fixture) {
2427 allScans . unshift ( { time : now , fixture, uuid } ) ;
2528}
2629
27- function modifyContent ( obj , allObj ) {
28- obj . HOWTO = marked ( obj . HOWTO ) ;
29- obj . details = marked ( obj . details ) ;
30- obj . Troubleshooting = marked ( obj . Troubleshooting ) ;
31- obj . similarItems = searchDatabase ( { fixture : obj . fixture } , allObj )
32- . filter ( item => item . uuid !== obj . uuid )
33- . splice ( 0 , 3 ) ;
34- return obj ;
35- }
36-
3730app . set ( 'view engine' , 'ejs' ) ;
3831
3932app . use ( express . static ( `${ __dirname } /public` ) ) ;
@@ -68,6 +61,7 @@ app.get('/recent', (req, res) => {
6861
6962app . get ( '/:uuid' , ( req , res ) => {
7063 loadDatabase ( ( allItems ) => {
64+ addMarkdown ( allItems ) ;
7165 const matches = searchDatabase ( req . params , allItems ) ;
7266 if ( matches . length === 0 ) {
7367 logScanned ( req . params . uuid ) ;
@@ -77,8 +71,10 @@ app.get('/:uuid', (req, res) => {
7771 } ) ;
7872 return ;
7973 }
74+ addSimilarItems ( matches [ 0 ] , allItems ) ;
8075 logScanned ( req . params . uuid , matches [ 0 ] . fixture ) ;
81- res . render ( 'item' , modifyContent ( matches [ 0 ] , allItems ) ) ;
76+ // modifyContent(matches[0], allItems
77+ res . render ( 'item' , matches [ 0 ] ) ;
8278 } ) ;
8379} ) ;
8480
0 commit comments