mirror of
https://github.com/Matewoo/pdf-writer.git
synced 2026-11-18 18:42:50 +01:00
add new feed page
feed page shows all dishes as a menu page for digital signage
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
/node_modules
|
||||
*.ttf
|
||||
/backend/node_modules
|
||||
|
||||
@@ -65,6 +65,10 @@ app.get('/edit/dailyDish', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../frontend/public/edit', 'dailyDish.html'));
|
||||
});
|
||||
|
||||
app.get('/feed', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../frontend/public', 'feed.html'));
|
||||
});
|
||||
|
||||
app.post('/save-week', (req, res) => {
|
||||
const { week, entries } = req.body;
|
||||
|
||||
@@ -157,6 +161,38 @@ app.get('/load-week-daily', (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/load-day-menu', (req, res) => {
|
||||
const { date } = req.query;
|
||||
|
||||
try {
|
||||
const entry = db.prepare('SELECT * FROM menu_entries WHERE date = ?').get(date);
|
||||
if (entry) {
|
||||
res.json(entry);
|
||||
} else {
|
||||
res.status(404).json({ error: 'No menu entry found for the given date' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading menu:', error);
|
||||
res.status(500).json({ error: 'Fehler beim Laden des Menüs' });
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/load-day-daily', (req, res) => {
|
||||
const { date } = req.query;
|
||||
|
||||
try {
|
||||
const entry = db.prepare('SELECT * FROM daily_entries WHERE date = ?').get(date);
|
||||
if (entry) {
|
||||
res.json(entry);
|
||||
} else {
|
||||
res.status(404).json({ error: 'No daily entry found for the given date' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading daily:', error);
|
||||
res.status(500).json({ error: 'Fehler beim Laden des Tagesgerichts' });
|
||||
}
|
||||
});
|
||||
|
||||
const { exec } = require('child_process');
|
||||
|
||||
app.post('/generate-pdf', (req, res) => {
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>dailyFeed</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Fira Sans', sans-serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #a81411;
|
||||
font-size: 80px;
|
||||
font-weight: 300;
|
||||
font-style: italic;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
h2 {
|
||||
color: #a81411;
|
||||
font-weight: bold;
|
||||
margin-bottom: 0;
|
||||
font-size: 25px;
|
||||
}
|
||||
|
||||
.category {
|
||||
color: rgb(72, 163, 238);
|
||||
font-weight: 600;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
font-size: 23px;
|
||||
}
|
||||
|
||||
.veggie {
|
||||
color: rgb(10, 194, 87);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.halal {
|
||||
color: rgb(10, 194, 87);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.main {
|
||||
font-weight: 600;
|
||||
margin-top: 5px;
|
||||
margin-bottom: 0;
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
.side {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
.price {
|
||||
font-style: italic;
|
||||
font-size: 20px;
|
||||
margin-top: 5px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
hr {
|
||||
border: 0;
|
||||
border-top: 0.5px solid #ffffff;
|
||||
width: 80%;
|
||||
margin-left: 0;
|
||||
margin-top: 4px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Was gibt's heute?</h1>
|
||||
<h2></h2>
|
||||
<hr>
|
||||
|
||||
|
||||
<script>
|
||||
setInterval(() => {
|
||||
window.location.reload();
|
||||
}, 15000);
|
||||
|
||||
</script>
|
||||
|
||||
<script src="src/feed.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,76 @@
|
||||
function loadDay(day) {
|
||||
Promise.all([
|
||||
fetch(`/load-day-menu?date=${encodeURIComponent(day)}`).then(response => response.json()),
|
||||
fetch(`/load-day-daily?date=${encodeURIComponent(day)}`).then(response => response.json())
|
||||
])
|
||||
.then(([menuData, dailyData]) => {
|
||||
if (menuData.error) {
|
||||
console.error('Error loading menu:', menuData.error);
|
||||
return;
|
||||
}
|
||||
if (dailyData.error) {
|
||||
console.error('Error loading daily:', dailyData.error);
|
||||
return;
|
||||
}
|
||||
|
||||
document.querySelector('h2').textContent = menuData.date_title.toUpperCase();
|
||||
|
||||
const categories = {
|
||||
meat: {
|
||||
category: 'Fleisch und Meer',
|
||||
main: menuData.meat_main,
|
||||
side: menuData.meat_side,
|
||||
price: menuData.meat_price,
|
||||
halal: menuData.halal ? '„HALAL“' : ''
|
||||
},
|
||||
veggi: {
|
||||
category: 'Frisch und lecker',
|
||||
main: menuData.veggi_main,
|
||||
side: menuData.veggi_side,
|
||||
price: menuData.veggi_price,
|
||||
veggi: '„veggi“'
|
||||
},
|
||||
daily: {
|
||||
category: 'Tagesempfehlung',
|
||||
main: dailyData.daily_main,
|
||||
side: dailyData.daily_side,
|
||||
price: dailyData.daily_price,
|
||||
special: dailyData.halal ? '„HALAL“' : (dailyData.veggi ? '„veggi“' : '')
|
||||
}
|
||||
};
|
||||
|
||||
const container = document.querySelector('body');
|
||||
container.innerHTML = `
|
||||
<h1>Was gibt's heute?</h1>
|
||||
<h2>${menuData.date_title.toUpperCase()}</h2>
|
||||
<hr>
|
||||
${Object.values(categories).map(item => `
|
||||
<p class="category">— ${item.category} <span class="halal">${item.halal || item.veggi || item.special || ''}</span></p>
|
||||
<p class="main">${item.main}</p>
|
||||
<p class="side">${item.side}</p>
|
||||
<p class="price">${item.price}</p>
|
||||
<hr>
|
||||
`).join('')}
|
||||
<p class="category">— Tagessuppe</p>
|
||||
<p class="main">Kürbiscremesuppe</p>
|
||||
<p class="price"><i>Großer Teller 4,00 € / Kleiner Teller 2,00 €</i></p>
|
||||
<hr>
|
||||
|
||||
<p class="category">— Frisch und knackig</p>
|
||||
<p class="main">Tagessalat</p>
|
||||
<p class="side">mit verschiedenen Toppings und Baguette</p>
|
||||
<p class="price">7,00 € / 4,90 €</p>
|
||||
|
||||
<p class="main">Salatbuffet</p>
|
||||
<p class="side">mit verschiedenen Dressings</p>
|
||||
<p class="price">Mittlerer Teller 3,50 € / Kleiner Teller 2,50 €</p>
|
||||
`;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error loading day:', error);
|
||||
});
|
||||
}
|
||||
|
||||
// Load today's menu on page load
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
loadDay(today);
|
||||
Reference in New Issue
Block a user