List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH 1/3] html.c: add html_intoption()
  2011-03-06 23:57 [PATCH 0/3] Create control panels for user options hjemli
@ 2011-03-06 22:57 ` hjemli
  2011-03-06 22:59 ` [PATCH 2/3] ui-diff.c: create a control panel for diff options hjemli
  2011-03-06 23:00 ` [PATCH 3/3] ui-stats.c: create a control panel for stat options hjemli
  2 siblings, 0 replies; 4+ messages in thread
From: hjemli @ 2011-03-06 22:57 UTC (permalink / raw)


This is similar to html_option, but for int values.

Signed-off-by: Lars Hjemli <hjemli at gmail.com>
---
 html.c |    8 ++++++++
 html.h |    1 +
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/html.c b/html.c
index a60bc13..ae1cef9 100644
--- a/html.c
+++ b/html.c
@@ -211,6 +211,14 @@ void html_option(const char *value, const char *text, const char *selected_value
 	html("</option>\n");
 }
 
+void html_intoption(int value, const char *text, int selected_value)
+{
+	htmlf("<option value='%d'%s>", value,
+	      value == selected_value ? " selected='selected'" : "");
+	html_txt(text);
+	html("</option>");
+}
+
 void html_link_open(const char *url, const char *title, const char *class)
 {
 	html("<a href='");
diff --git a/html.h b/html.h
index 1135fb8..20e1dc2 100644
--- a/html.h
+++ b/html.h
@@ -17,6 +17,7 @@ extern void html_url_path(const char *txt);
 extern void html_url_arg(const char *txt);
 extern void html_hidden(const char *name, const char *value);
 extern void html_option(const char *value, const char *text, const char *selected_value);
+extern void html_intoption(int value, const char *text, int selected_value);
 extern void html_link_open(const char *url, const char *title, const char *class);
 extern void html_link_close(void);
 extern void html_fileperm(unsigned short mode);
-- 
1.7.1





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] ui-diff.c: create a control panel for diff options
  2011-03-06 23:57 [PATCH 0/3] Create control panels for user options hjemli
  2011-03-06 22:57 ` [PATCH 1/3] html.c: add html_intoption() hjemli
@ 2011-03-06 22:59 ` hjemli
  2011-03-06 23:00 ` [PATCH 3/3] ui-stats.c: create a control panel for stat options hjemli
  2 siblings, 0 replies; 4+ messages in thread
From: hjemli @ 2011-03-06 22:59 UTC (permalink / raw)


Signed-off-by: Lars Hjemli <hjemli at gmail.com>
---
 cgit.css    |   27 +++++++++++++++++++
 cmd.c       |    2 +-
 ui-commit.c |   10 ++-----
 ui-diff.c   |   83 ++++++++++++++++++++++++++++++++++++++--------------------
 ui-diff.h   |    4 ++-
 5 files changed, 88 insertions(+), 38 deletions(-)

diff --git a/cgit.css b/cgit.css
index 1d90057..55afa94 100644
--- a/cgit.css
+++ b/cgit.css
@@ -331,6 +331,33 @@ table.commit-info {
 	margin-top: 1.5em;
 }
 
+div.cgit-panel {
+	float: right;
+	margin-top: 1.5em;
+}
+
+div.cgit-panel table {
+	border-collapse: collapse;
+	border: solid 1px #aaa;
+	background-color: #eee;
+}
+
+div.cgit-panel th {
+	text-align: center;
+}
+
+div.cgit-panel td {
+	padding: 0.25em 0.5em;
+}
+
+div.cgit-panel td.label {
+	padding-right: 0.5em;
+}
+
+div.cgit-panel td.ctrl {
+	padding-left: 0.5em;
+}
+
 table.commit-info th {
 	text-align: left;
 	font-weight: normal;
diff --git a/cmd.c b/cmd.c
index 536515b..05d5aaf 100644
--- a/cmd.c
+++ b/cmd.c
@@ -56,7 +56,7 @@ static void commit_fn(struct cgit_context *ctx)
 
 static void diff_fn(struct cgit_context *ctx)
 {
-	cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path);
+	cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path, 1);
 }
 
 static void info_fn(struct cgit_context *ctx)
