List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH 1/2] ui-shared: add homepage to tabs
@ 2016-02-22 15:39 Jason
  2016-02-22 15:39 ` [PATCH 2/2] cmd: redirect empty about/ to homepage or summary Jason
  2016-02-22 15:42 ` [PATCH 1/2] ui-shared: add homepage to tabs Jason
  0 siblings, 2 replies; 10+ messages in thread
From: Jason @ 2016-02-22 15:39 UTC (permalink / raw)


Signed-off-by: Jason A. Donenfeld <Jason at zx2c4.com>
---
 cgit.c       |  4 ++++
 cgit.h       |  1 +
 cgitrc.5.txt | 13 ++++++++-----
 scan-tree.c  |  2 ++
 shared.c     |  1 +
 ui-shared.c  |  5 +++++
 6 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/cgit.c b/cgit.c
index 7f83a2d..fc482be 100644
--- a/cgit.c
+++ b/cgit.c
@@ -41,6 +41,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va
 		repo->desc = xstrdup(value);
 	else if (!strcmp(name, "owner"))
 		repo->owner = xstrdup(value);
+	else if (!strcmp(name, "homepage"))
+		repo->homepage = xstrdup(value);
 	else if (!strcmp(name, "defbranch"))
 		repo->defbranch = xstrdup(value);
 	else if (!strcmp(name, "snapshots"))
@@ -793,6 +795,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
 		fprintf(f, "repo.module-link=%s\n", repo->module_link);
 	if (repo->section)
 		fprintf(f, "repo.section=%s\n", repo->section);
