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 +4 -4
- data/app/views/search.slim +1 -1
- data/lib/madness/search.rb +9 -2
- data/lib/madness/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e6d1a2a1af740dbcace6dcf480bdb39bd070f1a2950d0bfdc75728ee99104cf
|
4
|
+
data.tar.gz: 4342dcc15681c42998f97736dda3d118c5062e295beae85e482ebf850e920977
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d8c1f9366a41f91332e775c8c26d3a1994f4b13694a342a55c18a8cf99124f59257b3ce7f7ce1634c5759003dcfeb3a63f74f75ee1abaf835a30c9e83d68f9d
|
7
|
+
data.tar.gz: 7ed9cafc3418cdd966a55c2d0ba2fddee9e5e3bdae5c159e6caea8108d845d32a78ccdd77464469f8ff3cbdd70e70dac79e652e6001e980ea8662a3a0530ddee
|
data/app/views/search.slim
CHANGED
@@ -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
|
data/lib/madness/search.rb
CHANGED
@@ -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
|
-
|
23
|
-
|
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
|
data/lib/madness/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2021-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coderay
|