blueprint-jekyll-theme 0.1.0

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 (61) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +12 -0
  3. data/_includes/bp-agencyhead.html +134 -0
  4. data/_includes/bp-footer.html +104 -0
  5. data/_includes/bp-masthead.html +12 -0
  6. data/_includes/bp-search-box.html +12 -0
  7. data/_includes/display-media.html +22 -0
  8. data/_includes/head.html +24 -0
  9. data/_includes/header-breadcrumb.html +36 -0
  10. data/_includes/homepage/hero.html +46 -0
  11. data/_includes/homepage/media-homepage.html +98 -0
  12. data/_includes/links-baseurl.html +6 -0
  13. data/_includes/main-scripts.html +19 -0
  14. data/_includes/post.json +6 -0
  15. data/_includes/sublinks-baseurl.html +6 -0
  16. data/_layouts/contact-us.html +113 -0
  17. data/_layouts/default.html +15 -0
  18. data/_layouts/homepage.html +28 -0
  19. data/_layouts/media.html +192 -0
  20. data/_layouts/page-with-sideNav.html +124 -0
  21. data/_layouts/page.html +4 -0
  22. data/_layouts/post.html +37 -0
  23. data/_layouts/privacy.html +26 -0
  24. data/_layouts/search.html +40 -0
  25. data/_layouts/terms-of-use.html +26 -0
  26. data/_layouts/who-we-are.html +84 -0
  27. data/assets/img/career/stories/INTERN_serena.jpg +0 -0
  28. data/assets/img/career/stories/TAP_Sharlene.jpg +0 -0
  29. data/assets/img/career/stories/TAP_kaiwen.jpg +0 -0
  30. data/assets/img/career/stories/TAP_weijian.jpg +0 -0
  31. data/assets/img/facebook.png +0 -0
  32. data/assets/img/favicon.ico +0 -0
  33. data/assets/img/home/hero-banner-2.png +0 -0
  34. data/assets/img/home/hero-banner.png +0 -0
  35. data/assets/img/instagram.png +0 -0
  36. data/assets/img/logo_govtech.png +0 -0
  37. data/assets/img/logo_govtech.svg +44 -0
  38. data/assets/img/logo_hlb.svg +1 -0
  39. data/assets/img/post/pdf-icon.svg +7 -0
  40. data/assets/img/twitter.png +0 -0
  41. data/assets/img/what-we-do/application-development.svg +8 -0
  42. data/assets/img/what-we-do/cybersecurity.svg +7 -0
  43. data/assets/img/what-we-do/data-science.svg +11 -0
  44. data/assets/img/what-we-do/digitalisation-guide.svg +14 -0
  45. data/assets/img/what-we-do/geospatial.svg +7 -0
  46. data/assets/img/what-we-do/government-ict.svg +7 -0
  47. data/assets/img/what-we-do/sensors-iot.svg +9 -0
  48. data/assets/img/what-we-do/web-standards.svg +8 -0
  49. data/assets/img/youtube.png +0 -0
  50. data/assets/js/build-index.js +54 -0
  51. data/assets/js/cancel-notification.js +5 -0
  52. data/assets/js/common.js +383 -0
  53. data/assets/js/home.js +53 -0
  54. data/assets/js/jquery.sticky-sidebar.js +749 -0
  55. data/assets/js/lunr.min.js +1 -0
  56. data/assets/js/owl.carousel.js +3275 -0
  57. data/assets/js/search.js +167 -0
  58. data/assets/js/sideNav-offset.js +8 -0
  59. data/assets/js/worker.js +19 -0
  60. data/assets/posts.json +33 -0
  61. metadata +145 -0
