Skip to content

Commit

Permalink
Update gems, remove lunr.js (#528)
Browse files Browse the repository at this point in the history
Use Google Programmable Search instead.

Fix drive by unprintables in one article I noticed while on side quests
trying to fix lunr.js.

Before:


![image](https://github.com/user-attachments/assets/e43a7728-a375-4500-a276-969665188640)


After:


![image](https://github.com/user-attachments/assets/0bc1b651-3589-40af-8eb4-52951e07e1cc)
  • Loading branch information
noahp authored Nov 7, 2024
1 parent 43c00ac commit a11b170
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 110 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.7
3.2.2
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:3.0-slim-bullseye
FROM ruby:3.2.2-slim-bullseye

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
Expand Down
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ gem 'jekyll-seo-tag', "~> 2.7.1"

group :jekyll_plugins do
gem 'jekyll-diagrams'
gem 'jekyll-lunr-js-search', :git => 'https://github.com/memfault/jekyll-lunr-js-search.git', :ref => '497e6c31849162d74872ec421017f364fd84b7c4'
end

gem "jekyll-target-blank", "~> 2.0"
Expand Down
61 changes: 24 additions & 37 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
GIT
remote: https://github.com/memfault/jekyll-lunr-js-search.git
revision: 497e6c31849162d74872ec421017f364fd84b7c4
ref: 497e6c31849162d74872ec421017f364fd84b7c4
specs:
jekyll-lunr-js-search (3.3.0)
execjs (~> 2.7)
json (~> 2.0)
nokogiri (~> 1.7)

GEM
remote: https://rubygems.org/
specs:
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
colorator (1.1.0)
concurrent-ruby (1.1.9)
deep_merge (1.2.1)
em-websocket (0.5.2)
concurrent-ruby (1.3.4)
deep_merge (1.2.2)
em-websocket (0.5.3)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
http_parser.rb (~> 0)
eventmachine (1.2.7)
execjs (2.8.1)
ffi (1.15.4)
ffi (1.17.0)
forwardable-extended (2.6.0)
http_parser.rb (0.6.0)
i18n (1.8.10)
http_parser.rb (0.8.0)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
jekyll (4.2.1)
jekyll (4.2.2)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
Expand All @@ -49,47 +38,46 @@ GEM
deep_merge (~> 1.2)
jekyll (>= 3.0)
jekyll-paginate (1.1.0)
jekyll-sass-converter (2.1.0)
jekyll-sass-converter (2.2.0)
sassc (> 2.0.1, < 3.0)
jekyll-seo-tag (2.7.1)
jekyll (>= 3.8, < 5.0)
jekyll-sitemap (1.4.0)
jekyll (>= 3.7, < 5.0)
jekyll-target-blank (2.0.0)
jekyll-target-blank (2.0.2)
jekyll (>= 3.0, < 5.0)
nokogiri (~> 1.10)
jekyll-watch (2.2.1)
listen (~> 3.0)
json (2.6.3)
kramdown (2.3.1)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
liquid (4.0.3)
listen (3.7.0)
liquid (4.0.4)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.4.0)
mini_portile2 (2.8.4)
nokogiri (1.15.3)
mini_portile2 (2.8.7)
nokogiri (1.16.7)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (4.0.6)
racc (1.7.1)
rb-fsevent (0.11.0)
rb-inotify (0.10.1)
public_suffix (6.0.1)
racc (1.8.1)
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rexml (3.2.5)
rouge (3.26.1)
rexml (3.3.9)
rouge (3.30.0)
safe_yaml (1.0.5)
sassc (2.4.0)
ffi (~> 1.9)
terminal-table (2.0.0)
unicode-display_width (~> 1.1, >= 1.1.1)
unicode-display_width (1.8.0)
webrick (1.7.0)
webrick (1.8.2)

PLATFORMS
ruby
Expand All @@ -99,7 +87,6 @@ DEPENDENCIES
jekyll-diagrams
jekyll-feed (~> 0.15.1)
jekyll-get-json (~> 1.0)
jekyll-lunr-js-search!
jekyll-paginate (~> 1.1)
jekyll-seo-tag (~> 2.7.1)
jekyll-sitemap (~> 1.4)
Expand Down
17 changes: 0 additions & 17 deletions _includes/script.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,3 @@
<!-- Start of HubSpot Embed Code -->
<script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/8551838.js"></script>
<!-- End of HubSpot Embed Code -->

{% if jekyll.environment == "production" %}
<!-- This is installed from the https://github.com/slashdotdash/jekyll-lunr-js-search Gem -->
<script src="/js/search.min.js" type="text/javascript" charset="utf-8"></script>
{% endif %}

<script type="text/javascript">
$(function() {
$('#search-input').lunrSearch({
indexUrl : '/js/index.json', // url for the .json file containing search index data
results : '#search-results', // selector for containing search results element
template : '#search-results-template', // selector for Mustache.js template
titleMsg : '', //<h1>Search results<h1>', // message attached in front of results (can be empty)
emptyMsg : '<p>Nothing found.</p>' // shown message if search returns no results
});
});
</script>
39 changes: 5 additions & 34 deletions _includes/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,9 @@
<label for="search-input">
<h3>Search</h3>
</label>
<input autocomplete="off" type="text" id="search-input" name="q" placeholder="Search posts...">
<script
async
src="https://cse.google.com/cse.js?cx=8478db8b25997435c"
></script>
<div class="gcse-search"></div>
</form>

<section id="search-results" style="display: none;"> </section>

{% raw %}
<script id="search-results-template" type="text/mustache">
{{#entries}}
<article class="search-result">
<h1><a href="{{url}}">{{title}}</a></h1>
<small>
{{#date}}<time datetime="{{pubdate}}" pubdate>{{displaydate}}</time>{{/date}}
{{#is_post}}
{{#tags}} #{{.}}{{/tags}}
{{/is_post}}
</small>
</article>
{{/entries}}
</script>
{% endraw %}

<style>
#search-results {
padding-top: 1.3em;
}

.search-result {
padding-bottom: 0.5em;
}

.search-result h1 {
font-size: 1rem;
line-height: 1.5;
}
</style>
2 changes: 1 addition & 1 deletion _posts/2019-08-27-building-a-cli-for-firmware-projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ overridden by our environment, and now we can define this variable ourselves
from our Invoke task!

```
# nRF5_SDK_15.2.0/components/toolchain/gcc/Makefile.common
# nRF5_SDK_15.2.0/components/toolchain/gcc/Makefile.common
CCACHE ?= $(if $(filter Windows%,$(OS)),, \
$(if $(wildcard /usr/bin/ccache),ccache))
Expand Down
1 change: 0 additions & 1 deletion _sass/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ footer {
right: 15px;
width: 18px;
height: 18px;
background-image: url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='iso-8859-1'%3F%3E%3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 512 512' style='enable-background:new 0 0 512 512;' xml:space='preserve'%3E%3Cpath d='M225.474,0C101.151,0,0,101.151,0,225.474c0,124.33,101.151,225.474,225.474,225.474 c124.33,0,225.474-101.144,225.474-225.474C450.948,101.151,349.804,0,225.474,0z M225.474,409.323 c-101.373,0-183.848-82.475-183.848-183.848S124.101,41.626,225.474,41.626s183.848,82.475,183.848,183.848 S326.847,409.323,225.474,409.323z'/%3E%3Cpath d='M505.902,476.472L386.574,357.144c-8.131-8.131-21.299-8.131-29.43,0c-8.131,8.124-8.131,21.306,0,29.43l119.328,119.328 c4.065,4.065,9.387,6.098,14.715,6.098c5.321,0,10.649-2.033,14.715-6.098C514.033,497.778,514.033,484.596,505.902,476.472z'/%3E%3C/svg%3E%0A");
background-repeat: no-repeat;
background-size: contain;
}
Expand Down
16 changes: 0 additions & 16 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,6 @@ function darkModeSetup() {
})
}

// Ensures backward compatibility with IE old versions
function searchScroll() {
const scrollBox = document.getElementById('search-results');
const SCROLLED_CLASSNAME = 'scrolled-down';

if (document.addEventListener && scrollBox) {
scrollBox.addEventListener('scroll', () => {
if (scrollBox.scrollTop > 50) {
scrollBox.classList.add(SCROLLED_CLASSNAME);
} else {
scrollBox.classList.remove(SCROLLED_CLASSNAME);
}
});
}
}

// Function to set a cookie
function setCookie(name, value, days) {
const expires = new Date();
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ You can now access the server at [http://0.0.0.0:4000](http://0.0.0.0:4000)
### Locally

You'll need:

- Python 3.8 or later
- Ruby 2.7.7
- Ruby 3.2.2

#### Install Dependencies

Expand Down

0 comments on commit a11b170

Please sign in to comment.