Template:KumaGithubChanges

  • Revision slug: Template:KumaGithubChanges
  • Revision title: Template:KumaGithubChanges
  • Revision id: 314051
  • Created:
  • Creator: lmorchard
  • Is current revision? No
  • Comment

Revision Content

<% // Grab the current rev, snip off the line break var CURR_REV_URL = 'https://developer.mozilla.org/media/revision.txt'; var curr_rev = mdn.fetchHTTPResource(CURR_REV_URL); curr_rev = curr_rev.substr(0, curr_rev.length-1); var GITHUB_API_BASE = 'https://api.github.com'; var GITHUB_COMMIT_BASE = 'https://github.com/mozilla/kuma/commit/'; var GITHUB_AUTHOR_BASE = 'https://github.com/'; var compare_data = null; if (curr_rev) { var compare_url = GITHUB_API_BASE + '/repos/mozilla/kuma/compare/' + curr_rev + '...HEAD'; compare_data = mdn.fetchJSONResource(compare_url); } %> <% if (!compare_data) { %>

Changes since last Kuma push

Fetching data from GitHub failed.

<% } else { %>

Changes since last Kuma push (permalink / JSON)

    <% for (var i=0, c; c=compare_data.commits[i]; i++) { %>
  • <% if (c.author) { %> <%= c.author.login %> <% } else { %> <%= c.commit.author.name %> <% } %> <%= c.commit.message %>
  • <% } %>
<% } %>

Revision Source

<%
// Grab the current rev, snip off the line break
var CURR_REV_URL = 'https://developer.mozilla.org/media/revision.txt';
var curr_rev = mdn.fetchHTTPResource(CURR_REV_URL);
curr_rev = curr_rev.substr(0, curr_rev.length-1);
    
var GITHUB_API_BASE    = 'https://api.github.com';
var GITHUB_COMMIT_BASE = 'https://github.com/mozilla/kuma/commit/';
var GITHUB_AUTHOR_BASE = 'https://github.com/';

var compare_data = null;
if (curr_rev) {
    var compare_url = GITHUB_API_BASE + '/repos/mozilla/kuma/compare/' +
                        curr_rev + '...HEAD';
    compare_data = mdn.fetchJSONResource(compare_url);
}
%>
<% if (!compare_data) { %>
    <h2>Changes since last Kuma push</h2>
    <p>Fetching data from GitHub failed.</p>
<% } else { %>
    <h2>Changes since last Kuma push (<a href="<%= compare_data.permalink_url %>">permalink</a> / <a href="<%=compare_url%>">JSON</a>)</h2>
    <ul>
        <% for (var i=0, c; c=compare_data.commits[i]; i++) { %>
            <li>
                <% if (c.author) { %>
                    <a href="<%= GITHUB_AUTHOR_BASE + c.author.login %>"><img src="<%= c.author.avatar_url %>" style="width: 2em; height: 2em;" alt="<%= c.author.login %>"></a>
                <% } else { %>
                    <a href="<%= GITHUB_AUTHOR_BASE + c.commit.author.name %>"><img src="https://www.gravatar.com/avatar/<%= md5(c.commit.author.email) %>" style="width: 2em; height: 2em;" alt="<%= c.commit.author.name %>"></a>
                <% } %>
                <a href="<%= GITHUB_COMMIT_BASE + c.sha %>" title="<%= c.sha %>"><%= c.commit.message %></a>
            </li>
        <% } %>
    </ul>
<% } %>
Revert to this revision