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

Commit 299fce4

Browse files
committed
Add changelog page
1 parent 74df5d5 commit 299fce4

File tree

7 files changed

+282
-56
lines changed

7 files changed

+282
-56
lines changed

_config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# username/repository
2+
id: mistic100/jekyll-bootstrap-doc
13
# name of the software
24
name: Jekyll Bootstrap Doc
35
# current version of the software

_layouts/default.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ <h1>{{page.title}}</h1>
191191
=========================================== -->
192192
{% if site.header.trianglify %}
193193
<script src="https://cdnjs.cloudflare.com/ajax/libs/trianglify/1.0.1/trianglify.min.js"></script>
194-
<script>trianglify('{{site.header.color1}}', '{{site.header.color2}}', '{{site.name}}');</script>
194+
<script>jekyllBootstrapDoc.trianglify('{{site.header.color1}}', '{{site.header.color2}}', '{{site.name}}');</script>
195195
{% endif %}
196196

197197
{% if site.twitter.enabled or site.twitter.account %}

assets/css/style.css

Lines changed: 110 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
/**
2+
* Overwrites
3+
*/
14
.bs-docs-masthead {
25
padding-top: 50px;
36
padding-bottom: 40px;
47
margin-bottom: 20px;
58
}
69

710
.bs-docs-header h1, .bs-docs-header p {
8-
margin-right: 0px;
11+
margin-right: 0;
912
}
1013

1114
.bs-docs-sidebar .nav > li > a {
@@ -27,14 +30,17 @@
2730
#content:after {
2831
content: "";
2932
position: absolute;
30-
bottom: 0px;
31-
right: 0px;
33+
bottom: 0;
34+
right: 0;
3235
height: 50px;
3336
width: 30%;
3437
min-width: 300px;
3538
background: linear-gradient(135deg, transparent 50px, white 50px);
3639
}
3740

41+
/**
42+
* Title anchors
43+
*/
3844
.anchor-link {
3945
opacity: 0;
4046
position: absolute;
@@ -57,3 +63,104 @@ h4:hover .anchor-link,
5763
h5:hover .anchor-link {
5864
opacity: 1;
5965
}
66+
67+
/**
68+
* Releases titles
69+
*/
70+
#releases h1 {
71+
font-size: 28px;
72+
}
73+
74+
#releases h1 small {
75+
padding-left: 1em;
76+
}
77+
78+
#releases h1 a.release-date {
79+
float: right;
80+
font-size: 18px;
81+
}
82+
83+
/**
84+
* Loader
85+
* http://codepen.io/fox_hover/pen/YZxGed
86+
*/
87+
.spinner {
88+
position: relative;
89+
display: inline-block;
90+
width: 1em;
91+
height: 1em;
92+
}
93+
94+
.spinner::before, .spinner::after {
95+
content: "";
96+
display: block;
97+
position: absolute;
98+
border: 0.05em solid currentcolor;
99+
border-radius: 50%;
100+
}
101+
102+
.spinner::before {
103+
width: 0.936em;
104+
height: 0.936em;
105+
border-top-color: rgba(33, 33, 33, 0);
106+
border-left-color: rgba(33, 33, 33, 0);
107+
top: 0;
108+
left: 0;
109+
-webkit-animation: rotate-animation 1s linear 0s infinite;
110+
animation: rotate-animation 1s linear 0s infinite;
111+
}
112+
113+
.spinner::after {
114+
width: 0.6552em;
115+
height: 0.6552em;
116+
border-top-color: rgba(33, 33, 33, 0);
117+
border-left-color: rgba(33, 33, 33, 0);
118+
top: 0.1404em;
119+
left: 0.1404em;
120+
-webkit-animation: anti-rotate-animation 0.85s linear 0s infinite;
121+
animation: anti-rotate-animation 0.85s linear 0s infinite;
122+
}
123+
124+
@-webkit-keyframes rotate-animation {
125+
0% {
126+
-webkit-transform: rotateZ(0deg);
127+
transform: rotateZ(0deg);
128+
}
129+
100% {
130+
-webkit-transform: rotateZ(360deg);
131+
transform: rotateZ(360deg);
132+
}
133+
}
134+
135+
@keyframes rotate-animation {
136+
0% {
137+
-webkit-transform: rotateZ(0deg);
138+
transform: rotateZ(0deg);
139+
}
140+
100% {
141+
-webkit-transform: rotateZ(360deg);
142+
transform: rotateZ(360deg);
143+
}
144+
}
145+
146+
@-webkit-keyframes anti-rotate-animation {
147+
0% {
148+
-webkit-transform: rotateZ(0deg);
149+
transform: rotateZ(0deg);
150+
}
151+
100% {
152+
-webkit-transform: rotateZ(-360deg);
153+
transform: rotateZ(-360deg);
154+
}
155+
}
156+
157+
@keyframes anti-rotate-animation {
158+
0% {
159+
-webkit-transform: rotateZ(0deg);
160+
transform: rotateZ(0deg);
161+
}
162+
100% {
163+
-webkit-transform: rotateZ(-360deg);
164+
transform: rotateZ(-360deg);
165+
}
166+
}

