diff --git a/Makefile b/Makefile index 6185372..c3e29c2 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,9 @@ SUNDOWN_SRC=$(wildcard sundown/*.c) OBJ=dpi.o zet.dpi.o io.o $(SUNDOWN_SRC:c=o) CFLAGS=-Wall -Wextra -pedantic +all-reload: all + pkill $(BIN) + all: $(BIN) $(BIN): $(OBJ) diff --git a/zet.dpi.c b/zet.dpi.c index f91d842..6736960 100644 --- a/zet.dpi.c +++ b/zet.dpi.c @@ -22,14 +22,6 @@ #include "sundown/buffer.h" #include "sundown/houdini.h" -#define NAV_ALL "All" -#define NAV_NEW "New" -#define STRONG(html) "" html "" - -#define TOPBAR_NAV NAV_ALL " " NAV_NEW " " -#define TOPBAR_NAV_ALL STRONG(NAV_ALL) " " NAV_NEW " " -#define TOPBAR_NAV_NEW NAV_ALL " " STRONG(NAV_NEW) " " - static const size_t sigil_size = sizeof("§")-1; static const int id_length = 16; @@ -60,6 +52,12 @@ struct zet_search { char *id; }; +enum page { + PAGE_NEW, + PAGE_ALL, + PAGE_ZET, +}; + static int count_lines_in(const char *str) { int count = 0; char c; @@ -116,6 +114,25 @@ static int write_html(int fd, const char *buf, size_t len) { return 0; } +static int write_topbar(int fd, enum page page, const char *id) { + int rc = write_buf(fd, "
"); + + if (page == PAGE_ALL) rc |= write_buf(fd, ""); + rc |= write_buf(fd, "All"); + if (page == PAGE_ALL) rc |= write_buf(fd, ""); + + rc |= write_buf(fd, " "); + if (page == PAGE_NEW) rc |= write_buf(fd, ""); + rc |= write_buf(fd, "New"); + if (page == PAGE_NEW) rc |= write_buf(fd, ""); + + if (page == PAGE_ZET) { + rc |= dprintf(fd, " §%s", id, id); + } + rc |= write_buf(fd, "
"); + return rc; +} + static int passthrough_note_html(int fd, int note_fd) { int rc; do { @@ -266,10 +283,10 @@ static int dpi_serve_zet_index(int fd) { "Notes" "" "" - "" - "
" TOPBAR_NAV_ALL "
" - "