]>
git.cameronkatri.com Git - cgit.git/blob - ui-summary.c
1 /* ui-summary.c: functions for generating repo summary page
3 * Copyright (C) 2006-2014 cgit Development Team <cgit@lists.zx2c4.com>
5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text)
10 #include "ui-summary.h"
15 #include "ui-shared.h"
20 static void print_url(const char *url
)
24 if (ctx
.repo
->enable_log_filecount
)
26 if (ctx
.repo
->enable_log_linecount
)
30 htmlf("<tr class='nohover'><td colspan='%d'> </td></tr>", columns
);
31 htmlf("<tr class='nohover'><th class='left' colspan='%d'>Clone</th></tr>\n", columns
);
34 htmlf("<tr><td colspan='%d'><a rel='vcs-git' href='", columns
);
37 html_attr(ctx
.repo
->name
);
38 html(" Git repository'>");
40 html("</a></td></tr>\n");
43 void cgit_print_summary(void)
47 if (ctx
.repo
->enable_log_filecount
)
49 if (ctx
.repo
->enable_log_linecount
)
52 html("<table summary='repository info' class='list nowrap'>");
53 cgit_print_branches(ctx
.cfg
.summary_branches
);
54 htmlf("<tr class='nohover'><td colspan='%d'> </td></tr>", columns
);
55 cgit_print_tags(ctx
.cfg
.summary_tags
);
56 if (ctx
.cfg
.summary_log
> 0) {
57 htmlf("<tr class='nohover'><td colspan='%d'> </td></tr>", columns
);
58 cgit_print_log(ctx
.qry
.head
, 0, ctx
.cfg
.summary_log
, NULL
,
62 cgit_add_clone_urls(print_url
);
66 /* The caller must free the return value. */
67 static char* append_readme_path(const char *filename
, const char *ref
, const char *path
)
69 char *file
, *base_dir
, *full_path
, *resolved_base
= NULL
, *resolved_full
= NULL
;
70 /* If a subpath is specified for the about page, make it relative
71 * to the directory containing the configured readme. */
73 file
= xstrdup(filename
);
74 base_dir
= dirname(file
);
75 if (!strcmp(base_dir
, ".") || !strcmp(base_dir
, "..")) {
80 full_path
= xstrdup(path
);
82 full_path
= fmtalloc("%s/%s", base_dir
, path
);
85 resolved_base
= realpath(base_dir
, NULL
);
86 resolved_full
= realpath(full_path
, NULL
);
87 if (!resolved_base
|| !resolved_full
|| !starts_with(resolved_full
, resolved_base
)) {
100 void cgit_print_repo_readme(char *path
)
102 char *filename
, *ref
;
103 int free_filename
= 0;
105 if (ctx
.repo
->readme
.nr
== 0)
108 filename
= ctx
.repo
->readme
.items
[0].string
;
109 ref
= ctx
.repo
->readme
.items
[0].util
;
113 filename
= append_readme_path(filename
, ref
, path
);
118 /* Print the calculated readme, either from the git repo or from the
119 * filesystem, while applying the about-filter.
121 html("<div id='summary'>");
122 cgit_open_filter(ctx
.repo
->about_filter
, filename
);
124 cgit_print_file(filename
, ref
, 1);
126 html_include(filename
);
127 cgit_close_filter(ctx
.repo
->about_filter
);