From: Andrea Zagli Date: Sun, 24 Sep 2017 07:15:27 +0000 (+0200) Subject: Rendering of root directory content. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=1f7d643e37c8fe221f89dd80797550581113d55c;p=zakjukebox Rendering of root directory content. --- diff --git a/src/index.c b/src/index.c index a69d944..f1d4b02 100644 --- a/src/index.c +++ b/src/index.c @@ -24,6 +24,66 @@ #include "index.h" +static gchar +*render_dir (Commons *commons, const gchar *dir) +{ + g_autoptr (GError) error = NULL; + g_autoptr (GFile) gfdir = NULL; + g_autoptr (GFileEnumerator) gfenum = NULL; + + g_autoptr (GString) ret; + + g_autofree gchar *path; + + path = g_build_filename (commons->root, dir, NULL); + + ret = g_string_new (""); + g_string_append_printf (ret, "

%s

\n", path); + g_string_append (ret, "\n"); + + return g_strdup (ret->str); +} + void index_index (GMatchInfo *minfo, gpointer user_data) { @@ -33,7 +93,9 @@ index_index (GMatchInfo *minfo, gpointer user_data) g_autoptr(GError) error = NULL; TmplSymbol *symbol = NULL; gchar *str; - g_warning ("INDEX INDEX"); + + gchar *dir; + Commons *commons = (Commons *)user_data; file = g_file_new_for_path (CTPLDIR "/template.ctpl"); @@ -51,7 +113,8 @@ index_index (GMatchInfo *minfo, gpointer user_data) tmpl_symbol_assign_string (symbol, ""); symbol = tmpl_scope_get (scope, "body"); - tmpl_symbol_assign_string (symbol, commons->root); + dir = render_dir (commons, "/"); + tmpl_symbol_assign_string (symbol, dir); symbol = tmpl_scope_get (scope, "body_tag"); tmpl_symbol_assign_string (symbol, "");