"show graph" action: Print a menu on the left side.
[collection4.git] / src / action_list_graphs.c
index 81a2e19..42bab5d 100644 (file)
@@ -1,3 +1,26 @@
+/**
+ * collection4 - action_list_graphs.c
+ * Copyright (C) 2010  Florian octo Forster
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301  USA
+ *
+ * Authors:
+ *   Florian octo Forster <ff at octo.it>
+ **/
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -65,7 +88,14 @@ static int print_graph_inst_html (graph_config_t *cfg, /* {{{ */
   {
     if (!data->inst_more)
     {
-      printf ("    <li class=\"instance more\">More ...</li>\n");
+      memset (params, 0, sizeof (params));
+      graph_get_params (cfg, params, sizeof (params));
+      html_escape_buffer (params, sizeof (params));
+
+      printf ("    <li class=\"instance more\"><a href=\"%s"
+          "?action=show_graph;%s\">More &#x2026;</a></li>\n",
+          script_name (), params);
+
       data->inst_more = 1;
     }
     return (0);
@@ -85,6 +115,27 @@ static int print_graph_inst_html (graph_config_t *cfg, /* {{{ */
   return (0);
 } /* }}} int print_graph_inst_html */
 
+static int print_graph_html (graph_config_t *cfg, /* {{{ */
+    __attribute__((unused)) void *user_data)
+{
+  char params[1024];
+  char title[1024];
+
+  memset (title, 0, sizeof (title));
+  graph_get_title (cfg, title, sizeof (title));
+  html_escape_buffer (title, sizeof (title));
+
+  memset (params, 0, sizeof (params));
+  graph_get_params (cfg, params, sizeof (params));
+  html_escape_buffer (params, sizeof (params));
+
+  printf ("      <li class=\"graph\"><a href=\"%s?action=show_graph;%s\">"
+      "%s</a></li>\n",
+      script_name (), params, title);
+
+  return (0);
+} /* }}} int print_graph_html */
+
 struct page_data_s
 {
   const char *search_term;
@@ -108,7 +159,9 @@ static int print_search_result (void *user_data) /* {{{ */
 
   printf ("    <ul id=\"search-output\" class=\"graph_list\">\n");
   if (pg_data->search_term == NULL)
-    gl_instance_get_all (print_graph_inst_html, /* user_data = */ &cb_data);
+  {
+    gl_graph_get_all (print_graph_html, /* user_data = */ &cb_data);
+  }
   else
   {
     char *term_lc = strtolower_copy (pg_data->search_term);