Database-ready

This commit is contained in:
Gerrit Linnemann 2019-03-11 19:29:51 +01:00
parent 30d647fd86
commit b02a8894ca
9 changed files with 54 additions and 25 deletions

View File

@ -36,3 +36,23 @@ exports.init = function(express) {
return this;
}
exports.getItem = function(identifier, callback) {
const sql = `SELECT * FROM items WHERE identifier = '${identifier}'`
pool.query(sql, function (error, results, fields) {
if (error) throw error;
callback(results[0])
});
}
exports.getItemList = function(callback) {
const sql = `SELECT * FROM items i ORDER BY i.order ASC`
pool.query(sql, function (error, results, fields) {
if (error) throw error;
callback(results)
});
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

File diff suppressed because one or more lines are too long

View File

@ -30,16 +30,16 @@ a {
display: block;
position: absolute;
left: 5px;
top: 3px;
line-height: 0.8em;
top: 5px;
line-height: 1.2em;
font-size: 1.8em;
font-weight: bold;
text-align: center;
background-color: fade(@color_white, 10%);
border: 1px solid @color_grey;
border-radius: 3px;
width: 1.0em;
height: 1.0em;
width: 1.5em;
height: 1.5em;
z-index: 2;
}
}
@ -88,10 +88,6 @@ a {
.item {
display: block;
position: relative;
min-height: 250px;
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
&:hover {
text-decoration: none;
@ -106,6 +102,11 @@ a {
}
}
.preview {
height: auto;
width: 100%;
}
title {
display: block;
position: relative;
@ -139,7 +140,7 @@ a {
height: 100%;
#stage {
height: 30%;
height: auto;
border-bottom: 1px solid @color_orange;
margin-bottom: 10px;
}

View File

@ -3,11 +3,23 @@ var router = express.Router();
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Rent For Camp' });
var app = req.app
var db = app.get('DB')
db.getItemList((items)=>{
res.render('index', { title: 'Rent For Camp', items: items })
})
});
router.get('/article/show/:identifier', function(req, res, next) {
res.render('detail', { title: 'Anhänger Stema Retro' });
var app = req.app
var db = app.get('DB')
const identifier = req.params.identifier
db.getItem(identifier, (item)=>{
res.render('detail', { title: item.title, item: item })
})
});
module.exports = router;

View File

@ -3,10 +3,10 @@ extends layout
block content
#itemPage
a#back(href="/") «
#stage(style="background-image: url('https://i.ebayimg.com/00/s/NzY1WDEwMjQ=/z/mMEAAOSwB9dama23/$_72.JPG')")
img#stage(src=item.previewfile)
section#details
p Familienurlaub, Camping oder Wochenendausflug - erweitere deinen Stauraum um weitere 147 x 107cm.
p #{item.intro}
ul
li Gesamtgewicht: 750kg
li Nutzlast: 580kg
@ -14,4 +14,4 @@ block content
li Radgröße: 10"
li Ungebremst
p.price
span.value nur 20€ / Tag
span.value #{item.price}

View File

@ -6,12 +6,8 @@ block content
a.startLink(href="#", onclick="document.getElementById('items').scrollIntoView(); return false;") Jetzt stöbern
section#items
a.item(href="#", style="background-image: url('https://i.ebayimg.com/00/s/NzY1WDEwMjQ=/z/mMEAAOSwB9dama23/$_72.JPG')")
title Anhänger
intro Ich bin eine Beschreibung.
a.item(href="#", style="background-image: url('https://i.pinimg.com/originals/40/e7/7f/40e77f882031dc270a1010fd373a19d5.jpg')")
title Diesel-Heizung
intro Ich bin eine Beschreibung.
a.item(href="#", style="background-image: url('https://tenturi.com/91/reifentritt.jpg')")
title Reifen-Tritthilfe
intro Ich bin eine Beschreibung.
each val, index in items
a.item(href='/article/show/' + val.identifier)
img.preview(src=val.previewfile)
title #{val.title}
intro #{val.intro}