|
diff --git a/cgit.css b/cgit.css index 640bbc9..ef4bc62 100644 --- a/ cgit.css+++ b/ cgit.css |
|
@@ -120,49 +120,49 @@ td#search form { |
120 | |
120 | |
121 | td#search input { |
121 | td#search input { |
122 | font-size: 9pt; |
122 | font-size: 9pt; |
123 | padding: 0px; |
123 | padding: 0px; |
124 | width: 10em; |
124 | width: 10em; |
125 | border: solid 1px #333; |
125 | border: solid 1px #333; |
126 | color: #333; |
126 | color: #333; |
127 | background-color: #fff; |
127 | background-color: #fff; |
128 | } |
128 | } |
129 | |
129 | |
130 | td#content { |
130 | td#content { |
131 | padding: 1em 0.5em; |
131 | padding: 1em 0.5em; |
132 | } |
132 | } |
133 | |
133 | |
134 | div#blob { |
134 | div#blob { |
135 | border: solid 1px black; |
135 | border: solid 1px black; |
136 | } |
136 | } |
137 | |
137 | |
138 | div.error { |
138 | div.error { |
139 | color: red; |
139 | color: red; |
140 | font-weight: bold; |
140 | font-weight: bold; |
141 | margin: 1em 2em; |
141 | margin: 1em 2em; |
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 | } |
147 | |
147 | |
148 | div.ls-dir a { |
148 | div.ls-dir a { |
149 | font-weight: bold; |
149 | font-weight: bold; |
150 | } |
150 | } |
151 | |
151 | |
152 | th.filesize, td.filesize { |
152 | th.filesize, td.filesize { |
153 | text-align: right; |
153 | text-align: right; |
154 | } |
154 | } |
155 | |
155 | |
156 | td.filesize { |
156 | td.filesize { |
157 | font-family: monospace; |
157 | font-family: monospace; |
158 | } |
158 | } |
159 | |
159 | |
160 | td.filemode { |
160 | td.filemode { |
161 | font-family: monospace; |
161 | font-family: monospace; |
162 | } |
162 | } |
163 | |
163 | |
164 | td.blob { |
164 | td.blob { |
165 | white-space: pre; |
165 | white-space: pre; |
166 | font-family: monospace; |
166 | font-family: monospace; |
167 | background-color: white; |
167 | background-color: white; |
168 | } |
168 | } |
|
|
diff --git a/cgit.h b/cgit.h index 292e488..b7f8827 100644 --- a/ cgit.h+++ b/ cgit.h |
|
@@ -12,85 +12,87 @@ |
12 | #include <diff.h> |
12 | #include <diff.h> |
13 | #include <diffcore.h> |
13 | #include <diffcore.h> |
14 | #include <refs.h> |
14 | #include <refs.h> |
15 | #include <revision.h> |
15 | #include <revision.h> |
16 | #include <log-tree.h> |
16 | #include <log-tree.h> |
17 | #include <archive.h> |
17 | #include <archive.h> |
18 | #include <xdiff/xdiff.h> |
18 | #include <xdiff/xdiff.h> |
19 | |
19 | |
20 | |
20 | |
21 | typedef void (*configfn)(const char *name, const char *value); |
21 | typedef void (*configfn)(const char *name, const char *value); |
22 | |
22 | |
23 | struct cacheitem { |
23 | struct cacheitem { |
24 | char *name; |
24 | char *name; |
25 | struct stat st; |
25 | struct stat st; |
26 | int ttl; |
26 | int ttl; |
27 | int fd; |
27 | int fd; |
28 | }; |
28 | }; |
29 | |
29 | |
30 | struct repoinfo { |
30 | struct repoinfo { |
31 | char *url; |
31 | char *url; |
32 | char *name; |
32 | char *name; |
33 | char *path; |
33 | char *path; |
34 | char *desc; |
34 | char *desc; |
35 | char *owner; |
35 | char *owner; |
| |
36 | char *module_link; |
36 | int snapshots; |
37 | int snapshots; |
37 | }; |
38 | }; |
38 | |
39 | |
39 | struct repolist { |
40 | struct repolist { |
40 | int length; |
41 | int length; |
41 | int count; |
42 | int count; |
42 | struct repoinfo *repos; |
43 | struct repoinfo *repos; |
43 | }; |
44 | }; |
44 | |
45 | |
45 | struct commitinfo { |
46 | struct commitinfo { |
46 | struct commit *commit; |
47 | struct commit *commit; |
47 | char *author; |
48 | char *author; |
48 | char *author_email; |
49 | char *author_email; |
49 | unsigned long author_date; |
50 | unsigned long author_date; |
50 | char *committer; |
51 | char *committer; |
51 | char *committer_email; |
52 | char *committer_email; |
52 | unsigned long committer_date; |
53 | unsigned long committer_date; |
53 | char *subject; |
54 | char *subject; |
54 | char *msg; |
55 | char *msg; |
55 | }; |
56 | }; |
56 | |
57 | |
57 | struct taginfo { |
58 | struct taginfo { |
58 | char *tagger; |
59 | char *tagger; |
59 | char *tagger_email; |
60 | char *tagger_email; |
60 | int tagger_date; |
61 | int tagger_date; |
61 | char *msg; |
62 | char *msg; |
62 | }; |
63 | }; |
63 | |
64 | |
64 | extern const char cgit_version[]; |
65 | extern const char cgit_version[]; |
65 | |
66 | |
66 | extern struct repolist cgit_repolist; |
67 | extern struct repolist cgit_repolist; |
67 | extern struct repoinfo *cgit_repo; |
68 | extern struct repoinfo *cgit_repo; |
68 | |
69 | |
69 | extern char *cgit_root_title; |
70 | extern char *cgit_root_title; |
70 | extern char *cgit_css; |
71 | 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; |
75 | |
77 | |
76 | extern int cgit_nocache; |
78 | extern int cgit_nocache; |
77 | extern int cgit_snapshots; |
79 | extern int cgit_snapshots; |
78 | extern int cgit_max_lock_attempts; |
80 | extern int cgit_max_lock_attempts; |
79 | extern int cgit_cache_root_ttl; |
81 | extern int cgit_cache_root_ttl; |
80 | extern int cgit_cache_repo_ttl; |
82 | extern int cgit_cache_repo_ttl; |
81 | extern int cgit_cache_dynamic_ttl; |
83 | extern int cgit_cache_dynamic_ttl; |
82 | extern int cgit_cache_static_ttl; |
84 | extern int cgit_cache_static_ttl; |
83 | extern int cgit_cache_max_create_time; |
85 | extern int cgit_cache_max_create_time; |
84 | |
86 | |
85 | extern int cgit_max_msg_len; |
87 | extern int cgit_max_msg_len; |
86 | |
88 | |
87 | extern char *cgit_repo_name; |
89 | extern char *cgit_repo_name; |
88 | extern char *cgit_repo_desc; |
90 | extern char *cgit_repo_desc; |
89 | extern char *cgit_repo_owner; |
91 | extern char *cgit_repo_owner; |
90 | |
92 | |
91 | extern int cgit_query_has_symref; |
93 | extern int cgit_query_has_symref; |
92 | extern int cgit_query_has_sha1; |
94 | extern int cgit_query_has_sha1; |
93 | |
95 | |
94 | extern char *cgit_querystring; |
96 | extern char *cgit_querystring; |
95 | extern char *cgit_query_repo; |
97 | extern char *cgit_query_repo; |
96 | extern char *cgit_query_page; |
98 | extern char *cgit_query_page; |
|
|
diff --git a/cgitrc b/cgitrc index 3bae642..f217b39 100644 --- a/ cgitrc+++ b/ cgitrc |
|
@@ -26,59 +26,64 @@ |
26 | ## RewriteRule ^/git/$ /cgit/cgit.cgi [L,QSA] |
26 | ## RewriteRule ^/git/$ /cgit/cgit.cgi [L,QSA] |
27 | ## RewriteRule ^/git/([^/]+)/$ /cgit/cgit.cgi?r=$1 [L,QSA] |
27 | ## RewriteRule ^/git/([^/]+)/$ /cgit/cgit.cgi?r=$1 [L,QSA] |
28 | ## RewriteRule ^/git/([^/]+)/([^/]+)/$ /cgit/cgit.cgi?r=$1&p=$2 [L,QSA] |
28 | ## RewriteRule ^/git/([^/]+)/([^/]+)/$ /cgit/cgit.cgi?r=$1&p=$2 [L,QSA] |
29 | ## |
29 | ## |
30 | ## This setting is disabled by default. |
30 | ## This setting is disabled by default. |
31 | #virtual-root=/git |
31 | #virtual-root=/git |
32 | |
32 | |
33 | |
33 | |
34 | ## Set the title printed on the root page |
34 | ## Set the title printed on the root page |
35 | #root-title=Git repository browser |
35 | #root-title=Git repository browser |
36 | |
36 | |
37 | |
37 | |
38 | ## Link to css file |
38 | ## Link to css file |
39 | #css=/cgit/cgit.css |
39 | #css=/cgit/cgit.css |
40 | |
40 | |
41 | |
41 | |
42 | ## Link to logo file |
42 | ## Link to logo file |
43 | #logo=/cgit/git-logo.png |
43 | #logo=/cgit/git-logo.png |
44 | |
44 | |
45 | |
45 | |
46 | ## Url loaded when clicking the logo |
46 | ## Url loaded when clicking the logo |
47 | #logo-link=http://www.kernel.org/pub/software/scm/git/docs/ |
47 | #logo-link=http://www.kernel.org/pub/software/scm/git/docs/ |
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 |
52 | |
56 | |
53 | |
57 | |
54 | ## Root of cached output |
58 | ## Root of cached output |
55 | #cache-root=/var/cache/cgit |
59 | #cache-root=/var/cache/cgit |
56 | |
60 | |
57 | |
61 | |
58 | ## |
62 | ## |
59 | ## Time-To-Live settings: specifies how long (in minutes) different pages |
63 | ## Time-To-Live settings: specifies how long (in minutes) different pages |
60 | ## should be cached (0 for instant expiration, -1 for immortal pages) |
64 | ## should be cached (0 for instant expiration, -1 for immortal pages) |
61 | ## |
65 | ## |
62 | |
66 | |
63 | ## ttl for root page |
67 | ## ttl for root page |
64 | #cache-root-ttl=5 |
68 | #cache-root-ttl=5 |
65 | |
69 | |
66 | ## ttl for repo summary page |
70 | ## ttl for repo summary page |
67 | #cache-repo-ttl=5 |
71 | #cache-repo-ttl=5 |
68 | |
72 | |
69 | ## ttl for other dynamic pages |
73 | ## ttl for other dynamic pages |
70 | #cache-dynamic-ttl=5 |
74 | #cache-dynamic-ttl=5 |
71 | |
75 | |
72 | ## ttl for static pages (addressed by SHA-1) |
76 | ## ttl for static pages (addressed by SHA-1) |
73 | #cache-static-ttl=-1 |
77 | #cache-static-ttl=-1 |
74 | |
78 | |
75 | |
79 | |
76 | |
80 | |
77 | ## Example repository entry. Required values are repo.url and repo.path (each |
81 | ## Example repository entry. Required values are repo.url and repo.path (each |
78 | ## repository section must start with repo.url). |
82 | ## repository section must start with repo.url). |
79 | #repo.url=cgit |
83 | #repo.url=cgit |
80 | #repo.name=cgit |
84 | #repo.name=cgit |
81 | #repo.desc=the caching cgi for git |
85 | #repo.desc=the caching cgi for git |
82 | #repo.path=/pub/git/cgit |
86 | #repo.path=/pub/git/cgit |
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 |
|
|
diff --git a/html.c b/html.c index c0b2ed4..175b4b6 100644 --- a/ html.c+++ b/ html.c |
|
@@ -137,31 +137,32 @@ void html_link_open(char *url, char *title, char *class) |
137 | if (class) { |
137 | if (class) { |
138 | html("' class='"); |
138 | html("' class='"); |
139 | html_attr(class); |
139 | html_attr(class); |
140 | } |
140 | } |
141 | html("'>"); |
141 | html("'>"); |
142 | } |
142 | } |
143 | |
143 | |
144 | void html_link_close(void) |
144 | void html_link_close(void) |
145 | { |
145 | { |
146 | html("</a>"); |
146 | html("</a>"); |
147 | } |
147 | } |
148 | |
148 | |
149 | void html_fileperm(unsigned short mode) |
149 | void html_fileperm(unsigned short mode) |
150 | { |
150 | { |
151 | htmlf("%c%c%c", (mode & 4 ? 'r' : '-'), |
151 | htmlf("%c%c%c", (mode & 4 ? 'r' : '-'), |
152 | (mode & 2 ? 'w' : '-'), (mode & 1 ? 'x' : '-')); |
152 | (mode & 2 ? 'w' : '-'), (mode & 1 ? 'x' : '-')); |
153 | } |
153 | } |
154 | |
154 | |
155 | void html_filemode(unsigned short mode) |
155 | void html_filemode(unsigned short mode) |
156 | { |
156 | { |
157 | if (S_ISDIR(mode)) |
157 | if (S_ISDIR(mode)) |
158 | html("d"); |
158 | html("d"); |
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("-"); |
163 | html_fileperm(mode >> 6); |
165 | html_fileperm(mode >> 6); |
164 | html_fileperm(mode >> 3); |
166 | html_fileperm(mode >> 3); |
165 | html_fileperm(mode); |
167 | html_fileperm(mode); |
166 | } |
168 | } |
167 | |
| |
|
|
diff --git a/shared.c b/shared.c index 531d8c0..19d2df0 100644 --- a/ shared.c+++ b/ shared.c |
|
@@ -1,41 +1,42 @@ |
1 | /* shared.c: global vars + some callback functions |
1 | /* shared.c: global vars + some callback functions |
2 | * |
2 | * |
3 | * Copyright (C) 2006 Lars Hjemli |
3 | * Copyright (C) 2006 Lars Hjemli |
4 | * |
4 | * |
5 | * Licensed under GNU General Public License v2 |
5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) |
6 | * (see COPYING for full license text) |
7 | */ |
7 | */ |
8 | |
8 | |
9 | #include "cgit.h" |
9 | #include "cgit.h" |
10 | |
10 | |
11 | struct repolist cgit_repolist; |
11 | struct repolist cgit_repolist; |
12 | struct repoinfo *cgit_repo; |
12 | struct repoinfo *cgit_repo; |
13 | |
13 | |
14 | char *cgit_root_title = "Git repository browser"; |
14 | char *cgit_root_title = "Git repository browser"; |
15 | char *cgit_css = "/cgit.css"; |
15 | 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 | |
20 | char *cgit_cache_root = "/var/cache/cgit"; |
21 | char *cgit_cache_root = "/var/cache/cgit"; |
21 | |
22 | |
22 | int cgit_nocache = 0; |
23 | int cgit_nocache = 0; |
23 | int cgit_snapshots = 0; |
24 | int cgit_snapshots = 0; |
24 | int cgit_max_lock_attempts = 5; |
25 | int cgit_max_lock_attempts = 5; |
25 | int cgit_cache_root_ttl = 5; |
26 | int cgit_cache_root_ttl = 5; |
26 | int cgit_cache_repo_ttl = 5; |
27 | int cgit_cache_repo_ttl = 5; |
27 | int cgit_cache_dynamic_ttl = 5; |
28 | int cgit_cache_dynamic_ttl = 5; |
28 | int cgit_cache_static_ttl = -1; |
29 | int cgit_cache_static_ttl = -1; |
29 | int cgit_cache_max_create_time = 5; |
30 | int cgit_cache_max_create_time = 5; |
30 | |
31 | |
31 | int cgit_max_msg_len = 60; |
32 | int cgit_max_msg_len = 60; |
32 | |
33 | |
33 | char *cgit_repo_name = NULL; |
34 | char *cgit_repo_name = NULL; |
34 | char *cgit_repo_desc = NULL; |
35 | char *cgit_repo_desc = NULL; |
35 | char *cgit_repo_owner = NULL; |
36 | char *cgit_repo_owner = NULL; |
36 | |
37 | |
37 | int cgit_query_has_symref = 0; |
38 | int cgit_query_has_symref = 0; |
38 | int cgit_query_has_sha1 = 0; |
39 | int cgit_query_has_sha1 = 0; |
39 | |
40 | |
40 | char *cgit_querystring = NULL; |
41 | char *cgit_querystring = NULL; |
41 | char *cgit_query_repo = NULL; |
42 | char *cgit_query_repo = NULL; |
@@ -64,91 +65,96 @@ int chk_positive(int result, char *msg) |
64 | return result; |
65 | return result; |
65 | } |
66 | } |
66 | |
67 | |
67 | struct repoinfo *add_repo(const char *url) |
68 | struct repoinfo *add_repo(const char *url) |
68 | { |
69 | { |
69 | struct repoinfo *ret; |
70 | struct repoinfo *ret; |
70 | |
71 | |
71 | if (++cgit_repolist.count > cgit_repolist.length) { |
72 | if (++cgit_repolist.count > cgit_repolist.length) { |
72 | if (cgit_repolist.length == 0) |
73 | if (cgit_repolist.length == 0) |
73 | cgit_repolist.length = 8; |
74 | cgit_repolist.length = 8; |
74 | else |
75 | else |
75 | cgit_repolist.length *= 2; |
76 | cgit_repolist.length *= 2; |
76 | cgit_repolist.repos = xrealloc(cgit_repolist.repos, |
77 | cgit_repolist.repos = xrealloc(cgit_repolist.repos, |
77 | cgit_repolist.length * |
78 | cgit_repolist.length * |
78 | sizeof(struct repoinfo)); |
79 | sizeof(struct repoinfo)); |
79 | } |
80 | } |
80 | |
81 | |
81 | ret = &cgit_repolist.repos[cgit_repolist.count-1]; |
82 | ret = &cgit_repolist.repos[cgit_repolist.count-1]; |
82 | ret->url = xstrdup(url); |
83 | ret->url = xstrdup(url); |
83 | ret->name = ret->url; |
84 | ret->name = ret->url; |
84 | ret->path = NULL; |
85 | ret->path = NULL; |
85 | ret->desc = NULL; |
86 | ret->desc = NULL; |
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 | } |
90 | |
92 | |
91 | void cgit_global_config_cb(const char *name, const char *value) |
93 | void cgit_global_config_cb(const char *name, const char *value) |
92 | { |
94 | { |
93 | if (!strcmp(name, "root-title")) |
95 | if (!strcmp(name, "root-title")) |
94 | cgit_root_title = xstrdup(value); |
96 | cgit_root_title = xstrdup(value); |
95 | else if (!strcmp(name, "css")) |
97 | else if (!strcmp(name, "css")) |
96 | cgit_css = xstrdup(value); |
98 | cgit_css = xstrdup(value); |
97 | else if (!strcmp(name, "logo")) |
99 | else if (!strcmp(name, "logo")) |
98 | cgit_logo = xstrdup(value); |
100 | cgit_logo = xstrdup(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); |
103 | else if (!strcmp(name, "nocache")) |
107 | else if (!strcmp(name, "nocache")) |
104 | cgit_nocache = atoi(value); |
108 | cgit_nocache = atoi(value); |
105 | else if (!strcmp(name, "snapshots")) |
109 | else if (!strcmp(name, "snapshots")) |
106 | cgit_snapshots = atoi(value); |
110 | cgit_snapshots = atoi(value); |
107 | else if (!strcmp(name, "cache-root")) |
111 | else if (!strcmp(name, "cache-root")) |
108 | cgit_cache_root = xstrdup(value); |
112 | cgit_cache_root = xstrdup(value); |
109 | else if (!strcmp(name, "cache-root-ttl")) |
113 | else if (!strcmp(name, "cache-root-ttl")) |
110 | cgit_cache_root_ttl = atoi(value); |
114 | cgit_cache_root_ttl = atoi(value); |
111 | else if (!strcmp(name, "cache-repo-ttl")) |
115 | else if (!strcmp(name, "cache-repo-ttl")) |
112 | cgit_cache_repo_ttl = atoi(value); |
116 | cgit_cache_repo_ttl = atoi(value); |
113 | else if (!strcmp(name, "cache-static-ttl")) |
117 | else if (!strcmp(name, "cache-static-ttl")) |
114 | cgit_cache_static_ttl = atoi(value); |
118 | cgit_cache_static_ttl = atoi(value); |
115 | else if (!strcmp(name, "cache-dynamic-ttl")) |
119 | else if (!strcmp(name, "cache-dynamic-ttl")) |
116 | cgit_cache_dynamic_ttl = atoi(value); |
120 | cgit_cache_dynamic_ttl = atoi(value); |
117 | else if (!strcmp(name, "max-message-length")) |
121 | else if (!strcmp(name, "max-message-length")) |
118 | cgit_max_msg_len = atoi(value); |
122 | cgit_max_msg_len = atoi(value); |
119 | else if (!strcmp(name, "repo.url")) |
123 | else if (!strcmp(name, "repo.url")) |
120 | cgit_repo = add_repo(value); |
124 | cgit_repo = add_repo(value); |
121 | else if (!strcmp(name, "repo.name")) |
125 | else if (!strcmp(name, "repo.name")) |
122 | cgit_repo->name = xstrdup(value); |
126 | cgit_repo->name = xstrdup(value); |
123 | else if (cgit_repo && !strcmp(name, "repo.path")) |
127 | else if (cgit_repo && !strcmp(name, "repo.path")) |
124 | cgit_repo->path = xstrdup(value); |
128 | cgit_repo->path = xstrdup(value); |
125 | else if (cgit_repo && !strcmp(name, "repo.desc")) |
129 | else if (cgit_repo && !strcmp(name, "repo.desc")) |
126 | cgit_repo->desc = xstrdup(value); |
130 | cgit_repo->desc = xstrdup(value); |
127 | else if (cgit_repo && !strcmp(name, "repo.owner")) |
131 | else if (cgit_repo && !strcmp(name, "repo.owner")) |
128 | cgit_repo->owner = xstrdup(value); |
132 | cgit_repo->owner = xstrdup(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 | |
133 | void cgit_repo_config_cb(const char *name, const char *value) |
139 | void cgit_repo_config_cb(const char *name, const char *value) |
134 | { |
140 | { |
135 | if (!strcmp(name, "name")) |
141 | if (!strcmp(name, "name")) |
136 | cgit_repo_name = xstrdup(value); |
142 | cgit_repo_name = xstrdup(value); |
137 | else if (!strcmp(name, "desc")) |
143 | else if (!strcmp(name, "desc")) |
138 | cgit_repo_desc = xstrdup(value); |
144 | cgit_repo_desc = xstrdup(value); |
139 | else if (!strcmp(name, "owner")) |
145 | else if (!strcmp(name, "owner")) |
140 | cgit_repo_owner = xstrdup(value); |
146 | cgit_repo_owner = xstrdup(value); |
141 | } |
147 | } |
142 | |
148 | |
143 | void cgit_querystring_cb(const char *name, const char *value) |
149 | void cgit_querystring_cb(const char *name, const char *value) |
144 | { |
150 | { |
145 | if (!strcmp(name,"r")) { |
151 | if (!strcmp(name,"r")) { |
146 | cgit_query_repo = xstrdup(value); |
152 | cgit_query_repo = xstrdup(value); |
147 | } else if (!strcmp(name, "p")) { |
153 | } else if (!strcmp(name, "p")) { |
148 | cgit_query_page = xstrdup(value); |
154 | cgit_query_page = xstrdup(value); |
149 | } else if (!strcmp(name, "q")) { |
155 | } else if (!strcmp(name, "q")) { |
150 | cgit_query_search = xstrdup(value); |
156 | cgit_query_search = xstrdup(value); |
151 | } else if (!strcmp(name, "h")) { |
157 | } else if (!strcmp(name, "h")) { |
152 | cgit_query_head = xstrdup(value); |
158 | cgit_query_head = xstrdup(value); |
153 | cgit_query_has_symref = 1; |
159 | cgit_query_has_symref = 1; |
154 | } else if (!strcmp(name, "id")) { |
160 | } else if (!strcmp(name, "id")) { |
|
|
diff --git a/ui-tree.c b/ui-tree.c index 60f7560..dee8309 100644 --- a/ ui-tree.c+++ b/ ui-tree.c |
|
@@ -1,73 +1,74 @@ |
1 | /* ui-tree.c: functions for tree output |
1 | /* ui-tree.c: functions for tree output |
2 | * |
2 | * |
3 | * Copyright (C) 2006 Lars Hjemli |
3 | * Copyright (C) 2006 Lars Hjemli |
4 | * |
4 | * |
5 | * Licensed under GNU General Public License v2 |
5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) |
6 | * (see COPYING for full license text) |
7 | */ |
7 | */ |
8 | |
8 | |
9 | #include "cgit.h" |
9 | #include "cgit.h" |
10 | |
10 | |
11 | |
11 | |
12 | static int print_entry(const unsigned char *sha1, const char *base, |
12 | static int print_entry(const unsigned char *sha1, const char *base, |
13 | int baselen, const char *pathname, unsigned int mode, |
13 | int baselen, const char *pathname, unsigned int mode, |
14 | int stage) |
14 | int stage) |
15 | { |
15 | { |
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, |
25 | sha1_to_hex(sha1)); |
25 | sha1_to_hex(sha1)); |
26 | return 0; |
26 | return 0; |
27 | } |
27 | } |
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/", |
37 | sha1_to_hex(sha1), |
40 | sha1_to_hex(sha1), |
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"); |
52 | free(name); |
53 | free(name); |
53 | return 0; |
54 | return 0; |
54 | } |
55 | } |
55 | |
56 | |
56 | void cgit_print_tree(const char *hex, char *path) |
57 | void cgit_print_tree(const char *hex, char *path) |
57 | { |
58 | { |
58 | struct tree *tree; |
59 | struct tree *tree; |
59 | unsigned char sha1[20]; |
60 | unsigned char sha1[20]; |
60 | |
61 | |
61 | if (get_sha1_hex(hex, sha1)) { |
62 | if (get_sha1_hex(hex, sha1)) { |
62 | cgit_print_error(fmt("Invalid object id: %s", hex)); |
63 | cgit_print_error(fmt("Invalid object id: %s", hex)); |
63 | return; |
64 | return; |
64 | } |
65 | } |
65 | tree = parse_tree_indirect(sha1); |
66 | tree = parse_tree_indirect(sha1); |
66 | if (!tree) { |
67 | if (!tree) { |
67 | cgit_print_error(fmt("Not a tree object: %s", hex)); |
68 | cgit_print_error(fmt("Not a tree object: %s", hex)); |
68 | return; |
69 | return; |
69 | } |
70 | } |
70 | |
71 | |
71 | html_txt(path); |
72 | html_txt(path); |
72 | html("<table class='list'>\n"); |
73 | html("<table class='list'>\n"); |
73 | html("<tr class='nohover'>"); |
74 | html("<tr class='nohover'>"); |
|