+	if (repo->homepage)
+		fprintf(f, "repo.homepage=%s\n", repo->homepage);
 	if (repo->clone_url)
 		fprintf(f, "repo.clone-url=%s\n", repo->clone_url);
 	fprintf(f, "repo.enable-commit-graph=%d\n",
diff --git a/cgit.h b/cgit.h
index d10c799..325432b 100644
--- a/cgit.h
+++ b/cgit.h
@@ -81,6 +81,7 @@ struct cgit_repo {
 	char *path;
 	char *desc;
 	char *owner;
+	char *homepage;
 	char *defbranch;
 	char *module_link;
 	struct string_list readme;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 47850a8..94901bd 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -205,11 +205,11 @@ enable-git-config::
 	Flag which, when set to "1", will allow cgit to use git config to set
 	any repo specific settings. This option is used in conjunction with
 	"scan-path", and must be defined prior, to augment repo-specific
-	settings. The keys gitweb.owner, gitweb.category, and gitweb.description
-	will map to the cgit keys repo.owner, repo.section, and repo.desc,
-	respectively. All git config keys that begin with "cgit." will be mapped
-	to the corresponding "repo." key in cgit. Default value: "0". See also:
-	scan-path, section-from-path.
+	settings. The keys gitweb.owner, gitweb.category, gitweb.description,
+	and gitweb.homepage will map to the cgit keys repo.owner, repo.section,
+	repo.desc, and repo.homepage respectively. All git config keys that begin
+	with "cgit." will be mapped to the corresponding "repo." key in cgit.
+	Default value: "0". See also: scan-path, section-from-path.
 
 favicon::
 	Url used as link to a shortcut icon for cgit. It is suggested to use
@@ -496,6 +496,9 @@ repo.defbranch::
 repo.desc::
 	The value to show as repository description. Default value: none.
 
+repo.homepage::
+	The value to show as repository homepage. Default value: none.
+
 repo.email-filter::
 	Override the default email-filter. Default value: none. See also:
 	"enable-filter-overrides". See also: "FILTER API".
diff --git a/scan-tree.c b/scan-tree.c
index b5a10ff..2e87999 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -61,6 +61,8 @@ static int gitconfig_config(const char *key, const char *value, void *cb)
 		config_fn(repo, "desc", value);
 	else if (!strcmp(key, "gitweb.category"))
 		config_fn(repo, "section", value);
+	else if (!strcmp(key, "gitweb.homepage"))
+		config_fn(repo, "homepage", value);
 	else if (starts_with(key, "cgit."))
 		config_fn(repo, key + 5, value);
 
diff --git a/shared.c b/shared.c
index a078a27..a63633b 100644
--- a/shared.c
+++ b/shared.c
@@ -54,6 +54,7 @@ struct cgit_repo *cgit_add_repo(const char *url)
 	ret->path = NULL;
 	ret->desc = cgit_default_repo_desc;
 	ret->owner = NULL;
+	ret->homepage = NULL;
 	ret->section = ctx.cfg.section;
 	ret->snapshots = ctx.cfg.snapshots;
 	ret->enable_commit_graph = ctx.cfg.enable_commit_graph;
diff --git a/ui-shared.c b/ui-shared.c
index 03dcc08..8c2d851 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -997,6 +997,11 @@ void cgit_print_pageheader(void)
 		if (ctx.repo->max_stats)
 			cgit_stats_link("stats", NULL, hc("stats"),
 					ctx.qry.head, ctx.qry.vpath);
+		if (ctx.repo->homepage) {
+			html("<a href='");
+			html_attr(ctx.repo->homepage);
+			html("' target='_blank'>homepage &#x27a6;</a>");
+		}
 		html("</td><td class='form'>");
 		html("<form class='right' method='get' action='");
 		if (ctx.cfg.virtual_root) {
-- 
2.7.1



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

* [PATCH 2/2] cmd: redirect empty about/ to homepage or summary
  2016-02-22 15:39 [PATCH 1/2] ui-shared: add homepage to tabs Jason
@ 2016-02-22 15:39 ` Jason
  2016-02-22 15:42 ` [PATCH 1/2] ui-shared: add homepage to tabs Jason
  1 sibling, 0 replies; 10+ messages in thread
From: Jason @ 2016-02-22 15:39 UTC (permalink / raw)


Signed-off-by: Jason A. Donenfeld <Jason at zx2c4.com>
---
 cmd.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/cmd.c b/cmd.c
index 3093c62..0375c5a 100644
--- a/cmd.c
+++ b/cmd.c
@@ -47,8 +47,17 @@ static void about_fn(void)
 			cgit_redirect(redirect, true);
 			free(currenturl);
 			free(redirect);
-		} else
+		} else if (ctx.repo->readme.nr)
 			cgit_print_repo_readme(ctx.qry.path);
+		else if (ctx.repo->homepage)
+			cgit_redirect(ctx.repo->homepage, false);
+		else {
+			char *currenturl = cgit_currenturl();
+			char *redirect = fmtalloc("%s../", currenturl);
+			cgit_redirect(redirect, false);
+			free(currenturl);
+			free(redirect);
+		}
 	} else
 		cgit_print_site_readme();
 }
-- 
2.7.1



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

* [PATCH 1/2] ui-shared: add homepage to tabs
  2016-02-22 15:39 [PATCH 1/2] ui-shared: add homepage to tabs Jason
  2016-02-22 15:39 ` [PATCH 2/2] cmd: redirect empty about/ to homepage or summary Jason
@ 2016-02-22 15:42 ` Jason
  2016-02-22 17:03   ` john
  2016-02-23  6:49   ` peter
  1 sibling, 2 replies; 10+ messages in thread
From: Jason @ 2016-02-22 15:42 UTC (permalink / raw)


Seems like a very useful feature. I'd like some feedback on &#x27a6; though.

It'd be nice to have this:
http://fortawesome.github.io/Font-Awesome/icon/external-link/
or this:
http://www.fileformat.info/info/unicode/char/1f517/index.htm

But the former is overhead I won't accept and the latter isn't
available in all browsers.

Thoughts?


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