diff --git a/ui-commit.c b/ui-commit.c
index 2b4f677..536a8e8 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -39,7 +39,8 @@ void cgit_print_commit(char *hex, const char *prefix)
 	format_note(NULL, sha1, &notes, PAGE_ENCODING, 0);
 
 	load_ref_decorations(DECORATE_FULL_REFS);
-
+	
+	cgit_print_diff_ctrls();
 	html("<table summary='commit info' class='commit-info'>\n");
 	html("<tr><th>author</th><td>");
 	html_txt(info->author);
@@ -64,11 +65,6 @@ void cgit_print_commit(char *hex, const char *prefix)
 	cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, prefix, 0);
 	html(" (");
 	cgit_patch_link("patch", NULL, NULL, NULL, tmp, prefix);
-	html(") (");
-	if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff))
-		cgit_commit_link("unidiff", NULL, NULL, ctx.qry.head, tmp, prefix, 1);
-	else
-		cgit_commit_link("side-by-side diff", NULL, NULL, ctx.qry.head, tmp, prefix, 1);
 	html(")</td></tr>\n");
 	html("<tr><th>tree</th><td colspan='2' class='sha1'>");
 	tmp = xstrdup(hex);
@@ -139,7 +135,7 @@ void cgit_print_commit(char *hex, const char *prefix)
 			tmp = sha1_to_hex(commit->parents->item->object.sha1);
 		else
 			tmp = NULL;
-		cgit_print_diff(ctx.qry.sha1, tmp, prefix);
+		cgit_print_diff(ctx.qry.sha1, tmp, prefix, 0);
 	}
 	strbuf_release(&notes);
 	cgit_free_commitinfo(info);
diff --git a/ui-diff.c b/ui-diff.c
index a7bc667..b7767b3 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -167,7 +167,7 @@ static void inspect_filepair(struct diff_filepair *pair)
 void cgit_print_diffstat(const unsigned char *old_sha1,
 			 const unsigned char *new_sha1, const char *prefix)
 {
-	int i, save_context = ctx.qry.context;
+	int i;
 
 	html("<div class='diffstat-header'>");
 	cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1,
@@ -177,19 +177,6 @@ void cgit_print_diffstat(const unsigned char *old_sha1,
 		html_txt(prefix);
 		html("')");
 	}
-	html(" (");
-	ctx.qry.context = (save_context > 0 ? save_context : 3) << 1;
-	cgit_self_link("more", NULL, NULL, &ctx);
-	html("/");
-	ctx.qry.context = (save_context > 3 ? save_context : 3) >> 1;
-	cgit_self_link("less", NULL, NULL, &ctx);
-	ctx.qry.context = save_context;
-	html(" context)");
-	html(" (");
-	ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2;
-	cgit_self_link(ctx.qry.ignorews ? "ignore" : "show", NULL, NULL, &ctx);
-	ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2;
-	html(" whitespace changes)");
 	html("</div>");
 	html("<table summary='diffstat' class='diffstat'>");
 	max_changes = 0;
@@ -278,19 +265,6 @@ static void header(unsigned char *sha1, char *path1, int mode1,
 	html("</div>");
 }
 
-static void print_ssdiff_link()
-{
-	if (!strcmp(ctx.qry.page, "diff")) {
-		if (use_ssdiff)
-			cgit_diff_link("Unidiff", NULL, NULL, ctx.qry.head,
-				       ctx.qry.sha1, ctx.qry.sha2, ctx.qry.path, 1);
-		else
-			cgit_diff_link("Side-by-side diff", NULL, NULL,
-				       ctx.qry.head, ctx.qry.sha1,
-				       ctx.qry.sha2, ctx.qry.path, 1);
-	}
-}
-
 static void filepair_cb(struct diff_filepair *pair)
 {
 	unsigned long old_size = 0;
@@ -330,7 +304,56 @@ static void filepair_cb(struct diff_filepair *pair)
 		cgit_ssdiff_footer();
 }
 
-void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefix)
+void cgit_print_diff_ctrls()
+{
+	int i, curr;
+
+	html("<div class='cgit-panel'>");
+	html("<b>diff options</b>");
+	html("<form method='get' action='.'>");
+	cgit_add_hidden_formfields(1, 0, ctx.qry.page);
+	html("<table>");
+	html("<tr><td colspan='2'/></tr>");
+	html("<tr>");
+	html("<td class='label'>context:</td>");
+	html("<td class='ctrl'>");
+	html("<select name='context' onchange='this.form.submit();'>");
+	curr = ctx.qry.context;
+	if (!curr)
+		curr = 3;
+	for (i = 1; i <= 10; i++)
+		html_intoption(i, fmt("%d", i), curr);
+	for (i = 15; i <= 40; i += 5)
+		html_intoption(i, fmt("%d", i), curr);
+	html("</select>");
+	html("</td>");
+	html("</tr><tr>");
+	html("<td class='label'>space:</td>");
+	html("<td class='ctrl'>");
+	html("<select name='ignorews' onchange='this.form.submit();'>");
+	html_intoption(0, "include", ctx.qry.ignorews);
+	html_intoption(1, "ignore", ctx.qry.ignorews);
+	html("</select>");
+	html("</td>");
+	html("</tr><tr>");
+	html("<td class='label'>mode:</td>");
+	html("<td class='ctrl'>");
+	html("<select name='ss' onchange='this.form.submit();'>");
+	curr = ctx.qry.ssdiff;
+	if (!curr && ctx.cfg.ssdiff)
+		curr = 1;
+	html_intoption(0, "unified", curr);
+	html_intoption(1, "ssdiff", curr);
+	html("</select></td></tr>");
+	html("<tr><td/><td class='ctrl'>");
+	html("<noscript><input type='submit' value='reload'/></noscript>");
+	html("</td></tr></table>");
+	html("</form>");
+	html("</div>");
+}
+
+void cgit_print_diff(const char *new_rev, const char *old_rev,
+		     const char *prefix, int show_ctrls)
 {
 	enum object_type type;
 	unsigned long size;
@@ -369,7 +392,9 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefi
 	if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff))
 		use_ssdiff = 1;
 
