|
diff --git a/cmd.c b/cmd.c index e0eacbe..6cc91e6 100644 --- a/ cmd.c+++ b/ cmd.c |
|
@@ -7,32 +7,40 @@ |
7 | */ |
7 | */ |
8 | |
8 | |
9 | #include "cgit.h" |
9 | #include "cgit.h" |
10 | #include "cmd.h" |
10 | #include "cmd.h" |
11 | #include "ui-blob.h" |
11 | #include "ui-blob.h" |
12 | #include "ui-commit.h" |
12 | #include "ui-commit.h" |
13 | #include "ui-diff.h" |
13 | #include "ui-diff.h" |
14 | #include "ui-log.h" |
14 | #include "ui-log.h" |
15 | #include "ui-patch.h" |
15 | #include "ui-patch.h" |
16 | #include "ui-refs.h" |
16 | #include "ui-refs.h" |
17 | #include "ui-repolist.h" |
17 | #include "ui-repolist.h" |
18 | #include "ui-snapshot.h" |
18 | #include "ui-snapshot.h" |
19 | #include "ui-summary.h" |
19 | #include "ui-summary.h" |
20 | #include "ui-tag.h" |
20 | #include "ui-tag.h" |
21 | #include "ui-tree.h" |
21 | #include "ui-tree.h" |
22 | |
22 | |
| |
23 | static void about_fn(struct cgit_context *ctx) |
| |
24 | { |
| |
25 | if (ctx->repo) |
| |
26 | cgit_print_repo_readme(); |
| |
27 | else |
| |
28 | cgit_print_site_readme(); |
| |
29 | } |
| |
30 | |
23 | static void blob_fn(struct cgit_context *ctx) |
31 | static void blob_fn(struct cgit_context *ctx) |
24 | { |
32 | { |
25 | cgit_print_blob(ctx->qry.sha1, ctx->qry.path); |
33 | cgit_print_blob(ctx->qry.sha1, ctx->qry.path); |
26 | } |
34 | } |
27 | |
35 | |
28 | static void commit_fn(struct cgit_context *ctx) |
36 | static void commit_fn(struct cgit_context *ctx) |
29 | { |
37 | { |
30 | cgit_print_commit(ctx->qry.sha1); |
38 | cgit_print_commit(ctx->qry.sha1); |
31 | } |
39 | } |
32 | |
40 | |
33 | static void diff_fn(struct cgit_context *ctx) |
41 | static void diff_fn(struct cgit_context *ctx) |
34 | { |
42 | { |
35 | cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path); |
43 | cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path); |
36 | } |
44 | } |
37 | |
45 | |
38 | static void repolist_fn(struct cgit_context *ctx) |
46 | static void repolist_fn(struct cgit_context *ctx) |
@@ -71,32 +79,33 @@ static void summary_fn(struct cgit_context *ctx) |
71 | static void tag_fn(struct cgit_context *ctx) |
79 | static void tag_fn(struct cgit_context *ctx) |
72 | { |
80 | { |
73 | cgit_print_tag(ctx->qry.sha1); |
81 | cgit_print_tag(ctx->qry.sha1); |
74 | } |
82 | } |
75 | |
83 | |
76 | static void tree_fn(struct cgit_context *ctx) |
84 | static void tree_fn(struct cgit_context *ctx) |
77 | { |
85 | { |
78 | cgit_print_tree(ctx->qry.sha1, ctx->qry.path); |
86 | cgit_print_tree(ctx->qry.sha1, ctx->qry.path); |
79 | } |
87 | } |
80 | |
88 | |
81 | #define def_cmd(name, want_repo, want_layout) \ |
89 | #define def_cmd(name, want_repo, want_layout) \ |
82 | {#name, name##_fn, want_repo, want_layout} |
90 | {#name, name##_fn, want_repo, want_layout} |
83 | |
91 | |
84 | struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx) |
92 | struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx) |
85 | { |
93 | { |
86 | static struct cgit_cmd cmds[] = { |
94 | static struct cgit_cmd cmds[] = { |
| |
95 | def_cmd(about, 0, 1), |
87 | def_cmd(blob, 1, 0), |
96 | def_cmd(blob, 1, 0), |
88 | def_cmd(commit, 1, 1), |
97 | def_cmd(commit, 1, 1), |
89 | def_cmd(diff, 1, 1), |
98 | def_cmd(diff, 1, 1), |
90 | def_cmd(log, 1, 1), |
99 | def_cmd(log, 1, 1), |
91 | def_cmd(patch, 1, 0), |
100 | def_cmd(patch, 1, 0), |
92 | def_cmd(refs, 1, 1), |
101 | def_cmd(refs, 1, 1), |
93 | def_cmd(repolist, 0, 0), |
102 | def_cmd(repolist, 0, 0), |
94 | def_cmd(snapshot, 1, 0), |
103 | def_cmd(snapshot, 1, 0), |
95 | def_cmd(summary, 1, 1), |
104 | def_cmd(summary, 1, 1), |
96 | def_cmd(tag, 1, 1), |
105 | def_cmd(tag, 1, 1), |
97 | def_cmd(tree, 1, 1), |
106 | def_cmd(tree, 1, 1), |
98 | }; |
107 | }; |
99 | int i; |
108 | int i; |
100 | |
109 | |
101 | if (ctx->qry.page == NULL) { |
110 | if (ctx->qry.page == NULL) { |
102 | if (ctx->repo) |
111 | if (ctx->repo) |
|