The Code Train

Where Neil Crosby talks about coding on the train…

RSS Entries

GitHub Inactive Repository Demoter, a GreaseMonkey Script

Posted on March 2nd, 2009 by Neil Crosby. Filed under Uncategorized.

One of the things that’s been annoying me recently about GitHub is the way that a user’s repositories are presented on their profile page. Take my profile page for example — I have 16 repositories, but only 5 of them have had any active development over the last month. To my mind those ones are the most important on the page, and as such should be given pride of place. The others should be pushed down the page into their own section.

So, using the wonders of GreaseMonkey, that’s what I did with a spare half an hour yesterday evening. The demoter script I wrote is very simple — it looks for the first element on the page with a class of “projects”, then checks the last changed date of each of the projects contained within. If any of them contain a date that’s more than a month old then a quick appendChild of the original node onto the new “demoted” list moves it across. A heading is added before the new “demoted” list to explain what this new list contains, and we’re all done.

So far I’ve noticed one “bug” with this script. Normally, when GitHub displays information about a project, it’s the last changed date of the project that’s displayed. Unfortunately, if the user has forked a repository, it seems that the date displayed is when the repository was forked rather than the last time it was edited. Even if the fork happened months ago, and since then the user has made many edits themselves it’s still the fork date that’s displayed. You can see this in action on Brad’s profile page on the “homedir” project.

Short of GitHub exposing the actual last edited date on the page itself there is one other possible possibility for getting hold of a last edited(ish) date. For each of the project activity sparklines, GitHub makes a call back to the server to grab a chunk of parseable data. It might be possible to grab hold of that data using GreaseMonkey, but that’s a problem I leave to the enterprising reader. If you do solve the problem, please do fork my code and send a pull request — I’d love to have this solved in the script.

If you fancy having this “Inactive Repository Demotion” functionality on GitHub, all you have to do is download the script. Oh, and whilst you’re at it, don’t forget to follow the repository so you can be told of any updates or bugfixes.

EDIT:

As it turns out, I should probably be a little more explicit about how to install the script. First, download the entire repository as a zip or tgz. Open it up, and then open the script up in Firefox. The GreaseMonkey script will then install.

If you enjoyed this post, subscribe to The Code Train and read more when I write more.

2 Responses to “GitHub Inactive Repository Demoter, a GreaseMonkey Script”

  1. Thank you very much for this handy script. I tested it with GreaseKit on the beta version of Safari 4 and it works perfectly.

    Greetings

  2. Excellent – I wasn’t even aware of GreaseKit’s existence (I only really use Safari for testing), so I’m really glad the script works well with it.

Comments RSS

Leave a Reply

TheCodeTrain Theme by Neil Crosby, Powered by WordPress