Skip to content
This repository has been archived by the owner on May 17, 2020. It is now read-only.

Commit

Permalink
Add changelog page
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic100 committed Apr 17, 2017
1 parent 74df5d5 commit 299fce4
Show file tree
Hide file tree
Showing 7 changed files with 282 additions and 56 deletions.
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# username/repository
id: mistic100/jekyll-bootstrap-doc
# name of the software
name: Jekyll Bootstrap Doc
# current version of the software
Expand Down
2 changes: 1 addition & 1 deletion _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ <h1>{{page.title}}</h1>
=========================================== -->
{% if site.header.trianglify %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/trianglify/1.0.1/trianglify.min.js"></script>
<script>trianglify('{{site.header.color1}}', '{{site.header.color2}}', '{{site.name}}');</script>
<script>jekyllBootstrapDoc.trianglify('{{site.header.color1}}', '{{site.header.color2}}', '{{site.name}}');</script>
{% endif %}

{% if site.twitter.enabled or site.twitter.account %}
Expand Down
113 changes: 110 additions & 3 deletions assets/css/style.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/**
* Overwrites
*/
.bs-docs-masthead {
padding-top: 50px;
padding-bottom: 40px;
margin-bottom: 20px;
}

.bs-docs-header h1, .bs-docs-header p {
margin-right: 0px;
margin-right: 0;
}

.bs-docs-sidebar .nav > li > a {
Expand All @@ -27,14 +30,17 @@
#content:after {
content: "";
position: absolute;
bottom: 0px;
right: 0px;
bottom: 0;
right: 0;
height: 50px;
width: 30%;
min-width: 300px;
background: linear-gradient(135deg, transparent 50px, white 50px);
}

/**
* Title anchors
*/
.anchor-link {
opacity: 0;
position: absolute;
Expand All @@ -57,3 +63,104 @@ h4:hover .anchor-link,
h5:hover .anchor-link {
opacity: 1;
}

/**
* Releases titles
*/
#releases h1 {
font-size: 28px;
}

#releases h1 small {
padding-left: 1em;
}

#releases h1 a.release-date {
float: right;
font-size: 18px;
}

/**
* Loader
* http://codepen.io/fox_hover/pen/YZxGed
*/
.spinner {
position: relative;
display: inline-block;
width: 1em;
height: 1em;
}

.spinner::before, .spinner::after {
content: "";
display: block;
position: absolute;
border: 0.05em solid currentcolor;
border-radius: 50%;
}

.spinner::before {
width: 0.936em;
height: 0.936em;
border-top-color: rgba(33, 33, 33, 0);
border-left-color: rgba(33, 33, 33, 0);
top: 0;
left: 0;
-webkit-animation: rotate-animation 1s linear 0s infinite;
animation: rotate-animation 1s linear 0s infinite;
}

.spinner::after {
width: 0.6552em;
height: 0.6552em;
border-top-color: rgba(33, 33, 33, 0);
border-left-color: rgba(33, 33, 33, 0);
top: 0.1404em;
left: 0.1404em;
-webkit-animation: anti-rotate-animation 0.85s linear 0s infinite;
animation: anti-rotate-animation 0.85s linear 0s infinite;
}

@-webkit-keyframes rotate-animation {
0% {
-webkit-transform: rotateZ(0deg);
transform: rotateZ(0deg);
}
100% {
-webkit-transform: rotateZ(360deg);
transform: rotateZ(360deg);
}
}

@keyframes rotate-animation {
0% {
-webkit-transform: rotateZ(0deg);
transform: rotateZ(0deg);
}
100% {
-webkit-transform: rotateZ(360deg);
transform: rotateZ(360deg);
}
}

@-webkit-keyframes anti-rotate-animation {
0% {
-webkit-transform: rotateZ(0deg);
transform: rotateZ(0deg);
}
100% {
-webkit-transform: rotateZ(-360deg);
transform: rotateZ(-360deg);
}
}

@keyframes anti-rotate-animation {
0% {
-webkit-transform: rotateZ(0deg);
transform: rotateZ(0deg);
}
100% {
-webkit-transform: rotateZ(-360deg);
transform: rotateZ(-360deg);
}
}
83 changes: 83 additions & 0 deletions assets/js/changelog.js
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(/&quot;/g, '"').replace(/&#39;/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();
}
});
}());
117 changes: 65 additions & 52 deletions assets/js/script.js
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();
});
20 changes: 20 additions & 0 deletions changelog.html
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>
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ <h3 id="features">Features</h3>
<li>Github counters</li>
<li>Twitter &amp; Facebook buttons</li>
<li>Download options popup</li>
<li>Changelog page generated from GitHub releases</li>
</ul>

<h3 id="examples">Examples</h3>
Expand Down

0 comments on commit 299fce4

Please sign in to comment.