let summary headers link to to the respective subpages
[webgit] / src / actions.c
index f6790cb..4242ecb 100644 (file)
@@ -18,6 +18,7 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "webgit.h"
 #include "actions.h"
 #include "summary.h"
 #include "object.h"
 static Html
 webgit_main_menu_action (struct webgit_query* query)
 {
-  (void) query;
-  return html ("TODO: main menu");
-}
-
-static Html
-webgit_header_action (struct webgit_query* query)
-{
-  (void) query;
-  return html (
-               "webgit header action"
+  return html (html_tag ("div"),
+               html (
+                     html_tag ("img",
+                               html_attr ("src", webgit_webskinpath (query, "icons/webgit_logo.png")),
+                               html_attr ("alt", "Webgit-Logo")
+                               )
+                     ), "<br />",
+               html_include (webgit_skinpath (query, "inc/site.inc")), "<br />",
+               // TODO: webgit_user_config_link (query), "<br />",
+               html (
+                     html_tag ("a",
+                               html_attr ("href", webgit_webskinpath (query, "inc/about.html"))
+                               ),
+                     "Powered by webgit"
+                     )
                );
 }
 
@@ -77,6 +83,8 @@ webgit_main_content_action (struct webgit_query* query)
                           )
               );
 
+  int row = 0;
+
   LLIST_FOREACH (&query->repos, node)
     {
       struct webgit_repo_info* n = (struct webgit_repo_info*)node;
@@ -86,12 +94,9 @@ webgit_main_content_action (struct webgit_query* query)
       if (n->age < n->maxage)
         {
           html_list_append (table, html (
-                                         /*
-                                           TODO:
-                                           It would be great to have alternate rows with class="odd" or class="even"
-                                           html_tag ("tr", html_attr ("class", "odd")),
-                                         */
-                                         html_tag ("tr"),
+                                         html_tag ("tr",
+                                                   html_attr ("class", (++row & 1) ? "odd" : "even")
+                                                   ),
                                          html(html_tag ("td"),
                                               webgit_summary_link (query, n, html (n->name))),
                                          html(html_tag ("td"), n->url ?
@@ -156,12 +161,7 @@ static Html
 webgit_main_action (struct webgit_query* query)
 {
   return html(
-              html(html_tag("div", html_attr("id", "sub-menu")), webgit_header_action (query)), html_nl (),
-              /*
-                TODO:
-                I'm not sure if we need this? Is the sub-menu sufficient?
-                html(html_tag("div"), webgit_main_menu_action (query)), html_nl (), 
-              */
+              html(html_tag("div", html_attr("id", "sub-menu")), webgit_main_menu_action (query)), html_nl (),
               html(html_tag("div", html_attr("id", "content")), webgit_main_content_action (query)), html_nl ()
               );
 }
@@ -173,8 +173,41 @@ webgit_main_action (struct webgit_query* query)
 static Html
 webgit_summary_menu_action (struct webgit_repo_info* repo)
 {
-  (void) repo;
-  return html(html_tag("div", html_attr("id", "sub-menu")), "TODO: summary");
+  return html (html_tag ("div"),
+               repo->logo ?
+               html (
+                     html_tag ("a",
+                               html_attr ("href", repo->logolink ? repo->logolink : "/")),
+                     html (
+                           html_tag ("img",
+                                     html_attr ("src", repo->logo),
+                                     html_attr ("alt", html (repo->name,"-logo"))
+                                     )
+                           )
+                     )
+               : html (
+                       html_tag ("img",
+                                 html_attr ("src", webgit_webskinpath (repo->query, "icons/webgit_logo.png")),
+                                 html_attr ("alt", "Webgit-Logo")
+                                 )
+                       ), "<br />",
+               repo->readme ? html_include (repo->readme) : html (), "<br />",
+               html (
+                     html_tag ("a",
+                               html_attr ("href", html_fmt ("%s?repo=%s&action=config",
+                                                            repo->query->request->script_name,
+                                                            repo->name)
+                                          )
+                               ),
+                     "Configure"
+                     ),"<br />",
+               html (
+                     html_tag ("a",
+                               html_attr ("href", repo->query->request->script_name)
+                               ),
+                     "Main Page"
+                     ),"<br />"
+               );
 }
 
 
@@ -231,7 +264,12 @@ webgit_summary_content_action (struct webgit_repo_info* repo)
   /* log */
   html_list_append (content,
                     html (
-                          html (html_tag ("h2"), "Log of branch '", repo->last_head, "'"),
+                          html (html_tag ("h2"),
+                                webgit_log_link (repo->query, repo->name, repo->last_head,
+                                                 NULL, 0, repo->query->count,
+                                                 html ("Log of branch '", repo->last_head, "'")
+                                                 )
+                                ),
                           webgit_log_table (repo->query, repo->last_head, 5 /*TODO: config this*/, 0))
                     );
 
@@ -239,7 +277,11 @@ webgit_summary_content_action (struct webgit_repo_info* repo)
   /* branches */
   html_list_append (content,
                     html (
-                          html (html_tag ("h2"), "Branches"),
+                          html (html_tag ("h2"),
+                                webgit_branch_link (repo, NULL, repo->query->count,
+                                                    html ("Branches")
+                                                    )
+                                ),
                           webgit_branch_table (repo, NULL, 5 /*TODO: config this*/)
                           )
                     );
@@ -247,7 +289,11 @@ webgit_summary_content_action (struct webgit_repo_info* repo)
   /* tags */
   html_list_append (content,
                     html (
-                          html (html_tag ("h2"), "Tags"),
+                          html (html_tag ("h2"),
+                                webgit_tag_link (repo, NULL, repo->query->count,
+                                                 html ("Tags")
+                                                 )
+                                ),
                           webgit_tag_table (repo, NULL, 5 /*TODO: config this*/)
                           )
                     );
@@ -264,7 +310,7 @@ webgit_summary_action (struct webgit_query* query)
   webgit_repoinfo_find_last (repo);
 
   return html(
-              html(html_tag("div"), webgit_summary_menu_action (repo)), html_nl (),
+              html(html_tag("div", html_attr("id", "sub-menu")), webgit_summary_menu_action (repo)), html_nl (),
               html(html_tag("div", html_attr("id", "content")), webgit_summary_content_action (repo)), html_nl ()
               );
 }
@@ -292,6 +338,14 @@ static Html
 webgit_diff_action (struct webgit_query* query)
 {
   (void) query;
+#if 0
+  return html (html_tag ("div"),
+               "Webgit logo<br />",
+               "Readme.html <br />",
+               "User (cookie) config <br />",
+               "About webgit (info/admin) <br />"
+               );
+#endif
   return html("diff");
 }
 
@@ -371,7 +425,14 @@ static Html
 webgit_branch_menu_action (struct webgit_repo_info* repo)
 {
   (void) repo;
-  return html ("TODO: branch sidebar");
+  return html (html_tag ("div"),
+               "Project or webgit logo<br />",
+               "switch-branch-dropdown <br />",
+               "push/fetch/merge <br />",
+               "branch administation <br />",
+               "link to project summary <br />",
+               "link to main page <br />"
+               );
 }
 
 
@@ -382,7 +443,6 @@ webgit_branch_action (struct webgit_query* query)
   webgit_repoinfo_find_last (repo);
 
   return html(
-              html(html_tag("div", html_attr("id", "header")), webgit_header_action (query)), html_nl (),
               html(html_tag("div", html_attr("id", "sub-menu")), webgit_branch_menu_action (repo)), html_nl (),
               html(html_tag("div", html_attr("id", "content")), webgit_branch_table (repo, query->head, query->count), html_nl ())
               );
@@ -408,7 +468,13 @@ static Html
 webgit_config_menu_action (struct webgit_repo_info* repo)
 {
   (void) repo;
-  return html ("TODO: config menu");
+  return html (html_tag ("div"),
+               "Project or webgit logo<br />",
+               "manage remotes? <br />",
+               "manage subprojects? <br />",
+               "link to project summary <br />",
+               "link to main page <br />"
+               );
 }
 
 static Html