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) => {