jekyll-bonsai 0.0.3 → 0.0.7

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.
Files changed (193) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +676 -0
  3. data/README.md +3 -5
  4. data/_config.yml +173 -76
  5. data/_data/emoji.yml +45 -0
  6. data/_data/themes.yml +145 -0
  7. data/_includes/anchor-headings.html +5 -1
  8. data/_includes/btn_state.html +14 -0
  9. data/_includes/connect.html +11 -9
  10. data/_includes/cookie-consent.html +79 -0
  11. data/_includes/dates.html +22 -0
  12. data/_includes/hp-tooltip.html +106 -0
  13. data/_includes/img/bullet-net-web.svg +1 -1
  14. data/_includes/img/bullet-tree.svg +1 -1
  15. data/_includes/img/pencil-filter.svg +17 -0
  16. data/_includes/share.html +10 -8
  17. data/_includes/site-nav.html +83 -37
  18. data/_includes/tags.html +49 -0
  19. data/_includes/themes.scss.liquid +80 -0
  20. data/_includes/toc.html +187 -0
  21. data/_layouts/404.html +10 -0
  22. data/_layouts/about.html +14 -0
  23. data/_layouts/archive.html +77 -0
  24. data/_layouts/base.html +68 -0
  25. data/_layouts/book.html +40 -0
  26. data/_layouts/entry.html +238 -93
  27. data/_layouts/home.html +96 -0
  28. data/_layouts/post.html +30 -22
  29. data/_layouts/privacy.html +15 -0
  30. data/_layouts/recent.html +66 -0
  31. data/_layouts/state.html +54 -43
  32. data/_sass/base/_code.scss +133 -0
  33. data/_sass/base/_layout.scss +30 -29
  34. data/_sass/base/_link.scss +105 -0
  35. data/_sass/base/_main.scss +19 -126
  36. data/_sass/base/_markdown.scss +281 -0
  37. data/_sass/base/_typography.scss +81 -67
  38. data/_sass/base/code_themes/_gruvbox.scss +92 -0
  39. data/_sass/base/code_themes/_monokai.scss +217 -0
  40. data/_sass/base/code_themes/_solarized.scss +84 -0
  41. data/_sass/components/_btn.scss +95 -0
  42. data/_sass/components/_infobox.scss +48 -0
  43. data/_sass/components/_item.scss +28 -0
  44. data/_sass/components/_search.scss +61 -0
  45. data/_sass/components/_tag_pills.scss +24 -0
  46. data/_sass/components/_visited.scss +42 -0
  47. data/_sass/includes/_anchor_headings.scss +36 -0
  48. data/_sass/includes/_connect.scss +8 -0
  49. data/_sass/includes/_cookie_consent.scss +46 -0
  50. data/_sass/includes/_dates.scss +6 -0
  51. data/_sass/includes/_hp_tooltip.scss +41 -0
  52. data/_sass/includes/_share.scss +10 -0
  53. data/_sass/includes/_site_nav.scss +26 -150
  54. data/_sass/includes/_svg.scss +89 -0
  55. data/_sass/includes/_toc.scss +38 -0
  56. data/_sass/layouts/_404.scss +3 -0
  57. data/_sass/layouts/_about.scss +3 -0
  58. data/_sass/layouts/_archive.scss +26 -0
  59. data/_sass/layouts/_book.scss +17 -0
  60. data/_sass/layouts/_entry.scss +140 -0
  61. data/_sass/layouts/_home.scss +75 -0
  62. data/_sass/layouts/_post.scss +17 -0
  63. data/_sass/layouts/_privacy.scss +3 -0
  64. data/_sass/layouts/_recent.scss +77 -0
  65. data/_sass/layouts/_state.scss +98 -0
  66. data/_sass/main.scss +72 -0
  67. data/_sass/{support → util}/_functions.scss +0 -0
  68. data/_sass/{support → util}/_variables.scss +21 -87
  69. data/_sass/{support → util}/mixins/_buttons.scss +0 -0
  70. data/_sass/util/mixins/_layout.scss +81 -0
  71. data/_sass/{support → util}/mixins/_typography.scss +0 -0
  72. data/assets/css/styles.scss +29 -6
  73. data/assets/img/bonsai-star.png +0 -0
  74. data/assets/img/bonsai-star.svg +1 -0
  75. data/assets/img/books/the-ancient-art-of-bonsai.png +0 -0
  76. data/assets/img/nav-base-star.svg +1 -0
  77. data/assets/img/nav-bonsai-star.svg +1 -0
  78. data/assets/js/entry.js +33 -5
  79. data/assets/js/graph.js +21 -509
  80. data/assets/js/scripts.js +41 -57
  81. data/assets/js/search.js +165 -0
  82. data/assets/js/site-nav.js +99 -99
  83. data/assets/js/theme-colors.js +23 -37
  84. data/assets/js/vendor/lunr.js +3475 -0
  85. data/assets/js/vendor/lunr.min.js +6 -0
  86. data/assets/js/visited-nav.js +65 -0
  87. metadata +145 -150
  88. data/_entries/digital-garden.bonsai.md +0 -36
  89. data/_entries/digital-garden.field-logs.md +0 -10
  90. data/_entries/digital-garden.fork.md +0 -10
  91. data/_entries/digital-garden.md +0 -17
  92. data/_entries/digital-garden.path.md +0 -11
  93. data/_entries/digital-garden.plants.md +0 -12
  94. data/_entries/digital-garden.pollinate.md +0 -10
  95. data/_entries/digital-garden.steps.md +0 -10
  96. data/_entries/digital-garden.stream.md +0 -12
  97. data/_entries/digital-garden.sweep.md +0 -12
  98. data/_entries/digital-garden.weather.md +0 -12
  99. data/_entries/features.md +0 -10
  100. data/_entries/features.notes.hover-preview.md +0 -10
  101. data/_entries/features.notes.md +0 -12
  102. data/_entries/features.notes.note-body.md +0 -12
  103. data/_entries/features.notes.note-body.share.md +0 -10
  104. data/_entries/features.notes.note-body.sidenotes.md +0 -52
  105. data/_entries/features.notes.note-foot.links.md +0 -10
  106. data/_entries/features.notes.note-foot.md +0 -11
  107. data/_entries/features.notes.note-foot.posts.md +0 -10
  108. data/_entries/features.notes.note-foot.webmentions.md +0 -10
  109. data/_entries/features.notes.note-head.md +0 -10
  110. data/_entries/features.pages.field-blogs.md +0 -10
  111. data/_entries/features.pages.md +0 -12
  112. data/_entries/features.pages.recent.md +0 -10
  113. data/_entries/features.pages.status-tags.md +0 -10
  114. data/_entries/features.site-nav.graph.links.md +0 -10
  115. data/_entries/features.site-nav.graph.links.namespacing.md +0 -14
  116. data/_entries/features.site-nav.graph.links.wikilinks.md +0 -25
  117. data/_entries/features.site-nav.graph.md +0 -12
  118. data/_entries/features.site-nav.graph.nodes.current-note.md +0 -10
  119. data/_entries/features.site-nav.graph.nodes.md +0 -12
  120. data/_entries/features.site-nav.graph.nodes.mia.missing-note.md +0 -20
  121. data/_entries/features.site-nav.graph.nodes.visited-status.md +0 -10
  122. data/_entries/features.site-nav.graph.toggle-graph.md +0 -13
  123. data/_entries/features.site-nav.graph.type.md +0 -16
  124. data/_entries/features.site-nav.graph.type.net-web.md +0 -10
  125. data/_entries/features.site-nav.graph.type.tree.md +0 -12
  126. data/_entries/features.site-nav.md +0 -10
  127. data/_entries/features.site-nav.visited.md +0 -14
  128. data/_entries/features.tags.md +0 -13
  129. data/_entries/features.themes.dark.md +0 -12
  130. data/_entries/features.themes.light.md +0 -10
  131. data/_entries/features.themes.md +0 -12
  132. data/_entries/features.visited.delete-data.md +0 -10
  133. data/_entries/features.visited.md +0 -12
  134. data/_entries/features.visitor-preferences.md +0 -27
  135. data/_entries/feedback.md +0 -10
  136. data/_entries/people.creator.md +0 -12
  137. data/_entries/people.md +0 -13
  138. data/_entries/people.visitors.md +0 -12
  139. data/_entries/plugins.jekyll-wikilinks.md +0 -10
  140. data/_entries/plugins.md +0 -10
  141. data/_entries/root.md +0 -26
  142. data/_includes/entry-attrs.html +0 -27
  143. data/_includes/head.html +0 -23
  144. data/_includes/hover-preview.html +0 -84
  145. data/_includes/metrics.html +0 -10
  146. data/_includes/styles.scss.liquid +0 -3
  147. data/_layouts/default.html +0 -39
  148. data/_pages/about.md +0 -7
  149. data/_pages/posts.html +0 -19
  150. data/_pages/recent.html +0 -48
  151. data/_plugins/doc_filters.rb +0 -44
  152. data/_plugins/prep_entry.rb +0 -43
  153. data/_plugins/sidenote.rb +0 -123
  154. data/_plugins/tags.rb +0 -52
  155. data/_sass/base/base.scss +0 -3
  156. data/_sass/color/dark.scss +0 -58
  157. data/_sass/color/light.scss +0 -58
  158. data/_sass/includes/_btn.scss +0 -106
  159. data/_sass/includes/_graph.scss +0 -69
  160. data/_sass/includes/_nav.scss +0 -89
  161. data/_sass/includes/_tooltip.scss +0 -29
  162. data/_sass/includes/includes.scss +0 -9
  163. data/_sass/markdown/_code.scss +0 -340
  164. data/_sass/markdown/_content.scss +0 -400
  165. data/_sass/markdown/_tables.scss +0 -60
  166. data/_sass/markdown/markdown.scss +0 -7
  167. data/_sass/modules.scss +0 -14
  168. data/_sass/pages/_index.scss +0 -72
  169. data/_sass/pages/_posts.scss +0 -17
  170. data/_sass/pages/_recent.scss +0 -26
  171. data/_sass/pages/_state.scss +0 -72
  172. data/_sass/pages/pages.scss +0 -4
  173. data/_sass/support/mixins/_layout.scss +0 -56
  174. data/_sass/support/mixins/mixins.scss +0 -3
  175. data/_sass/support/support.scss +0 -3
  176. data/_states/bamboo.md +0 -8
  177. data/_states/berry.md +0 -8
  178. data/_states/bloom.md +0 -8
  179. data/_states/bud.md +0 -6
  180. data/_states/fruit.md +0 -8
  181. data/_states/melon.md +0 -8
  182. data/_states/pot-bamboo.md +0 -8
  183. data/_states/seed.md +0 -8
  184. data/_states/sprout.md +0 -8
  185. data/_states/tags.md +0 -8
  186. data/_states/tea.md +0 -8
  187. data/assets/css/styles-dark.scss +0 -3
  188. data/assets/css/styles-light.scss +0 -3
  189. data/assets/img/nav-dot-dark.svg +0 -1
  190. data/assets/img/nav-dot-light.svg +0 -1
  191. data/assets/img/nav-wiki-links-dark.svg +0 -1
  192. data/assets/img/nav-wiki-links-light.svg +0 -1
  193. 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
