git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gitweb: make HTML links out of http/https URLs in changelogs
@ 2006-11-21 22:02 Kir Kolyshkin
  2006-11-21 22:28 ` Jakub Narebski
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Kir Kolyshkin @ 2006-11-21 22:02 UTC (permalink / raw)
  To: git

It is a common practice to put links to bugzillas, mailing lists, etc. 
in git log entries. The fact that gitweb doesn't make HTML links out of 
that URLs makes following those URLs inconvenient. This patch fixes that 
problem, trying to address cases when URL is enclosed in round or square 
brackets.

Slightly tested on http://git.openvz.org/. Applicable to git-1.4.4.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
---
 gitweb/gitweb.perl |    2 ++
 1 file changed, 2 insertions(+)

--- git-1.4.4/gitweb/gitweb.perl	2006-11-15 08:22:27.000000000 +0100
+++ git-1.4.4-my/gitweb/gitweb.perl	2006-11-21 22:49:14.000000000 +0100
@@ -828,6 +828,8 @@
 			$line =~ s/$hash_text/$link/;
 		}
 	}
+	# make HTML links out of http(s) URLs
+	$line =~ s/(http[s]?:\/\/[^[:space:]\]\)]+)/<a href="\1">\1<\/a>/g;
 	return $line;
 }
 


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

* Re: [PATCH] gitweb: make HTML links out of http/https URLs in changelogs
  2006-11-21 22:02 [PATCH] gitweb: make HTML links out of http/https URLs in changelogs Kir Kolyshkin
@ 2006-11-21 22:28 ` Jakub Narebski
  2006-11-21 23:55 ` Randal L. Schwartz
  2006-11-22  0:06 ` Petr Baudis
  2 siblings, 0 replies; 6+ messages in thread
From: Jakub Narebski @ 2006-11-21 22:28 UTC (permalink / raw)
  To: git

Kir Kolyshkin wrote:

> It is a common practice to put links to bugzillas, mailing lists, etc. 
> in git log entries. The fact that gitweb doesn't make HTML links out of 
> that URLs makes following those URLs inconvenient. This patch fixes that 
> problem, trying to address cases when URL is enclosed in round or square 
> brackets.

Preliminary committags support was sent as an RFC patch on git mailing list
once. Hyperlinking plain text http, https, ftp, ftps links etc. is a special
case of committag. That wha is implemented now, namely hyperlinking
commitsha to commit view is also special case of comittag.

And I plan to implement it, only later. But you are welcome to do it
instead.

gitweb-xmms2 http://git.xmms.se/?p=gitweb-xmms2.git has xmms2 related
committags support (links to xmms2 Mantis bugtracker from BUG(n) and
FEATURE(n))
 
> Slightly tested on http://git.openvz.org/. Applicable to git-1.4.4.
> 
> Signed-off-by: Kir Kolyshkin <kir@openvz.org>
> ---
>  gitweb/gitweb.perl |    2 ++
>  1 file changed, 2 insertions(+)
> 
> --- git-1.4.4/gitweb/gitweb.perl      2006-11-15 08:22:27.000000000 +0100
> +++ git-1.4.4-my/gitweb/gitweb.perl   2006-11-21 22:49:14.000000000 +0100
> @@ -828,6 +828,8 @@

Could you please send patches created by git tools, namely git-format-patch,
or if you really need to send GNU diff patches, use -p option? It really
helps in patch review.

>                       $line =~ s/$hash_text/$link/;
>               }
>       }
> +     # make HTML links out of http(s) URLs
> +     $line =~ s/(http[s]?:\/\/[^[:space:]\]\)]+)/<a href="\1">\1<\/a>/g;
>       return $line;
>  }

Wont work correctly if commit message has sha1 of commit in it; it would be
changed to 
 <a href="$my_uri?p=$project;a=commit;h=$hash_text" class="text">$hash_text</a>
then the code you added will add hyperlink in place of href value (!).
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git


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

