This repository has been archived by the owner on May 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
282 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
(function() { | ||
/** | ||
* Fetch releases from github with a cache of 1 hour | ||
* @returns {promise<object[]>} | ||
*/ | ||
function fetchReleases() { | ||
var cacheDate = localStorage.releasesCacheDate; | ||
|
||
if (cacheDate && (new Date() - new Date(cacheDate)) < 1000 * 3600) { | ||
return $.when(JSON.parse(localStorage.releasesCache)); | ||
} | ||
else { | ||
return $.getJSON(releasesAPI) | ||
.then(function(data) { | ||
localStorage.releasesCacheDate = new Date().toString(); | ||
localStorage.releasesCache = JSON.stringify(data); | ||
return data; | ||
}); | ||
} | ||
} | ||
|
||
/** | ||
* Adds a release to #releases | ||
* @param {object} release | ||
*/ | ||
function appendRelease(release) { | ||
// Format date | ||
var date = moment(release.published_at).format('LL'); | ||
|
||
// Convert markdown to html | ||
var desc = marked(release.body, { breaks: true }); | ||
|
||
// Remove some escaping done by marked.js | ||
desc = desc.replace(/"/g, '"').replace(/'/g, "'"); | ||
|
||
// Add links to issues | ||
desc = desc.replace(/(#([0-9]+))/g, '<a href="' + issuesBase + '$2">$1</a>'); | ||
|
||
// Exclude headers from side menu | ||
desc = desc.replace(/(<h[2-5])/g, '$1 data-no-menu'); | ||
|
||
// Build dom | ||
$('#releases').append( | ||
$('<section>') | ||
.addClass('bs-docs-section') | ||
.append( | ||
$('<h1>') | ||
.addClass('page-header') | ||
.attr('id', release.id) | ||
.text(release.name) | ||
.append( | ||
$('<small>') | ||
.text(date), | ||
$('<a>') | ||
.addClass('release-date') | ||
.attr('href', release.html_url) | ||
.append( | ||
$('<i>').addClass('glyphicon glyphicon-tag') | ||
) | ||
), | ||
$('<article>').html(desc) | ||
) | ||
); | ||
} | ||
|
||
fetchReleases() | ||
.then(function(releases) { | ||
$('#spinner').remove(); | ||
|
||
releases.forEach(function(release) { | ||
appendRelease(release); | ||
}); | ||
|
||
if (jekyllBootstrapDoc) { | ||
jekyllBootstrapDoc.buildSideMenu(); | ||
jekyllBootstrapDoc.addHeadingAnchors(); | ||
} | ||
|
||
if (window.location.hash && $(window.location.hash).length) { | ||
$(window.location.hash)[0].scrollIntoView(); | ||
} | ||
}); | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,72 @@ | ||
$(function() { | ||
// build side menu | ||
var html = ''; | ||
|
||
$('.bs-docs-section').each(function() { | ||
var h1 = $(this).find('h1[id]').first(), | ||
h23 = $(this).find('h2[id], h3[id]:not([data-no-menu])'); | ||
|
||
if (h1.length) { | ||
html += '<li><a href="#' + h1[0].id + '">' + h1.clone().children().remove().end().text() + '</a>'; | ||
|
||
if (h23.length) { | ||
html += '<ul class="nav">'; | ||
h23.each(function() { | ||
html += '<li><a href="#' + this.id + '">' + $(this).clone().children().remove().end().text() + '</a></li>'; | ||
}); | ||
html += '</ul>'; | ||
var jekyllBootstrapDoc = { | ||
buildSideMenu: function() { | ||
var html = ''; | ||
|
||
$('.bs-docs-section').each(function() { | ||
var h1 = $(this).find('h1[id]').first(), | ||
h23 = $(this).find('h2[id], h3[id]:not([data-no-menu])'); | ||
|
||
if (h1.length) { | ||
html += '<li><a href="#' + h1[0].id + '">' + h1.clone().children().remove().end().text() + '</a>'; | ||
|
||
if (h23.length) { | ||
html += '<ul class="nav">'; | ||
h23.each(function() { | ||
html += '<li><a href="#' + this.id + '">' + $(this).clone().children().remove().end().text() + '</a></li>'; | ||
}); | ||
html += '</ul>'; | ||
} | ||
|
||
html += '</li>'; | ||
} | ||
}); | ||
|
||
html += '</li>'; | ||
if (html == '') { | ||
$('[role=complementary]').hide(); | ||
$('[role=main]').removeClass('col-md-9').addClass('col-md-12'); | ||
} | ||
else { | ||
$('[role=complementary]').show(); | ||
$('[role=main]').removeClass('col-md-12').addClass('col-md-9'); | ||
$('.bs-docs-sidenav').html(html); | ||
} | ||
}); | ||
}, | ||
|
||
if (html == '') { | ||
$('[role=complementary]').hide(); | ||
$('[role=main]').toggleClass('col-md-9 col-md-12'); | ||
} | ||
else { | ||
$('.bs-docs-sidenav').html(html); | ||
} | ||
addHeadingAnchors: function() { | ||
$('h1[id], h2[id], h3[id], h4[id], h5[id]').each(function() { | ||
if ($(this).children('.anchor-link').length === 0) { | ||
$(this).prepend('<a href="#' + this.id + '" class="anchor-link">§</i>'); | ||
} | ||
}); | ||
}, | ||
|
||
// add heading anchors | ||
$('h1[id], h2[id], h3[id], h4[id], h5[id]').each(function() { | ||
$(this).prepend('<a href="#' + this.id + '" class="anchor-link">§</i>'); | ||
}); | ||
|
||
// enable bootbox | ||
$('[data-bootbox]').on('click', function() { | ||
var $target = $('#' + $(this).data('bootbox')); | ||
bootbox.alert({ | ||
title: $target.attr('title'), | ||
message: $target.html(), | ||
size: $(this).data('bootbox-size') | ||
enableBootbox: function() { | ||
$('[data-bootbox]').off('click').on('click', function() { | ||
var $target = $('#' + $(this).data('bootbox')); | ||
bootbox.alert({ | ||
title: $target.attr('title'), | ||
message: $target.html(), | ||
size: $(this).data('bootbox-size') | ||
}); | ||
}); | ||
}, | ||
|
||
trianglify: function(color1, color2, seed) { | ||
var header = $('#content'); | ||
var pattern = Trianglify({ | ||
width: window.screen.width | header.outerWidth(), | ||
height: header.outerHeight(), | ||
cell_size: 90, | ||
seed: seed, | ||
x_colors: [color1, color2] | ||
}); | ||
}); | ||
}); | ||
|
||
function trianglify(color1, color2, seed) { | ||
var header = $('#content'); | ||
var pattern = Trianglify({ | ||
width: window.screen.width | header.outerWidth(), | ||
height: header.outerHeight(), | ||
cell_size: 90, | ||
seed: seed, | ||
x_colors: [color1, color2] | ||
}); | ||
|
||
header.css('background-image', 'url(' + pattern.png() + ')'); | ||
} | ||
header.css('background-image', 'url(' + pattern.png() + ')'); | ||
} | ||
}; | ||
|
||
$(function() { | ||
jekyllBootstrapDoc.buildSideMenu(); | ||
jekyllBootstrapDoc.addHeadingAnchors(); | ||
jekyllBootstrapDoc.enableBootbox(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
layout: default | ||
title: Changelog | ||
--- | ||
|
||
<div id="releases"> | ||
<div id="spinner" style="text-align:center; color: #888; font-size:100px;"> | ||
<span class="spinner"></span> | ||
</div> | ||
</div> | ||
|
||
<script src="https://cdn.jsdelivr.net/marked/0.3.5/marked.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script> | ||
|
||
<script> | ||
var releasesAPI = 'https://api.github.com/repos/{{site.id}}/releases'; | ||
var issuesBase = 'https://github.com/{{site.id}}/issues/'; | ||
</script> | ||
|
||
<script src="{{site.github.url}}/assets/js/changelog.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters