summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c2
-rw-r--r--cgit.h1
-rw-r--r--cgitrc.5.txt4
-rw-r--r--ui-tree.c27
4 files changed, 23 insertions, 11 deletions
diff --git a/cgit.c b/cgit.c
index b0e1c44..a4788cb 100644
--- a/cgit.c
+++ b/cgit.c
@@ -63,12 +63,14 @@ void config_cb(const char *name, const char *value)
else if (!strcmp(name, "index-header"))
ctx.cfg.index_header = xstrdup(value);
else if (!strcmp(name, "index-info"))
ctx.cfg.index_info = xstrdup(value);
else if (!strcmp(name, "logo-link"))
ctx.cfg.logo_link = xstrdup(value);
+ else if (!strcmp(name, "linenumbers"))
+ ctx.cfg.linenumbers = atoi(value);
else if (!strcmp(name, "module-link"))
ctx.cfg.module_link = xstrdup(value);
else if (!strcmp(name, "virtual-root")) {
ctx.cfg.virtual_root = trim_end(value, '/');
if (!ctx.cfg.virtual_root && (!strcmp(value, "/")))
ctx.cfg.virtual_root = "";
diff --git a/cgit.h b/cgit.h
index adb8da4..2fdc531 100644
--- a/cgit.h
+++ b/cgit.h
@@ -171,12 +171,13 @@ struct cgit_config {
int cache_static_ttl;
int embedded;
int enable_index_links;
int enable_log_filecount;
int enable_log_linecount;
int local_time;
+ int linenumbers;
int max_repo_count;
int max_commit_count;
int max_lock_attempts;
int max_msg_len;
int max_repodesc_len;
int max_stats;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 3c35b02..a762ccc 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -143,12 +143,16 @@ logo::
logo-link::
Url loaded when clicking on the cgit logo image. If unspecified the
calculated url of the repository index page will be used. Default
value: none.
+linenumbers::
+ If set to "1" lines in tree view will have numbers.
+ Default value: "0".
+
max-commit-count::
Specifies the number of entries to list per page in "log" view. Default
value: "50".
max-message-length::
Specifies the maximum number of commit message characters to display in
diff --git a/ui-tree.c b/ui-tree.c
index 7bf2ad2..f64e6e0 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -20,25 +20,30 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size)
unsigned long lineno, idx;
const char *numberfmt =
"<a class='no' id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a>\n";
html("<table summary='blob content' class='blob'>\n");
- html("<tr><td class='linenumbers'><pre>");
- idx = 0;
- lineno = 0;
-
- if (size) {
- htmlf(numberfmt, ++lineno);
- while(idx < size - 1) { // skip absolute last newline
- if (buf[idx] == '\n')
- htmlf(numberfmt, ++lineno);
- idx++;
+ if (ctx.cfg.linenumbers) {
+ html("<tr><td class='linenumbers'><pre>");
+ idx = 0;
+ lineno = 0;
+
+ if (size) {
+ htmlf(numberfmt, ++lineno);
+ while(idx < size - 1) { // skip absolute last newline
+ if (buf[idx] == '\n')
+ htmlf(numberfmt, ++lineno);
+ idx++;
+ }
}
+ html("</pre></td>\n");
+ }
+ else {
+ html("<tr>\n");
}
- html("</pre></td>\n");
if (ctx.repo->source_filter) {
html("<td class='lines'><pre><code>");
ctx.repo->source_filter->argv[1] = xstrdup(name);
cgit_open_filter(ctx.repo->source_filter);
write(STDOUT_FILENO, buf, size);