all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Yuri Khan <yuri.v.khan@gmail.com>
To: Kaushal Modi <kaushal.modi@gmail.com>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: Add a commit hash (first 6 chars) column to cgit webpage?
Date: Thu, 5 May 2016 18:15:04 +0600	[thread overview]
Message-ID: <CAP_d_8WFUGGq21u42+Xm7d6Do=Atb=xO2utSC9xsUYnGoox_mA@mail.gmail.com> (raw)
In-Reply-To: <CAFyQvY1zJ5BMPWrK8b_RW0B2imcoe1O4_8y3t83ou_w=-y_yZg@mail.gmail.com>

On Wed, May 4, 2016 at 9:16 PM, Kaushal Modi <kaushal.modi@gmail.com> 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);
});



  reply	other threads:[~2016-05-05 12:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-03 14:37 Add a commit hash (first 6 chars) column to cgit webpage? Kaushal Modi
2016-05-03 14:57 ` Eli Zaretskii
2016-05-04  3:05   ` Kaushal Modi
2016-05-04 14:52     ` Eli Zaretskii
2016-05-04 15:12 ` Yuri Khan
2016-05-04 15:16   ` Kaushal Modi
2016-05-05 12:15     ` Yuri Khan [this message]
2016-05-05 16:42       ` Kaushal Modi
2018-10-22 16:51         ` Kaushal Modi
2018-10-22 17:49           ` Yuri Khan
2018-10-22 18:00             ` Kaushal Modi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAP_d_8WFUGGq21u42+Xm7d6Do=Atb=xO2utSC9xsUYnGoox_mA@mail.gmail.com' \
    --to=yuri.v.khan@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=kaushal.modi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.