assets/js/changelog.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
(function() {
2+
/**
3+
* Fetch releases from github with a cache of 1 hour
4+
* @returns {promise<object[]>}
5+
*/
6+
function fetchReleases() {
7+
var cacheDate = localStorage.releasesCacheDate;
8+
9+
if (cacheDate && (new Date() - new Date(cacheDate)) < 1000 * 3600) {
10+
return $.when(JSON.parse(localStorage.releasesCache));
11+
}
12+
else {
13+
return $.getJSON(releasesAPI)
14+
.then(function(data) {
15+
localStorage.releasesCacheDate = new Date().toString();
16+
localStorage.releasesCache = JSON.stringify(data);
17+
return data;
18+
});
19+
}
20+
}
21+
22+
/**
23+
* Adds a release to #releases
24+
* @param {object} release
25+
*/
26+
function appendRelease(release) {
27+
// Format date
28+
var date = moment(release.published_at).format('LL');
29+
30+
// Convert markdown to html
31+
var desc = marked(release.body, { breaks: true });
32+
33+
// Remove some escaping done by marked.js
34+
desc = desc.replace(/&quot;/g, '"').replace(/&#39;/g, "'");
35+
36+
// Add links to issues
37+
desc = desc.replace(/(#([0-9]+))/g, '<a href="' + issuesBase + '$2">$1</a>');
38+
39+
// Exclude headers from side menu
40+
desc = desc.replace(/(<h[2-5])/g, '$1 data-no-menu');
41+
42+
// Build dom
43+
$('#releases').append(
44+
$('<section>')
45+
.addClass('bs-docs-section')
46+
.append(
47+
$('<h1>')
48+
.addClass('page-header')
49+
.attr('id', release.id)
50+
.text(release.name)
51+
.append(
52+
$('<small>')
53+
.text(date),
54+
$('<a>')
55+
.addClass('release-date')
56+
.attr('href', release.html_url)
57+
.append(
58+
$('<i>').addClass('glyphicon glyphicon-tag')
59+
)
60+
),
61+
$('<article>').html(desc)
62+
)
63+
);
64+
}
65+
66+
fetchReleases()
67+
.then(function(releases) {
68+
$('#spinner').remove();
69+
70+
releases.forEach(function(release) {
71+
appendRelease(release);
72+
});
73+
74+
if (jekyllBootstrapDoc) {
75+
jekyllBootstrapDoc.buildSideMenu();
76+
jekyllBootstrapDoc.addHeadingAnchors();
77+
}
78+
79+
if (window.location.hash && $(window.location.hash).length) {
80+
$(window.location.hash)[0].scrollIntoView();
81+
}
82+
});
83+
}());

assets/js/script.js

Lines changed: 65 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,72 @@
1-
$(function() {
2-
// build side menu
3-
var html = '';
4-
5-
$('.bs-docs-section').each(function() {
6-
var h1 = $(this).find('h1[id]').first(),
7-
h23 = $(this).find('h2[id], h3[id]:not([data-no-menu])');
8-
9-
if (h1.length) {
10-
html += '<li><a href="#' + h1[0].id + '">' + h1.clone().children().remove().end().text() + '</a>';
11-
12-
if (h23.length) {
13-
html += '<ul class="nav">';
14-
h23.each(function() {
15-
html += '<li><a href="#' + this.id + '">' + $(this).clone().children().remove().end().text() + '</a></li>';
16-
});
17-
html += '</ul>';
1+
var jekyllBootstrapDoc = {
2+
buildSideMenu: function() {
3+
var html = '';
4+
5+
$('.bs-docs-section').each(function() {
6+
var h1 = $(this).find('h1[id]').first(),
7+
h23 = $(this).find('h2[id], h3[id]:not([data-no-menu])');
8+
9+
if (h1.length) {
10+
html += '<li><a href="#' + h1[0].id + '">' + h1.clone().children().remove().end().text() + '</a>';
11+
12+
if (h23.length) {
13+
html += '<ul class="nav">';
14+
h23.each(function() {
15+
html += '<li><a href="#' + this.id + '">' + $(this).clone().children().remove().end().text() + '</a></li>';
16+
});
17+
html += '</ul>';
18+
}
19+
20+
html += '</li>';
1821
}
22+
});
1923

20-
html += '</li>';
24+
if (html == '') {
25+
$('[role=complementary]').hide();
26+
$('[role=main]').removeClass('col-md-9').addClass('col-md-12');
27+
}
28+
else {
29+
$('[role=complementary]').show();
30+
$('[role=main]').removeClass('col-md-12').addClass('col-md-9');
31+
$('.bs-docs-sidenav').html(html);
2132
}
22-
});
33+
},
2334

24-
if (html == '') {
25-
$('[role=complementary]').hide();
26-
$('[role=main]').toggleClass('col-md-9 col-md-12');
27-
}
28-
else {
29-
$('.bs-docs-sidenav').html(html);
30-
}
35+
addHeadingAnchors: function() {
36+
$('h1[id], h2[id], h3[id], h4[id], h5[id]').each(function() {
37+
if ($(this).children('.anchor-link').length === 0) {
38+
$(this).prepend('<a href="#' + this.id + '" class="anchor-link">§</i>');
39+
}
40+
});
41+
},
3142

32-
// add heading anchors
33-
$('h1[id], h2[id], h3[id], h4[id], h5[id]').each(function() {
34-
$(this).prepend('<a href="#' + this.id + '" class="anchor-link">§</i>');
35-
});
36-
37-
// enable bootbox
38-
$('[data-bootbox]').on('click', function() {
39-
var $target = $('#' + $(this).data('bootbox'));
40-
bootbox.alert({
41-
title: $target.attr('title'),
42-
message: $target.html(),
43-
size: $(this).data('bootbox-size')
43+
enableBootbox: function() {
44+
$('[data-bootbox]').off('click').on('click', function() {
45+
var $target = $('#' + $(this).data('bootbox'));
46+
bootbox.alert({
47+
title: $target.attr('title'),
48+
message: $target.html(),
49+
size: $(this).data('bootbox-size')
50+
});
51+
});
52+
},
53+
54+
trianglify: function(color1, color2, seed) {
55+
var header = $('#content');
56+
var pattern = Trianglify({
57+
width: window.screen.width | header.outerWidth(),
58+
height: header.outerHeight(),
59+
cell_size: 90,
60+
seed: seed,
61+
x_colors: [color1, color2]
4462
});
45-
});
46-
});
4763

48-
function trianglify(color1, color2, seed) {
49-
var header = $('#content');
50-
var pattern = Trianglify({
51-
width: window.screen.width | header.outerWidth(),
52-
height: header.outerHeight(),
53-
cell_size: 90,
54-
seed: seed,
55-
x_colors: [color1, color2]
56-
});
57-
58-
header.css('background-image', 'url(' + pattern.png() + ')');
59-
}
64+
header.css('background-image', 'url(' + pattern.png() + ')');
65+
}
66+
};
67+
68+
$(function() {
69+
jekyllBootstrapDoc.buildSideMenu();
70+
jekyllBootstrapDoc.addHeadingAnchors();
71+
jekyllBootstrapDoc.enableBootbox();
72+
});

changelog.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
layout: default
3+
title: Changelog
4+
---
5+
6+
<div id="releases">
7+
<div id="spinner" style="text-align:center; color: #888; font-size:100px;">
8+
<span class="spinner"></span>
9+
</div>
10+
</div>
11+
12+
<script src="https://cdn.jsdelivr.net/marked/0.3.5/marked.min.js"></script>
13+
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
14+
15+
<script>
16+
var releasesAPI = 'https://api.github.com/repos/{{site.id}}/releases';
17+
var issuesBase = 'https://github.com/{{site.id}}/issues/';
18+
</script>
19+
20+
<script src="{{site.github.url}}/assets/js/changelog.js"></script>

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ <h3 id="features">Features</h3>
2525
<li>Github counters</li>
2626
<li>Twitter &amp; Facebook buttons</li>
2727
<li>Download options popup</li>
28+
<li>Changelog page generated from GitHub releases</li>
2829
</ul>
2930

3031
<h3 id="examples">Examples</h3>

0 commit comments

Comments
 (0)