@@ -0,0 +1,167 @@
1
+ var runSearch = function(json_data, posts_data) {
2
+
3
+ // Bolds the keywords in the preview string
4
+ function highlightKeywords(content, previewStartPosition, matchMetadata) {
5
+ var previewSize = 300;
6
+ var matchMap = {};
7
+
8
+ // Create an object containing search hit position and length of search hit in the document (for content within preview)
9
+ for (keyword in matchMetadata) {
10
+ var positionArray;
11
+
12
+ if (!matchMetadata[keyword]['content']) {
13
+ return;
14
+ }
15
+
16
+ positionArray = matchMetadata[keyword]['content']['position'];
17
+
18
+ for (var positionIndex = 0; positionIndex < positionArray.length; positionIndex++) {
19
+ var hitPosition = positionArray[positionIndex][0];
20
+ if ((hitPosition >= previewStartPosition) && (hitPosition < previewStartPosition+previewSize)) {
21
+ matchMap[hitPosition] = positionArray[positionIndex][1];
22
+ }
23
+ }
24
+ }
25
+
26
+ // Go through each search hit and bold it
27
+ if (Object.keys(matchMap).length !== 0) {
28
+ var processedPreview = '';
29
+ var currPosition = previewStartPosition;
30
+ for (wordPosition in matchMap) {
31
+ var wordEnd = parseInt(wordPosition) + parseInt(matchMap[wordPosition]) + 1;
32
+ processedPreview += content.substring(currPosition, wordPosition) + '<b>' + content.substring(wordPosition, wordEnd) + '</b>';
33
+ currPosition = wordEnd;
34
+ }
35
+
36
+ if (wordEnd < previewStartPosition+previewSize) {
37
+ processedPreview += content.substring(currPosition, previewStartPosition+previewSize);
38
+ }
39
+ return processedPreview;
40
+ }
41
+
42
+ return content.substring(previewStartPosition, previewStartPosition+previewSize);
43
+ }
44
+
45
+ // Find the earliest space in the preview closest to (firstPosition - numLeadingChars)
46
+ function returnStartOfPreview(content, firstPosition) {
47
+ var numLeadingChars = 30;
48
+ if (firstPosition-numLeadingChars <= 0) {
49
+ return 0;
50
+ } else {
51
+ for (var index = firstPosition-numLeadingChars; index < firstPosition; index++) {
52
+ if (content.charAt(index) === ' ') {
53
+ return index;
54
+ }
55
+ }
56
+ return firstPosition;
57
+ }
58
+ }
59
+
60
+ // Find the position of the first keyword match in the document
61
+ function returnFirstKeywordPosition(matchMetadata) {
62
+ var firstPosition = -1;
63
+
64
+ // Iterate over each keyword in the search query
65
+ for (keyword in matchMetadata) {
66
+
67
+ if (matchMetadata[keyword]['content'] !== undefined) {
68
+ var positionArray = matchMetadata[keyword]['content']['position'];
69
+
70
+ // Find the earliest first position across all keywords
71
+ for (var positionIndex = 0; positionIndex < positionArray.length; positionIndex++) {
72
+ if (firstPosition == -1 || (firstPosition > positionArray[positionIndex][0])) {
73
+ firstPosition = positionArray[positionIndex][0];
74
+ }
75
+ }
76
+ }
77
+ }
78
+
79
+ return firstPosition;
80
+ }
81
+
82
+ // Return the preview content for each search result - returns the snippet that has the first hit in the document (up to 300 chars)
83
+ function returnResultsList(results) {
84
+ var searchPara = '';
85
+ var post_data = posts_data; // Obtain JSON var of all the posts in the site
86
+
87
+
88
+ // Iterate over the results
89
+ for (var i = 0; i < results.length; i++) {
90
+ var key = parseInt(results[i]['ref']);
91
+ var resultObject = post_data[key];
92
+
93
+
94
+ var matchMetadata = results[i]['matchData']['metadata'];
95
+ var keywordSet = new Set();
96
+
97
+ var titleTruncateLength = 90;
98
+ var resultTitle = resultObject['title'].substring(0, titleTruncateLength);
99
+
100
+ if (resultObject['title'].length > titleTruncateLength) {
101
+ var indexOfLastWord = resultObject['title'].substring(0,titleTruncateLength).lastIndexOf(" ");
102
+ var resultTitle = resultObject['title'].substring(0, indexOfLastWord);
103
+ resultTitle += ' ...';
104
+ }
105
+ searchPara += '<a class="search-content" href="' + resultObject['url'] + '">' + ' ' + resultTitle + '</a>';
106
+
107
+ // Find the position of the earliest keyword in the document
108
+ var firstPosition = returnFirstKeywordPosition(matchMetadata);
109
+
110
+ // Find the preview start position
111
+ var previewStartPosition = returnStartOfPreview(resultObject['content'], firstPosition);
112
+
113
+ // Process the preview to embolden keywords
114
+ var processedPreview = highlightKeywords(resultObject['content'], previewStartPosition, matchMetadata);
115
+ // var postDate = new Date(resultObject['datestring']).toDateString().substring(4);
116
+ searchPara += '<p class="search-content permalink">' + resultObject['url'] + '</p><br>';
117
+ // searchPara += '<p class="search-content" > '+ postDate + ' ...' + processedPreview + '...</p><br>';
118
+
119
+ if (processedPreview) {
120
+ searchPara += '<p class="search-content" > ' + ' ...' + processedPreview + '...</p><br>';
121
+ }
122
+ }
123
+
124
+ return searchPara;
125
+ }
126
+
127
+ // Display search results if there are results, else, state that there are no results found
128
+ function displaySearchResults(results, searchTerm) {
129
+ var searchResults = document.getElementById('search-results');
130
+ var searchResultsCount = document.getElementById('search-results-count');
131
+ // document.getElementById('search-bar').setAttribute("value", searchTerm);
132
+ document.getElementsByName('query')[1].setAttribute("value", searchTerm);
133
+ searchResultsCount.innerHTML = results.length + " results for '" + searchTerm + "'";
134
+ if (results.length) { // If there are results
135
+ searchResults.innerHTML = returnResultsList(results);
136
+ } else {
137
+ searchResults.innerHTML = '';
138
+ }
139
+ }
140
+
141
+ // Obtain the query string, load the pre-built lunr index, and perform search
142
+ function getQueryVariable(variable) {
143
+ var query = window.location.search.substring(1);
144
+ var vars = query.split('&');
145
+
146
+ for (var i = 0; i < vars.length; i++) {
147
+ var pair = vars[i].split('=');
148
+
149
+ if (pair[0] === variable) {
150
+ return decodeURIComponent(pair[1].replace(/\+/g, '%20'));
151
+ }
152
+ }
153
+ }
154
+
155
+ var searchTerm = getQueryVariable('query');
156
+
157
+ if (searchTerm) {
158
+
159
+ // Load the pre-built lunr index
160
+ var idx = lunr.Index.load(JSON.parse(json_data));
161
+
162
+ // Get lunr to perform a search
163
+ var results = idx.search(searchTerm);
164
+
165
+ window.onload = displaySearchResults(results, searchTerm);
166
+ }
167
+ };
@@ -0,0 +1,8 @@
1
+ $(document).ready(function(){
2
+ $('.sidenav').stickySidebar({
3
+ topSpacing: 40,
4
+ bottomSpacing: 40,
5
+ containerSelector: '.has-side-nav',
6
+ innerWrapperSelector: '.sidebar__inner'
7
+ });
8
+ });
@@ -0,0 +1,19 @@
1
+ onmessage = function(event) {
2
+ self.importScripts('https://unpkg.com/lunr/lunr.js');
3
+
4
+ var documents = event.data;
5
+
6
+ var index = lunr(function () {
7
+ this.ref('id');
8
+ this.field('url');
9
+ this.field('title');
10
+ this.field('content');
11
+ this.metadataWhitelist = ['position'];
12
+
13
+ documents.forEach(function(doc) {
14
+ this.add(doc);
15
+ }, this);
16
+ });
17
+
18
+ postMessage(JSON.stringify(index));
19
+ }
@@ -0,0 +1,33 @@
1
+ ---
2
+
3
+ ---
4
+ {% assign index = 0 %} {% assign tempindex = 0 %}posts_json=[
5
+ {%- for post in site.application-guidelines -%}
6
+ {%- assign tempindex = forloop.index0 -%}
7
+ {%- assign index = tempindex -%}
8
+ {%- include post.json -%},
9
+ {%- endfor -%}
10
+
11
+
12
+ {%- for post in site.posts -%}
13
+
14
+ {%- capture index -%}
15
+ {{ tempindex | plus: forloop.index}}
16
+ {%- endcapture -%}
17
+
18
+ {%- include post.json -%},
19
+ {%- endfor -%}
20
+ {%- assign tempindex = index -%}
21
+
22
+
23
+
24
+ {%- for post in site.html_pages -%}
25
+
26
+ {%- capture index -%}
27
+ {{ tempindex | plus: forloop.index}}
28
+ {%- endcapture -%}
29
+
30
+ {%- include post.json -%}{% unless forloop.last %},{% endunless %}
31
+ {%- endfor -%}
32
+
33
+ ]
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blueprint-jekyll-theme
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Preston
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-06-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.0'
55
+ description:
56
+ email:
57
+ - prestonlimlianjie@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - README.md
63
+ - _includes/bp-agencyhead.html
64
+ - _includes/bp-footer.html
65
+ - _includes/bp-masthead.html
66
+ - _includes/bp-search-box.html
67
+ - _includes/display-media.html
68
+ - _includes/head.html
69
+ - _includes/header-breadcrumb.html
70
+ - _includes/homepage/hero.html
71
+ - _includes/homepage/media-homepage.html
72
+ - _includes/links-baseurl.html
73
+ - _includes/main-scripts.html
74
+ - _includes/post.json
75
+ - _includes/sublinks-baseurl.html
76
+ - _layouts/contact-us.html
77
+ - _layouts/default.html
78
+ - _layouts/homepage.html
79
+ - _layouts/media.html
80
+ - _layouts/page-with-sideNav.html
81
+ - _layouts/page.html
82
+ - _layouts/post.html
83
+ - _layouts/privacy.html
84
+ - _layouts/search.html
85
+ - _layouts/terms-of-use.html
86
+ - _layouts/who-we-are.html
87
+ - assets/img/career/stories/INTERN_serena.jpg
88
+ - assets/img/career/stories/TAP_Sharlene.jpg
89
+ - assets/img/career/stories/TAP_kaiwen.jpg
90
+ - assets/img/career/stories/TAP_weijian.jpg
91
+ - assets/img/facebook.png
92
+ - assets/img/favicon.ico
93
+ - assets/img/home/hero-banner-2.png
94
+ - assets/img/home/hero-banner.png
95
+ - assets/img/instagram.png
96
+ - assets/img/logo_govtech.png
97
+ - assets/img/logo_govtech.svg
98
+ - assets/img/logo_hlb.svg
99
+ - assets/img/post/pdf-icon.svg
100
+ - assets/img/twitter.png
101
+ - assets/img/what-we-do/application-development.svg
102
+ - assets/img/what-we-do/cybersecurity.svg
103
+ - assets/img/what-we-do/data-science.svg
104
+ - assets/img/what-we-do/digitalisation-guide.svg
105
+ - assets/img/what-we-do/geospatial.svg
106
+ - assets/img/what-we-do/government-ict.svg
107
+ - assets/img/what-we-do/sensors-iot.svg
108
+ - assets/img/what-we-do/web-standards.svg
109
+ - assets/img/youtube.png
110
+ - assets/js/build-index.js
111
+ - assets/js/cancel-notification.js
112
+ - assets/js/common.js
113
+ - assets/js/home.js
114
+ - assets/js/jquery.sticky-sidebar.js
115
+ - assets/js/lunr.min.js
116
+ - assets/js/owl.carousel.js
117
+ - assets/js/search.js
118
+ - assets/js/sideNav-offset.js
119
+ - assets/js/worker.js
120
+ - assets/posts.json
121
+ homepage: https://github.com/opengovsg/blueprint-jekyll-theme
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.7.4
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: This theme built using the beta version of the Blueprint Design System.
145
+ test_files: []