From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.devel Subject: Re: Add a commit hash (first 6 chars) column to cgit webpage? Date: Thu, 5 May 2016 18:15:04 +0600 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1462450579 27272 80.91.229.3 (5 May 2016 12:16:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 5 May 2016 12:16:19 +0000 (UTC) Cc: Emacs developers To: Kaushal Modi Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 05 14:16:12 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ayICO-0008Kn-Sm for ged-emacs-devel@m.gmane.org; Thu, 05 May 2016 14:16:09 +0200 Original-Received: from localhost ([::1]:53306 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ayICK-0004FT-QR for ged-emacs-devel@m.gmane.org; Thu, 05 May 2016 08:16:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59631) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ayICB-000421-2z for emacs-devel@gnu.org; Thu, 05 May 2016 08:16:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ayIBz-0001NI-1Z for emacs-devel@gnu.org; Thu, 05 May 2016 08:15:49 -0400 Original-Received: from mail-lf0-x233.google.com ([2a00:1450:4010:c07::233]:36595) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ayIBx-0001Ii-LR for emacs-devel@gnu.org; Thu, 05 May 2016 08:15:42 -0400 Original-Received: by mail-lf0-x233.google.com with SMTP id u64so93880547lff.3 for ; Thu, 05 May 2016 05:15:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=p+qif8Gwlzj7CK38be4hEK2LetNVfy0NpvyhHwWSems=; b=LZJ18QsQnf+IVJPRVS5OnOxOdFcXrbtaeePfwCKokhrcbVE6aGc2BAHHMoJ0rnJ++A i3iXGt/jy6LcODhq2NrRpNVXSy0goiwkJL81oX7tTPtiVEnKkfFzb4O1XaSlZXnjqrT1 ZoH9H2vLqWDo0ZxrvQTjkPEMqtYHJ+ZZwhvPx4cRQlAtTsIocJ/YtulYzkSy+Izk9IKz abs2whT0MO0hEAz5Ec6xOWZ2hKlZ330b0TAmcDtTOlJN4PpOlobwn+dAN7hUnb6Gzgm2 Og29mCXqcLFT1o9W2DGyqhQa1uEJoyFiCJGZTnPtMVwzUHfd408WvsCqG9VJwcd8Phqi oXPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=p+qif8Gwlzj7CK38be4hEK2LetNVfy0NpvyhHwWSems=; b=ApjPyKX5d6m+bzfTwF3vgmNqD0Sv262tmEEQ3BMtF7PdO3zX8jGV4vnw+5nLNIDfGC nB4w/3OQp7UNCS3dqDJWGG2rZqMDD9wB18L3VKRGTBcT7FsPFl0hJU/wc+ooiYDFRU71 Pq/idiqgn/AzgofYxgD7yXA7TgYXYyw7XovAmqDhSRU0yTlUJx7zHbirdtsgKd3zrDZB OAI8z+l3h61H7JkQ4oLAQFHg3GiOprgN8+YFz1CFn9ClFgBRXmqtEUcHbT+AjzVQgpGV b7FPkuNzsmExUeJ3xiEjf7JH9vGRTITw4AnJTAo5rLF1G7fYTBw33COb+O9LkOZwCkb8 9kXA== X-Gm-Message-State: AOPr4FVaJFsWa7uXk6FBzG3RaPkaBjXTOL0GNgrPMY6iuHbS1osCZ6bKwpABaF+Ywo7JAHkJzTN0K2oMhkY+GA== X-Received: by 10.25.25.7 with SMTP id 7mr5747537lfz.166.1462450523685; Thu, 05 May 2016 05:15:23 -0700 (PDT) Original-Received: by 10.112.172.197 with HTTP; Thu, 5 May 2016 05:15:04 -0700 (PDT) In-Reply-To: X-Google-Sender-Auth: u-w2xuyBzvdWJoI4RlIF98F2MdM X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::233 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:203602 Archived-At: On Wed, May 4, 2016 at 9:16 PM, Kaushal Modi wrote: >> Which browser do you use? I could probably whip something up in >> Greasemonkey (which is a Firefox extension). I am also told >> Greasemonkey scripts can be installed in Chrom{e,ium}. > > Thanks! I use both Firefox (on RHEL) and Chrome (on Windows). I have hosted the script on my home server: http://greasemonkey.centaur.ath.cx/cgit_Add_commit_hash_column.user.js You can install this in Firefoxoids using the Greasemonkey or Tampermonkey extension, and in Chromides using Tampermonkey. If you need this on other aliases of Savannah cgit, or on other cgit instances, just add the corresponding @include patterns. (If you feel adventurous, replace the host with a *; this will enable the script on all pages whose URL contains /cgit/ and /log/ in that order.) The script makes some assumptions about the page DOM structure and is therefore subject to software rot if that structure changes. (Security notice: Userscripts run in the security context of your browser. Carefully review any userscript you install.) A courtesy inspection/archival copy follows. // ==UserScript== // @name cgit: Add commit hash column // @namespace http://yurikhan.github.io/ // @include http://git.savannah.gnu.org/cgit/*/log/* // @version 1 // @grant none // ==/UserScript== var header_row = document.querySelector('table.list tr:first-child'); var th = document.createElement('th'); th.className = 'left'; th.textContent = 'Hash'; var before = header_row.querySelector('th:nth-child(2)'); header_row.insertBefore(th, before); var rows = document.querySelectorAll('table.list tr:not(.nohover)'); Array.prototype.forEach.call(rows, function(row) { var link = row.querySelector('a[href*="/commit/"]'); var hash = null; ((link.search || '').replace(/^\?/, '').split('&') .map(function(param) { return param.split('='); }) .filter(function(pair) { return pair[0] === 'id'; }) .forEach(function(pair) { hash = pair[1]; })) var td = document.createElement('td'); td.textContent = (hash || '').slice(0, 7); for (var before = link; !(before instanceof HTMLTableCellElement); before = before.parentNode); row.insertBefore(td, before); }); rows = document.querySelectorAll( 'table.list tr.nohover:not(:first-child)'); Array.prototype.forEach.call(rows, function(row) { var td = document.createElement('td'); var before = row.querySelector('td:nth-child(2)'); row.insertBefore(td, before); });