Template:KumaGithubChanges

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

Revision Content

<% var GITHUB_API_BASE = 'https://api.github.com'; var CURR_REV_URL = 'https://developer.mozilla.org/media/revision.txt'; var curr_rev = mdn.fetchHTTPResource(CURR_REV_URL); log.debug("CURR REV " + curr_rev); function fetchJSON (url, cache_tmout) { if (!cache_tmout) cache_tmout = 3600; var key = 'test'; return } var compare_data = null; if (curr_rev) { var compare_url = GITHUB_API_BASE + '/repos/mozilla/kuma/compare/' + curr_rev + '...HEAD'; log.debug("COMPARE URL " + compare_url); compare_data = cacheFn('test', 600, function (next) { var opts = { method: 'GET', headers: { 'Cache-Control': env.cache_control }, url: compare_url }; try { request(opts, function (err, resp, body) { var result = null; if (resp && 200 == resp.statusCode) { result = JSON.parse(body); } next(result); }); } catch (e) { next(null); } }); log.debug("COMPARE DATA " + compare_data); var blurgh = mdn.fetchHTTPResource(compare_url); log.debug("BLURGH " + blurgh); } %> <% if (!compare_data) { %>

Fetching data from GitHub failed.

<% } else { %> Compare: <%= compare_data %> <% } %>

Revision Source

<%
var GITHUB_API_BASE = 'https://api.github.com';
var CURR_REV_URL = 'https://developer.mozilla.org/media/revision.txt';

var curr_rev = mdn.fetchHTTPResource(CURR_REV_URL);
log.debug("CURR REV " + curr_rev);

function fetchJSON (url, cache_tmout) {
    if (!cache_tmout) cache_tmout = 3600;
    var key = 'test';
    return 
}
    
var compare_data = null;
if (curr_rev) {
    var compare_url = GITHUB_API_BASE + '/repos/mozilla/kuma/compare/' + curr_rev + '...HEAD';
    log.debug("COMPARE URL " + compare_url);
    
    compare_data = cacheFn('test', 600, function (next) {
        var opts = {
            method: 'GET',
            headers: { 'Cache-Control': env.cache_control },
            url: compare_url
        };
        try {
            request(opts, function (err, resp, body) {
                var result = null;
                if (resp && 200 == resp.statusCode) {
                    result = JSON.parse(body);
                }
                next(result);
            });
        } catch (e) {
            next(null);
        }            
    });
    
    log.debug("COMPARE DATA " + compare_data);

    var blurgh = mdn.fetchHTTPResource(compare_url);
    log.debug("BLURGH " + blurgh);
}
%>
<% if (!compare_data) { %>
    <p>Fetching data from GitHub failed.</p>
<% } else { %>
    Compare: <%= compare_data %>

<% } %>
Revert to this revision