Skip to content

Commit 3726327

Browse files
author
Doug Wright
committed
FIX: broken div in template, REFACTOR: obj editing in app.get for item page
1 parent 458013b commit 3726327

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

app.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
2737
app.set('view engine', 'ejs');
2838

2939
app.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

views/partials/itemImgInfo.ejs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
<a href="/<%- similarItems[i].uuid %>"> <img class="miniItemImg" src=" <%- similarItems[i].picture %> " /> </a>
2929
<%} %>
3030
<% } %>
31-
</d
32-
iv>
31+
</div>
3332
<% } %>
3433
</article>
3534
<%}%>

0 commit comments

Comments
 (0)