jekyll-bonsai 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +676 -0
- data/README.md +2 -6
- data/_config.yml +173 -76
- data/_data/emoji.yml +45 -0
- data/_data/themes.yml +145 -0
- data/_includes/anchor-headings.html +5 -1
- data/_includes/btn_state.html +14 -0
- data/_includes/connect.html +11 -9
- data/_includes/cookie-consent.html +79 -0
- data/_includes/dates.html +22 -0
- data/_includes/hp-tooltip.html +106 -0
- data/_includes/img/bullet-net-web.svg +1 -1
- data/_includes/img/bullet-tree.svg +1 -1
- data/_includes/img/pencil-filter.svg +17 -0
- data/_includes/share.html +10 -8
- data/_includes/site-nav.html +83 -37
- data/_includes/themes.scss.liquid +80 -0
- data/_includes/toc.html +187 -0
- data/_layouts/404.html +10 -0
- data/_layouts/about.html +14 -0
- data/_layouts/archive.html +77 -0
- data/_layouts/base.html +68 -0
- data/_layouts/book.html +49 -0
- data/_layouts/entry.html +221 -93
- data/_layouts/home.html +96 -0
- data/_layouts/post.html +40 -22
- data/_layouts/privacy.html +15 -0
- data/_layouts/recent.html +65 -0
- data/_layouts/state.html +54 -43
- data/_sass/base/_code.scss +133 -0
- data/_sass/base/_layout.scss +30 -29
- data/_sass/base/_link.scss +105 -0
- data/_sass/base/_main.scss +19 -126
- data/_sass/base/_markdown.scss +281 -0
- data/_sass/base/_typography.scss +81 -67
- data/_sass/base/code_themes/_gruvbox.scss +92 -0
- data/_sass/base/code_themes/_monokai.scss +217 -0
- data/_sass/base/code_themes/_solarized.scss +84 -0
- data/_sass/components/_btn.scss +95 -0
- data/_sass/components/_infobox.scss +48 -0
- data/_sass/components/_item.scss +28 -0
- data/_sass/components/_search.scss +61 -0
- data/_sass/components/_tag_pills.scss +24 -0
- data/_sass/components/_visited.scss +42 -0
- data/_sass/includes/_anchor_headings.scss +36 -0
- data/_sass/includes/_connect.scss +8 -0
- data/_sass/includes/_cookie_consent.scss +46 -0
- data/_sass/includes/_dates.scss +6 -0
- data/_sass/includes/_hp_tooltip.scss +41 -0
- data/_sass/includes/_share.scss +10 -0
- data/_sass/includes/_site_nav.scss +26 -150
- data/_sass/includes/_svg.scss +89 -0
- data/_sass/includes/_toc.scss +38 -0
- data/_sass/layouts/_404.scss +3 -0
- data/_sass/layouts/_about.scss +3 -0
- data/_sass/layouts/_archive.scss +26 -0
- data/_sass/layouts/_book.scss +17 -0
- data/_sass/layouts/_entry.scss +140 -0
- data/_sass/layouts/_home.scss +75 -0
- data/_sass/layouts/_post.scss +17 -0
- data/_sass/layouts/_privacy.scss +3 -0
- data/_sass/layouts/_recent.scss +77 -0
- data/_sass/layouts/_state.scss +98 -0
- data/_sass/main.scss +72 -0
- data/_sass/{support → util}/_functions.scss +0 -0
- data/_sass/{support → util}/_variables.scss +21 -87
- data/_sass/{support → util}/mixins/_buttons.scss +0 -0
- data/_sass/util/mixins/_layout.scss +81 -0
- data/_sass/{support → util}/mixins/_typography.scss +0 -0
- data/assets/css/styles.scss +29 -6
- data/assets/img/bonsai-star.png +0 -0
- data/assets/img/bonsai-star.svg +1 -0
- data/assets/img/nav-base-star.svg +1 -0
- data/assets/img/nav-bonsai-star.svg +1 -0
- data/assets/js/entry.js +33 -5
- data/assets/js/graph.js +21 -509
- data/assets/js/scripts.js +41 -57
- data/assets/js/search.js +164 -0
- data/assets/js/site-nav.js +99 -99
- data/assets/js/theme-colors.js +23 -37
- data/assets/js/vendor/lunr.js +3475 -0
- data/assets/js/vendor/lunr.min.js +6 -0
- data/assets/js/visited-nav.js +65 -0
- metadata +143 -150
- data/_entries/digital-garden.bonsai.md +0 -36
- data/_entries/digital-garden.field-logs.md +0 -10
- data/_entries/digital-garden.fork.md +0 -10
- data/_entries/digital-garden.md +0 -17
- data/_entries/digital-garden.path.md +0 -11
- data/_entries/digital-garden.plants.md +0 -12
- data/_entries/digital-garden.pollinate.md +0 -10
- data/_entries/digital-garden.steps.md +0 -10
- data/_entries/digital-garden.stream.md +0 -12
- data/_entries/digital-garden.sweep.md +0 -12
- data/_entries/digital-garden.weather.md +0 -12
- data/_entries/features.md +0 -10
- data/_entries/features.notes.hover-preview.md +0 -10
- data/_entries/features.notes.md +0 -12
- data/_entries/features.notes.note-body.md +0 -12
- data/_entries/features.notes.note-body.share.md +0 -10
- data/_entries/features.notes.note-body.sidenotes.md +0 -52
- data/_entries/features.notes.note-foot.links.md +0 -10
- data/_entries/features.notes.note-foot.md +0 -11
- data/_entries/features.notes.note-foot.posts.md +0 -10
- data/_entries/features.notes.note-foot.webmentions.md +0 -10
- data/_entries/features.notes.note-head.md +0 -10
- data/_entries/features.pages.field-blogs.md +0 -10
- data/_entries/features.pages.md +0 -12
- data/_entries/features.pages.recent.md +0 -10
- data/_entries/features.pages.status-tags.md +0 -10
- data/_entries/features.site-nav.graph.links.md +0 -10
- data/_entries/features.site-nav.graph.links.namespacing.md +0 -14
- data/_entries/features.site-nav.graph.links.wikilinks.md +0 -25
- data/_entries/features.site-nav.graph.md +0 -12
- data/_entries/features.site-nav.graph.nodes.current-note.md +0 -10
- data/_entries/features.site-nav.graph.nodes.md +0 -12
- data/_entries/features.site-nav.graph.nodes.mia.missing-note.md +0 -20
- data/_entries/features.site-nav.graph.nodes.visited-status.md +0 -10
- data/_entries/features.site-nav.graph.toggle-graph.md +0 -13
- data/_entries/features.site-nav.graph.type.md +0 -16
- data/_entries/features.site-nav.graph.type.net-web.md +0 -10
- data/_entries/features.site-nav.graph.type.tree.md +0 -12
- data/_entries/features.site-nav.md +0 -10
- data/_entries/features.site-nav.visited.md +0 -14
- data/_entries/features.tags.md +0 -13
- data/_entries/features.themes.dark.md +0 -12
- data/_entries/features.themes.light.md +0 -10
- data/_entries/features.themes.md +0 -12
- data/_entries/features.visited.delete-data.md +0 -10
- data/_entries/features.visited.md +0 -12
- data/_entries/features.visitor-preferences.md +0 -27
- data/_entries/feedback.md +0 -10
- data/_entries/people.creator.md +0 -12
- data/_entries/people.md +0 -13
- data/_entries/people.visitors.md +0 -12
- data/_entries/plugins.jekyll-wikilinks.md +0 -10
- data/_entries/plugins.md +0 -10
- data/_entries/root.md +0 -26
- data/_includes/entry-attrs.html +0 -27
- data/_includes/head.html +0 -23
- data/_includes/hover-preview.html +0 -84
- data/_includes/metrics.html +0 -10
- data/_includes/styles.scss.liquid +0 -3
- data/_layouts/default.html +0 -39
- data/_pages/about.md +0 -7
- data/_pages/posts.html +0 -19
- data/_pages/recent.html +0 -48
- data/_plugins/doc_filters.rb +0 -44
- data/_plugins/prep_entry.rb +0 -43
- data/_plugins/sidenote.rb +0 -123
- data/_plugins/tags.rb +0 -52
- data/_sass/base/base.scss +0 -3
- data/_sass/color/dark.scss +0 -58
- data/_sass/color/light.scss +0 -58
- data/_sass/includes/_btn.scss +0 -106
- data/_sass/includes/_graph.scss +0 -69
- data/_sass/includes/_nav.scss +0 -89
- data/_sass/includes/_tooltip.scss +0 -29
- data/_sass/includes/includes.scss +0 -9
- data/_sass/markdown/_code.scss +0 -340
- data/_sass/markdown/_content.scss +0 -400
- data/_sass/markdown/_tables.scss +0 -60
- data/_sass/markdown/markdown.scss +0 -7
- data/_sass/modules.scss +0 -14
- data/_sass/pages/_index.scss +0 -72
- data/_sass/pages/_posts.scss +0 -17
- data/_sass/pages/_recent.scss +0 -26
- data/_sass/pages/_state.scss +0 -72
- data/_sass/pages/pages.scss +0 -4
- data/_sass/support/mixins/_layout.scss +0 -56
- data/_sass/support/mixins/mixins.scss +0 -3
- data/_sass/support/support.scss +0 -3
- data/_states/bamboo.md +0 -8
- data/_states/berry.md +0 -8
- data/_states/bloom.md +0 -8
- data/_states/bud.md +0 -6
- data/_states/fruit.md +0 -8
- data/_states/melon.md +0 -8
- data/_states/pot-bamboo.md +0 -8
- data/_states/seed.md +0 -8
- data/_states/sprout.md +0 -8
- data/_states/tags.md +0 -8
- data/_states/tea.md +0 -8
- data/assets/css/styles-dark.scss +0 -3
- data/assets/css/styles-light.scss +0 -3
- data/assets/img/nav-dot-dark.svg +0 -1
- data/assets/img/nav-dot-light.svg +0 -1
- data/assets/img/nav-wiki-links-dark.svg +0 -1
- data/assets/img/nav-wiki-links-light.svg +0 -1
- data/index.html +0 -82
data/assets/js/scripts.js
CHANGED
@@ -1,64 +1,34 @@
|
|
1
1
|
---
|
2
2
|
---
|
3
|
-
import GraphNav from './graph.js';
|
4
|
-
import ThemeColors from './theme-colors.js';
|
5
3
|
import Entry from './entry.js';
|
6
4
|
import SiteNav from './site-nav.js';
|
7
5
|
|
8
|
-
//
|
9
6
|
// go
|
10
|
-
//
|
11
7
|
// from: https://stackoverflow.com/questions/9899372/pure-javascript-equivalent-of-jquerys-ready-how-to-call-a-function-when-t
|
12
8
|
(() => {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
initLinks();
|
10
|
+
|
11
|
+
if (!isSafari() && !isMobile()) {
|
12
|
+
applyPencilFilter();
|
13
|
+
}
|
14
|
+
|
17
15
|
new SiteNav();
|
18
|
-
new GraphNav();
|
19
16
|
if (document.getElementById('entry')) {
|
20
17
|
new Entry();
|
21
18
|
}
|
22
19
|
})();
|
23
20
|
|
24
|
-
//
|
25
|
-
// init
|
26
|
-
//
|
27
|
-
function initListeners () {
|
28
|
-
// open external links in new window; wiki-links in current window.
|
29
|
-
document.querySelectorAll("a:not(.wiki-link):not(.wiki-link-embed-link):not(.sem-tag):not(.stat-tag):not(.anchor-heading):not(.footnote):not(.reversefootnote)").forEach(setupLinkOpen);
|
30
|
-
// init hover-preview.html listeners.
|
31
|
-
document.querySelectorAll('{{ include.wrapperQuerySelector }} a:not(.wiki-link-embed-link):not(.stat-tag):not(.anchor-heading)').forEach(setupListeners);
|
32
|
-
|
33
|
-
document.getElementById('stat-tags-btn')
|
34
|
-
.addEventListener('click', function(event) {
|
35
|
-
goTo('{{ site.baseurl }}/stat/tags');
|
36
|
-
}, false);
|
37
|
-
document.getElementById('posts-btn')
|
38
|
-
.addEventListener('click', function(event) {
|
39
|
-
goTo('{{ site.baseurl }}/posts');
|
40
|
-
}, false);
|
41
|
-
document.getElementById('recent-btn')
|
42
|
-
.addEventListener('click', function(event) {
|
43
|
-
goTo('{{ site.baseurl }}/recent');
|
44
|
-
}, false);
|
45
|
-
document.getElementById('home-btn')
|
46
|
-
.addEventListener('click', function(event) {
|
47
|
-
goTo('{{ site.baseurl }}/');
|
48
|
-
}, false);
|
49
|
-
|
50
|
-
document.getElementById('wiki-link-nav-checkbox')
|
51
|
-
.addEventListener('click', function(event) {
|
52
|
-
expandGraphNav();
|
53
|
-
document.getElementById('svg-graph').dispatchEvent(new Event('draw')); // tell graph to redraw itself
|
54
|
-
}, false);
|
55
|
-
}
|
56
|
-
|
57
|
-
//
|
58
21
|
// helpers
|
59
|
-
|
60
|
-
function
|
61
|
-
|
22
|
+
|
23
|
+
function initLinks() {
|
24
|
+
// web
|
25
|
+
// open external links in new window; wiki-links in current window.
|
26
|
+
document.querySelectorAll('a.web-link').forEach(setupLinkOpen);
|
27
|
+
// wiki
|
28
|
+
// init hp-tooltip.html listeners.
|
29
|
+
document.querySelectorAll('{{ include.wrapperQuerySelector }} a.wiki-link').forEach(setupListeners);
|
30
|
+
// add microdata to wiki links
|
31
|
+
document.querySelectorAll('a.wiki-link').forEach((wikiLink) => wikiLink.classList.add('u-url'));
|
62
32
|
}
|
63
33
|
|
64
34
|
function setupLinkOpen (link) {
|
@@ -66,15 +36,29 @@ function setupLinkOpen (link) {
|
|
66
36
|
link.setAttribute("rel", "noopener"); // for security: https://css-tricks.com/use-target_blank/#correct-html
|
67
37
|
}
|
68
38
|
|
69
|
-
function
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
39
|
+
function applyPencilFilter() {
|
40
|
+
// apply pencil-filter to all svg images
|
41
|
+
let imgElements = document.getElementsByClassName('embed-image-wrapper');
|
42
|
+
Array.prototype.forEach.call(imgElements, (img) => {
|
43
|
+
if (img.firstElementChild.tagName === "svg") {
|
44
|
+
if ('{{ site.bonsai.svg.filter }}') {
|
45
|
+
// attach filter to svg element's parent because of safari/mobile bug
|
46
|
+
// bug from: https://github.com/Fyrd/caniuse/issues/3803
|
47
|
+
// workaround from: https://newbedev.com/why-is-filter-drop-shadow-causing-my-svg-to-disappear-in-safari
|
48
|
+
img.style.filter = "url(#PencilTexture)";
|
49
|
+
}
|
50
|
+
}
|
51
|
+
});
|
80
52
|
}
|
53
|
+
|
54
|
+
function isMobile() {
|
55
|
+
// from: https://stackoverflow.com/questions/58141018/mobile-device-detection
|
56
|
+
var check = false;
|
57
|
+
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera);
|
58
|
+
return check;
|
59
|
+
};
|
60
|
+
|
61
|
+
function isSafari() {
|
62
|
+
// Safari 3.0+ "[object HTMLElementConstructor]"
|
63
|
+
return /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || (typeof safari !== 'undefined' && window['safari'].pushNotification));
|
64
|
+
};
|
data/assets/js/search.js
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
---
|
2
|
+
---
|
3
|
+
|
4
|
+
window.store = {
|
5
|
+
{% for doc in site.documents %}
|
6
|
+
{% unless site.bonsai.nav.search.exclude contains doc.type %}
|
7
|
+
"{{ doc.url | slugify }}": {
|
8
|
+
"title": "{{ doc.title | xml_escape }}",
|
9
|
+
"content": {{ doc.content | strip_html | strip_newlines | jsonify }},
|
10
|
+
"status": "{{ doc.status | xml_escape }}",
|
11
|
+
"tags": "{{ doc.tags | xml_escape }}",
|
12
|
+
"emoji": "{{ doc.emoji | xml_escape }}",
|
13
|
+
"url": "{{ doc.url | xml_escape }}",
|
14
|
+
}
|
15
|
+
{% unless forloop.last %},{% endunless %}
|
16
|
+
{% endunless %}
|
17
|
+
{% endfor %}
|
18
|
+
};
|
19
|
+
export default class Search {
|
20
|
+
|
21
|
+
constructor() {
|
22
|
+
this.searchBtn = document.getElementById('search-btn');
|
23
|
+
this.search = document.getElementById('search');
|
24
|
+
this.searchInput = document.getElementById('search-input');
|
25
|
+
this.searchResults = document.getElementById('search-results');
|
26
|
+
this.navContent = document.getElementById('site-nav-content');
|
27
|
+
this.init();
|
28
|
+
}
|
29
|
+
|
30
|
+
init() {
|
31
|
+
this.searchInput.classList.add('hide');
|
32
|
+
this.searchResults.classList.add('hide');
|
33
|
+
this.initIndex();
|
34
|
+
this.bindEvents();
|
35
|
+
}
|
36
|
+
|
37
|
+
bindEvents() {
|
38
|
+
// keys
|
39
|
+
/// cmd/ctrl + k
|
40
|
+
document.addEventListener('keydown', (event) => {
|
41
|
+
const macKeys = (event.metaKey && (event.key === 'k'));
|
42
|
+
const winKeys = (event.ctrlKey && (event.key === 'k'));
|
43
|
+
if (macKeys || winKeys) {
|
44
|
+
this.toggleSearch();
|
45
|
+
}
|
46
|
+
});
|
47
|
+
// enter
|
48
|
+
document.addEventListener('keydown', (event) => {
|
49
|
+
if (event.key === 'Enter') {
|
50
|
+
this.doSearch();
|
51
|
+
}
|
52
|
+
});
|
53
|
+
/// esc
|
54
|
+
document.addEventListener('keydown', (event) => {
|
55
|
+
if (event.key === 'Escape') {
|
56
|
+
this.hideSearch();
|
57
|
+
}
|
58
|
+
});
|
59
|
+
// btn
|
60
|
+
this.searchBtn.addEventListener('click', () => {
|
61
|
+
this.toggleSearch();
|
62
|
+
});
|
63
|
+
// unfocus
|
64
|
+
this.searchInput.addEventListener('focusout', (event) => {
|
65
|
+
// click on a search result:
|
66
|
+
// if (event.relatedTarget.nodeName !== 'A')
|
67
|
+
if (!event.relatedTarget) {
|
68
|
+
this.hideSearch();
|
69
|
+
}
|
70
|
+
});
|
71
|
+
}
|
72
|
+
|
73
|
+
initIndex() {
|
74
|
+
// lunr: https://lunrjs.com/
|
75
|
+
// from: https://learn.cloudcannon.com/jekyll/jekyll-search-using-lunr-js/
|
76
|
+
// Initalize lunr with the fields it will be searching on. I've given title
|
77
|
+
// a boost of 10 to indicate matches on this field are more important.
|
78
|
+
this.idx = lunr(function () {
|
79
|
+
this.field('id');
|
80
|
+
this.field('title', { boost: 10 });
|
81
|
+
this.field('status');
|
82
|
+
// this.field('tags');
|
83
|
+
this.field('emoji');
|
84
|
+
this.field('content');
|
85
|
+
|
86
|
+
for (var key in window.store) { // Add the data to lunr
|
87
|
+
this.add({
|
88
|
+
'id': key,
|
89
|
+
'title': window.store[key].title,
|
90
|
+
'status': window.store[key].status,
|
91
|
+
// 'tags': window.store[key].tags,
|
92
|
+
'emoji': window.store[key].emoji,
|
93
|
+
'content': window.store[key].content
|
94
|
+
});
|
95
|
+
}
|
96
|
+
});
|
97
|
+
}
|
98
|
+
|
99
|
+
toggleSearch() {
|
100
|
+
if (this.searchInput.classList.contains('hide')) {
|
101
|
+
this.showSearch();
|
102
|
+
} else {
|
103
|
+
this.hideSearch();
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
showSearch() {
|
108
|
+
this.searchInput.classList.remove('hide');
|
109
|
+
this.searchInput.focus();
|
110
|
+
this.navContent.style.filter = "blur(4px)";
|
111
|
+
}
|
112
|
+
|
113
|
+
hideSearch() {
|
114
|
+
this.searchInput.classList.add('hide');
|
115
|
+
this.searchResults.classList.add('hide');
|
116
|
+
this.navContent.style.filter = "";
|
117
|
+
}
|
118
|
+
|
119
|
+
doSearch() {
|
120
|
+
// from: https://learn.cloudcannon.com/jekyll/jekyll-search-using-lunr-js/
|
121
|
+
var results = this.idx.search(this.searchInput.value);
|
122
|
+
this.displayResults(results, window.store);
|
123
|
+
}
|
124
|
+
|
125
|
+
displayResults(results, store) {
|
126
|
+
if (results.length) {
|
127
|
+
var appendString = '<ul>';
|
128
|
+
|
129
|
+
for (var i = 0; i < results.length; i++) {
|
130
|
+
var item = store[results[i].ref];
|
131
|
+
appendString += '<li>'
|
132
|
+
appendString += '<a href="' + '{{ site.baseurl }}' + item.url + '">';
|
133
|
+
if (item.status) {
|
134
|
+
appendString += '<h6> ' + item.status + ' ' + item.title + '</h6>';
|
135
|
+
} else if (item.emoji) {
|
136
|
+
appendString += '<h6> ' + item.emoji + ' ' + item.title + '</h6>';
|
137
|
+
} else {
|
138
|
+
appendString += '<h6> ' + item.title + '</h6>';
|
139
|
+
}
|
140
|
+
appendString += '<p>' + item.content.substring(0, 150) + '...</p>';
|
141
|
+
appendString += '</a>';
|
142
|
+
appendString += '</li>';
|
143
|
+
}
|
144
|
+
} else {
|
145
|
+
var appendString = '<ul><li>No results found</li></ul>';
|
146
|
+
}
|
147
|
+
this.searchResults.innerHTML = appendString + '</ul>';
|
148
|
+
this.searchResults.classList.remove('hide');
|
149
|
+
}
|
150
|
+
|
151
|
+
// getQueryVariable(variable) {
|
152
|
+
// // from: https://learn.cloudcannon.com/jekyll/jekyll-search-using-lunr-js/
|
153
|
+
// var query = window.location.search.substring(1);
|
154
|
+
// var vars = query.split('&');
|
155
|
+
|
156
|
+
// for (var i = 0; i < vars.length; i++) {
|
157
|
+
// var pair = vars[i].split('=');
|
158
|
+
|
159
|
+
// if (pair[0] === variable) {
|
160
|
+
// return decodeURIComponent(pair[1].replace(/\+/g, '%20'));
|
161
|
+
// }
|
162
|
+
// }
|
163
|
+
// }
|
164
|
+
}
|
data/assets/js/site-nav.js
CHANGED
@@ -1,132 +1,132 @@
|
|
1
1
|
---
|
2
2
|
---
|
3
3
|
|
4
|
+
import GraphNav from './graph.js';
|
5
|
+
import Search from './search.js';
|
6
|
+
import ThemeColors from './theme-colors.js';
|
7
|
+
import VisitedNav from './visited-nav.js';
|
8
|
+
|
4
9
|
export default class SiteNav {
|
5
10
|
|
6
11
|
constructor() {
|
7
|
-
//
|
8
|
-
|
9
|
-
this.
|
10
|
-
this.
|
11
|
-
this.
|
12
|
-
|
13
|
-
this.
|
14
|
-
|
12
|
+
// bonsai-burger --> [[.]]
|
13
|
+
this.bonsaiBurger = document.getElementById('bonsai-burger-nav-checkbox');
|
14
|
+
this.sideBar = document.getElementById('side-bar');
|
15
|
+
this.mainView = document.getElementById('main');
|
16
|
+
this.bonsai = document.getElementById('nav-bonsai');
|
17
|
+
|
18
|
+
this.bonsaiBurger.addEventListener('click', () => {
|
19
|
+
this.toggleSiteNav();
|
20
|
+
this.graph.redraw();
|
21
|
+
});
|
15
22
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
23
|
+
// themes
|
24
|
+
new ThemeColors();
|
25
|
+
|
26
|
+
// search
|
27
|
+
{% if site.bonsai.nav.search.enabled %}
|
28
|
+
this.search = new Search();
|
29
|
+
{% endif %}
|
22
30
|
|
23
|
-
|
24
|
-
this.
|
25
|
-
|
26
|
-
|
31
|
+
// graph
|
32
|
+
this.graph = new GraphNav();
|
33
|
+
|
34
|
+
// visited nav
|
35
|
+
{% if site.bonsai.nav.visited.enabled %}
|
36
|
+
// attach elements
|
37
|
+
// this.navType set in initNavType();
|
38
|
+
this.navTypeCheckBox = document.getElementById('nav-type-checkbox');
|
39
|
+
this.navTypeEmojiSpan = document.getElementById('nav-type-emoji-span');
|
40
|
+
this.visited = new VisitedNav();
|
41
|
+
this.initNavType();
|
42
|
+
this.navTypeCheckBox.addEventListener('click', () => {
|
43
|
+
this.updateNavType();
|
44
|
+
});
|
45
|
+
{% endif %}
|
46
|
+
|
47
|
+
// visited data
|
48
|
+
// visitedURLs set in initVisitedData();
|
49
|
+
this.deleteVisitedBtn = document.getElementById('delete-btn');
|
50
|
+
this.initVisitedData();
|
27
51
|
this.deleteVisitedBtn.addEventListener('click', () => {
|
28
|
-
this.
|
52
|
+
this.deleteVisitedData();
|
29
53
|
});
|
30
54
|
}
|
31
55
|
|
56
|
+
// bonsai-burger
|
57
|
+
|
58
|
+
toggleSiteNav() {
|
59
|
+
if (document.getElementById('bonsai-burger-nav-checkbox').checked) {
|
60
|
+
this.sideBar.classList.add('nav-open');
|
61
|
+
this.mainView.classList.add('hide');
|
62
|
+
this.bonsai.hidden = false;
|
63
|
+
} else {
|
64
|
+
this.sideBar.classList.remove('nav-open');
|
65
|
+
this.mainView.classList.remove('hide');
|
66
|
+
this.bonsai.hidden = true;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
// graph <-> visited toggles
|
71
|
+
|
32
72
|
initNavType() {
|
33
73
|
this.navType = localStorage.getItem('nav-type');
|
34
|
-
if (this.navType !== "graph" && this.navType !== "
|
35
|
-
this.navType = '{{ site.
|
74
|
+
if (this.navType !== "graph" && this.navType !== "visited") {
|
75
|
+
this.navType = '{{ site.bonsai.nav.type }}';
|
36
76
|
}
|
37
77
|
this.navTypeCheckBox.checked = (this.navType === "graph");
|
38
78
|
this.updateNavType();
|
39
79
|
}
|
40
80
|
|
41
|
-
initVisited() {
|
42
|
-
this.visited = JSON.parse(localStorage.getItem('visited'));
|
43
|
-
if (!this.visited) this.visited = [];
|
44
|
-
}
|
45
|
-
|
46
81
|
updateNavType() {
|
47
82
|
if (this.navTypeCheckBox.checked) {
|
48
|
-
this.navTypeEmojiSpan.innerText = "
|
83
|
+
this.navTypeEmojiSpan.innerText = "{{ site.data.emoji.visited }}";
|
49
84
|
this.navType = "graph";
|
50
|
-
this.
|
51
|
-
this.
|
52
|
-
document.getElementById("svg-graph").classList.remove("hide");
|
85
|
+
this.visited.hide();
|
86
|
+
this.graph.graphDiv.classList.remove("hide");
|
53
87
|
} else {
|
54
|
-
this.navTypeEmojiSpan.innerText = "
|
55
|
-
this.navType = "
|
56
|
-
|
57
|
-
this.
|
58
|
-
this.visitedNav.classList.add("show");
|
88
|
+
this.navTypeEmojiSpan.innerText = "{{ site.data.emoji.graph }}";
|
89
|
+
this.navType = "visited";
|
90
|
+
this.graph.graphDiv.classList.add("hide");
|
91
|
+
this.visited.show();
|
59
92
|
}
|
60
93
|
localStorage.setItem('nav-type', this.navType);
|
61
94
|
}
|
62
95
|
|
63
|
-
|
64
|
-
// visited
|
65
|
-
//
|
96
|
+
// visited-data
|
66
97
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
98
|
+
initVisitedData() {
|
99
|
+
// init
|
100
|
+
this.visitedURLs = JSON.parse(localStorage.getItem('visited'));
|
101
|
+
if (!this.visitedURLs) this.visitedURLs = [];
|
102
|
+
// populate
|
103
|
+
if (this.visitedURLs) {
|
104
|
+
// remove duplicates to current (since json and !SortedSet)
|
105
|
+
// step backward so splicing doesn't change indeces as tabs are removed
|
106
|
+
for (var i = this.visitedURLs.length - 1; i > -1; i--) {
|
107
|
+
let aTab = this.visitedURLs[i];
|
108
|
+
if ((aTab['title'] == window.document.title)
|
109
|
+
&& (aTab['url'] == window.location.pathname)) {
|
110
|
+
this.visitedURLs.splice(i, 1);
|
111
|
+
}
|
76
112
|
}
|
113
|
+
this.visitedURLs.push({ title: window.document.title, url: window.location.pathname });
|
114
|
+
localStorage.setItem('visited', JSON.stringify(this.visitedURLs));
|
77
115
|
}
|
78
|
-
|
79
|
-
|
116
|
+
// draw
|
117
|
+
{% if site.bonsai.nav.visited.enabled %}
|
118
|
+
this.visited.build(this.visitedURLs);
|
119
|
+
{% endif %}
|
80
120
|
}
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
this.buildVisitedTabs();
|
92
|
-
}
|
93
|
-
|
94
|
-
//
|
95
|
-
// dynamically built elements
|
96
|
-
//
|
97
|
-
|
98
|
-
buildNavLink(title, url) {
|
99
|
-
var visitedNavLink = document.createElement('a');
|
100
|
-
visitedNavLink.setAttribute('href', url);
|
101
|
-
visitedNavLink.classList.add('wiki-link');
|
102
|
-
visitedNavLink.innerText = title;
|
103
|
-
return visitedNavLink;
|
104
|
-
}
|
105
|
-
|
106
|
-
buildNavList() {
|
107
|
-
var visitedNavList = document.createElement('ul');
|
108
|
-
visitedNavList.classList.add('visited-nav-list');
|
109
|
-
return visitedNavList;
|
110
|
-
}
|
111
|
-
|
112
|
-
buildNavListItem(i, o) {
|
113
|
-
var visitedNavListItem = document.createElement('li');
|
114
|
-
visitedNavListItem.classList.add('visited-nav-list-item');
|
115
|
-
visitedNavListItem.classList.add('show');
|
116
|
-
visitedNavListItem.setAttribute('style', `--animation-show-order: ${i};`);
|
117
|
-
// visitedNavListItem.setAttribute('style', `--animation-hide-order: ${o};`);
|
118
|
-
return visitedNavListItem;
|
119
|
-
}
|
120
|
-
|
121
|
-
buildVisitedTabs() {
|
122
|
-
var visitedNavList = this.buildNavList();
|
123
|
-
this.visitedNav.appendChild(visitedNavList);
|
124
|
-
for (var i = this.visited.length - 1; i > -1; i--) {
|
125
|
-
const visitedDoc = this.visited[i];
|
126
|
-
var visitedNavListItem = this.buildNavListItem(this.visited.length - i, i);
|
127
|
-
var visitedNavLink = this.buildNavLink(visitedDoc['title'], visitedDoc['url']);
|
128
|
-
visitedNavListItem.appendChild(visitedNavLink);
|
129
|
-
visitedNavList.appendChild(visitedNavListItem);
|
121
|
+
|
122
|
+
deleteVisitedData() {
|
123
|
+
// reset
|
124
|
+
this.visitedURLs = [];
|
125
|
+
// store
|
126
|
+
localStorage.setItem('visited', JSON.stringify([]));
|
127
|
+
// redraw
|
128
|
+
{% if site.bonsai.nav.visited.enabled %}
|
129
|
+
this.visited.rebuild(this.visitedURLs);
|
130
|
+
{% endif %}
|
130
131
|
}
|
131
|
-
}
|
132
132
|
}
|
data/assets/js/theme-colors.js
CHANGED
@@ -4,14 +4,13 @@
|
|
4
4
|
export default class ThemeColors {
|
5
5
|
constructor() {
|
6
6
|
// this.theme set in initThemeColors();
|
7
|
-
this.cssFile = document.querySelector('[rel="stylesheet"]');
|
8
7
|
this.favicon = document.querySelector('[rel="icon"]');
|
9
8
|
this.navBonsai = document.getElementById('nav-bonsai');
|
10
9
|
this.navBase = document.getElementById('nav-base');
|
11
|
-
this.
|
12
|
-
|
13
|
-
|
14
|
-
this.
|
10
|
+
this.themeColorBtns = document.querySelectorAll('a[data-theme-id]');
|
11
|
+
// logo
|
12
|
+
this.homeLogo = document.getElementById('home-logo');
|
13
|
+
this.rootLogo = document.getElementById('root-logo');
|
15
14
|
this.init();
|
16
15
|
}
|
17
16
|
|
@@ -21,50 +20,37 @@ export default class ThemeColors {
|
|
21
20
|
}
|
22
21
|
|
23
22
|
bindEvents() {
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
Array.prototype.forEach.call(this.themeColorBtns, (btn) => {
|
24
|
+
btn.addEventListener('click', (event) => {
|
25
|
+
this.updateThemeColors(event);
|
26
|
+
});
|
27
27
|
});
|
28
28
|
}
|
29
29
|
|
30
30
|
initThemeColors() {
|
31
31
|
this.theme = localStorage.getItem("theme-colors");
|
32
|
-
if (this.theme
|
33
|
-
this.theme =
|
32
|
+
if (!this.theme) {
|
33
|
+
this.theme = '{{ site.bonsai.default_theme }}' !== "" ? '{{ site.bonsai.default_theme }}' : '{{ site.data.themes[0].id }}';
|
34
34
|
}
|
35
|
-
this.themeColorsCheckbox.checked = (this.theme === "dark");
|
36
35
|
this.updateThemeColors();
|
37
36
|
}
|
38
37
|
|
39
|
-
updateThemeColors () {
|
40
|
-
|
41
|
-
|
42
|
-
this.themeColorsEmojiSpan.innerHTML = "☀️";
|
43
|
-
this.theme = "dark";
|
44
|
-
} else {
|
45
|
-
this.themeColorsEmojiSpan.innerHTML = "🌘";
|
46
|
-
this.theme = "light";
|
38
|
+
updateThemeColors (event) {
|
39
|
+
if (event) {
|
40
|
+
this.theme = event.target.dataset.themeId;
|
47
41
|
}
|
48
|
-
// update
|
49
|
-
|
50
|
-
this.cssFile.setAttribute('href', "{{site.baseurl}}/assets/css/styles-" + this.theme + yesThisReallyIsSupposedToBeCSSNotSCSS);
|
42
|
+
// update theme color data
|
43
|
+
document.documentElement.setAttribute('data-theme', this.theme);
|
51
44
|
// update icons and images
|
52
|
-
this.favicon.setAttribute('href',
|
53
|
-
this.
|
54
|
-
this.
|
55
|
-
if (this.
|
56
|
-
this.
|
45
|
+
this.favicon.setAttribute('href', `{{site.baseurl}}${getComputedStyle(document.documentElement).getPropertyValue('--favicon-src')}`.replaceAll(/\s/g,''));
|
46
|
+
this.navBase.setAttribute('src', `{{site.baseurl}}${getComputedStyle(document.documentElement).getPropertyValue('--nav-burger-base')}`.replaceAll(/\s/g,''));
|
47
|
+
this.navBonsai.setAttribute('src', `{{site.baseurl}}${getComputedStyle(document.documentElement).getPropertyValue('--nav-burger-bonsai')}`.replaceAll(/\s/g,''));
|
48
|
+
if (this.homeLogo) {
|
49
|
+
this.homeLogo.setAttribute('src', `{{site.baseurl}}${getComputedStyle(document.documentElement).getPropertyValue('--logo-src')}`.replaceAll(/\s/g,''));
|
50
|
+
}
|
51
|
+
if (this.rootLogo) {
|
52
|
+
this.rootLogo.setAttribute('src', `{{site.baseurl}}${getComputedStyle(document.documentElement).getPropertyValue('--logo-src')}`.replaceAll(/\s/g,''));
|
57
53
|
}
|
58
|
-
// update bullet icon colors
|
59
|
-
let bulletLinks = document.getElementsByClassName('bullet-link');
|
60
|
-
Array.prototype.forEach.call(bulletLinks, (bl) => {
|
61
|
-
// using $link-line-stroke-color
|
62
|
-
if (this.theme == 'dark') {
|
63
|
-
bl.style.stroke = '#5c5962'; // $grey-dk-200
|
64
|
-
} else {
|
65
|
-
bl.style.stroke = '#8C6239'; // $brown-02
|
66
|
-
}
|
67
|
-
});
|
68
54
|
// save to local storage
|
69
55
|
window.localStorage.setItem('theme-colors', this.theme);
|
70
56
|
}
|