author | Lars Hjemli <hjemli@gmail.com> | 2009-08-09 11:27:21 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2009-08-09 11:41:54 (UTC) |
commit | 537c05f138d59c1eb3ac8e2d8b0dca3a38aa5dd4 (patch) (unidiff) | |
tree | 73b1d25a96dd171c5503fae1fefc6a27a7d58683 /cgit.c | |
parent | e1782fff8a78b7f265432603351281ad2988bb40 (diff) | |
download | cgit-537c05f138d59c1eb3ac8e2d8b0dca3a38aa5dd4.zip cgit-537c05f138d59c1eb3ac8e2d8b0dca3a38aa5dd4.tar.gz cgit-537c05f138d59c1eb3ac8e2d8b0dca3a38aa5dd4.tar.bz2 |
Add 'about-filter' and 'repo.about-filter' options
These options can be used to execute a filter command on each about-page,
both top-level and for each repository (repo.about-filter can be used
to override the current about-filter).
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -61,120 +61,124 @@ void config_cb(const char *name, const char *value) | |||
61 | else if (!strcmp(name, "module-link")) | 61 | else if (!strcmp(name, "module-link")) |
62 | ctx.cfg.module_link = xstrdup(value); | 62 | ctx.cfg.module_link = xstrdup(value); |
63 | else if (!strcmp(name, "virtual-root")) { | 63 | else if (!strcmp(name, "virtual-root")) { |
64 | ctx.cfg.virtual_root = trim_end(value, '/'); | 64 | ctx.cfg.virtual_root = trim_end(value, '/'); |
65 | if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) | 65 | if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) |
66 | ctx.cfg.virtual_root = ""; | 66 | ctx.cfg.virtual_root = ""; |
67 | } else if (!strcmp(name, "nocache")) | 67 | } else if (!strcmp(name, "nocache")) |
68 | ctx.cfg.nocache = atoi(value); | 68 | ctx.cfg.nocache = atoi(value); |
69 | else if (!strcmp(name, "noheader")) | 69 | else if (!strcmp(name, "noheader")) |
70 | ctx.cfg.noheader = atoi(value); | 70 | ctx.cfg.noheader = atoi(value); |
71 | else if (!strcmp(name, "snapshots")) | 71 | else if (!strcmp(name, "snapshots")) |
72 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); | 72 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); |
73 | else if (!strcmp(name, "enable-index-links")) | 73 | else if (!strcmp(name, "enable-index-links")) |
74 | ctx.cfg.enable_index_links = atoi(value); | 74 | ctx.cfg.enable_index_links = atoi(value); |
75 | else if (!strcmp(name, "enable-log-filecount")) | 75 | else if (!strcmp(name, "enable-log-filecount")) |
76 | ctx.cfg.enable_log_filecount = atoi(value); | 76 | ctx.cfg.enable_log_filecount = atoi(value); |
77 | else if (!strcmp(name, "enable-log-linecount")) | 77 | else if (!strcmp(name, "enable-log-linecount")) |
78 | ctx.cfg.enable_log_linecount = atoi(value); | 78 | ctx.cfg.enable_log_linecount = atoi(value); |
79 | else if (!strcmp(name, "max-stats")) | 79 | else if (!strcmp(name, "max-stats")) |
80 | ctx.cfg.max_stats = cgit_find_stats_period(value, NULL); | 80 | ctx.cfg.max_stats = cgit_find_stats_period(value, NULL); |
81 | else if (!strcmp(name, "cache-size")) | 81 | else if (!strcmp(name, "cache-size")) |
82 | ctx.cfg.cache_size = atoi(value); | 82 | ctx.cfg.cache_size = atoi(value); |
83 | else if (!strcmp(name, "cache-root")) | 83 | else if (!strcmp(name, "cache-root")) |
84 | ctx.cfg.cache_root = xstrdup(value); | 84 | ctx.cfg.cache_root = xstrdup(value); |
85 | else if (!strcmp(name, "cache-root-ttl")) | 85 | else if (!strcmp(name, "cache-root-ttl")) |
86 | ctx.cfg.cache_root_ttl = atoi(value); | 86 | ctx.cfg.cache_root_ttl = atoi(value); |
87 | else if (!strcmp(name, "cache-repo-ttl")) | 87 | else if (!strcmp(name, "cache-repo-ttl")) |
88 | ctx.cfg.cache_repo_ttl = atoi(value); | 88 | ctx.cfg.cache_repo_ttl = atoi(value); |
89 | else if (!strcmp(name, "cache-static-ttl")) | 89 | else if (!strcmp(name, "cache-static-ttl")) |
90 | ctx.cfg.cache_static_ttl = atoi(value); | 90 | ctx.cfg.cache_static_ttl = atoi(value); |
91 | else if (!strcmp(name, "cache-dynamic-ttl")) | 91 | else if (!strcmp(name, "cache-dynamic-ttl")) |
92 | ctx.cfg.cache_dynamic_ttl = atoi(value); | 92 | ctx.cfg.cache_dynamic_ttl = atoi(value); |
93 | else if (!strcmp(name, "about-filter")) | ||
94 | ctx.cfg.about_filter = new_filter(value, 0); | ||
93 | else if (!strcmp(name, "commit-filter")) | 95 | else if (!strcmp(name, "commit-filter")) |
94 | ctx.cfg.commit_filter = new_filter(value, 0); | 96 | ctx.cfg.commit_filter = new_filter(value, 0); |
95 | else if (!strcmp(name, "embedded")) | 97 | else if (!strcmp(name, "embedded")) |
96 | ctx.cfg.embedded = atoi(value); | 98 | ctx.cfg.embedded = atoi(value); |
97 | else if (!strcmp(name, "max-message-length")) | 99 | else if (!strcmp(name, "max-message-length")) |
98 | ctx.cfg.max_msg_len = atoi(value); | 100 | ctx.cfg.max_msg_len = atoi(value); |
99 | else if (!strcmp(name, "max-repodesc-length")) | 101 | else if (!strcmp(name, "max-repodesc-length")) |
100 | ctx.cfg.max_repodesc_len = atoi(value); | 102 | ctx.cfg.max_repodesc_len = atoi(value); |
101 | else if (!strcmp(name, "max-repo-count")) | 103 | else if (!strcmp(name, "max-repo-count")) |
102 | ctx.cfg.max_repo_count = atoi(value); | 104 | ctx.cfg.max_repo_count = atoi(value); |
103 | else if (!strcmp(name, "max-commit-count")) | 105 | else if (!strcmp(name, "max-commit-count")) |
104 | ctx.cfg.max_commit_count = atoi(value); | 106 | ctx.cfg.max_commit_count = atoi(value); |
105 | else if (!strcmp(name, "source-filter")) | 107 | else if (!strcmp(name, "source-filter")) |
106 | ctx.cfg.source_filter = new_filter(value, 1); | 108 | ctx.cfg.source_filter = new_filter(value, 1); |
107 | else if (!strcmp(name, "summary-log")) | 109 | else if (!strcmp(name, "summary-log")) |
108 | ctx.cfg.summary_log = atoi(value); | 110 | ctx.cfg.summary_log = atoi(value); |
109 | else if (!strcmp(name, "summary-branches")) | 111 | else if (!strcmp(name, "summary-branches")) |
110 | ctx.cfg.summary_branches = atoi(value); | 112 | ctx.cfg.summary_branches = atoi(value); |
111 | else if (!strcmp(name, "summary-tags")) | 113 | else if (!strcmp(name, "summary-tags")) |
112 | ctx.cfg.summary_tags = atoi(value); | 114 | ctx.cfg.summary_tags = atoi(value); |
113 | else if (!strcmp(name, "agefile")) | 115 | else if (!strcmp(name, "agefile")) |
114 | ctx.cfg.agefile = xstrdup(value); | 116 | ctx.cfg.agefile = xstrdup(value); |
115 | else if (!strcmp(name, "renamelimit")) | 117 | else if (!strcmp(name, "renamelimit")) |
116 | ctx.cfg.renamelimit = atoi(value); | 118 | ctx.cfg.renamelimit = atoi(value); |
117 | else if (!strcmp(name, "robots")) | 119 | else if (!strcmp(name, "robots")) |
118 | ctx.cfg.robots = xstrdup(value); | 120 | ctx.cfg.robots = xstrdup(value); |
119 | else if (!strcmp(name, "clone-prefix")) | 121 | else if (!strcmp(name, "clone-prefix")) |
120 | ctx.cfg.clone_prefix = xstrdup(value); | 122 | ctx.cfg.clone_prefix = xstrdup(value); |
121 | else if (!strcmp(name, "local-time")) | 123 | else if (!strcmp(name, "local-time")) |
122 | ctx.cfg.local_time = atoi(value); | 124 | ctx.cfg.local_time = atoi(value); |
123 | else if (!strcmp(name, "repo.group")) | 125 | else if (!strcmp(name, "repo.group")) |
124 | ctx.cfg.repo_group = xstrdup(value); | 126 | ctx.cfg.repo_group = xstrdup(value); |
125 | else if (!strcmp(name, "repo.url")) | 127 | else if (!strcmp(name, "repo.url")) |
126 | ctx.repo = cgit_add_repo(value); | 128 | ctx.repo = cgit_add_repo(value); |
127 | else if (!strcmp(name, "repo.name")) | 129 | else if (!strcmp(name, "repo.name")) |
128 | ctx.repo->name = xstrdup(value); | 130 | ctx.repo->name = xstrdup(value); |
129 | else if (ctx.repo && !strcmp(name, "repo.path")) | 131 | else if (ctx.repo && !strcmp(name, "repo.path")) |
130 | ctx.repo->path = trim_end(value, '/'); | 132 | ctx.repo->path = trim_end(value, '/'); |
131 | else if (ctx.repo && !strcmp(name, "repo.clone-url")) | 133 | else if (ctx.repo && !strcmp(name, "repo.clone-url")) |
132 | ctx.repo->clone_url = xstrdup(value); | 134 | ctx.repo->clone_url = xstrdup(value); |
133 | else if (ctx.repo && !strcmp(name, "repo.desc")) | 135 | else if (ctx.repo && !strcmp(name, "repo.desc")) |
134 | ctx.repo->desc = xstrdup(value); | 136 | ctx.repo->desc = xstrdup(value); |
135 | else if (ctx.repo && !strcmp(name, "repo.owner")) | 137 | else if (ctx.repo && !strcmp(name, "repo.owner")) |
136 | ctx.repo->owner = xstrdup(value); | 138 | ctx.repo->owner = xstrdup(value); |
137 | else if (ctx.repo && !strcmp(name, "repo.defbranch")) | 139 | else if (ctx.repo && !strcmp(name, "repo.defbranch")) |
138 | ctx.repo->defbranch = xstrdup(value); | 140 | ctx.repo->defbranch = xstrdup(value); |
139 | else if (ctx.repo && !strcmp(name, "repo.snapshots")) | 141 | else if (ctx.repo && !strcmp(name, "repo.snapshots")) |
140 | ctx.repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ | 142 | ctx.repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ |
141 | else if (ctx.repo && !strcmp(name, "repo.enable-log-filecount")) | 143 | else if (ctx.repo && !strcmp(name, "repo.enable-log-filecount")) |
142 | ctx.repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); | 144 | ctx.repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); |
143 | else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount")) | 145 | else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount")) |
144 | ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); | 146 | ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); |
145 | else if (ctx.repo && !strcmp(name, "repo.max-stats")) | 147 | else if (ctx.repo && !strcmp(name, "repo.max-stats")) |
146 | ctx.repo->max_stats = cgit_find_stats_period(value, NULL); | 148 | ctx.repo->max_stats = cgit_find_stats_period(value, NULL); |
147 | else if (ctx.repo && !strcmp(name, "repo.module-link")) | 149 | else if (ctx.repo && !strcmp(name, "repo.module-link")) |
148 | ctx.repo->module_link= xstrdup(value); | 150 | ctx.repo->module_link= xstrdup(value); |
151 | else if (ctx.repo && !strcmp(name, "repo.about-filter")) | ||
152 | ctx.repo->about_filter = new_filter(value, 0); | ||
149 | else if (ctx.repo && !strcmp(name, "repo.commit-filter")) | 153 | else if (ctx.repo && !strcmp(name, "repo.commit-filter")) |
150 | ctx.repo->commit_filter = new_filter(value, 0); | 154 | ctx.repo->commit_filter = new_filter(value, 0); |
151 | else if (ctx.repo && !strcmp(name, "repo.source-filter")) | 155 | else if (ctx.repo && !strcmp(name, "repo.source-filter")) |
152 | ctx.repo->source_filter = new_filter(value, 1); | 156 | ctx.repo->source_filter = new_filter(value, 1); |
153 | else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) { | 157 | else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) { |
154 | if (*value == '/') | 158 | if (*value == '/') |
155 | ctx.repo->readme = xstrdup(value); | 159 | ctx.repo->readme = xstrdup(value); |
156 | else | 160 | else |
157 | ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value)); | 161 | ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value)); |
158 | } else if (!strcmp(name, "include")) | 162 | } else if (!strcmp(name, "include")) |
159 | parse_configfile(value, config_cb); | 163 | parse_configfile(value, config_cb); |
160 | } | 164 | } |
161 | 165 | ||
162 | static void querystring_cb(const char *name, const char *value) | 166 | static void querystring_cb(const char *name, const char *value) |
163 | { | 167 | { |
164 | if (!strcmp(name,"r")) { | 168 | if (!strcmp(name,"r")) { |
165 | ctx.qry.repo = xstrdup(value); | 169 | ctx.qry.repo = xstrdup(value); |
166 | ctx.repo = cgit_get_repoinfo(value); | 170 | ctx.repo = cgit_get_repoinfo(value); |
167 | } else if (!strcmp(name, "p")) { | 171 | } else if (!strcmp(name, "p")) { |
168 | ctx.qry.page = xstrdup(value); | 172 | ctx.qry.page = xstrdup(value); |
169 | } else if (!strcmp(name, "url")) { | 173 | } else if (!strcmp(name, "url")) { |
170 | ctx.qry.url = xstrdup(value); | 174 | ctx.qry.url = xstrdup(value); |
171 | cgit_parse_url(value); | 175 | cgit_parse_url(value); |
172 | } else if (!strcmp(name, "qt")) { | 176 | } else if (!strcmp(name, "qt")) { |
173 | ctx.qry.grep = xstrdup(value); | 177 | ctx.qry.grep = xstrdup(value); |
174 | } else if (!strcmp(name, "q")) { | 178 | } else if (!strcmp(name, "q")) { |
175 | ctx.qry.search = xstrdup(value); | 179 | ctx.qry.search = xstrdup(value); |
176 | } else if (!strcmp(name, "h")) { | 180 | } else if (!strcmp(name, "h")) { |
177 | ctx.qry.head = xstrdup(value); | 181 | ctx.qry.head = xstrdup(value); |
178 | ctx.qry.has_symref = 1; | 182 | ctx.qry.has_symref = 1; |
179 | } else if (!strcmp(name, "id")) { | 183 | } else if (!strcmp(name, "id")) { |
180 | ctx.qry.sha1 = xstrdup(value); | 184 | ctx.qry.sha1 = xstrdup(value); |