- // your page initialization code here
14
- // the DOM will be available here
15
- initListeners();
16
- new ThemeColors();
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 goTo (location) {
61
- window.location.href = location;
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 expandGraphNav() {
70
- var siteNav = document.getElementById('site-nav');
71
- var wikiBonsai = document.getElementById('nav-bonsai');
72
-
73
- if (document.getElementById('wiki-link-nav-checkbox').checked) {
74
- siteNav.classList.add('nav-open');
75
- wikiBonsai.hidden = false;
76
- } else {
77
- siteNav.classList.remove('nav-open');
78
- wikiBonsai.hidden = true;
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
+ };
@@ -0,0 +1,165 @@
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
+ event.preventDefault();
45
+ this.toggleSearch();
46
+ }
47
+ });
48
+ // enter
49
+ document.addEventListener('keydown', (event) => {
50
+ if (event.key === 'Enter') {
51
+ this.doSearch();
52
+ }
53
+ });
54
+ /// esc
55
+ document.addEventListener('keydown', (event) => {
56
+ if (event.key === 'Escape') {
57
+ this.hideSearch();
58
+ }
59
+ });
60
+ // btn
61
+ this.searchBtn.addEventListener('click', () => {
62
+ this.toggleSearch();
63
+ });
64
+ // unfocus
65
+ this.searchInput.addEventListener('focusout', (event) => {
66
+ // click on a search result:
67
+ // if (event.relatedTarget.nodeName !== 'A')
68
+ if (!event.relatedTarget) {
69
+ this.hideSearch();
70
+ }
71
+ });
72
+ }
73
+
74
+ initIndex() {
75
+ // lunr: https://lunrjs.com/
76
+ // from: https://learn.cloudcannon.com/jekyll/jekyll-search-using-lunr-js/
77
+ // Initalize lunr with the fields it will be searching on. I've given title
78
+ // a boost of 10 to indicate matches on this field are more important.
79
+ this.idx = lunr(function () {
80
+ this.field('id');
81
+ this.field('title', { boost: 10 });
82
+ this.field('status');
83
+ // this.field('tags');
84
+ this.field('emoji');
85
+ this.field('content');
86
+
87
+ for (var key in window.store) { // Add the data to lunr
88
+ this.add({
89
+ 'id': key,
90
+ 'title': window.store[key].title,
91
+ 'status': window.store[key].status,
92
+ // 'tags': window.store[key].tags,
93
+ 'emoji': window.store[key].emoji,
94
+ 'content': window.store[key].content
95
+ });
96
+ }
97
+ });
98
+ }
99
+
100
+ toggleSearch() {
101
+ if (this.searchInput.classList.contains('hide')) {
102
+ this.showSearch();
103
+ } else {
104
+ this.hideSearch();
105
+ }
106
+ }
107
+
108
+ showSearch() {
109
+ this.searchInput.classList.remove('hide');
110
+ this.searchInput.focus();
111
+ this.navContent.style.filter = "blur(4px)";
112
+ }
113
+
114
+ hideSearch() {
115
+ this.searchInput.classList.add('hide');
116
+ this.searchResults.classList.add('hide');
117
+ this.navContent.style.filter = "";
118
+ }
119
+
120
+ doSearch() {
121
+ // from: https://learn.cloudcannon.com/jekyll/jekyll-search-using-lunr-js/
122
+ var results = this.idx.search(this.searchInput.value);
123
+ this.displayResults(results, window.store);
124
+ }
125
+
126
+ displayResults(results, store) {
127
+ if (results.length) {
128
+ var appendString = '<ul>';
129
+
130
+ for (var i = 0; i < results.length; i++) {
131
+ var item = store[results[i].ref];
132
+ appendString += '<li>'
133
+ appendString += '<a href="' + '{{ site.baseurl }}' + item.url + '">';
134
+ if (item.status) {
135
+ appendString += '<h6> ' + item.status + ' ' + item.title + '</h6>';
136
+ } else if (item.emoji) {
137
+ appendString += '<h6> ' + item.emoji + ' ' + item.title + '</h6>';
138
+ } else {
139
+ appendString += '<h6> ' + item.title + '</h6>';
140
+ }
141
+ appendString += '<p>' + item.content.substring(0, 150) + '...</p>';
142
+ appendString += '</a>';
143
+ appendString += '</li>';
144
+ }
145
+ } else {
146
+ var appendString = '<ul><li>No results found</li></ul>';
147
+ }
148
+ this.searchResults.innerHTML = appendString + '</ul>';
149
+ this.searchResults.classList.remove('hide');
150
+ }
151
+
152
+ // getQueryVariable(variable) {
153
+ // // from: https://learn.cloudcannon.com/jekyll/jekyll-search-using-lunr-js/
154
+ // var query = window.location.search.substring(1);
155
+ // var vars = query.split('&');
156
+
157
+ // for (var i = 0; i < vars.length; i++) {
158
+ // var pair = vars[i].split('=');
159
+
160
+ // if (pair[0] === variable) {
161
+ // return decodeURIComponent(pair[1].replace(/\+/g, '%20'));
162
+ // }
163
+ // }
164
+ // }
165
+ }
@@ -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
- // this.navType set in initNavType();
8
- // this.visited set in initVisited();
9
- this.visitedNav = document.getElementById('visited-nav');
10
- this.navTypeCheckBox = document.getElementById('nav-type-checkbox');
11
- this.navTypeEmojiSpan = document.getElementById('nav-type-emoji-span');
12
- this.deleteVisitedBtn = document.getElementById('delete-btn');
13
- this.init();
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
- init() {
17
- this.initNavType();
18
- this.initVisited();
19
- this.bindEvents();
20
- this.addVisited();
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
- bindEvents() {
24
- this.navTypeCheckBox.addEventListener('click', () => {
25
- this.updateNavType();
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.deleteVisitedHistory();
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 !== "tabs") {
35
- this.navType = '{{ site.nav_type }}';
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.visitedNav.classList.remove("show");
51
- this.visitedNav.classList.add("hide");
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 = "tabs";
56
- document.getElementById("svg-graph").classList.add("hide");
57
- this.visitedNav.classList.remove("hide");
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
- addVisited() {
68
- if (this.visited) {
69
- // remove duplicates to current (since json and !SortedSet)
70
- // step backward so splicing doesn't change indeces as tabs are removed
71
- for (var i = this.visited.length - 1; i > -1; i--) {
72
- let aTab = this.visited[i];
73
- if ((aTab['title'] == window.document.title)
74
- && (aTab['url'] == window.location.pathname)) {
75
- this.visited.splice(i, 1);
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
- this.visited.push({ title: window.document.title, url: window.location.pathname });
79
- localStorage.setItem('visited', JSON.stringify(this.visited));
116
+ // draw
117
+ {% if site.bonsai.nav.visited.enabled %}
118
+ this.visited.build(this.visitedURLs);
119
+ {% endif %}
80
120
  }
81
- this.buildVisitedTabs();
82
- }
83
-
84
- deleteVisitedHistory() {
85
- // reset visited data
86
- this.visited = [];
87
- localStorage.setItem('visited', JSON.stringify([]));
88
- // reset visible elements
89
- document.getElementById('svg-graph').dispatchEvent(new Event('draw')); // tell graph to redraw itself
90
- this.visitedNav.innerHTML = "";
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
  }
@@ -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.themeColorsCheckbox = document.getElementById('theme-colors-checkbox');
12
- this.themeColorsEmojiSpan = document.getElementById('theme-colors-emoji-span');
13
- // home-page logo
14
- this.homeBonsaiLogo = document.getElementById('home-bonsai');
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
- this.themeColorsCheckbox.addEventListener('click', () => {
25
- this.updateThemeColors();
26
- document.getElementById('svg-graph').dispatchEvent(new Event('draw')); // tell graph to redraw itself
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 !== "dark" && this.theme !== "light") {
33
- this.theme = getComputedStyle(document.documentElement).getPropertyValue('content');
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
- // toggle theme colors
41
- if (this.themeColorsCheckbox.checked) {
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 css file
49
- const yesThisReallyIsSupposedToBeCSSNotSCSS = '.css'
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', "{{site.baseurl}}/assets/img/favicon-" + this.theme + ".png");
53
- this.navBonsai.setAttribute('src', "{{site.baseurl}}/assets/img/nav-bonsai-" + this.theme + ".svg");
54
- this.navBase.setAttribute('src', "{{site.baseurl}}/assets/img/nav-base-" + this.theme + ".svg");
55
- if (this.homeBonsaiLogo) {
56
- this.homeBonsaiLogo.setAttribute('src', "{{site.baseurl}}/assets/img/bonsai-" + this.theme + ".svg");
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
  }