@@ -24,6 +24,16 @@ function logScanned(uuid, fixture) {
2424 allScans . unshift ( { time : now , fixture, uuid } ) ;
2525}
2626
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+
2737app . set ( 'view engine' , 'ejs' ) ;
2838
2939app . use ( express . static ( `${ __dirname } /public` ) ) ;
@@ -68,13 +78,7 @@ app.get('/:uuid', (req, res) => {
6878 return ;
6979 }
7080 logScanned ( req . params . uuid , matches [ 0 ] . fixture ) ;
71- matches [ 0 ] . HOWTO = marked ( matches [ 0 ] . HOWTO ) ;
72- matches [ 0 ] . details = marked ( matches [ 0 ] . details ) ;
73- matches [ 0 ] . Troubleshooting = marked ( matches [ 0 ] . Troubleshooting ) ;
74- matches [ 0 ] . similarItems = searchDatabase ( { fixture : matches [ 0 ] . fixture } , allItems )
75- . filter ( item => item . uuid !== matches [ 0 ] . uuid )
76- . splice ( 0 , 3 ) ;
77- res . render ( 'item' , matches [ 0 ] ) ;
81+ res . render ( 'item' , modifyContent ( matches [ 0 ] , allItems ) ) ;
7882 } ) ;
7983} ) ;
8084
0 commit comments