* Re: [PATCH] gitweb: make HTML links out of http/https URLs in changelogs
  2006-11-21 22:02 [PATCH] gitweb: make HTML links out of http/https URLs in changelogs Kir Kolyshkin
  2006-11-21 22:28 ` Jakub Narebski
@ 2006-11-21 23:55 ` Randal L. Schwartz
  2006-11-22  0:06 ` Petr Baudis
  2 siblings, 0 replies; 6+ messages in thread
From: Randal L. Schwartz @ 2006-11-21 23:55 UTC (permalink / raw)
  To: Kir Kolyshkin; +Cc: git

>>>>> "Kir" == Kir Kolyshkin <kir@openvz.org> writes:

Kir> +	# make HTML links out of http(s) URLs
Kir> +	$line =~ s/(http[s]?:\/\/[^[:space:]\]\)]+)/<a href="\1">\1<\/a>/g;

Perl tip of the day:

On the right side of s///, you want $1, not \1, because \1 accidentally
works, but \10 (instead of the proper $10) will give you a control-h.  Ick.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.

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

* Re: [PATCH] gitweb: make HTML links out of http/https URLs in changelogs
  2006-11-21 22:02 [PATCH] gitweb: make HTML links out of http/https URLs in changelogs Kir Kolyshkin
  2006-11-21 22:28 ` Jakub Narebski
  2006-11-21 23:55 ` Randal L. Schwartz
@ 2006-11-22  0:06 ` Petr Baudis
  2006-11-22  9:00   ` Kir Kolyshkin
  2 siblings, 1 reply; 6+ messages in thread
From: Petr Baudis @ 2006-11-22  0:06 UTC (permalink / raw)
  To: Kir Kolyshkin; +Cc: git

On Tue, Nov 21, 2006 at 11:02:36PM CET, Kir Kolyshkin wrote:
> Slightly tested on http://git.openvz.org/. Applicable to git-1.4.4.

...but in git's gitweb view it will make this <a
href="http://git.openvz.org/.">http://git.openvz.org/.</a>. :-)

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
The meaning of Stonehenge in Traflamadorian, when viewed from above, is:
"Replacement part being rushed with all possible speed."

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

* Re: [PATCH] gitweb: make HTML links out of http/https URLs in changelogs
  2006-11-22  0:06 ` Petr Baudis
@ 2006-11-22  9:00   ` Kir Kolyshkin
  2006-11-22 20:56     ` Petr Baudis
  0 siblings, 1 reply; 6+ messages in thread
From: Kir Kolyshkin @ 2006-11-22  9:00 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git

Petr Baudis wrote:
> On Tue, Nov 21, 2006 at 11:02:36PM CET, Kir Kolyshkin wrote:
>   
>> Slightly tested on http://git.openvz.org/. Applicable to git-1.4.4.
>>     
>
> ...but in git's gitweb view it will make this <a
> href="http://git.openvz.org/.">http://git.openvz.org/.</a>. :-)
Not a problem actually since "." means "current directory", so it will 
work fine (and I have checked that) :)
Sure there is a room for improvement for this regex -- and I am 
collecting those.


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

* Re: [PATCH] gitweb: make HTML links out of http/https URLs in changelogs
  2006-11-22  9:00   ` Kir Kolyshkin
@ 2006-11-22 20:56     ` Petr Baudis
  0 siblings, 0 replies; 6+ messages in thread
From: Petr Baudis @ 2006-11-22 20:56 UTC (permalink / raw)
  To: Kir Kolyshkin; +Cc: git

On Wed, Nov 22, 2006 at 10:00:05AM CET, Kir Kolyshkin wrote:
> Petr Baudis wrote:
> >On Tue, Nov 21, 2006 at 11:02:36PM CET, Kir Kolyshkin wrote:
> >  
> >>Slightly tested on http://git.openvz.org/. Applicable to git-1.4.4.
> >>    
> >
> >...but in git's gitweb view it will make this <a
> >href="http://git.openvz.org/.">http://git.openvz.org/.</a>. :-)
> Not a problem actually since "." means "current directory", so it will 
> work fine (and I have checked that) :)
> Sure there is a room for improvement for this regex -- and I am 
> collecting those.

But "http://git.openvz.org/index.html." might not work so fine, nor
"http://git.openvz.org/,"...

Bad URLs matchers which don't snip unlikely (!= invalid!) characters
from the end of the URL are my pet peeve. ;-)

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
The meaning of Stonehenge in Traflamadorian, when viewed from above, is:
"Replacement part being rushed with all possible speed."

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

end of thread, other threads:[~2006-11-22 20:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-21 22:02 [PATCH] gitweb: make HTML links out of http/https URLs in changelogs Kir Kolyshkin
2006-11-21 22:28 ` Jakub Narebski
2006-11-21 23:55 ` Randal L. Schwartz
2006-11-22  0:06 ` Petr Baudis
2006-11-22  9:00   ` Kir Kolyshkin
2006-11-22 20:56     ` Petr Baudis

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