jekyll_ranked_search 0.0.4 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa336a48a9eb94c3a0e7e395dee1a9c4a7938339cfa800e528db49b3c2876953
4
- data.tar.gz: ced1e0e9cd3919a5a5fc28848c80523a81987698c11b0be0b4ea487f5f3ca3a7
3
+ metadata.gz: b7a50962fa0617b6acc80b702c06695a27f2ad056030e80e4c099230f958d39b
4
+ data.tar.gz: c26e47d1f49e7d50edd91c1263dde8a6188b0a2c491bc99d22223f98dc60b9a6
5
5
  SHA512:
6
- metadata.gz: f87c796fa346ac49d87bb939ee85ed37cfbe4083954a2963e2fb04e95963b87e0b95d2b5b03356364a1ce84f59d366fc74477e65fd532f1808ed272b810cda22
7
- data.tar.gz: 811a1bebdcbef011282022bfe7083d2284d0c690132aad7a79431fd01fd0548144540f8499c61e04458e6f93ab1b29f4a61a3d05c220e5fede490ce7c05d5861
6
+ metadata.gz: d6f1fa610a8afa056eb0451ea234294044beae405e4375a46e495c83cf6ab697a57f978e394082705f0692057ffb316e53a99d6d80099cfa6cebfdcd15a7df9e
7
+ data.tar.gz: 4557557cbbc06268b6fbe725de5d7cbe31ab72ffaffa3393b46ec9e9c4ba9eee68cff3ba39ce655d3e1c97f420eb152f86246b7eb88eb8333fab32d3ec029e66
@@ -122,15 +122,26 @@ class TfidfConverter < Jekyll::Generator
122
122
  site.data['tfidf'] = tfidf.to_json
123
123
  end
124
124
 
125
+ # Tokenize document by removing special characters and splitting
126
+ # the document into tokens.
127
+ # @param [String] doc The document to tokenize
128
+ # @return [Array<String>] individual tokens/words
125
129
  def tokenize_words(doc)
126
130
  # Remove stopwords from document
127
131
  @stopwords ||= self.load_stopwords
128
132
 
133
+ # TODO: Remove Liquid tags via regex
134
+
129
135
  # Split document into tokens
130
136
  splitted_doc = doc.strip.downcase.split
131
137
 
132
138
  # Remove stopwords in place
133
- splitted_doc.delete_if { |word| @stopwords.include?(word) }
139
+ splitted_doc.delete_if do |word|
140
+ if @stopwords.include?(word)
141
+ Jekyll.logger.debug "Removing stopword:", word
142
+ end
143
+ @stopwords.include?(word)
144
+ end
134
145
 
135
146
  # Remove special characters (only at beginning and end)
136
147
  splitted_doc.map! { |word| word.gsub(/[^a-z0-9_\/\-\s]/i, '') }
@@ -138,11 +149,12 @@ class TfidfConverter < Jekyll::Generator
138
149
  splitted_doc
139
150
  end
140
151
 
141
- # Load stopwords from file
152
+ # Load english stopwords from file
153
+ # @return [Array<String>] the stopwords
142
154
  def load_stopwords
143
155
  Jekyll.logger.info "Loading stopwords"
144
156
  stopwords = Set.new
145
- File.open(File.join(File.dirname(__FILE__), "stopwords.txt"), "r") do |f|
157
+ File.open(File.join(File.dirname(__FILE__), "stopwords/en.txt"), "r") do |f|
146
158
  f.each_line do |line|
147
159
  stopwords.add line.strip
148
160
  end
data/lib/search.js CHANGED
@@ -54,7 +54,7 @@ class SearchBox extends LitElement {
54
54
  box-sizing: border-box;
55
55
  width: 100%;
56
56
  // margin: 0 auto;
57
- padding: .4em;
57
+ padding: .4em 30px;
58
58
  border: 1px solid #ccc;
59
59
  font-size: 1.2em;
60
60
  border-radius: 4px;
@@ -62,6 +62,20 @@ class SearchBox extends LitElement {
62
62
  z-index: 11;
63
63
  }
64
64
 
65
+ label {
66
+ position: relative;
67
+ }
68
+
69
+ label::before {
70
+ content: "";
71
+ position: absolute;
72
+ left: 10px;
73
+ top: 0;
74
+ bottom: 0;
75
+ width: 20px;
76
+ background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='currentColor' class=''%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z' /%3E%3C/svg%3E") no-repeat center center;
77
+ }
78
+
65
79
  #results {
66
80
  position: absolute;
67
81
  width: 100%;
@@ -245,7 +259,9 @@ class SearchBox extends LitElement {
245
259
 
246
260
  render() {
247
261
  return html`<div>
262
+ <label>
248
263
  <input id="q" type="text" placeholder="${this._placeholder}" @keyup="${this.search}" @click=${this.openIfResults} @focus=${this.focus}>
264
+ </label>
249
265
  ${this._open ? html`
250
266
  <div id="results">
251
267
  ${this._results.map((result) => html`
@@ -2,8 +2,6 @@
2
2
  'tis
3
3
  'twas
4
4
  've
5
- 10
6
- 39
7
5
  a
8
6
  a's
9
7
  able
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_ranked_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Friedrich Ewald
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-05 00:00:00.000000000 Z
11
+ date: 2024-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redcarpet
@@ -24,7 +24,10 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.6'
27
- description: Offline search plugin for Jekyll posts using TF-IDF
27
+ description: |
28
+ A webcomponent based search box that provides search functionality for your Jekyll blog.
29
+
30
+ If you have any feedback or suggestions for improvement, please open an issue on Github.
28
31
  email: freddiemailster@gmail.com
29
32
  executables: []
30
33
  extensions: []
@@ -33,7 +36,7 @@ files:
33
36
  - lib/jekyll_ranked_search.rb
34
37
  - lib/search.js
35
38
  - lib/search.json
36
- - lib/stopwords.txt
39
+ - lib/stopwords/en.txt
37
40
  homepage: https://github.com/f-ewald/jekyll_ranked_search
38
41
  licenses:
39
42
  - MIT
@@ -53,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
56
  - !ruby/object:Gem::Version
54
57
  version: '0'
55
58
  requirements: []
56
- rubygems_version: 3.4.13
59
+ rubygems_version: 3.4.15
57
60
  signing_key:
58
61
  specification_version: 4
59
62
  summary: TF-IDF offline search for Jekyll posts