aboutsummaryrefslogtreecommitdiffstats
path: root/ui-shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-shared.c')
-rw-r--r--ui-shared.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c
index aba93e8..9ab6409 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -87,6 +87,70 @@ char *cgit_currurl()
87 return fmt("%s/", cgit_virtual_root); 87 return fmt("%s/", cgit_virtual_root);
88} 88}
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
91void cgit_print_date(time_t secs, char *format) 155void cgit_print_date(time_t secs, char *format)
92{ 156{