madness 0.9.1 → 0.9.2

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: 47b714c88a5567bdac3687145b5d69456f593c71aa7cb712f162a257bd4d3d5c
4
- data.tar.gz: ec6667431386f6fca35632be3732bd1ca8e6e48b9494320ab710f4f354e5c8c6
3
+ metadata.gz: 6e6d1a2a1af740dbcace6dcf480bdb39bd070f1a2950d0bfdc75728ee99104cf
4
+ data.tar.gz: 4342dcc15681c42998f97736dda3d118c5062e295beae85e482ebf850e920977
5
5
  SHA512:
6
- metadata.gz: 138229a6aae6c248876ccd5ab49873baed8c83c868676ecd2885e2b4b567b61ffabe047aafad085731b8b7261bff9d10bfc079c23a6b1e238b9ee3596de1c914
7
- data.tar.gz: 38e6889d17c90470bffae9c28f61ec9b4367d05cebac5830d5f5a02dbbf2abc7c7e302898e092052a6fdff3678a1b2296213cf10d803af119dc151a592e703e4
6
+ metadata.gz: 0d8c1f9366a41f91332e775c8c26d3a1994f4b13694a342a55c18a8cf99124f59257b3ce7f7ce1634c5759003dcfeb3a63f74f75ee1abaf835a30c9e83d68f9d
7
+ data.tar.gz: 7ed9cafc3418cdd966a55c2d0ba2fddee9e5e3bdae5c159e6caea8108d845d32a78ccdd77464469f8ff3cbdd70e70dac79e652e6001e980ea8662a3a0530ddee
@@ -2,7 +2,7 @@
2
2
 
3
3
  .main class=(config.sidebar ? 'with-sidebar' : 'without-sidebar')
4
4
  form.search-form action="/_search" method="get"
5
- input.search-field type="text" name="q" value="#{params[:q]}" placeholder="Search" autofocus=true
5
+ input.search-field type="text" name="q" value="#{params[:q]}" placeholder="Search (use quotes for exact match)" autofocus=true
6
6
  input type="submit" value="Search" style='display:none'
7
7
 
8
8
  hr
@@ -1,3 +1,5 @@
1
+ require 'shellwords'
2
+
1
3
  module Madness
2
4
  class Search
3
5
  include ServerHelper
@@ -13,14 +15,19 @@ module Madness
13
15
 
14
16
  def search(query)
15
17
  query = query.downcase
18
+ words = Shellwords.split query
19
+ word_count = words.count
16
20
  result = {}
21
+ return result if words.empty?
17
22
 
18
23
  index.each do |file, content|
19
24
  file = file.remove("#{@path}/")[0...-3]
20
25
  url = file_url file
21
26
  label = file_label file
22
- next unless content.include? query
23
- result[label] = url
27
+ found = 0
28
+ words.each { |word| found += 1 if content.include? word }
29
+ next unless found == word_count
30
+ result[label] = url
24
31
  end
25
32
 
26
33
  result
@@ -1,3 +1,3 @@
1
1
  module Madness
2
- VERSION = "0.9.1"
2
+ VERSION = "0.9.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: madness
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-04 00:00:00.000000000 Z
11
+ date: 2021-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coderay