<commit_before>{Status, Timeline} = Chorus = @Chorus
{extend} = $ = jQuery

class GithubCommit extends Status
    constructor: (id, username, avatar, date, text, raw, @url) ->
        super id, username, avatar, date, text, raw

    getUrl: -> "http://github.com/#{ @url }"

    getStreamUrl: ->
        "http://github.com/#{ @url.replace /\/commit\/[^\/]+$/, ''}"

    @from = (json) ->
        {author, url, id, authored_date, message} = json
        {name, email} = author
        new GithubCommit id, name, gravatar(email), authored_date, message, json, url

class GithubCommits extends Timeline
    constructor: (@username, @repo, options) ->
        @queryUrl = "http://github.com/api/v2/json/commits/list"
        @queryUrl += "/#{@username}/#{@repo}/#{options?.branch ? 'master'}"
        super options

    update: -> jQuery.ajax
        url: @queryUrl
        dataType: "jsonp"
        success: (data) => @prePublish data

    statusesFromData: (data) -> GithubCommit.from item for item in data.commits

Timeline.shorthands.unshift
    pattern: /^GH:([a-z-_]+)\/([a-z-_]+)/i,
    fun: (_, name, project) -> new GithubCommits name, project

extend Chorus, {GithubCommit, GithubCommits}

gravatar = (email) ->
    "http://www.gravatar.com/avatar/#{ md5 trim(email).toLowerCase() }"

trim = (str) -> str.replace(/^\s+|\s+$/g, "")

md5 = `function (string) {
 
	function RotateLeft(lValue, iShiftBits) {
		return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
	}
 
	function AddUnsigned(lX,lY) {
		var lX4,lY4,lX8,lY8,lResult;
		lX8 = (lX & 0x80000000);
		lY8 = (lY & 0x80000000);
		lX4 = (lX & 0x40000000);
		lY4 = (lY & 0x40000000);
		lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
		if (lX4 & lY4) {
			return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
		}<commit_msg>added a shorthand for branches<commit_after>{Status, Timeline} = Chorus = @Chorus
{extend} = $ = jQuery

class GithubCommit extends Status
    constructor: (id, username, avatar, date, text, raw, @url) ->
        super id, username, avatar, date, text, raw

    getUrl: -> "http://github.com/#{ @url }"

    getStreamUrl: ->
        "http://github.com/#{ @url.replace /\/commit\/[^\/]+$/, ''}"

    @from = (json) ->
        {author, url, id, authored_date, message} = json
        {name, email} = author
        new GithubCommit id, name, gravatar(email), authored_date, message, json, url

class GithubCommits extends Timeline
    constructor: (@username, @repo, options) ->
        @queryUrl = "http://github.com/api/v2/json/commits/list"
        @queryUrl += "/#{@username}/#{@repo}/#{options?.branch ? 'master'}"
        super options

    update: -> jQuery.ajax
        url: @queryUrl
        dataType: "jsonp"
        success: (data) => @prePublish data

    statusesFromData: (data) -> GithubCommit.from item for item in data.commits

Timeline.shorthands.unshift
    pattern: /^GH:([a-z-_]+)\/([a-z-_]+)/i,
    fun: (_, name, project) -> new GithubCommits name, project

Timeline.shorthands.unshift
    pattern: /^GH:([^\/]+)\/([^\/]+)\/([^\/]+)/i,
    fun: (_, name, project, branch) ->
        new GithubCommits name, project, branch: branch

extend Chorus, {GithubCommit, GithubCommits}

gravatar = (email) ->
    "http://www.gravatar.com/avatar/#{ md5 trim(email).toLowerCase() }"

trim = (str) -> str.replace(/^\s+|\s+$/g, "")

md5 = `function (string) {
 
	function RotateLeft(lValue, iShiftBits) {
		return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
	}
 
	function AddUnsigned(lX,lY) {
		var lX4,lY4,lX8,lY8,lResult;
		lX8 = (lX & 0x80000000);
		lY8 = (lY & 0x80000000);
		lX4 = (lX & 0x40000000);
		lY4 = (lY & 0x40000000);
		lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
		if (lX4 & lY4) {
			return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
		}
{'fraction_non_alphanumeric': 0.183738967638406, 'fraction_numerical': 0.0353035571008291, 'mean_word_length': 3.118942731277533, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 14, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4778355', 'n_tokens_mistral': 1519, 'n_tokens_neox': 1401, 'n_words': 305}