submodule repo links in tree view
authorChristian Thaeter <ct@pipapo.org>
Thu, 3 Jan 2008 16:58:55 +0000 (17:58 +0100)
committerChristian Thaeter <ct@pipapo.org>
Thu, 3 Jan 2008 16:58:55 +0000 (17:58 +0100)
src/object.c
src/repo.c
src/repo.h

index 616e5c6..8ea886f 100644 (file)
@@ -20,6 +20,7 @@
 */
 
 #include "object.h"
+#include "repo.h"
 
 #define SHA1_HEADER <openssl/sha.h>
 #include "git/cache.h"
@@ -280,7 +281,15 @@ ctgit_html_tree (const unsigned char *sha1, const char *base, int baselen,
                                               html (
                                                     html_tag ("tr"),
                                                     html (html_tag ("td"), pretty_mode (mode)),
-                                                    html (html_tag ("td"), html_strndup (pathname, SIZE_MAX)),
+                                                    html (html_tag ("td"),
+                                                          ctgit_repo_link (query_in_flight,
+                                                                           query_in_flight->repo,
+                                                                           strlen (query_in_flight->repo),
+                                                                           pathname, strlen (pathname),
+                                                                           NULL, 0,
+                                                                           "summary",
+                                                                           html_strndup (pathname, SIZE_MAX))
+                                                          ),
                                                     html (html_tag ("td"), "history")
                                                     ),
                                               html_nl ()
index f46349b..d8ad0df 100644 (file)
 #include <stdint.h>
 #include <time.h>
 
+
+Html
+ctgit_repo_link (struct ctgit_query* query,
+                 const char* repo_prefix,
+                 int repo_prefix_len,
+                 const char* repo,
+                 int repo_len,
+                 const char* object,
+                 int object_len,
+                 const char* action,
+                 Html text)
+{
+  return html (
+               html_tag ("a",
+                         html_attr ("href", html (
+                                                  html_fmt ("%s?repo=%.*s%s%.*s",
+                                                            query->request->script_name,
+                                                            repo_prefix_len, repo_prefix,
+                                                            repo_prefix && repo ? "/" : "",
+                                                            repo_len, repo,
+                                                            object_len, object),
+                                                  action ?
+                                                  html_fmt ("&action=%s", action) : html (),
+                                                  object ?
+                                                  html_fmt ("&object=%.*s", object_len, object) : html ()
+                                                  )
+                                    )
+                         ),
+               text
+               );
+}
+
 static struct ctgit_repo_info* in_flight;       /* stupid git callback has no void* userdata; we have to pass self in a global */
 
 static void
index e2d9fd7..a25a83c 100644 (file)
 #define CTGIT_CONF_PREFIX "web."
 
 
+Html
+ctgit_repo_link (struct ctgit_query* query,
+                 const char* repo_prefix,
+                 int repo_prefix_len,
+                 const char* repo,
+                 int repo_len,
+                 const char* object,
+                 int object_len,
+                 const char* action,
+                 Html text);
+
+
 //int
 //ctgit_repo_conf_cb (const char *var, const char *value);