Skip to content

Commit 82693eb

Browse files
committed
Add changelog page
1 parent 73f9e0a commit 82693eb

File tree

6 files changed

+169
-52
lines changed

6 files changed

+169
-52
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/jQuery-QueryBuilder
13
# name of the software
24
name: jQuery QueryBuilder
35
# current version of the software

_includes/navbar.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
<a href="{{site.github.url}}/api">API</a>
1111
</li>
1212

13+
<li>
14+
<a href="{{site.github.url}}/changelog.html">Changelog</a>
15+
</li>
16+
1317
<li class="dropdown">
1418
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button">Advanced <span class="caret"></span></a>
1519
<ul class="dropdown-menu">

_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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,16 @@ h4:hover .anchor-link,
5757
h5:hover .anchor-link {
5858
opacity: 1;
5959
}
60+
61+
#releases h1 {
62+
font-size: 28px;
63+
}
64+
65+
#releases h1 small {
66+
padding-left: 1em;
67+
}
68+
69+
#releases h1 a.release-date {
70+
float: right;
71+
font-size: 18px;
72+
}

assets/js/script.js

Lines changed: 64 additions & 51 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() + ')');
64+
header.css('background-image', 'url(' + pattern.png() + ')');
65+
}
5966
}
67+
68+
$(function() {
69+
jekyllBootstrapDoc.buildSideMenu();
70+
jekyllBootstrapDoc.addHeadingAnchors();
71+
jekyllBootstrapDoc.enableBootbox();
72+
});

changelog.html

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
layout: default
3+
title: Changelog
4+
---
5+
6+
<div id="releases"></div>
7+
8+
<script src="https://cdn.jsdelivr.net/marked/0.3.5/marked.min.js"></script>
9+
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
10+
11+
<script>
12+
var releasesAPI = 'https://api.github.com/repos/{{site.id}}/releases';
13+
var issuesBase = 'https://github.com/{{site.id}}/issues/';
14+
15+
(function() {
16+
function fetchReleases() {
17+
var cacheDate = localStorage.releasesCacheDate;
18+
19+
if (cacheDate && (new Date() - new Date(cacheDate)) < 1000 * 3600) {
20+
return $.when(JSON.parse(localStorage.releasesCache));
21+
}
22+
else {
23+
return $.getJSON(releasesAPI)
24+
.then(function(data) {
25+
localStorage.releasesCacheDate = new Date().toString();
26+
localStorage.releasesCache = JSON.stringify(data);
27+
return data;
28+
});
29+
}
30+
}
31+
32+
function unescape(html) {
33+
return html
34+
.replace(/&quot;/g, '"')
35+
.replace(/&#39;/g, "'");
36+
}
37+
38+
function replaceIssueLinks(html) {
39+
return html.replace(/(#([0-9]+))/g, '<a href="' + issuesBase + '$2">$1</a>');
40+
}
41+
42+
function sanitizeHeaders(html) {
43+
return html.replace(/(<h[2-5])/g, '$1 data-no-menu');
44+
}
45+
46+
function appendRelease(release, container) {
47+
var date = moment(release.published_at);
48+
var desc = sanitizeHeaders(replaceIssueLinks(unescape(marked(release.body, { breaks: true }))));
49+
50+
container.append(
51+
$('<section>')
52+
.addClass('bs-docs-section')
53+
.append(
54+
$('<h1>')
55+
.addClass('page-header')
56+
.attr('id', release.id)
57+
.text(release.name)
58+
.append(
59+
$('<small>')
60+
.text(date.format('LL')),
61+
$('<a>')
62+
.addClass('release-date')
63+
.attr('href', release.html_url)
64+
.html('<i class="glyphicon glyphicon-tag"></i>')
65+
),
66+
$('<article>').html(desc)
67+
)
68+
);
69+
}
70+
71+
fetchReleases()
72+
.then(function(releases) {
73+
var container = $('#releases');
74+
75+
releases.forEach(function(release) {
76+
appendRelease(release, container);
77+
});
78+
79+
if (jekyllBootstrapDoc) {
80+
jekyllBootstrapDoc.buildSideMenu();
81+
jekyllBootstrapDoc.addHeadingAnchors();
82+
}
83+
});
84+
}());
85+
</script>

0 commit comments

Comments
 (0)