update man pages and generate project frontpage - ics2txt - convert icalendar .ics file to plain text HTML git clone git://bitreich.org/ics2txt git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/ics2txt DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit cf5ca595cdbe8c8d7d3358e58a43452cc222d7c2 DIR parent 24ae7d2759496b7907cce29f0c26697950453ff5 HTML Author: Josuah Demangeon <me@josuah.net> Date: Sun, 20 Jun 2021 19:50:06 +0200 update man pages and generate project frontpage Diffstat: M .gitignore | 2 ++ A .site/head.gph | 5 +++++ A .site/head.html | 24 ++++++++++++++++++++++++ A .site/style.css | 39 +++++++++++++++++++++++++++++++ M Makefile | 11 ++++++++--- R README -> README.md | 0 M ics2tsv.1 | 10 +--------- D ics2txt.1 | 106 ------------------------------ A tsv2agenda.1 | 76 +++++++++++++++++++++++++++++++ M tsv2agenda.c | 9 ++++++--- A tsv2ics.1 | 53 ++++++++++++++++++++++++++++++ 11 files changed, 214 insertions(+), 121 deletions(-) --- DIR diff --git a/.gitignore b/.gitignore @@ -4,3 +4,5 @@ /tsv2ics /tsv2agenda /ics2txt-[0-9]* +/style.css +/index.* DIR diff --git a/.site/head.gph b/.site/head.gph @@ -0,0 +1,5 @@ +ics2txt +──────────────────────────────────────────────────────────────────────────────── +[9|release v0.1|/ics2txt/ics2txt-VERSION.tar.gz|server|port] +[h|git clone git://code.z0.is/ics2txt/|URL:git://code.z0.is/ics2txt/||] +[h|web version|URL:http://code.z0.is/ics2txt/||] DIR diff --git a/.site/head.html b/.site/head.html @@ -0,0 +1,24 @@ +<!DOCTYPE html> +<title>ics2txt</title> +<meta charset="UTF-8"/> +<meta name="viewport" content="initial-scale=1.0"> + +<style> +body { padding:5em 5ch; font-family:sans; max-width:550pt; margin:auto; line-height:1.4em; } +a { text-decoration:none; } +h1 { line-height: 3em; } +h2,h3,h4,h5,h6 { line-height:2em; } +pre,code { background: #f6f6f6; } +pre { padding:1em 2ch; line-height:1.1em; overflow:auto; } +blockquote { padding-left:1.4ch; margin-left:1ch; border-left:solid 1px grey; } +img { max-width:100%; } +</style> + +<header> +<a href="//josuah.net/">josuah.net</a> +<nav style="float:right;"> +<a href="/ics2txt/ics2txt-VERSION.tar.gz">vVERSION</a> - +<a href="git://code.z0.is/ics2txt/">git</a> - +<a href="gopher://code.z0.is/1/ics2txt/">gopher</a> +</nav> +</header> DIR diff --git a/.site/style.css b/.site/style.css @@ -0,0 +1,39 @@ +body { + padding: 5em 5ch; + font-family: sans; + max-width: 550pt; + margin: auto; + line-height: 1.4em; +} + +a { + text-decoration: none; +} + +h1 { + line-height: 3em; +} + +h2,h3,h4,h5,h6 { + line-height: 2em; +} + +pre, code { + background: #f6f6f6; +} + +pre { + padding: 1em 2ch; + line-height: 1.1em; + overflow: auto; +} + +blockquote { + padding-left: 1.4ch; + margin-left: 1ch; + border-left: solid 1px grey; +} + +img { + max-width: 100%; +} DIR diff --git a/Makefile b/Makefile @@ -12,7 +12,7 @@ HDR = ical.h base64.h util.h OBJ = ${SRC:.c=.o} AWK = tsv2ics.awk BIN = ics2tree ics2tsv tsv2agenda -MAN1 = ics2txt.1 ics2tsv.1 +MAN1 = ics2tsv.1 tsv2ics.1 tsv2agenda.1 all: ${BIN} @@ -28,7 +28,7 @@ ${BIN}: ${OBJ} ${BIN:=.o} ${CC} ${LDFLAGS} -o $@ $@.o ${OBJ} clean: - rm -rf *.o ${BIN} ${AWK:.awk} ${NAME}-${VERSION} *.gz + rm -rf *.o ${BIN} ${AWK:.awk=} ${NAME}-${VERSION} *.gz install: ${BIN} ${AWK:.awk=} mkdir -p ${DESTDIR}$(PREFIX)/bin @@ -38,8 +38,13 @@ install: ${BIN} ${AWK:.awk=} dist: clean mkdir -p ${NAME}-${VERSION} - cp -r README Makefile ${AWK} ${MAN1} ${SRC} ${NAME}-${VERSION} + cp -r README.md Makefile ${AWK} ${MAN1} ${SRC} ${NAME}-${VERSION} tar -cf - ${NAME}-${VERSION} | gzip -c >${NAME}-${VERSION}.tar.gz +site: dist + notmarkdown README.md | notmarkdown-html | cat .site/head.html - >index.html + notmarkdown README.md | notmarkdown-gph | cat .site/head.gph - >index.gph + sed -i "s/VERSION/${VERSION}/g" index.* + .SUFFIXES: .awk .PHONY: ${AWK} DIR diff --git a/README b/README.md DIR diff --git a/ics2tsv.1 b/ics2tsv.1 @@ -118,15 +118,6 @@ Timezone to use for printing dates, as documented by . .Sh EXAMPLES . -Convert a calendar from HTTP -.Pa .ics -to custom -.Pa .txt -sorted by start date: -.Dl curl "$url.ics" | ics2tsv | sort -n -k 1,1 | tsv2tsv -. -.Pp -. .Pp Split an .ics @@ -142,6 +133,7 @@ ics2tsv -f CATEGORIES icalendar.ics | awk -F '\et' '{ print >>($6".tsv") }\' .Xr cal 1 , .Xr calendar 1 , .Xr date 1 , +.Xr tsv2agenda 1 , .Xr tzset 3 . . DIR diff --git a/ics2txt.1 b/ics2txt.1 @@ -1,106 +0,0 @@ -.Dd $Mdocdate: Mar 1 2020$ -.Dt ICS2TXT 1 -.Os -. -. -.Sh NAME -. -.Nm ics2txt -.Nd convert ics file to simpler tsv or txt formats -. -. -.Sh SYNOPSIS -. -.Nm ics2txt Ar <file.ics >file.txt -.Pp -.Nm ics2txt Ar <file.tsv >file.ics -.Nm ics2tsv Ar <file.ics >file.tsv -.Nm tsv2tcal Ar <file.tsv >file.txt -.Nm tcal2tsv Ar <file.txt >file.tsv -.Nm tsv2ics Ar <file.tsv >file.ics -. -.Sh DESCRIPTION -. -.Nm -is set of awk scripts to deal with iCal -.Pq Pa .ics -format to publish, display and convert *.ics files, though a simple -central TSV format. -. -.Pp -They all read from either stdin or the file passed as argument, and -write to stdout. -. -.Pp -.The -.Pa file.tsv -have one line per event, with the first line declaring fields order -and presence, among: -. -.Bl -tag -width xxxxx -offset 1n -compact -.It Dq beg -Begining of event (epoch) -.It Dq end -End of event (epoch) -.It Dq cat -Category -.It Dq loc -Location -.It Dq sum -Summary -.It Dq des -Description -.El -. -. -.Sh EXAMPLES -. -Convert a calendar from HTTP -.Pa .ics -to custom -.Pa .txt -sorted by start date: -.Dl curl "$url.ics" | ics2tsv | sort -n -k 1,1 | tsv2txt -. -.Pp -Convert a custom -.Pa .txt -format back to an -.Pa .ics -file and publish it: -.Dl tcal2tsv cal.txt | tsv2ics | ssh "www@$host" 'cat >/var/www/cal.ics' -. -.Pp -Split an -.ics -file according to the category, saved as -.Pa .tsv : -.Bd -literal -ics2tsv cal.txt | awk -F '\et' ' - NR == 1 { for (i = 1; i <= NF; i++) F[$i] = i; next } - { print >>($F["cat"]".tsv") } -\' -.Ed -. -. -.Sh SEE ALSO -. -.Xr cal 1 , -.Xr calendar 1 , -.Xr date 1 , -.Xr sort 1 -. -. -.Sh STANDARDS -. -.Rs -.%A Desruisseaux -.%D September 2009 -.%T Internet Calendaring and Scheduling Core Object Specification (iCalendar) -.%R RFC 5545 -.Re -. -. -.Sh AUTHORS -. -.An Josuah Demangeon Aq Mt me@josuah.net DIR diff --git a/tsv2agenda.1 b/tsv2agenda.1 @@ -0,0 +1,76 @@ +.Dd $Mdocdate: Mar 1 2020$ +.Dt TSV2AGENDA 1 +.Os +. +. +.Sh NAME +. +.Nm tsv2agenda +.Nd convert TSV input to a visual agenda roll +. +. +.Sh SYNOPSIS +. +.Nm tsv2agenda +.Op Fl f Ar fromdate +.Op Fl t Ar todate +. +.Sh DESCRIPTION +. +.Nm +is a converter that reads tsv format as produced by +.Xr ics2tsv 1 +and represents an aligned text agenda from it. +. +.Pp +Every column (after the 4th one) present on the input is displayed on +the output (if not empty). +. +.Bl -tag +. +.It Fl f Ar fromdate +Show only events starting from +.Ar fromdate . +By default the current time: showing all future events. +. +.It Fl t Ar todate +Show only events up to +.Ar todate . +By default show all future events. +. +.El +. +. +.Sh ENVIRONMENT VARIABLES +. +.Bl -tag +. +.It TZ +Timezone to use for printing dates, as documented by +.Xr tzset 3 . +. +.El +. +. +.Sh EXAMPLES +. +Show the events from a +.Pa icalendar.ics +file sorted by start date: +.Dl curl "$url.ics" | ics2tsv | sort -n -k 1,1 | tsv2agenda +. +.Pp +. +. +.Sh SEE ALSO +. +.Xr cal 1 , +.Xr calendar 1 , +.Xr ics2tsv 1 , +.Xr tsv2ics 1 , +.Xr tzset 3 +. +. +.Sh AUTHORS +. +.An Josuah Demangeon Aq Mt me@josuah.net DIR diff --git a/tsv2agenda.c b/tsv2agenda.c @@ -119,6 +119,8 @@ print(AgendaCtx *ctx, char **fields) return; localtime_r(&t, &end); + fputc('\n', stdout); + print_header1(&ctx->beg, &beg); print_row(ctx, fields, i++); print_header2(&beg, &end); @@ -142,7 +144,8 @@ tsv_to_agenda(AgendaCtx *ctx, FILE *fp) char *fields[FIELD_MAX]; ctx->linenum++; - if (getline(&ln1, &sz1, fp) < 0) + getline(&ln1, &sz1, fp); + if (ferror(fp)) err(1, "reading stdin: %s", strerror(errno)); if (feof(fp)) err(1, "empty input"); @@ -167,7 +170,8 @@ tsv_to_agenda(AgendaCtx *ctx, FILE *fp) char *fields[FIELD_MAX]; ctx->linenum++; - if (getline(&ln2, &sz2, fp) < 0) + getline(&ln2, &sz2, fp); + if (ferror(fp)) err(1, "reading stdin: %s", strerror(errno)); if (feof(fp)) break; @@ -177,7 +181,6 @@ tsv_to_agenda(AgendaCtx *ctx, FILE *fp) err(1, "line %zd: bad number of columns", ctx->linenum, strerror(errno)); - fputc('\n', stdout); print(ctx, fields); } fputc('\n', stdout); DIR diff --git a/tsv2ics.1 b/tsv2ics.1 @@ -0,0 +1,53 @@ +.Dd $Mdocdate: Mar 1 2020$ +.Dt TSV2ICS 1 +.Os +. +. +.Sh NAME +. +.Nm tsv2ics +.Nd convert ics file to simpler tsv or txt formats +. +. +.Sh SYNOPSIS +. +.Nm tsv2ics Ar <file.ics >file.txt +. +.Sh DESCRIPTION +. +.Nm +convert a tab-separated value input as produced by +.Xr ics2tsv 1 +and produce iCalendar formatted output. +The dates are formatted in UTC timestamps. +. +. +.Sh EXAMPLES +. +Only keep the dates and +.Dq SUMMARY +from an iCalendar: +.Dl ics2tsv -f SUMMARY icalendar.ics | tsv2ics +. +. +.Sh SEE ALSO +. +.Xr cal 1 , +.Xr calendar 1 , +.Xr ics2tsv 1 , +.Xr tsv2agenda 1 +. +. +.Sh STANDARDS +. +.Rs +.%A Desruisseaux +.%D September 2009 +.%T Internet Calendaring and Scheduling Core Object Specification (iCalendar) +.%R RFC 5545 +.Re +. +. +.Sh AUTHORS +. +.An Josuah Demangeon Aq Mt me@josuah.net