-	print_ssdiff_link();
+	if (show_ctrls)
+		cgit_print_diff_ctrls();
+
 	cgit_print_diffstat(old_rev_sha1, new_rev_sha1, prefix);
 
 	if (use_ssdiff) {
diff --git a/ui-diff.h b/ui-diff.h
index 12d0c62..0161ffb 100644
--- a/ui-diff.h
+++ b/ui-diff.h
@@ -1,11 +1,13 @@
 #ifndef UI_DIFF_H
 #define UI_DIFF_H
 
+extern void cgit_print_diff_ctrls();
+
 extern void cgit_print_diffstat(const unsigned char *old_sha1,
 				const unsigned char *new_sha1);
 
 extern void cgit_print_diff(const char *new_hex, const char *old_hex,
-			    const char *prefix);
+			    const char *prefix, int show_ctrls);
 
 extern struct diff_filespec *cgit_get_current_old_file(void);
 extern struct diff_filespec *cgit_get_current_new_file(void);
-- 
1.7.1





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] ui-stats.c: create a control panel for stat options
  2011-03-06 23:57 [PATCH 0/3] Create control panels for user options hjemli
  2011-03-06 22:57 ` [PATCH 1/3] html.c: add html_intoption() hjemli
  2011-03-06 22:59 ` [PATCH 2/3] ui-diff.c: create a control panel for diff options hjemli
