feat:location support
This commit is contained in:
@@ -34,6 +34,8 @@ desc { desc = desc "\\n" $0; next; }
|
|||||||
if (!to)
|
if (!to)
|
||||||
exit 1
|
exit 1
|
||||||
getline
|
getline
|
||||||
|
location = substr($0, 1, 2) == "@ " ? substr($0, 3) : ""
|
||||||
|
if (location) getline
|
||||||
summary = substr($0, 1, 2) == "# " ? substr($0, 3) : ""
|
summary = substr($0, 1, 2) == "# " ? substr($0, 3) : ""
|
||||||
if (!summary)
|
if (!summary)
|
||||||
exit 1
|
exit 1
|
||||||
@@ -83,6 +85,7 @@ END {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
escape(summary);
|
escape(summary);
|
||||||
|
escape(location);
|
||||||
escape(desc);
|
escape(desc);
|
||||||
|
|
||||||
# print ical
|
# print ical
|
||||||
@@ -102,6 +105,7 @@ END {
|
|||||||
print "DTEND;VALUE=" to_type ":" to
|
print "DTEND;VALUE=" to_type ":" to
|
||||||
if (summary) print_fold("SUMMARY:", summary, i, s);
|
if (summary) print_fold("SUMMARY:", summary, i, s);
|
||||||
if (desc) print_fold("DESCRIPTION:", desc, i, s);
|
if (desc) print_fold("DESCRIPTION:", desc, i, s);
|
||||||
|
if (location) print_fold("LOCATION:", location, i, s);
|
||||||
print "END:VEVENT"
|
print "END:VEVENT"
|
||||||
print "END:VCALENDAR"
|
print "END:VCALENDAR"
|
||||||
}
|
}
|
||||||
|
@@ -72,6 +72,7 @@ ENDFILE {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
escape(summary);
|
escape(summary);
|
||||||
|
escape(location);
|
||||||
escape(desc);
|
escape(desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,6 +87,8 @@ NR == FNR {
|
|||||||
if (!to)
|
if (!to)
|
||||||
exit 1
|
exit 1
|
||||||
getline
|
getline
|
||||||
|
location = substr($0, 1, 2) == "@ " ? substr($0, 3) : ""
|
||||||
|
if (location) getline
|
||||||
summary = substr($0, 1, 2) == "# " ? substr($0, 3) : ""
|
summary = substr($0, 1, 2) == "# " ? substr($0, 3) : ""
|
||||||
if (!summary)
|
if (!summary)
|
||||||
exit 1
|
exit 1
|
||||||
@@ -98,7 +101,7 @@ NR == FNR {
|
|||||||
/^BEGIN:VEVENT$/ { inside = 1; print; next }
|
/^BEGIN:VEVENT$/ { inside = 1; print; next }
|
||||||
/^X-ALT-DESC/ && inside { next } # drop this alternative description
|
/^X-ALT-DESC/ && inside { next } # drop this alternative description
|
||||||
/^ / && inside { next } # drop this folded line (the only content with folded lines will be updated)
|
/^ / && inside { next } # drop this folded line (the only content with folded lines will be updated)
|
||||||
/^(DTSTART|DTEND|SUMMARY|CATEGORIES|DESCRIPTION|LAST-MODIFIED)/ && inside { next } # skip for now, we will write updated fields at the end
|
/^(DTSTART|DTEND|SUMMARY|LOCATION|CATEGORIES|DESCRIPTION|LAST-MODIFIED)/ && inside { next } # skip for now, we will write updated fields at the end
|
||||||
/^SEQUENCE/ && inside { seq = $2; next } # store sequence number and skip
|
/^SEQUENCE/ && inside { seq = $2; next } # store sequence number and skip
|
||||||
/^END:VEVENT$/ {
|
/^END:VEVENT$/ {
|
||||||
seq = seq ? seq + 1 : 1
|
seq = seq ? seq + 1 : 1
|
||||||
@@ -108,6 +111,7 @@ NR == FNR {
|
|||||||
print "DTEND;VALUE=" to_type ":" to
|
print "DTEND;VALUE=" to_type ":" to
|
||||||
print_fold("SUMMARY:", summary, i, s)
|
print_fold("SUMMARY:", summary, i, s)
|
||||||
print_fold("DESCRIPTION:", desc, i, s)
|
print_fold("DESCRIPTION:", desc, i, s)
|
||||||
|
print_fold("LOCATION:", location, i, s)
|
||||||
inside = ""
|
inside = ""
|
||||||
}
|
}
|
||||||
{ print }
|
{ print }
|
||||||
|
17
src/main.sh
17
src/main.sh
@@ -280,16 +280,22 @@ __edit() {
|
|||||||
start=$(__canonical_datetime_hm "$1")
|
start=$(__canonical_datetime_hm "$1")
|
||||||
end=$(__canonical_datetime_hm "$2")
|
end=$(__canonical_datetime_hm "$2")
|
||||||
fpath="$3"
|
fpath="$3"
|
||||||
|
location=$(awk -v field="LOCATION" "$AWK_GET" "$fpath")
|
||||||
summary=$(awk -v field="SUMMARY" "$AWK_GET" "$fpath")
|
summary=$(awk -v field="SUMMARY" "$AWK_GET" "$fpath")
|
||||||
description=$(awk -v field="DESCRIPTION" "$AWK_GET" "$fpath")
|
description=$(awk -v field="DESCRIPTION" "$AWK_GET" "$fpath")
|
||||||
filetmp=$(mktemp --suffix='.md')
|
filetmp=$(mktemp --suffix='.md')
|
||||||
(
|
(
|
||||||
echo "::: |> $start"
|
echo "::: |> $start"
|
||||||
echo "::: <| $end"
|
echo "::: <| $end"
|
||||||
|
) >"$filetmp"
|
||||||
|
if [ -n "$location" ]; then
|
||||||
|
echo "@ $location" >>"$filetmp"
|
||||||
|
fi
|
||||||
|
(
|
||||||
echo "# $summary"
|
echo "# $summary"
|
||||||
echo ""
|
echo ""
|
||||||
echo "$description"
|
echo "$description"
|
||||||
) >"$filetmp"
|
) >>"$filetmp"
|
||||||
checksum=$(cksum "$filetmp")
|
checksum=$(cksum "$filetmp")
|
||||||
$EDITOR "$filetmp" >/dev/tty
|
$EDITOR "$filetmp" >/dev/tty
|
||||||
|
|
||||||
@@ -374,6 +380,7 @@ if [ "${1:-}" = "--new" ]; then
|
|||||||
(
|
(
|
||||||
echo "::: |> $start"
|
echo "::: |> $start"
|
||||||
echo "::: <| $end"
|
echo "::: <| $end"
|
||||||
|
echo "@ <!-- write location here, optional line -->"
|
||||||
echo "# <!-- write summary here -->"
|
echo "# <!-- write summary here -->"
|
||||||
echo ""
|
echo ""
|
||||||
) >"$filetmp"
|
) >"$filetmp"
|
||||||
@@ -452,6 +459,7 @@ if [ "${1:-}" = "--day" ]; then
|
|||||||
elif [ -z "$key" ] && [ -n "$fpath" ]; then
|
elif [ -z "$key" ] && [ -n "$fpath" ]; then
|
||||||
fpath="$ROOT/$fpath"
|
fpath="$ROOT/$fpath"
|
||||||
__edit "$start" "$end" "$fpath"
|
__edit "$start" "$end" "$fpath"
|
||||||
|
exec $0 --day "$DISPLAY_DATE"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -468,8 +476,11 @@ if [ "${1:-}" = "--preview" ]; then
|
|||||||
fpath="$ROOT/$fpath"
|
fpath="$ROOT/$fpath"
|
||||||
start=$(__canonical_datetime "$start" "%a ")
|
start=$(__canonical_datetime "$start" "%a ")
|
||||||
end=$(__canonical_datetime "$end" "%a ")
|
end=$(__canonical_datetime "$end" "%a ")
|
||||||
echo "${GREEN}From: ${OFF}${CYAN}$start${OFF}"
|
location=$(awk -v field="LOCATION" "$AWK_GET" "$fpath")
|
||||||
echo "${GREEN}To: ${OFF}${CYAN}$end${OFF}"
|
echo "📅 ${CYAN}$start${OFF} -> ${CYAN}$end${OFF}"
|
||||||
|
if [ -n "${location:-}" ]; then
|
||||||
|
echo "📍 ${CYAN}$location${OFF}"
|
||||||
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
awk -v field="DESCRIPTION" "$AWK_GET" "$fpath" | $CAT
|
awk -v field="DESCRIPTION" "$AWK_GET" "$fpath" | $CAT
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user