all repos — cgit @ 57bb4fdb8419d7c250d4c6146910df3263943951

a hyperfast web frontend for git written in c

Merge branch 'master' of http://op-co.de/cgit
Lars Hjemli hjemli@gmail.com
Tue, 08 Dec 2009 18:31:07 +0100
commit

57bb4fdb8419d7c250d4c6146910df3263943951

parent

5c34d96f7e000eb47418ac9e39dabf92b767c9f2

6 files changed, 31 insertions(+), 17 deletions(-)

jump to
M cgit.ccgit.c

@@ -165,6 +165,8 @@ else if (!strcmp(name, "max-message-length"))

ctx.cfg.max_msg_len = atoi(value); else if (!strcmp(name, "max-repodesc-length")) ctx.cfg.max_repodesc_len = atoi(value); + else if (!strcmp(name, "max-blob-size")) + ctx.cfg.max_blob_size = atoi(value); else if (!strcmp(name, "max-repo-count")) ctx.cfg.max_repo_count = atoi(value); else if (!strcmp(name, "max-commit-count"))

@@ -270,6 +272,7 @@ ctx->cfg.max_commit_count = 50;

ctx->cfg.max_lock_attempts = 5; ctx->cfg.max_msg_len = 80; ctx->cfg.max_repodesc_len = 80; + ctx->cfg.max_blob_size = 0; ctx->cfg.max_stats = 0; ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; ctx->cfg.renamelimit = -1;
M cgit.csscgit.css

@@ -162,6 +162,11 @@ table.list td a {

color: black; } +table.list td a.ls-dir { + font-weight: bold; + color: #00f; +} + table.list td a:hover { color: #00f; }
M cgit.hcgit.h

@@ -185,6 +185,7 @@ int max_commit_count;

int max_lock_attempts; int max_msg_len; int max_repodesc_len; + int max_blob_size; int max_stats; int nocache; int noplainemail;
M cgitrc.5.txtcgitrc.5.txt

@@ -177,6 +177,10 @@ max-repodesc-length::

Specifies the maximum number of repo description characters to display on the repository index page. Default value: "80". +max-blob-size:: + Specifies the maximum size of a blob to display HTML for in KBytes. + Default value: "0" (limit disabled). + max-stats:: Set the default maximum statistics period. Valid values are "week", "month", "quarter" and "year". If unspecified, statistics are
M filters/syntax-highlighting.shfilters/syntax-highlighting.sh

@@ -3,6 +3,10 @@ # This script can be used to implement syntax highlighting in the cgit

# tree-view by refering to this file with the source-filter or repo.source- # filter options in cgitrc. # +# This script requires a shell supporting the ${var##pattern} syntax. +# It is supported by at least dash and bash, however busybox environments +# might have to use an external call to sed instead. +# # Note: the highlight command (http://www.andre-simon.de/) uses css for syntax # highlighting, so you'll probably want something like the following included # in your css file (generated by highlight 2.4.8 and adapted for cgit):

@@ -20,20 +24,11 @@ # table.blob .kwb { color:#830000; }

# table.blob .kwc { color:#000000; font-weight:bold; } # table.blob .kwd { color:#010181; } -case "$1" in - *.c) - highlight -f -I -X -S c - ;; - *.h) - highlight -f -I -X -S c - ;; - *.sh) - highlight -f -I -X -S sh - ;; - *.css) - highlight -f -I -X -S css - ;; - *) - highlight -f -I -X -S txt - ;; -esac +# store filename and extension in local vars +BASENAME="$1" +EXTENSION="${BASENAME##*.}" + +# map Makefile and Makefile.* to .mk +[ "${BASENAME%%.*}" == "Makefile" ] && EXTENSION=mk + +exec highlight --force -f -I -X -S $EXTENSION 2>/dev/null
M ui-tree.cui-tree.c

@@ -107,6 +107,12 @@ cgit_plain_link("plain", NULL, NULL, ctx.qry.head,

curr_rev, path); htmlf(")<br/>blob: %s\n", sha1_to_hex(sha1)); + if (ctx.cfg.max_blob_size && size / 1024 > ctx.cfg.max_blob_size) { + htmlf("<div class='error'>blob size (%dKB) exceeds display size limit (%dKB).</div>", + size / 1024, ctx.cfg.max_blob_size); + return; + } + if (buffer_is_binary(buf, size)) print_binary_buffer(buf, size); else