diff options
author | Lars Hjemli <hjemli@gmail.com> | 2007-06-17 08:23:08 (JST) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-06-17 08:39:05 (JST) |
commit | 44947bfcdc0d6e8c7d673bea0538cbf2a182f289 (patch) | |
tree | 3f65d6842738a8314ed72d5575a0b523061556b7 /ui-shared.c | |
parent | f91b9696a36008c245a3195800ba0c5fa3e890f9 (diff) | |
download | cgit-44947bfcdc0d6e8c7d673bea0538cbf2a182f289.zip cgit-44947bfcdc0d6e8c7d673bea0538cbf2a182f289.tar.gz |
Add and use cgit_tree_link()
This creates a new function used to generate links to 'tree' page and uses
the function everywhere a link to the 'tree' page is generated.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-shared.c')
-rw-r--r-- | ui-shared.c | 64 |
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 | ||
90 | static 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 = "&"; | ||
129 | } | ||
130 | if (head && head != cgit_query_head) { | ||
131 | html(delim); | ||
132 | html("h="); | ||
133 | html_attr(head); | ||
134 | delim = "&"; | ||
135 | } | ||
136 | return fmt("%s", delim); | ||
137 | } | ||
138 | |||
139 | void 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 | ||
91 | void cgit_print_date(time_t secs, char *format) | 155 | void cgit_print_date(time_t secs, char *format) |
92 | { | 156 | { |