From c4ccf61f4caf8c293713586531b4a2ea709756c8 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Tue, 1 Sep 2009 13:39:19 +0200 Subject: [PATCH] gitweb: Create links leading to 'blame_incremental' using JavaScript The new 'blame_incremental' view requires JavaScript to run. Not all web browsers implement JavaScript (e.g. text browsers such as Lynx), and not all users have JavaScript enabled. Therefore instead of unconditionally linking to 'blame_incremental' view, we use JavaScript to convert those links to lead to view utilizing JavaScript, by adding 'js=1' to link. Currently the only action that takes 'js=1' into account is 'blame', which then acts as if it was called as 'blame_incremental' action. Possible enhancement would be to do JavaScript redirect by setting window.location instead of modifying $format and $action in git_blame_common() subroutine. The only JavaScript-aware/using view is currently 'blame_incremental'. While at it move reading JavaScript to git_footer_html() subroutine. Note that in this view we do not add 'js=1' currently (even though perhaps we should; note that for consistency we should also add 'js=1' in links added by JavaScript part of 'blame_incremental'). This idea was originally implemented by Petr Baudis in http://article.gmane.org/gmane.comp.version-control.git/47614 but it added \n!; + if ($action eq 'blame_incremental') { + print qq!\n!; + } else { + print qq!\n!; + } + print "\n" . ""; } @@ -4793,6 +4807,10 @@ sub git_tag { sub git_blame_common { my $format = shift || 'porcelain'; + if ($format eq 'porcelain' && $cgi->param('js')) { + $format = 'incremental'; + $action = 'blame_incremental'; # for page title etc + } # permissions gitweb_check_feature('blame') @@ -4872,7 +4890,7 @@ sub git_blame_common { if ($format eq 'incremental') { print "\n"; @@ -5003,14 +5021,6 @@ sub git_blame_common { close $fd or print "Reading blob failed\n"; - if ($format eq 'incremental') { - print qq!\n!. - qq!\n!; - } - git_footer_html(); } -- 2.30.2