summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--cgit.h3
-rw-r--r--ui-commit.c10
-rw-r--r--ui-repolist.c35
-rw-r--r--ui-shared.c64
-rw-r--r--ui-tree.c33
5 files changed, 107 insertions, 38 deletions
diff --git a/cgit.h b/cgit.h
index b93e2e8..9a19c97 100644
--- a/cgit.h
+++ b/cgit.h
@@ -203,2 +203,5 @@ extern char *cgit_pageurl(const char *reponame, const char *pagename,
203 203
204extern void cgit_tree_link(char *name, char *title, char *class, char *head,
205 char *rev, char *path);
206
204extern void cgit_print_error(char *msg); 207extern void cgit_print_error(char *msg);
diff --git a/ui-commit.c b/ui-commit.c
index ed5384d..885f870 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -155,2 +155,3 @@ void cgit_print_commit(const char *hex)
155 char *filename; 155 char *filename;
156 char *tmp;
156 int i; 157 int i;
@@ -183,6 +184,7 @@ void cgit_print_commit(const char *hex)
183 html("</td></tr>\n"); 184 html("</td></tr>\n");
184 html("<tr><th>tree</th><td colspan='2' class='sha1'><a href='"); 185 html("<tr><th>tree</th><td colspan='2' class='sha1'>");
185 query = fmt("h=%s", sha1_to_hex(commit->object.sha1)); 186 tmp = xstrdup(hex);
186 html_attr(cgit_pageurl(cgit_query_repo, "tree", query)); 187 cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL,
187 htmlf("'>%s</a></td></tr>\n", sha1_to_hex(commit->tree->object.sha1)); 188 cgit_query_head, tmp, NULL);
189 html("</td></tr>\n");
188 for (p = commit->parents; p ; p = p->next) { 190 for (p = commit->parents; p ; p = p->next) {
diff --git a/ui-repolist.c b/ui-repolist.c
index e5c6c20..8ade91a 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -46,3 +46,2 @@ void cgit_print_repolist(struct cacheitem *item)
46{ 46{
47 struct repoinfo *repo;
48 int i; 47 int i;
@@ -67,33 +66,31 @@ void cgit_print_repolist(struct cacheitem *item)
67 for (i=0; i<cgit_repolist.count; i++) { 66 for (i=0; i<cgit_repolist.count; i++) {
68 repo = &cgit_repolist.repos[i]; 67 cgit_repo = &cgit_repolist.repos[i];
69 if ((last_group == NULL && repo->group != NULL) || 68 if ((last_group == NULL && cgit_repo->group != NULL) ||
70 (last_group != NULL && repo->group == NULL) || 69 (last_group != NULL && cgit_repo->group == NULL) ||
71 (last_group != NULL && repo->group!= NULL && 70 (last_group != NULL && cgit_repo->group != NULL &&
72 strcmp(repo->group, last_group))) { 71 strcmp(cgit_repo->group, last_group))) {
73 html("<tr class='nohover'><td colspan='4' class='repogroup'>"); 72 html("<tr class='nohover'><td colspan='4' class='repogroup'>");
74 html_txt(repo->group); 73 html_txt(cgit_repo->group);
75 html("</td></tr>"); 74 html("</td></tr>");
76 last_group = repo->group; 75 last_group = cgit_repo->group;
77 } 76 }
78 htmlf("<tr><td class='%s'>", 77 htmlf("<tr><td class='%s'>",
79 repo->group ? "sublevel-repo" : "toplevel-repo"); 78 cgit_repo->group ? "sublevel-repo" : "toplevel-repo");
80 html_link_open(cgit_repourl(repo->url), repo->desc, NULL); 79 html_link_open(cgit_repourl(cgit_repo->url), NULL, NULL);
81 html_txt(repo->name); 80 html_txt(cgit_repo->name);
82 html_link_close(); 81 html_link_close();
83 html("</td><td>"); 82 html("</td><td>");
84 html_ntxt(cgit_max_repodesc_len, repo->desc); 83 html_ntxt(cgit_max_repodesc_len, cgit_repo->desc);
85 html("</td><td>"); 84 html("</td><td>");
86 html_txt(repo->owner); 85 html_txt(cgit_repo->owner);
87 html("</td><td>"); 86 html("</td><td>");
88 print_modtime(repo); 87 print_modtime(cgit_repo);
89 html("</td><td>"); 88 html("</td><td>");
90 html_link_open(cgit_repourl(repo->url), 89 html_link_open(cgit_repourl(cgit_repo->url),
91 "Summary", "button"); 90 "Summary", "button");
92 html("S</a>"); 91 html("S</a>");
93 html_link_open(cgit_pageurl(repo->name, "log", NULL), 92 html_link_open(cgit_pageurl(cgit_repo->name, "log", NULL),
94 "Log", "button"); 93 "Log", "button");
95 html("L</a>"); 94 html("L</a>");
96 html_link_open(cgit_pageurl(repo->name, "tree", NULL), 95 cgit_tree_link("F", "Files", "button", NULL, NULL, NULL);
97 "Files", "button");
98 html("F</a>");
99 html("</td></tr>\n"); 96 html("</td></tr>\n");
diff --git a/ui-shared.c b/ui-shared.c
index aba93e8..9ab6409 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -89,2 +89,66 @@ char *cgit_currurl()
89 89
90static char *repolink(char *title, char *class, char *page, char *head,
91 char *path)
92{
93 char *delim = "?";
94
95 html("<a");
96 if (title) {
97 html(" title='");
98 html_attr(title);
99 html("'");
100 }
101 if (class) {
102 html(" class='");
103 html_attr(class);
104 html("'");
105 }
106 html(" href='");
107 if (cgit_virtual_root) {
108 html_attr(cgit_virtual_root);
109 if (cgit_virtual_root[strlen(cgit_virtual_root) - 1] != '/')
110 html("/");
111 html_attr(cgit_repo->url);
112 if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/')
113 html("/");
114 html(page);
115 html("/");
116 if (path)
117 html_attr(path);
118 } else {
119 html(cgit_script_name);
120 html("?url=");
121 html_attr(cgit_repo->url);
122 if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/')
123 html("/");
124 html(page);
125 html("/");
126 if (path)
127 html_attr(path);
128 delim = "&amp;";
129 }
130 if (head && head != cgit_query_head) {
131 html(delim);
132 html("h=");
133 html_attr(head);
134 delim = "&amp;";
135 }
136 return fmt("%s", delim);
137}
138
139void cgit_tree_link(char *name, char *title, char *class, char *head,
140 char *rev, char *path)
141{
142 char *delim;
143
144 delim = repolink(title, class, "tree", head, path);
145 if (rev && rev != cgit_query_head) {
146 html(delim);
147 html("id=");
148 html_attr(rev);
149 }
150 html("'>");
151 html_txt(name);
152 html("</a>");
153}
90 154
diff --git a/ui-tree.c b/ui-tree.c
index db0bef6..3b82374 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -57,2 +57,3 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
57 char *name; 57 char *name;
58 char *fullpath;
58 enum object_type type; 59 enum object_type type;
@@ -62,2 +63,5 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
62 name = xstrdup(pathname); 63 name = xstrdup(pathname);
64 fullpath = fmt("%s%s%s", cgit_query_path ? cgit_query_path : "",
65 cgit_query_path ? "/" : "", name);
66
63 type = sha1_object_info(sha1, &size); 67 type = sha1_object_info(sha1, &size);
@@ -69,6 +73,3 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
69 } 73 }
70 qry = fmt("h=%s&amp;path=%s%s%s", curr_rev, 74
71 cgit_query_path ? cgit_query_path : "",
72 cgit_query_path ? "/" : "", pathname);
73 url = cgit_pageurl(cgit_query_repo, "tree", qry);
74 html("<tr><td class='filemode'>"); 75 html("<tr><td class='filemode'>");
@@ -81,11 +82,15 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
81 sha1_to_hex(sha1))); 82 sha1_to_hex(sha1)));
83 html("'>");
84 html_txt(name);
85 html("</a>");
82 } else if (S_ISDIR(mode)) { 86 } else if (S_ISDIR(mode)) {
83 html("class='ls-dir'><a href='"); 87 html("class='ls-dir'>");
84 html_attr(url); 88 cgit_tree_link(name, NULL, NULL, cgit_query_head,
89 curr_rev, fullpath);
85 } else { 90 } else {
86 html("class='ls-blob'><a href='"); 91 html("class='ls-blob'>");
87 html_attr(url); 92 cgit_tree_link(name, NULL, NULL, cgit_query_head,
93 curr_rev, fullpath);
88 } 94 }
89 htmlf("'>%s</a></td>", name); 95 htmlf("</td><td class='filesize'>%li</td>", size);
90 htmlf("<td class='filesize'>%li</td>", size);
91 96
@@ -152,7 +157,5 @@ static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
152 fmt("h=%s&amp;path=%s", curr_rev, buffer)); 157 fmt("h=%s&amp;path=%s", curr_rev, buffer));
153 htmlf(" / <a href='"); 158 html("/");
154 html_attr(url); 159 cgit_tree_link(xstrdup(pathname), NULL, NULL, cgit_query_head,
155 html("'>"); 160 curr_rev, buffer);
156 html_txt(xstrdup(pathname));
157 html("</a>");
158 161