* [PATCH 1/2] ui-shared: add homepage to tabs
  2016-02-22 15:42 ` [PATCH 1/2] ui-shared: add homepage to tabs Jason
@ 2016-02-22 17:03   ` john
  2016-02-22 17:12     ` Jason
  2016-02-23  6:49   ` peter
  1 sibling, 1 reply; 10+ messages in thread
From: john @ 2016-02-22 17:03 UTC (permalink / raw)


On Mon, Feb 22, 2016 at 04:42:12PM +0100, Jason A. Donenfeld wrote:
> Seems like a very useful feature. I'd like some feedback on &#x27a6; though.
> 
> It'd be nice to have this:
> http://fortawesome.github.io/Font-Awesome/icon/external-link/
> or this:
> http://www.fileformat.info/info/unicode/char/1f517/index.htm
> 
> But the former is overhead I won't accept and the latter isn't
> available in all browsers.
> 
> Thoughts?

I'm not convinced by the arrow, I wonder if we'd be better off inlining
Wikipedia's external link image [1] as base64; it's quite small and is
licensed as GPLv2.

It might be nice to move this into CSS with an "external_link" class and
use :after to apply the image which will make per-site customization
easier.


[1] https://commons.wikimedia.org/wiki/File:Icon_External_Link.png


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

* [PATCH 1/2] ui-shared: add homepage to tabs
  2016-02-22 17:03   ` john
@ 2016-02-22 17:12     ` Jason
  2016-02-22 17:29       ` Jason
  0 siblings, 1 reply; 10+ messages in thread
From: Jason @ 2016-02-22 17:12 UTC (permalink / raw)


Hi John,

I actually started doing that initially, with the base64 src of that exact
image, but then found that it looked bad with custom CSS, since a PNG,
unlike a font, embeds the color.

But, adding it into the CSS instead makes lots of sense. Great thinking.

Jason

On Mon, Feb 22, 2016 at 6:03 PM, John Keeping <john at keeping.me.uk> wrote:

> On Mon, Feb 22, 2016 at 04:42:12PM +0100, Jason A. Donenfeld wrote:
> > Seems like a very useful feature. I'd like some feedback on &#x27a6;
> though.
> >
> > It'd be nice to have this:
> > http://fortawesome.github.io/Font-Awesome/icon/external-link/
> > or this:
> > http://www.fileformat.info/info/unicode/char/1f517/index.htm
> >
> > But the former is overhead I won't accept and the latter isn't
> > available in all browsers.
> >
> > Thoughts?
>
> I'm not convinced by the arrow, I wonder if we'd be better off inlining
> Wikipedia's external link image [1] as base64; it's quite small and is
> licensed as GPLv2.
>
> It might be nice to move this into CSS with an "external_link" class and
> use :after to apply the image which will make per-site customization
> easier.
>
>
> [1] https://commons.wikimedia.org/wiki/File:Icon_External_Link.png
>



-- 
Jason A. Donenfeld
Deep Space Explorer
fr: +33 6 51 90 82 66
us: +1 513 476 1200
www.jasondonenfeld.com
www.zx2c4.com
zx2c4.com/keys/AB9942E6D4A4CFC3412620A749FC7012A5DE03AE.asc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20160222/61c9b916/attachment.html>


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

* [PATCH 1/2] ui-shared: add homepage to tabs
  2016-02-22 17:12     ` Jason
@ 2016-02-22 17:29       ` Jason
  0 siblings, 0 replies; 10+ messages in thread
From: Jason @ 2016-02-22 17:29 UTC (permalink / raw)


Here we go:
https://git.zx2c4.com/cgit/commit/?h=jd/zx2c4-deployment&id=e160fa1fe7efbae91ff04992df0b3464f43a4426

You can see it in action here:
https://git.zx2c4.com/password-store/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20160222/446aab43/attachment.html>


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

* [PATCH 1/2] ui-shared: add homepage to tabs
  2016-02-22 15:42 ` [PATCH 1/2] ui-shared: add homepage to tabs Jason
  2016-02-22 17:03   ` john
@ 2016-02-23  6:49   ` peter
  2016-02-23 14:26     ` Jason
  1 sibling, 1 reply; 10+ messages in thread
From: peter @ 2016-02-23  6:49 UTC (permalink / raw)


Hi Jason,

Thank you for this patch, this is indeed a very useful feature.

Would you reconsider opening the homepage link in the current tab
by default? This way visitors have the option to open the homepage
in new tab if they like (e.g., using middle-click), but they are not
forced to do so.

Regards,
Peter


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

* [PATCH 1/2] ui-shared: add homepage to tabs
  2016-02-23  6:49   ` peter