@ 2011-03-06 23:00 ` hjemli
  2 siblings, 0 replies; 4+ messages in thread
From: hjemli @ 2011-03-06 23:00 UTC (permalink / raw)


Signed-off-by: Lars Hjemli <hjemli at gmail.com>
---
 ui-stats.c |   51 +++++++++++++++++++++++++++------------------------
 1 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/ui-stats.c b/ui-stats.c
index 2a0c174..36e17d9 100644
--- a/ui-stats.c
+++ b/ui-stats.c
@@ -386,6 +386,33 @@ void cgit_show_stats(struct cgit_context *ctx)
 	top = ctx->qry.ofs;
 	if (!top)
 		top = 10;
+
+	html("<div class='cgit-panel'>");
+	html("<b>stat options</b>");
+	html("<form method='get' action=''>");
+	cgit_add_hidden_formfields(1, 0, "stats");
+	html("<table><tr><td colspan='2'/></tr>");
+	if (ctx->repo->max_stats > 1) {
+		html("<tr><td class='label'>Period:</td>");
+		html("<td class='ctrl'><select name='period' onchange='this.form.submit();'>");
+		for (i = 0; i < ctx->repo->max_stats; i++)
+			html_option(fmt("%c", periods[i].code),
+				    periods[i].name, fmt("%c", period->code));
+		html("</select></td></tr>");
+	}
+	html("<tr><td class='label'>Authors:</td>");
+	html("<td class='ctrl'><select name='ofs' onchange='this.form.submit();'>");
+	html_intoption(10, "10", top);
+	html_intoption(25, "25", top);
+	html_intoption(50, "50", top);
+	html_intoption(100, "100", top);
+	html_intoption(-1, "all", top);
+	html("</select></td><tr>");
+	html("<tr><td/><td class='ctrl'>");
+	html("<noscript><input type='submit' value='Reload'/></noscript>");
+	html("</td></tr></table>");
+	html("</form>");
+	html("</div>");
 	htmlf("<h2>Commits per author per %s", period->name);
 	if (ctx->qry.path) {
 		html(" (path '");
@@ -393,30 +420,6 @@ void cgit_show_stats(struct cgit_context *ctx)
 		html("')");
 	}
 	html("</h2>");
-
-	html("<form method='get' action='' style='float: right; text-align: right;'>");
-	cgit_add_hidden_formfields(1, 0, "stats");
-	if (ctx->repo->max_stats > 1) {
-		html("Period: ");
-		html("<select name='period' onchange='this.form.submit();'>");
-		for (i = 0; i < ctx->repo->max_stats; i++)
-			htmlf("<option value='%c'%s>%s</option>",
-				periods[i].code,
-				period == &periods[i] ? " selected" : "",
-				periods[i].name);
-		html("</select><br/><br/>");
-	}
-	html("Authors: ");
-	html("");
-	html("<select name='ofs' onchange='this.form.submit();'>");
-	htmlf("<option value='10'%s>10</option>", top == 10 ? " selected" : "");
-	htmlf("<option value='25'%s>25</option>", top == 25 ? " selected" : "");
-	htmlf("<option value='50'%s>50</option>", top == 50 ? " selected" : "");
-	htmlf("<option value='100'%s>100</option>", top == 100 ? " selected" : "");
-	htmlf("<option value='-1'%s>All</option>", top == -1 ? " selected" : "");
-	html("</select>");
-	html("<noscript>&nbsp;&nbsp;<input type='submit' value='Reload'/></noscript>");
-	html("</form>");
 	print_authors(&authors, top, period);
 }
 
-- 
1.7.1





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 0/3] Create control panels for user options
@ 2011-03-06 23:57 hjemli
  2011-03-06 22:57 ` [PATCH 1/3] html.c: add html_intoption() hjemli
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: hjemli @ 2011-03-06 23:57 UTC (permalink / raw)


This patch series introduces a control panel for the commit, diff and
stat pages, which is intended to make the user options on these pages
more accessible.

Lars Hjemli (3):
  html.c: add html_intoption()
  ui-diff.c: create a control panel for diff options
  ui-stats.c: create a control panel for stat options

 cgit.css    |   27 +++++++++++++++++++
 cmd.c       |    2 +-
 html.c      |    8 +++++
 html.h      |    1 +
 ui-commit.c |   10 ++-----
 ui-diff.c   |   83 ++++++++++++++++++++++++++++++++++++++--------------------
 ui-diff.h   |    4 ++-
 ui-stats.c  |   51 +++++++++++++++++++-----------------
 8 files changed, 124 insertions(+), 62 deletions(-)





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-03-06 23:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-06 23:57 [PATCH 0/3] Create control panels for user options hjemli
2011-03-06 22:57 ` [PATCH 1/3] html.c: add html_intoption() hjemli
2011-03-06 22:59 ` [PATCH 2/3] ui-diff.c: create a control panel for diff options hjemli
2011-03-06 23:00 ` [PATCH 3/3] ui-stats.c: create a control panel for stat options hjemli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).