From 6eff6e7e773eb6e1238017e5b2a2973392945c46 Mon Sep 17 00:00:00 2001 From: Fredrik Wahlberg Date: Thu, 23 Jan 2025 19:31:06 +0100 Subject: [PATCH] =?UTF-8?q?L=C3=A4gger=20till=20loggning=20av=20todos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 2 +- server.js | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/public/index.html b/public/index.html index 822d63b..d291790 100644 --- a/public/index.html +++ b/public/index.html @@ -3,7 +3,7 @@ - Task Input App + Fredriks todos diff --git a/server.js b/server.js index 435cb7b..5483cca 100644 --- a/server.js +++ b/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) => {