Warmcat homepage andy@warmcat.com
libwebsockets
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"", "gen_ut":1745908127, "reponame":"cgit", "desc":"CGI gitweb", "owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://warmcat.com/repo/cgit", "f":3, "items": [ {"schema":"libjg2-1", "cid":"bda6a336186a227548aba64f32fe7eb8", "commit": {"type":"commit", "time": 1530589970, "time_ofs": 480, "oid_tree": { "oid": "a13f9e35f0a4cda207a0083f221d342f1ef19cec", "alias": []}, "oid":{ "oid": "d9bf962c214ba5bab96ba34b1ab8dff657101e26", "alias": []}, "msg": "ui-tree: render any clientside README files in tree view", "sig_commit": { "git_time": { "time": 1530589970, "offset": 480 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" }, "sig_author": { "git_time": { "time": 1529303111, "offset": 480 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" }}, "body": "ui-tree: render any clientside README files in tree view\n\nWhile listing the items in tree view, if we spot a filename\nmatching any inline-readme entries from the config file,\nwe stash the first one into walk_tree_context.\n\nAfter the tree view has been shown, if there is a stashed\ninline-readme we render it inline.\n\nSigned-off-by: Andy Green \u003candy@warmcat.com\u003e" , "diff": "diff --git a/ui-tree.c b/ui-tree.c\nindex 98d39ce..2114c27 100644\n--- a/ui-tree.c\n+++ b/ui-tree.c\n@@ -1,6 +1,6 @@\n /* ui-tree.c: functions for tree output\n *\n- * Copyright (C) 2006-2017 cgit Development Team \u003ccgit@lists.zx2c4.com\u003e\n+ * Copyright (C) 2006-2018 cgit Development Team \u003ccgit@lists.zx2c4.com\u003e\n *\n * Licensed under GNU General Public License v2\n * (see COPYING for full license text)\n@@ -12,11 +12,48 @@\n #include \u0022ui-shared.h\u0022\n \n struct walk_tree_context {\n+\tstruct object_id inline_oid;\n \tchar *curr_rev;\n \tchar *match_path;\n+\tchar *inline_filename;\n \tint state;\n };\n \n+struct wildcard {\n+\tconst char *name;\n+\tsize_t len;\n+};\n+\n+static int check_wildcards(struct string_list_item *s, void *arg)\n+{\n+\tstruct wildcard *wc \u003d arg;\n+\tint n;\n+\n+\tif (!strcmp(s-\u003estring, wc-\u003ename))\n+\t\treturn 1;\n+\n+\tif (s-\u003estring[0] !\u003d '*')\n+\t\treturn 0;\n+\n+\tn \u003d strlen(s-\u003estring);\n+\tif (wc-\u003elen \u003c n - 1)\n+\t\treturn 0;\n+\n+\treturn !strcmp(s-\u003estring + 1, wc-\u003ename + wc-\u003elen - (n - 1));\n+}\n+\n+static int string_list_wildcard_check(struct string_list *sl,\n+\t\t\t\t const char *name)\n+{\n+\tstruct wildcard wc;\n+\n+\twc.name \u003d name;\n+\twc.len \u003d strlen(name);\n+\n+\treturn for_each_string_list(\u0026ctx.repo-\u003einline_readme,\n+\t\t\t\t check_wildcards, \u0026wc);\n+}\n+\n static void print_text_buffer(const char *name, char *buf, unsigned long size)\n {\n \tunsigned long lineno, idx;\n@@ -291,11 +328,19 @@ static int ls_item(const struct object_id *oid, struct strbuf *base,\n \t\t\t\t\u0026fullpath);\n \t} else {\n \t\tchar *ext \u003d strrchr(name, '.');\n+\n \t\tstrbuf_addstr(\u0026class, \u0022ls-blob\u0022);\n \t\tif (ext)\n \t\t\tstrbuf_addf(\u0026class, \u0022 %s\u0022, ext + 1);\n+\n \t\tcgit_tree_link(name, NULL, class.buf, ctx.qry.head,\n \t\t\t walk_tree_ctx-\u003ecurr_rev, fullpath.buf);\n+\n+\t\tif (!walk_tree_ctx-\u003einline_filename \u0026\u0026\n+\t\t string_list_wildcard_check(\u0026ctx.repo-\u003einline_readme, name)) {\n+\t\t\twalk_tree_ctx-\u003einline_filename \u003d xstrdup(pathname);\n+\t\t\toidcpy(\u0026walk_tree_ctx-\u003einline_oid, oid);\n+\t\t}\n \t}\n \thtmlf(\u0022\u003c/td\u003e\u003ctd class\u003d'ls-size'\u003e%li\u003c/td\u003e\u0022, size);\n \n@@ -333,7 +378,40 @@ static void ls_head(void)\n \n static void ls_tail(struct walk_tree_context *walk_tree_ctx)\n {\n+\tenum object_type type;\n+\tchar *buf, *mimetype;\n+\tunsigned long size;\n+\n \thtml(\u0022\u003c/table\u003e\u005cn\u0022);\n+\n+\tif (!walk_tree_ctx-\u003einline_filename)\n+\t\tgoto done;\n+\n+\ttype \u003d oid_object_info(the_repository, \u0026walk_tree_ctx-\u003einline_oid, \u0026size);\n+\tif (type \u003d\u003d OBJ_BAD)\n+\t\tgoto done;\n+\n+\tbuf \u003d read_object_file(\u0026walk_tree_ctx-\u003einline_oid, \u0026type, \u0026size);\n+\tif (!buf)\n+\t\tgoto done;\n+\n+\t/* create a vertical gap between tree nav / inline */\n+\thtml(\u0022\u003ctable class\u003d\u005c\u0022tabs\u005c\u0022\u003e\u003ctr\u003e\u003ctd\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\u0022);\n+\n+\tmimetype \u003d get_mimetype_for_filename(walk_tree_ctx-\u003einline_filename);\n+\n+\thtmlf(\u0022\u003ch2\u003e%s\u003c/h2\u003e\u0022, walk_tree_ctx-\u003einline_filename);\n+\thtml(\u0022\u003cdiv class\u003dblob\u003e\u0026nbsp;\u003c/div\u003e\u005cn\u0022);\n+\n+\tif (mimetype)\n+\t\tinclude_file(walk_tree_ctx-\u003einline_filename, mimetype);\n+\telse\n+\t\tprint_buffer(walk_tree_ctx-\u003einline_filename, buf, size);\n+\n+\tfree(mimetype);\n+\tfree(buf);\n+\n+done:\n \tcgit_print_layout_end();\n }\n \n@@ -441,4 +519,6 @@ void cgit_print_tree(const char *rev, char *path)\n \n cleanup:\n \tfree(walk_tree_ctx.curr_rev);\n+\tif (walk_tree_ctx.inline_filename)\n+\t\tfree(walk_tree_ctx.inline_filename);\n }\n","s":{"c":1745908127,"u": 999}} ],"g": 2702,"chitpc": 0,"ehitpc": 0,"indexed":0 , "ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}