Lägger till loggning av todos
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Task Input App</title>
|
||||
<title>Fredriks todos</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<!-- Flatpickr for dates -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
|
||||
|
||||
18
server.js
18
server.js
@@ -12,12 +12,26 @@ app.use(express.static('public'));
|
||||
// Endpoint to receive task data and append to file
|
||||
app.post('/add-task', (req, res) => {
|
||||
const { subject, description, scheduled } = req.body;
|
||||
const currentDateTime = new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '');
|
||||
|
||||
const orgFormattedData = `
|
||||
let orgFormattedData = `
|
||||
* TODO ${subject}
|
||||
SCHEDULED: <${scheduled}>
|
||||
:LOGBOOK:
|
||||
- State "TODO" from [${currentDateTime}]
|
||||
:END:
|
||||
`;
|
||||
|
||||
if (description) {
|
||||
orgFormattedData = `
|
||||
* TODO ${subject}
|
||||
${description}
|
||||
SCHEDULED: <${scheduled}>
|
||||
`;
|
||||
:LOGBOOK:
|
||||
- State "TODO" from [${currentDateTime}]
|
||||
:END:
|
||||
`;
|
||||
}
|
||||
|
||||
const filePath = path.join(__dirname, 'tasks.org');
|
||||
fs.appendFile(filePath, orgFormattedData, (err) => {
|
||||
|
||||
Reference in New Issue
Block a user