@ 2016-02-23 14:26     ` Jason
  2016-02-23 14:32       ` john
  0 siblings, 1 reply; 10+ messages in thread
From: Jason @ 2016-02-23 14:26 UTC (permalink / raw)


On Tue, Feb 23, 2016 at 7:49 AM, Peter Colberg <peter at colberg.org> wrote:
> Would you reconsider opening the homepage link in the current tab
> by default? This way visitors have the option to open the homepage
> in new tab if they like (e.g., using middle-click), but they are not
> forced to do so.

As I understand it, this is one of those things where people who
learned HTML in the 90s love target=_blank, but Web 9.0 hipsters now
all deplore target=_blank, for good reasons probably, and write
articles in markdown decrying the use.  Unfortunately, I'm one of
those 90s luddites. So...

Does anybody have strong opinions one way or another about this? I'm
happy to get rid of target=_blank if others care about this too.


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

* [PATCH 1/2] ui-shared: add homepage to tabs
  2016-02-23 14:26     ` Jason
@ 2016-02-23 14:32       ` john
  2016-02-23 14:36         ` Jason
  0 siblings, 1 reply; 10+ messages in thread
From: john @ 2016-02-23 14:32 UTC (permalink / raw)


On Tue, Feb 23, 2016 at 03:26:28PM +0100, Jason A. Donenfeld wrote:
> On Tue, Feb 23, 2016 at 7:49 AM, Peter Colberg <peter at colberg.org> wrote:
> > Would you reconsider opening the homepage link in the current tab
> > by default? This way visitors have the option to open the homepage
> > in new tab if they like (e.g., using middle-click), but they are not
> > forced to do so.
> 
> As I understand it, this is one of those things where people who
> learned HTML in the 90s love target=_blank, but Web 9.0 hipsters now
> all deplore target=_blank, for good reasons probably, and write
> articles in markdown decrying the use.  Unfortunately, I'm one of
> those 90s luddites. So...
> 
> Does anybody have strong opinions one way or another about this? I'm
> happy to get rid of target=_blank if others care about this too.

I prefer being in control of where links open and get annoyed when it
seems like nothing has happened and I have to hunt for a new tab so I'm
with Peter in favour of removing it.


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

* [PATCH 1/2] ui-shared: add homepage to tabs
  2016-02-23 14:32       ` john
@ 2016-02-23 14:36         ` Jason
  0 siblings, 0 replies; 10+ messages in thread
From: Jason @ 2016-02-23 14:36 UTC (permalink / raw)


Fixed.
https://git.zx2c4.com/cgit/commit/?id=c424b5cb0253d8b55d3932efa51aa703dab2bf40


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

end of thread, other threads:[~2016-02-23 14:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-22 15:39 [PATCH 1/2] ui-shared: add homepage to tabs Jason
2016-02-22 15:39 ` [PATCH 2/2] cmd: redirect empty about/ to homepage or summary Jason
2016-02-22 15:42 ` [PATCH 1/2] ui-shared: add homepage to tabs Jason
2016-02-22 17:03   ` john
2016-02-22 17:12     ` Jason
2016-02-22 17:29       ` Jason
2016-02-23  6:49   ` peter
2016-02-23 14:26     ` Jason
2016-02-23 14:32       ` john
2016-02-23 14:36         ` Jason

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).