abouttreesummaryrefslogcommitdiff
diff options
context:
space:
mode:
authorpatrick-scho2025-12-01 01:05:31 +0100
committerpatrick-scho2025-12-01 01:05:31 +0100
commitcc0722edd0776bacaec72e9b0e7a39983ee45e1e (patch)
tree10c5b7ff428b85498a8002b17f71678da41faa18
parente8a031e1a565111169213d7fc13db4dd14fd926e (diff)
downloadps-cgit-cc0722edd0776bacaec72e9b0e7a39983ee45e1e.tar.gz
ps-cgit-cc0722edd0776bacaec72e9b0e7a39983ee45e1e.zip
moar changez
-rw-r--r--ui-summary.c72
-rw-r--r--ui-summary.h1
-rw-r--r--ui-tree.c21
3 files changed, 65 insertions, 29 deletions
diff --git a/ui-summary.c b/ui-summary.c
index 19a6e0d..b5224f2 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -105,15 +105,6 @@ void cgit_print_repo_readme(const char *path)
char *filename, *ref, *mimetype;
int free_filename = 0;
- // summary {{{
- int columns = 3;
-
- if (ctx.repo->enable_log_filecount)
- columns++;
- if (ctx.repo->enable_log_linecount)
- columns++;
- // }}}
-
mimetype = get_mimetype_for_filename(path);
if (mimetype && (!strncmp(mimetype, "image/", 6) || !strncmp(mimetype, "video/", 6))) {
ctx.page.mimetype = mimetype;
@@ -153,21 +144,56 @@ void cgit_print_repo_readme(const char *path)
if (free_filename)
free(filename);
- // summary {{{
- html("<table summary='repository info' class='list nowrap'>");
- cgit_print_branches(ctx.cfg.summary_branches);
- htmlf("<tr class='nohover'><td colspan='%d'>&nbsp;</td></tr>", columns);
- cgit_print_tags(ctx.cfg.summary_tags);
- if (ctx.cfg.summary_log > 0) {
- htmlf("<tr class='nohover'><td colspan='%d'>&nbsp;</td></tr>", columns);
- cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL,
- NULL, NULL, 0, 0, 0);
- }
- urls = 0;
- cgit_add_clone_urls(print_url);
- html("</table>");
- // }}}
done:
cgit_print_layout_end();
}
+
+void cgit_print_repo_readme_no_layout(const char *path)
+{
+ char *filename, *ref, *mimetype;
+ int free_filename = 0;
+
+ mimetype = get_mimetype_for_filename(path);
+ if (mimetype && (!strncmp(mimetype, "image/", 6) || !strncmp(mimetype, "video/", 6))) {
+ ctx.page.mimetype = mimetype;
+ ctx.page.charset = NULL;
+ cgit_print_plain();
+ free(mimetype);
+ return;
+ }
+ free(mimetype);
+
+ // cgit_print_layout_start();
+ if (ctx.repo->readme.nr == 0)
+ goto done;
+
+ filename = ctx.repo->readme.items[0].string;
+ ref = ctx.repo->readme.items[0].util;
+
+ if (path) {
+ free_filename = 1;
+ filename = append_readme_path(filename, ref, path);
+ if (!filename)
+ goto done;
+ }
+
+ /* Print the calculated readme, either from the git repo or from the
+ * filesystem, while applying the about-filter.
+ */
+ html("<div id='summary'>");
+ cgit_open_filter(ctx.repo->about_filter, filename);
+ if (ref)
+ cgit_print_file(filename, ref, 1);
+ else
+ html_include(filename);
+ cgit_close_filter(ctx.repo->about_filter);
+
+ html("</div>");
+ if (free_filename)
+ free(filename);
+
+
+done:
+ // cgit_print_layout_end();
+}
diff --git a/ui-summary.h b/ui-summary.h
index cba696a..4118fb9 100644
--- a/ui-summary.h
+++ b/ui-summary.h
@@ -3,5 +3,6 @@
extern void cgit_print_summary(void);
extern void cgit_print_repo_readme(const char *path);
+extern void cgit_print_repo_readme_no_layout(const char *path);
#endif /* UI_SUMMARY_H */
diff --git a/ui-tree.c b/ui-tree.c
index 1e4efb2..2e632ee 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -273,9 +273,11 @@ static void ls_head(void)
html("</tr>\n");
}
-static void ls_tail(void)
+static void ls_tail(const char *readme_path)
{
html("</table>\n");
+ if (readme_path)
+ cgit_print_repo_readme_no_layout(readme_path);
cgit_print_layout_end();
}
@@ -296,7 +298,8 @@ static void ls_tree(const struct object_id *oid, const char *path, struct walk_t
ls_head();
read_tree_recursive(the_repository, tree, "", 0, 1,
&paths, ls_item, walk_tree_ctx);
- ls_tail();
+ const char *readme_path = "readme.md";
+ ls_tail(readme_path);
}
@@ -378,12 +381,18 @@ void cgit_print_tree(const char *rev, char *path)
repo_get_commit_tree(the_repository, commit),
"", 0, 0,
&paths, walk_tree, &walk_tree_ctx);
- if (walk_tree_ctx.state == 1)
- ls_tail();
- else if (walk_tree_ctx.state == 2)
+ const char *readme_path = "readme.md"; // TODO: add more readme options
+ if (walk_tree_ctx.state == 1) {
+ ls_tail(readme_path);
+ }
+ else if (walk_tree_ctx.state == 2) {
+ if (readme_path)
+ cgit_print_repo_readme_no_layout(readme_path);
cgit_print_layout_end();
- else
+ }
+ else {
cgit_print_error_page(404, "Not found", "Path not found");
+ }
cleanup:
free(walk_tree_ctx.curr_rev);