Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWillner committed Jun 8, 2019
2 parents c0f9370 + 46f6485 commit e21a5ae
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/csv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ getCSVQueryChecklists() {
SELECT
T2.title,
T2.type,
'thingstodo://show?uuid='||T2.uuid,
'things:///show?id='||T2.uuid,
date(T1.creationDate,"unixepoch"),
date(T1.userModificationDate,"unixepoch"),
"",
Expand Down
47 changes: 47 additions & 0 deletions plugins/ical.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

myPluginID="$(getNextPluginID)"
myPlugin="plugin$myPluginID"
myPluginCommand='ical'
myPluginDescription="Shows $LIMIT_BY tasks ordered by due date as iCal"
myPluginMethod='queryIcal'

eval "$myPlugin=('$myPluginCommand' '$myPluginDescription' '$myPluginMethod')"

queryIcal() {
IFS=$'\n'
echo "BEGIN:VCALENDAR"
echo "VERSION:2.0"
for a in $(sqlite3 "$THINGSDB" "$(getIcalQuery)"| awk '{gsub("<[^>]*>", "")}1' | iconv -c -f UTF-8 -t "${ENCODING:-WINDOWS-1252//TRANSLIT}" || true); do
echo "BEGIN:VEVENT"
IFS='|' read -ra ADDR <<< "$a"
duedate="${ADDR[0]}"
title="${ADDR[1]:-}"
url="${ADDR[2]:-}"
notes="${ADDR[3]:-}"
echo "DTSTART;VALUE=DATE:${duedate//-}"
echo "SUMMARY:$title"
echo "DESCRIPTION:$notes - $url"
echo "END:VEVENT"
done
echo "END:VCALENDAR"
}

getIcalQuery() {
read -rd '' query <<-SQL || true
SELECT
date(TASK.dueDate,"unixepoch"),
"" || TASK.title,
"things:///show?id=" || TASK.uuid,
"" || REPLACE(REPLACE(TASK.notes, CHAR(13), ', '), CHAR(10), ', ')
FROM $TASKTABLE as TASK
LEFT OUTER JOIN $TASKTABLE PROJECT ON TASK.project = PROJECT.uuid
LEFT OUTER JOIN $AREATABLE AREA ON TASK.area = AREA.uuid
LEFT OUTER JOIN $TASKTABLE HEADING ON TASK.actionGroup = HEADING.uuid
WHERE TASK.$ISNOTTRASHED AND TASK.$ISOPEN
AND TASK.dueDate NOT NULL
ORDER BY TASK.dueDate
LIMIT $LIMIT_BY
SQL
echo "$query"
}

0 comments on commit e21a5ae

Please sign in to comment.