]> gitweb.ps.run Git - ps-cgit/commitdiff
Merge branch 'master' of http://op-co.de/cgit
authorLars Hjemli <hjemli@gmail.com>
Tue, 8 Dec 2009 17:31:07 +0000 (18:31 +0100)
committerLars Hjemli <hjemli@gmail.com>
Tue, 8 Dec 2009 17:31:07 +0000 (18:31 +0100)
cgit.c
cgit.css
cgit.h
cgitrc.5.txt
filters/syntax-highlighting.sh
ui-tree.c

diff --git a/cgit.c b/cgit.c
index bfde9f98ccfdf1c793aa1d70e1558e90a4b5ace5..08cb5d25621c2bd120982c86c0898e08497a083b 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -165,6 +165,8 @@ void config_cb(const char *name, const char *value)
                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 @@ static void prepare_context(struct cgit_context *ctx)
        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;
index c47ebc96126b8629cd6824b0d3346aaa216d48a7..ef7d3c1e863584ab4eae062408c17a34fe8dffbf 100644 (file)
--- a/cgit.css
+++ b/cgit.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;
 }
diff --git a/cgit.h b/cgit.h
index 6c6c460f9d03108b17a0da008381d93c69f262cf..39853dfe2f8d75df6c2eeae4013173012775dc8a 100644 (file)
--- a/cgit.h
+++ b/cgit.h
@@ -185,6 +185,7 @@ struct cgit_config {
        int max_lock_attempts;
        int max_msg_len;
        int max_repodesc_len;
+       int max_blob_size;
        int max_stats;
        int nocache;
        int noplainemail;
index 0c1348563568a96e05edf6ed9f617eaaabe69cfa..e69140bbfe4553c0e131a14248cf23799a16d221 100644 (file)
@@ -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
index 999ad0ce3d07f00a6e6d0cc8999502dd9a5e96c4..6b1c576404f886b9368b6147cf1e83cae819f274 100755 (executable)
@@ -3,6 +3,10 @@
 # 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):
 # 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
index f53ab6414b9ad50c8f4210eaab8afc169a5c4a00..f281937f0afc2141fc058818f6cfb18a77bfeb57 100644 (file)
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -107,6 +107,12 @@ static void print_object(const unsigned char *sha1, char *path, const char *base
                        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