From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jakub Narebski Subject: [PATCHv3/RFC 4/5] gitweb: Create links leading to 'blame_incremental' using JavaScript Date: Tue, 1 Sep 2009 13:39:19 +0200 Message-ID: <1251805160-5303-5-git-send-email-jnareb@gmail.com> References: <1251805160-5303-1-git-send-email-jnareb@gmail.com> <1251805160-5303-2-git-send-email-jnareb@gmail.com> <1251805160-5303-3-git-send-email-jnareb@gmail.com> <1251805160-5303-4-git-send-email-jnareb@gmail.com> Cc: Petr Baudis , Fredrik Kuivinen , Giuseppe Bilotta , Luben Tuikov , Martin Koegler , Jakub Narebski To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Tue Sep 01 13:32:43 2009 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1MiRbO-0001Kk-7D for gcvg-git-2@lo.gmane.org; Tue, 01 Sep 2009 13:32:42 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754068AbZIALcL (ORCPT ); Tue, 1 Sep 2009 07:32:11 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753915AbZIALcK (ORCPT ); Tue, 1 Sep 2009 07:32:10 -0400 Received: from mail-fx0-f217.google.com ([209.85.220.217]:51858 "EHLO mail-fx0-f217.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753972AbZIALcE (ORCPT ); Tue, 1 Sep 2009 07:32:04 -0400 Received: by fxm17 with SMTP id 17so3435949fxm.37 for ; Tue, 01 Sep 2009 04:32:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:received:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references; bh=U0KIvKJmvq7VUCcbu5PLv2ZD83Lhs1p7joEBMK+WmP8=; b=W69URx7lA+ZtlKpddqvD9Wh0HsYMg4U0XaG7XuYVRcsXPnPzx0zVML32rNNvlnBHwW aHpGJw8sG0nFCk5CGuEcA4rY6CDQsRZ9YdN4ZTCu8Xk/XwDKH9jgeVmkyOpiVqoVZ0Bv i7OlaiID1yMUOS2pzxoTfBPG+d+wRZOGI7uPI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=G/22IyPJ3Z1n9aktAXRv/P+cFf3LBY8zFLWaTy0pC8TGX4PGX/v2v7tBj6Z3rQTy68 OqTfON1YHQTCAx+uDEWEy5RMG/wUxa9vGnKt/EKaAl0ZavYLXpA63gB3IDHjMRuvohA4 bl/7JI+eqYqIL7jeoMgBb4Ka2vjQ/DXiosaA4= Received: by 10.103.86.9 with SMTP id o9mr2869323mul.4.1251804725227; Tue, 01 Sep 2009 04:32:05 -0700 (PDT) Received: from localhost.localdomain (abwl209.neoplus.adsl.tpnet.pl [83.8.235.209]) by mx.google.com with ESMTPS id s10sm3758388muh.47.2009.09.01.04.32.03 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 01 Sep 2009 04:32:04 -0700 (PDT) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.13.4/8.13.4) with ESMTP id n81BdXFq005349; Tue, 1 Sep 2009 13:39:33 +0200 Received: (from jnareb@localhost) by localhost.localdomain (8.13.4/8.13.4/Submit) id n81BdWBf005348; Tue, 1 Sep 2009 13:39:32 +0200 X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1251805160-5303-4-git-send-email-jnareb@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: 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" . ""; } @@ -4806,6 +4820,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') @@ -4885,7 +4903,7 @@ sub git_blame_common { if ($format eq 'incremental') { print "\n"; @@ -5016,14 +5034,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(); } -- 1.6.3.3