Re: [PATCH v2 04/15] Add source page

2018-06-18 Thread John Keeping
On Mon, Jun 18, 2018 at 10:57:35AM +0800, Andy Green wrote:
> From: John Keeping 
> 
> We are about to introduce rendering of content for the tree view.  This
> source page will allow bypassing the renderer and accessing the content
> of the current tree view.
> 
> Signed-off-by: John Keeping 
> ---

While testing this series, I noticed a slight deficiency in the source
view in that nothing in the header is highlighted.

The following fixup seems like the right thing to do.  What do you
think?

-- >8 --
Subject: [PATCH] fixup! Add source page

Signed-off-by: John Keeping 
---
 ui-shared.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/ui-shared.c b/ui-shared.c
index f358a68..c769ff8 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -1006,6 +1006,10 @@ void cgit_print_pageheader(void)
if (ctx.qry.page && !strcmp(ctx.qry.page, "blame"))
cgit_blame_link("blame", NULL, hc("blame"), 
ctx.qry.head,
ctx.qry.sha1, ctx.qry.vpath);
+   else if (ctx.qry.page && !strcmp(ctx.qry.page, "source"))
+   cgit_source_link("tree", NULL, hc("source"),
+ctx.qry.head, ctx.qry.sha1,
+ctx.qry.vpath);
else
cgit_tree_link("tree", NULL, hc("tree"), ctx.qry.head,
   ctx.qry.sha1, ctx.qry.vpath);
-- 
2.17.1

___
CGit mailing list
CGit@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH v2 04/15] Add source page

2018-06-17 Thread Andy Green
From: John Keeping 

We are about to introduce rendering of content for the tree view.  This
source page will allow bypassing the renderer and accessing the content
of the current tree view.

Signed-off-by: John Keeping 
---
 cmd.c   |6 ++
 ui-shared.c |   10 ++
 ui-shared.h |3 +++
 3 files changed, 19 insertions(+)

diff --git a/cmd.c b/cmd.c
index 63f0ae5..56e21df 100644
--- a/cmd.c
+++ b/cmd.c
@@ -138,6 +138,11 @@ static void refs_fn(void)
cgit_print_refs();
 }
 
+static void source_fn(void)
+{
+   cgit_print_tree(ctx.qry.sha1, ctx.qry.path);
+}
+
 static void snapshot_fn(void)
 {
cgit_print_snapshot(ctx.qry.head, ctx.qry.sha1, ctx.qry.path,
@@ -187,6 +192,7 @@ struct cgit_cmd *cgit_get_cmd(void)
def_cmd(refs, 1, 0, 0),
def_cmd(repolist, 0, 0, 0),
def_cmd(snapshot, 1, 0, 0),
+   def_cmd(source, 1, 1, 0),
def_cmd(stats, 1, 1, 0),
def_cmd(summary, 1, 0, 0),
def_cmd(tag, 1, 0, 0),
diff --git a/ui-shared.c b/ui-shared.c
index ce806f6..2ff9329 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -298,6 +298,12 @@ void cgit_tree_link(const char *name, const char *title, 
const char *class,
reporevlink("tree", name, title, class, head, rev, path);
 }
 
+void cgit_source_link(const char *name, const char *title, const char *class,
+   const char *head, const char *rev, const char *path)
+{
+   reporevlink("source", name, title, class, head, rev, path);
+}
+
 void cgit_plain_link(const char *name, const char *title, const char *class,
 const char *head, const char *rev, const char *path)
 {
@@ -480,6 +486,10 @@ static void cgit_self_link(char *name, const char *title, 
const char *class)
cgit_tree_link(name, title, class, ctx.qry.head,
   ctx.qry.has_sha1 ? ctx.qry.sha1 : NULL,
   ctx.qry.path);
+   else if (!strcmp(ctx.qry.page, "source"))
+   cgit_source_link(name, title, class, ctx.qry.head,
+ctx.qry.has_sha1 ? ctx.qry.sha1 : NULL,
+ctx.qry.path);
else if (!strcmp(ctx.qry.page, "plain"))
cgit_plain_link(name, title, class, ctx.qry.head,
ctx.qry.has_sha1 ? ctx.qry.sha1 : NULL,
diff --git a/ui-shared.h b/ui-shared.h
index b760a17..5923aaf 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -23,6 +23,9 @@ extern void cgit_tag_link(const char *name, const char *title,
 extern void cgit_tree_link(const char *name, const char *title,
   const char *class, const char *head,
   const char *rev, const char *path);
+extern void cgit_source_link(const char *name, const char *title,
+const char *class, const char *head,
+const char *rev, const char *path);
 extern void cgit_plain_link(const char *name, const char *title,
const char *class, const char *head,
const char *rev, const char *path);

___
CGit mailing list
CGit@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/cgit