author | Lars Hjemli <hjemli@gmail.com> | 2007-05-11 10:12:48 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-05-11 10:12:48 (UTC) |
commit | ded9393b173853d2e960f9b176aeb0bc4ed35be2 (patch) (unidiff) | |
tree | 5c062b21e85ef0fe243ad900e9f4ffaf2ded0f62 | |
parent | cc1dbd1b5d610bd5e626f54d310f11cf47684ea1 (diff) | |
download | cgit-ded9393b173853d2e960f9b176aeb0bc4ed35be2.zip cgit-ded9393b173853d2e960f9b176aeb0bc4ed35be2.tar.gz cgit-ded9393b173853d2e960f9b176aeb0bc4ed35be2.tar.bz2 |
Add submodule links in tree listing
When a submodule occurs in a tree, generate a link to show the
module/commit. The link is specified as a sprintf string in /etc/cgitrc,
using parameters 'module-link' and 'repo.module-link'. This should probably
be extended with repo.module-link.$path.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.css | 2 | ||||
-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | cgitrc | 5 | ||||
-rw-r--r-- | html.c | 3 | ||||
-rw-r--r-- | shared.c | 6 | ||||
-rw-r--r-- | ui-tree.c | 19 |
6 files changed, 26 insertions, 11 deletions
@@ -142,5 +142,5 @@ div.error { | |||
142 | } | 142 | } |
143 | 143 | ||
144 | div.ls-blob, div.ls-dir { | 144 | td.ls-blob, td.ls-dir, td.ls-mod { |
145 | font-family: monospace; | 145 | font-family: monospace; |
146 | } | 146 | } |
@@ -34,4 +34,5 @@ struct repoinfo { | |||
34 | char *desc; | 34 | char *desc; |
35 | char *owner; | 35 | char *owner; |
36 | char *module_link; | ||
36 | int snapshots; | 37 | int snapshots; |
37 | }; | 38 | }; |
@@ -71,4 +72,5 @@ extern char *cgit_css; | |||
71 | extern char *cgit_logo; | 72 | extern char *cgit_logo; |
72 | extern char *cgit_logo_link; | 73 | extern char *cgit_logo_link; |
74 | extern char *cgit_module_link; | ||
73 | extern char *cgit_virtual_root; | 75 | extern char *cgit_virtual_root; |
74 | extern char *cgit_cache_root; | 76 | extern char *cgit_cache_root; |
@@ -48,4 +48,8 @@ | |||
48 | 48 | ||
49 | 49 | ||
50 | ## Url loaded when clicking a submodule link | ||
51 | #module-link=./?repo=%s&page=commit&id=%s | ||
52 | |||
53 | |||
50 | ## Number of chars shown of commit subject message (in log view) | 54 | ## Number of chars shown of commit subject message (in log view) |
51 | #max-message-length=60 | 55 | #max-message-length=60 |
@@ -83,2 +87,3 @@ | |||
83 | #repo.owner=Lars Hjemli | 87 | #repo.owner=Lars Hjemli |
84 | #repo.snapshots=1 # override a sitewide snapshot-setting | 88 | #repo.snapshots=1 # override a sitewide snapshot-setting |
89 | #repo.module-link=/git/%s/commit/?id=%s # override the standard module-link | ||
@@ -159,4 +159,6 @@ void html_filemode(unsigned short mode) | |||
159 | else if (S_ISLNK(mode)) | 159 | else if (S_ISLNK(mode)) |
160 | html("l"); | 160 | html("l"); |
161 | else if (S_ISDIRLNK(mode)) | ||
162 | html("m"); | ||
161 | else | 163 | else |
162 | html("-"); | 164 | html("-"); |
@@ -165,3 +167,2 @@ void html_filemode(unsigned short mode) | |||
165 | html_fileperm(mode); | 167 | html_fileperm(mode); |
166 | } | 168 | } |
167 | |||
@@ -16,4 +16,5 @@ char *cgit_css = "/cgit.css"; | |||
16 | char *cgit_logo = "/git-logo.png"; | 16 | char *cgit_logo = "/git-logo.png"; |
17 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; | 17 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; |
18 | char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; | ||
18 | char *cgit_virtual_root = NULL; | 19 | char *cgit_virtual_root = NULL; |
19 | 20 | ||
@@ -86,4 +87,5 @@ struct repoinfo *add_repo(const char *url) | |||
86 | ret->owner = NULL; | 87 | ret->owner = NULL; |
87 | ret->snapshots = cgit_snapshots; | 88 | ret->snapshots = cgit_snapshots; |
89 | ret->module_link = cgit_module_link; | ||
88 | return ret; | 90 | return ret; |
89 | } | 91 | } |
@@ -99,4 +101,6 @@ void cgit_global_config_cb(const char *name, const char *value) | |||
99 | else if (!strcmp(name, "logo-link")) | 101 | else if (!strcmp(name, "logo-link")) |
100 | cgit_logo_link = xstrdup(value); | 102 | cgit_logo_link = xstrdup(value); |
103 | else if (!strcmp(name, "module-link")) | ||
104 | cgit_module_link = xstrdup(value); | ||
101 | else if (!strcmp(name, "virtual-root")) | 105 | else if (!strcmp(name, "virtual-root")) |
102 | cgit_virtual_root = xstrdup(value); | 106 | cgit_virtual_root = xstrdup(value); |
@@ -129,4 +133,6 @@ void cgit_global_config_cb(const char *name, const char *value) | |||
129 | else if (cgit_repo && !strcmp(name, "repo.snapshots")) | 133 | else if (cgit_repo && !strcmp(name, "repo.snapshots")) |
130 | cgit_repo->snapshots = atoi(value); | 134 | cgit_repo->snapshots = atoi(value); |
135 | else if (cgit_repo && !strcmp(name, "repo.module-link")) | ||
136 | cgit_repo->module_link= xstrdup(value); | ||
131 | } | 137 | } |
132 | 138 | ||
@@ -16,9 +16,9 @@ static int print_entry(const unsigned char *sha1, const char *base, | |||
16 | char *name; | 16 | char *name; |
17 | enum object_type type; | 17 | enum object_type type; |
18 | unsigned long size; | 18 | unsigned long size = 0; |
19 | 19 | ||
20 | name = xstrdup(pathname); | 20 | name = xstrdup(pathname); |
21 | type = sha1_object_info(sha1, &size); | 21 | type = sha1_object_info(sha1, &size); |
22 | if (type == OBJ_BAD) { | 22 | if (type == OBJ_BAD && !S_ISDIRLNK(mode)) { |
23 | htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", | 23 | htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", |
24 | name, | 24 | name, |
@@ -28,9 +28,12 @@ static int print_entry(const unsigned char *sha1, const char *base, | |||
28 | html("<tr><td class='filemode'>"); | 28 | html("<tr><td class='filemode'>"); |
29 | html_filemode(mode); | 29 | html_filemode(mode); |
30 | html("</td><td>"); | 30 | html("</td><td "); |
31 | if (S_ISDIRLNK(mode)) { | 31 | if (S_ISDIRLNK(mode)) { |
32 | htmlf("<div class='ls-dirlnk'>%s => submodule</div>", name); | 32 | htmlf("class='ls-mod'><a href='"); |
33 | html_attr(fmt(cgit_repo->module_link, | ||
34 | name, | ||
35 | sha1_to_hex(sha1))); | ||
33 | } else if (S_ISDIR(mode)) { | 36 | } else if (S_ISDIR(mode)) { |
34 | html("<div class='ls-dir'><a href='"); | 37 | html("class='ls-dir'><a href='"); |
35 | html_attr(cgit_pageurl(cgit_query_repo, "tree", | 38 | html_attr(cgit_pageurl(cgit_query_repo, "tree", |
36 | fmt("id=%s&path=%s%s/", | 39 | fmt("id=%s&path=%s%s/", |
@@ -38,14 +41,12 @@ static int print_entry(const unsigned char *sha1, const char *base, | |||
38 | cgit_query_path ? cgit_query_path : "", | 41 | cgit_query_path ? cgit_query_path : "", |
39 | pathname))); | 42 | pathname))); |
40 | htmlf("'>%s</a></div>", name); | ||
41 | } else { | 43 | } else { |
42 | html("<div class='ls-blob'><a href='"); | 44 | html("class='ls-blob'><a href='"); |
43 | html_attr(cgit_pageurl(cgit_query_repo, "view", | 45 | html_attr(cgit_pageurl(cgit_query_repo, "view", |
44 | fmt("id=%s&path=%s%s", sha1_to_hex(sha1), | 46 | fmt("id=%s&path=%s%s", sha1_to_hex(sha1), |
45 | cgit_query_path ? cgit_query_path : "", | 47 | cgit_query_path ? cgit_query_path : "", |
46 | pathname))); | 48 | pathname))); |
47 | htmlf("'>%s</a></div>", name); | ||
48 | } | 49 | } |
49 | html("</div></td>"); | 50 | htmlf("'>%s</a></div></td>", name); |
50 | htmlf("<td class='filesize'>%li</td>", size); | 51 | htmlf("<td class='filesize'>%li</td>", size); |
51 | html("</tr>\n"); | 52 | html("</tr>\n"); |