j1m_search 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.md +21 -0
- data/README.md +41 -0
- data/_data/modules/default/j1_search-0.0.1/j1_jekyll_search.yml +134 -0
- data/_data/resources/default/j1_search-0.0.1/resource.yml +24 -0
- data/_plugins/simple_search_filter.rb +37 -0
- data/assets/data/search.json +79 -0
- data/assets/themes/j1/j1/js/adapters/simple_jekyll_search.js +85 -0
- data/assets/themes/j1/simple_jekyll_search/css/search.css +91 -0
- data/assets/themes/j1/simple_jekyll_search/js/jekyll_search.js +467 -0
- data/assets/themes/j1/simple_jekyll_search/js/jekyll_search.min.js +25 -0
- data/assets/themes/j1/simple_jekyll_search/js/jekyll_view_results.js +39 -0
- data/assets/themes/j1/simple_jekyll_search/json/search.json +63 -0
- data/assets/themes/j1/simple_jekyll_search/plugins/simple_search_filter.rb +19 -0
- data/exe/console +14 -0
- data/exe/setup +8 -0
- data/lib/j1m_search.rb +5 -0
- data/lib/j1m_search/version.rb +3 -0
- metadata +107 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8f70649369e9732ff01c58bfd3847bd3ad5785c4
|
4
|
+
data.tar.gz: 6cc91f989e5cf20e9f4ca6b70b7cea8774ead112
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a5cecb84956f0ed6325be536b02eda8593efd52213e2f6fb24ec29964df51017660a2b70b9e3d7f1691836212af534a8dfa25d4e4fc2e9d76746e41b7da95f92
|
7
|
+
data.tar.gz: 073ed2ce6784ec7d148a1a5e773aaba1bd02d48ed90ad7dfa68a97dae41ca8ee8d07421662a66071d426bb425711edbe52cdb7374642fddf5cd6710f35191276
|
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Juergen Adams
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# J1mNav
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/j1m_nav`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'j1m_nav'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install j1m_nav
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/j1m_nav.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
@@ -0,0 +1,134 @@
|
|
1
|
+
# ------------------------------------------------------------------------------
|
2
|
+
# J1: ~/_data/modules/j1_jekyll_search.yml
|
3
|
+
# J1 SimpleJekyllSearch specific configuration data (SEARCH Module)
|
4
|
+
#
|
5
|
+
# Product/Info:
|
6
|
+
# https://jekyll.one
|
7
|
+
# https://github.com/christian-fei/Simple-Jekyll-Search
|
8
|
+
#
|
9
|
+
# Copyright (C) 2017 Juergen Adams
|
10
|
+
# Copyright (C) 2015 Christian Fei
|
11
|
+
#
|
12
|
+
# J1 Template is licensed under the MIT License.
|
13
|
+
# For details, see https://jekyll.one
|
14
|
+
# SimpleJekyllSearch is licensed under the MIT License.
|
15
|
+
# For details, see https://github.com/christian-fei/Simple-Jekyll-Search
|
16
|
+
#
|
17
|
+
# ------------------------------------------------------------------------------
|
18
|
+
|
19
|
+
# GENERAL settings
|
20
|
+
# -------------------------------------------------------------------------
|
21
|
+
|
22
|
+
# version
|
23
|
+
# --------------------------------------------------------------------
|
24
|
+
# Current version of the module
|
25
|
+
#
|
26
|
+
# values: string
|
27
|
+
# default: no defaults
|
28
|
+
#
|
29
|
+
version: 0.0.1
|
30
|
+
|
31
|
+
# MODULE settings
|
32
|
+
# -------------------------------------------------------------------------
|
33
|
+
|
34
|
+
# DEFAULT settings
|
35
|
+
# --------------------------------------------------------------------
|
36
|
+
#
|
37
|
+
# placement
|
38
|
+
# ---------------------------------------------------------------
|
39
|
+
# Enables|Disables the console log.
|
40
|
+
#
|
41
|
+
# values: boolean (true|false)
|
42
|
+
# default: false
|
43
|
+
#
|
44
|
+
# target
|
45
|
+
# ---------------------------------------------------------------
|
46
|
+
# ...
|
47
|
+
#
|
48
|
+
# values: string
|
49
|
+
# default: bootstrapTheme
|
50
|
+
#
|
51
|
+
# searchInput
|
52
|
+
# ---------------------------------------------------------------
|
53
|
+
# ...
|
54
|
+
#
|
55
|
+
#
|
56
|
+
# values: boolean (true|false)
|
57
|
+
# default: true
|
58
|
+
#
|
59
|
+
# resultsOutput
|
60
|
+
# ---------------------------------------------------------------
|
61
|
+
# ...
|
62
|
+
#
|
63
|
+
# values: string
|
64
|
+
# default: bootstrapTheme.name
|
65
|
+
#
|
66
|
+
# resultsContainer
|
67
|
+
# ---------------------------------------------------------------
|
68
|
+
# ...
|
69
|
+
#
|
70
|
+
#
|
71
|
+
# values: string
|
72
|
+
# default: bootstrapDefaultTheme.name
|
73
|
+
#
|
74
|
+
# indexData
|
75
|
+
# ---------------------------------------------------------------
|
76
|
+
# ...
|
77
|
+
#
|
78
|
+
#
|
79
|
+
# values: string
|
80
|
+
# default: bootstrapTheme.css
|
81
|
+
#
|
82
|
+
# resultTemplate
|
83
|
+
# ---------------------------------------------------------------
|
84
|
+
# ...
|
85
|
+
#
|
86
|
+
#
|
87
|
+
# values: string
|
88
|
+
# default: bootstrapTheme.css
|
89
|
+
#
|
90
|
+
# resultLimit
|
91
|
+
# ---------------------------------------------------------------
|
92
|
+
# ...
|
93
|
+
#
|
94
|
+
#
|
95
|
+
# values: string
|
96
|
+
# default: bootstrapTheme.css
|
97
|
+
#
|
98
|
+
# minSearchItemLen
|
99
|
+
# ---------------------------------------------------------------
|
100
|
+
# ...
|
101
|
+
#
|
102
|
+
#
|
103
|
+
# values: string
|
104
|
+
# default: bootstrapTheme.css
|
105
|
+
#
|
106
|
+
# searchFuzzy
|
107
|
+
# ---------------------------------------------------------------
|
108
|
+
# ...
|
109
|
+
#
|
110
|
+
#
|
111
|
+
# values: string
|
112
|
+
# default: bootstrapTheme.css
|
113
|
+
#
|
114
|
+
# searchExlude
|
115
|
+
# ---------------------------------------------------------------
|
116
|
+
# ...
|
117
|
+
#
|
118
|
+
#
|
119
|
+
# values: string
|
120
|
+
# default: bootstrapTheme.css
|
121
|
+
#
|
122
|
+
defaults:
|
123
|
+
placement: navbar
|
124
|
+
target: _blank
|
125
|
+
searchInput: jss-input
|
126
|
+
resultsOutput: jss-panel
|
127
|
+
resultsContainer: jss-results
|
128
|
+
indexData: /assets/data/search.json
|
129
|
+
resultTemplate: <a href="{url}" class="list-group-item" target="{{site.data.j1_config.simple_search.target}}"> <h4 class="list-group-item-heading">{title}</h4> <p class="list-group-item-text">{tagline}</p> </a>
|
130
|
+
resultLimit: 10
|
131
|
+
minSearchItemLen: 3
|
132
|
+
searchFuzzy: false
|
133
|
+
searchExlude: Impress
|
134
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
# -------------------------------------------------------------
|
3
|
+
# Simple Jekyll Search (SEARCH Module)
|
4
|
+
#
|
5
|
+
- resource:
|
6
|
+
enabled: true
|
7
|
+
version: 0.0.1
|
8
|
+
id: j1_jekyll_search
|
9
|
+
comment: Resources for Jekyll Search
|
10
|
+
layout: [ home, page, post, app ]
|
11
|
+
region: head
|
12
|
+
required: always
|
13
|
+
script_load: defer
|
14
|
+
data:
|
15
|
+
css: []
|
16
|
+
files: [
|
17
|
+
simple_jekyll_search/css/search.css,
|
18
|
+
j1/js/adapters/simple_jekyll_search.js,
|
19
|
+
simple_jekyll_search/js/jekyll_view_results.js
|
20
|
+
]
|
21
|
+
js: [
|
22
|
+
simple_jekyll_search/js/jekyll_search
|
23
|
+
]
|
24
|
+
init_function: JekyllSearch.init
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# ------------------------------------------------------------------------------
|
2
|
+
# J1: ~/_plugins/simple_search_filter.rb
|
3
|
+
# Liquid filter's to be used with JekyllSimple Search
|
4
|
+
#
|
5
|
+
# Product/Info:
|
6
|
+
# http://jekyll.one
|
7
|
+
#
|
8
|
+
# Copyright (C) 2016 Juergen Adams
|
9
|
+
#
|
10
|
+
# Licensed under the Creative Commons Attribution 3.0 Unported License.
|
11
|
+
# For details, see http://creativecommons.org/licenses/by/3.0/.
|
12
|
+
#
|
13
|
+
# ------------------------------------------------------------------------------
|
14
|
+
# $LastChangedDate: 2016-12-04 19:37:21 +0100 (So, 04 Dez 2016) $
|
15
|
+
# $LastChangedRevision: 13 $
|
16
|
+
# $LastChangedBy: jadams $
|
17
|
+
# ------------------------------------------------------------------------------
|
18
|
+
|
19
|
+
module Jekyll
|
20
|
+
module CharFilter
|
21
|
+
def remove_chars(input)
|
22
|
+
input.gsub! '\\','\'
|
23
|
+
input.gsub! /\t/, ' '
|
24
|
+
input.strip_control_and_extended_characters
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
Liquid::Template.register_filter(Jekyll::CharFilter)
|
30
|
+
|
31
|
+
class String
|
32
|
+
def strip_control_and_extended_characters()
|
33
|
+
chars.each_with_object("") do |char, str|
|
34
|
+
str << char if char.ascii_only? and char.ord.between?(32,126)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
---
|
2
|
+
regenerate: false
|
3
|
+
---
|
4
|
+
|
5
|
+
{% comment %}
|
6
|
+
# ------------------------------------------------------------------------------
|
7
|
+
# J1: ~/assets/data/search.json
|
8
|
+
# Liquid JSON template to generate ALL data used by SimpleJekyllSearch
|
9
|
+
#
|
10
|
+
# Product/Info:
|
11
|
+
# http://jekyll.one
|
12
|
+
#
|
13
|
+
# Copyright (C) 2017 Juergen Adams
|
14
|
+
#
|
15
|
+
# J1 Template is licensed under the MIT License.
|
16
|
+
# For details, see https://jekyll.one
|
17
|
+
#
|
18
|
+
# ------------------------------------------------------------------------------
|
19
|
+
#
|
20
|
+
# The Liquid template search.json is used by J1 SimpleJekyllSearch.
|
21
|
+
# This template is a helper that creates the search database (JSON)
|
22
|
+
# for all documets.
|
23
|
+
# SimpleJekyllSearch, a JavaScript library to add search functionality
|
24
|
+
# to any Jekyll Site or Blog. This template is a helper to generate
|
25
|
+
# the corresponding search index data file search.json within the
|
26
|
+
# site generated by Jekyll.
|
27
|
+
#
|
28
|
+
# The Liquid generates a JSON file as an array that contains objects for all
|
29
|
+
# posts and pages included for indexing. See below the fields taken from the
|
30
|
+
# source files.
|
31
|
+
#
|
32
|
+
# NOTE:
|
33
|
+
# Be careful changing the Liquid code. If the code is changed, check
|
34
|
+
# the integrity of the JSON data created. Corrupted JSON data makes
|
35
|
+
# the Javascript of an Adapter to fail and no functionality will
|
36
|
+
# be available for most UNCLEAR reasons.
|
37
|
+
#
|
38
|
+
# -----------------------------------------------------------------------------
|
39
|
+
# Test data:
|
40
|
+
# {{ liquid_var | debug }}
|
41
|
+
#
|
42
|
+
# -----------------------------------------------------------------------------
|
43
|
+
{% endcomment %}
|
44
|
+
|
45
|
+
{% capture cache %}
|
46
|
+
|
47
|
+
{% for post in site.posts %}
|
48
|
+
{% unless post.noindex %}
|
49
|
+
{
|
50
|
+
"title" : "{{ post.title | escape }}",
|
51
|
+
"category" : "{{ post.category }}",
|
52
|
+
"tagline" : "{{ post.tagline }}",
|
53
|
+
"tags" : "{{ post.tags | join: ', ' }}",
|
54
|
+
"date" : "{{ post.date }}",
|
55
|
+
"url" : "{{ site.baseurl }}{{ post.url }}.html"
|
56
|
+
}, {% endunless %}
|
57
|
+
{% endfor %}
|
58
|
+
|
59
|
+
{% for page in site.pages %}
|
60
|
+
{% unless page.noindex %}
|
61
|
+
{% unless page.url contains 'assets' or page.url contains '.json' or page.url contains '.txt' or page.url == '/'%}
|
62
|
+
{
|
63
|
+
"title" : "{{ page.title | escape }}",
|
64
|
+
"group" : "{{ page.group }}",
|
65
|
+
"tagline" : "{{ page.tagline }}",
|
66
|
+
"tags" : "{{ page.tags | join: ', ' }}",
|
67
|
+
"url" : "{{ site.baseurl }}{{ page.url }}.html"
|
68
|
+
}, {% endunless %} {% endunless %}
|
69
|
+
{% endfor %}
|
70
|
+
|
71
|
+
{}
|
72
|
+
|
73
|
+
{% endcapture %}
|
74
|
+
|
75
|
+
[
|
76
|
+
{{ cache | strip_empty_lines }}
|
77
|
+
]
|
78
|
+
|
79
|
+
{% assign cache = nil %}
|
@@ -0,0 +1,85 @@
|
|
1
|
+
---
|
2
|
+
regenerate: false
|
3
|
+
---
|
4
|
+
|
5
|
+
{% capture cache %}
|
6
|
+
|
7
|
+
{% comment %}
|
8
|
+
# -----------------------------------------------------------------------------
|
9
|
+
# J1: ~/assets/themes/j1/j1/js/adapters/simple_jekyll_search.js
|
10
|
+
# Liquid JS template to create the J1 adapter for SimpleJekyllSearch
|
11
|
+
#
|
12
|
+
# Product/Info:
|
13
|
+
# https://jekyll.one
|
14
|
+
# https://github.com/christian-fei/Simple-Jekyll-Search
|
15
|
+
#
|
16
|
+
# Copyright (C) 2017 Juergen Adams
|
17
|
+
# Copyright (C) 2015 Christian Fei
|
18
|
+
#
|
19
|
+
# J1 Template is licensed under the MIT License.
|
20
|
+
# For details, see https://jekyll.one
|
21
|
+
# SimpleJekyllSearch is licensed under the MIT License.
|
22
|
+
# For details, see https://github.com/christian-fei/Simple-Jekyll-Search
|
23
|
+
#
|
24
|
+
# -----------------------------------------------------------------------------
|
25
|
+
# Test data:
|
26
|
+
# {{ liquid_var | debug }}
|
27
|
+
#
|
28
|
+
# -----------------------------------------------------------------------------
|
29
|
+
{% endcomment %}
|
30
|
+
|
31
|
+
/*
|
32
|
+
# -----------------------------------------------------------------------------
|
33
|
+
# J1: ~/assets/themes/j1/j1/js/adapters/simple_jekyll_search.js
|
34
|
+
# J1 Adapter for SimpleJekyllSearch
|
35
|
+
#
|
36
|
+
# Product/Info:
|
37
|
+
# https://jekyll.one
|
38
|
+
# https://github.com/christian-fei/Simple-Jekyll-Search
|
39
|
+
#
|
40
|
+
# Copyright (C) 2017 Juergen Adams
|
41
|
+
# Copyright (C) 2015 Christian Fei
|
42
|
+
#
|
43
|
+
# J1 Template is licensed under the MIT License.
|
44
|
+
# For details, see https://jekyll.one
|
45
|
+
# SimpleJekyllSearch is licensed under the MIT License.
|
46
|
+
# For details, see https://github.com/christian-fei/Simple-Jekyll-Search
|
47
|
+
#
|
48
|
+
# -----------------------------------------------------------------------------
|
49
|
+
# Adapter generated: {{site.time}}
|
50
|
+
# -----------------------------------------------------------------------------
|
51
|
+
*/
|
52
|
+
|
53
|
+
{% assign config = site.data.modules.j1_jekyll_search %}
|
54
|
+
|
55
|
+
{% if config.enabled %}
|
56
|
+
|
57
|
+
var JekyllSearch = function () {
|
58
|
+
|
59
|
+
return {
|
60
|
+
// Initialize
|
61
|
+
init: function () {
|
62
|
+
SimpleJekyllSearch({
|
63
|
+
searchInput: document.getElementById( {{config.searchInput | json }} ),
|
64
|
+
resultsOutput: document.getElementById( {{config.searchOutput | json }} ),
|
65
|
+
resultsContainer: document.getElementById( {{config.resultsContainer | json }} ),
|
66
|
+
json: {{config.indexData | json }},
|
67
|
+
searchResultTemplate: {{config.resultTemplate | json }},
|
68
|
+
limit: {{config.resultLimit | json }},
|
69
|
+
minSearchItemLen: {{config.minSearchItemLen | json }},
|
70
|
+
fuzzy: {{config.searchFuzzy | json }},
|
71
|
+
exclude: [
|
72
|
+
{{config.searchExlude| json }}
|
73
|
+
],
|
74
|
+
noResultsText: {{config.noResultsText | json }},
|
75
|
+
});
|
76
|
+
} // end init
|
77
|
+
}; // end return
|
78
|
+
}();
|
79
|
+
|
80
|
+
{% endif %}
|
81
|
+
|
82
|
+
{% endcapture %}
|
83
|
+
|
84
|
+
{{ cache | strip_empty_lines }}
|
85
|
+
{% assign cache = nil %}
|
@@ -0,0 +1,91 @@
|
|
1
|
+
/*
|
2
|
+
# -----------------------------------------------------------------------------
|
3
|
+
# J1: ~/assets/themes/j1/simple-jekyll-search/css/search.css
|
4
|
+
# Provides styles for Simple-Jekyll-Search
|
5
|
+
#
|
6
|
+
# Product/Info:
|
7
|
+
# http://jekyll.one
|
8
|
+
# https://github.com/christian-fei/Simple-Jekyll-Search
|
9
|
+
#
|
10
|
+
# Copyright (C) 2016 Christian Fei.
|
11
|
+
# Copyright (C) 2016 Juergen Adams
|
12
|
+
#
|
13
|
+
# Licensed under the Creative Commons Attribution 3.0 Unported License.
|
14
|
+
# For details, see http://creativecommons.org/licenses/by/3.0/.
|
15
|
+
#
|
16
|
+
# -----------------------------------------------------------------------------
|
17
|
+
# $LastChangedDate: 2016-12-04 19:37:21 +0100 (So, 04 Dez 2016) $
|
18
|
+
# $LastChangedRevision: 13 $
|
19
|
+
# $LastChangedBy: jadams $
|
20
|
+
# -----------------------------------------------------------------------------
|
21
|
+
*/
|
22
|
+
|
23
|
+
#jekyll-search-container {
|
24
|
+
list-style: none;
|
25
|
+
font-size: 12px;
|
26
|
+
background-color: white;
|
27
|
+
position: absolute;
|
28
|
+
top: 40px; /* if you change anything about the nav, you'll prob. need to reset the top and left values here.*/
|
29
|
+
left: 20px;
|
30
|
+
z-index: -1;
|
31
|
+
width:223px;
|
32
|
+
border-left: 1px solid #dedede;
|
33
|
+
box-shadow: 2px 3px 2px #dedede;
|
34
|
+
}
|
35
|
+
|
36
|
+
/* input area - sidebar */
|
37
|
+
#jss-input-sidebar {
|
38
|
+
padding: .5em;
|
39
|
+
margin-left: 20px;
|
40
|
+
margin-right: 20px;
|
41
|
+
width: 20em;
|
42
|
+
font-size: 0.8em;
|
43
|
+
-webkit-box-sizing: border-box;
|
44
|
+
-moz-box-sizing: border-box;
|
45
|
+
box-sizing: border-box;
|
46
|
+
float: right;
|
47
|
+
margin-top: 15px;
|
48
|
+
}
|
49
|
+
|
50
|
+
/* input area - main page (index.html) */
|
51
|
+
#jss-input-index {
|
52
|
+
padding: .5em;
|
53
|
+
margin-left: 0px;
|
54
|
+
margin-right: 20px;
|
55
|
+
width: 20em;
|
56
|
+
font-size: 0.8em;
|
57
|
+
-webkit-box-sizing: border-box;
|
58
|
+
-moz-box-sizing: border-box;
|
59
|
+
box-sizing: border-box;
|
60
|
+
float: right;
|
61
|
+
margin-top: 15px;
|
62
|
+
}
|
63
|
+
|
64
|
+
.panel-search {
|
65
|
+
margin: 35px;
|
66
|
+
border-color: #000;
|
67
|
+
}
|
68
|
+
|
69
|
+
.panel-search-index {
|
70
|
+
margin-left: 0px;
|
71
|
+
}
|
72
|
+
|
73
|
+
.panel-heading {
|
74
|
+
padding: 20px 15px !important;
|
75
|
+
}
|
76
|
+
|
77
|
+
.panel-search > .panel-heading {
|
78
|
+
color: #424242 !important;
|
79
|
+
background-color: #9E9E9E !important;
|
80
|
+
border-color: #000 !important;
|
81
|
+
}
|
82
|
+
|
83
|
+
.list-group-item-text {
|
84
|
+
color: #D32F2F !important;
|
85
|
+
margin-left: 1.2em;
|
86
|
+
}
|
87
|
+
|
88
|
+
.panel-search p {
|
89
|
+
font-size: 1.1em;
|
90
|
+
margin-left: 1.5em;
|
91
|
+
}
|
@@ -0,0 +1,467 @@
|
|
1
|
+
/*
|
2
|
+
# -----------------------------------------------------------------------------
|
3
|
+
# J1: ~/assets/themes/j1/simple_jekyll_search/js/jekyll_search.js
|
4
|
+
# Provides JavaScript functions performing searches for SimpleJekyllSearch
|
5
|
+
#
|
6
|
+
# Product/Info:
|
7
|
+
# https://jekyll.one
|
8
|
+
# https://github.com/christian-fei/Simple-Jekyll-Search
|
9
|
+
#
|
10
|
+
# Copyright (C) 2017 Juergen Adams
|
11
|
+
# Copyright (C) 2015 Christian Fei
|
12
|
+
#
|
13
|
+
# J1 Template is licensed under the MIT License.
|
14
|
+
# For details, see https://jekyll.one
|
15
|
+
# SimpleJekyllSearch is licensed under the MIT License.
|
16
|
+
# For details, see https://github.com/christian-fei/Simple-Jekyll-Search
|
17
|
+
#
|
18
|
+
# -----------------------------------------------------------------------------
|
19
|
+
*/
|
20
|
+
|
21
|
+
(function e(t, n, r) {
|
22
|
+
function s(o, u) {
|
23
|
+
if (!n[o]) {
|
24
|
+
if (!t[o]) {
|
25
|
+
var a = typeof require == "function" && require;
|
26
|
+
if (!u && a) return a(o, !0);
|
27
|
+
if (i) return i(o, !0);
|
28
|
+
throw new Error("Cannot find module '" + o + "'")
|
29
|
+
}
|
30
|
+
var f = n[o] = {
|
31
|
+
exports: {}
|
32
|
+
};
|
33
|
+
t[o][0].call(f.exports, function(e) {
|
34
|
+
var n = t[o][1][e];
|
35
|
+
return s(n ? n : e)
|
36
|
+
}, f, f.exports, e, t, n, r)
|
37
|
+
}
|
38
|
+
return n[o].exports
|
39
|
+
}
|
40
|
+
var i = typeof require == "function" && require;
|
41
|
+
for (var o = 0; o < r.length; o++) s(r[o]);
|
42
|
+
return s
|
43
|
+
})({
|
44
|
+
1: [function(require, module, exports) {
|
45
|
+
'use strict'
|
46
|
+
module.exports = {
|
47
|
+
load: load
|
48
|
+
}
|
49
|
+
|
50
|
+
function load(location, callback) {
|
51
|
+
var xhr = getXHR()
|
52
|
+
xhr.open('GET', location, true)
|
53
|
+
xhr.onreadystatechange = createStateChangeListener(xhr, callback)
|
54
|
+
xhr.send()
|
55
|
+
}
|
56
|
+
|
57
|
+
function createStateChangeListener(xhr, callback) {
|
58
|
+
return function() {
|
59
|
+
if (xhr.readyState === 4 && xhr.status === 200) {
|
60
|
+
try {
|
61
|
+
callback(null, JSON.parse(xhr.responseText))
|
62
|
+
} catch (err) {
|
63
|
+
callback(err, null)
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
function getXHR() {
|
70
|
+
return (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP')
|
71
|
+
}
|
72
|
+
|
73
|
+
}, {}],
|
74
|
+
2: [function(require, module, exports) {
|
75
|
+
'use strict'
|
76
|
+
module.exports = function OptionsValidator(params) {
|
77
|
+
if (!validateParams(params)) {
|
78
|
+
throw new Error('-- OptionsValidator: required options missing')
|
79
|
+
}
|
80
|
+
if (!(this instanceof OptionsValidator)) {
|
81
|
+
return new OptionsValidator(params)
|
82
|
+
}
|
83
|
+
|
84
|
+
var requiredOptions = params.required
|
85
|
+
|
86
|
+
this.getRequiredOptions = function() {
|
87
|
+
return requiredOptions
|
88
|
+
}
|
89
|
+
|
90
|
+
this.validate = function(parameters) {
|
91
|
+
var errors = []
|
92
|
+
requiredOptions.forEach(function(requiredOptionName) {
|
93
|
+
if (parameters[requiredOptionName] === undefined) {
|
94
|
+
errors.push(requiredOptionName)
|
95
|
+
}
|
96
|
+
})
|
97
|
+
return errors
|
98
|
+
}
|
99
|
+
|
100
|
+
function validateParams(params) {
|
101
|
+
if (!params) {
|
102
|
+
return false
|
103
|
+
}
|
104
|
+
return params.required !== undefined && params.required instanceof Array
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}, {}],
|
108
|
+
3: [function(require, module, exports) {
|
109
|
+
'use strict'
|
110
|
+
module.exports = {
|
111
|
+
put: put,
|
112
|
+
clear: clear,
|
113
|
+
get: get,
|
114
|
+
search: search,
|
115
|
+
setOptions: setOptions
|
116
|
+
}
|
117
|
+
|
118
|
+
var FuzzySearchStrategy = require('./SearchStrategies/FuzzySearchStrategy')
|
119
|
+
var LiteralSearchStrategy = require('./SearchStrategies/LiteralSearchStrategy')
|
120
|
+
|
121
|
+
var data = []
|
122
|
+
var opt = {}
|
123
|
+
opt.fuzzy = false
|
124
|
+
opt.limit = 10
|
125
|
+
opt.searchStrategy = opt.fuzzy ? FuzzySearchStrategy : LiteralSearchStrategy
|
126
|
+
// jadams: Added minSearchItemLen as an option
|
127
|
+
opt.minSearchItemLen = 4
|
128
|
+
// jadams: Added resultsOutput as an option
|
129
|
+
opt.resultsOutput = document.getElementById('jss-panel')
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
function put(data) {
|
134
|
+
if (isObject(data)) {
|
135
|
+
return addObject(data)
|
136
|
+
}
|
137
|
+
if (isArray(data)) {
|
138
|
+
return addArray(data)
|
139
|
+
}
|
140
|
+
return undefined
|
141
|
+
}
|
142
|
+
|
143
|
+
function clear() {
|
144
|
+
data.length = 0
|
145
|
+
return data
|
146
|
+
}
|
147
|
+
|
148
|
+
function get() {
|
149
|
+
return data
|
150
|
+
}
|
151
|
+
|
152
|
+
|
153
|
+
function isObject(obj) {
|
154
|
+
return !!obj && Object.prototype.toString.call(obj) === '[object Object]'
|
155
|
+
}
|
156
|
+
|
157
|
+
function isArray(obj) {
|
158
|
+
return !!obj && Object.prototype.toString.call(obj) === '[object Array]'
|
159
|
+
}
|
160
|
+
|
161
|
+
function addObject(_data) {
|
162
|
+
data.push(_data)
|
163
|
+
return data
|
164
|
+
}
|
165
|
+
|
166
|
+
function addArray(_data) {
|
167
|
+
var added = []
|
168
|
+
for (var i = 0; i < _data.length; i++) {
|
169
|
+
if (isObject(_data[i])) {
|
170
|
+
added.push(addObject(_data[i]))
|
171
|
+
}
|
172
|
+
}
|
173
|
+
return added
|
174
|
+
}
|
175
|
+
|
176
|
+
function search(crit) {
|
177
|
+
var n = crit.length
|
178
|
+
|
179
|
+
// jadams: Added|Evaluate minSearchItemLen
|
180
|
+
if (n < opt.minSearchItemLen) {
|
181
|
+
return []
|
182
|
+
}
|
183
|
+
if (!crit) {
|
184
|
+
return []
|
185
|
+
}
|
186
|
+
return findMatches(data, crit, opt.searchStrategy, opt)
|
187
|
+
}
|
188
|
+
|
189
|
+
function setOptions(_opt) {
|
190
|
+
opt = _opt || {}
|
191
|
+
|
192
|
+
opt.fuzzy = _opt.fuzzy || false
|
193
|
+
opt.limit = _opt.limit || 10
|
194
|
+
// jadams: Added minSearchItemLen as an option
|
195
|
+
opt.minSearchItemLen = _opt.minSearchItemLen || 3
|
196
|
+
opt.searchStrategy = _opt.fuzzy ? FuzzySearchStrategy : LiteralSearchStrategy
|
197
|
+
// jadams: Added show|hide for resultsOutput as an option
|
198
|
+
opt.resultsOutput = _opt.resultsOutput || 'jss-panel'
|
199
|
+
}
|
200
|
+
|
201
|
+
function findMatches(data, crit, strategy, opt) {
|
202
|
+
var matches = []
|
203
|
+
for (var i = 0; i < data.length && matches.length < opt.limit; i++) {
|
204
|
+
var match = findMatchesInObject(data[i], crit, strategy, opt)
|
205
|
+
if (match) {
|
206
|
+
matches.push(match)
|
207
|
+
}
|
208
|
+
}
|
209
|
+
return matches
|
210
|
+
}
|
211
|
+
|
212
|
+
function findMatchesInObject(obj, crit, strategy, opt) {
|
213
|
+
for (var key in obj) {
|
214
|
+
if (!isExcluded(obj[key], opt.exclude) && strategy.matches(obj[key], crit)) {
|
215
|
+
return obj
|
216
|
+
}
|
217
|
+
}
|
218
|
+
}
|
219
|
+
|
220
|
+
function isExcluded(term, excludedTerms) {
|
221
|
+
var excluded = false
|
222
|
+
excludedTerms = excludedTerms || []
|
223
|
+
for (var i = 0; i < excludedTerms.length; i++) {
|
224
|
+
var excludedTerm = excludedTerms[i]
|
225
|
+
if (!excluded && new RegExp(term).test(excludedTerm)) {
|
226
|
+
excluded = true
|
227
|
+
}
|
228
|
+
}
|
229
|
+
return excluded
|
230
|
+
}
|
231
|
+
|
232
|
+
}, {
|
233
|
+
"./SearchStrategies/FuzzySearchStrategy": 4,
|
234
|
+
"./SearchStrategies/LiteralSearchStrategy": 5
|
235
|
+
}],
|
236
|
+
4: [function(require, module, exports) {
|
237
|
+
'use strict'
|
238
|
+
module.exports = new FuzzySearchStrategy()
|
239
|
+
|
240
|
+
function FuzzySearchStrategy() {
|
241
|
+
this.matches = function(string, crit) {
|
242
|
+
if (typeof string !== 'string' || typeof crit !== 'string') {
|
243
|
+
return false
|
244
|
+
}
|
245
|
+
var fuzzy = crit.split('')
|
246
|
+
.reduce(function(a, b) {
|
247
|
+
return a + '[^' + b + ']*' + b;
|
248
|
+
})
|
249
|
+
fuzzy = new RegExp(fuzzy, 'gi')
|
250
|
+
return !!fuzzy.test(string)
|
251
|
+
}
|
252
|
+
}
|
253
|
+
|
254
|
+
}, {}],
|
255
|
+
5: [function(require, module, exports) {
|
256
|
+
'use strict'
|
257
|
+
module.exports = new LiteralSearchStrategy()
|
258
|
+
|
259
|
+
function LiteralSearchStrategy() {
|
260
|
+
this.matches = function(string, crit) {
|
261
|
+
if (typeof string !== 'string') {
|
262
|
+
return false
|
263
|
+
}
|
264
|
+
string = string.trim()
|
265
|
+
return string.toLowerCase().indexOf(crit.toLowerCase()) >= 0
|
266
|
+
}
|
267
|
+
}
|
268
|
+
|
269
|
+
}, {}],
|
270
|
+
6: [function(require, module, exports) {
|
271
|
+
'use strict'
|
272
|
+
module.exports = {
|
273
|
+
compile: compile,
|
274
|
+
setOptions: setOptions
|
275
|
+
}
|
276
|
+
|
277
|
+
var options = {}
|
278
|
+
options.pattern = /\{(.*?)\}/g
|
279
|
+
options.template = ''
|
280
|
+
options.middleware = function() {}
|
281
|
+
|
282
|
+
function setOptions(_options) {
|
283
|
+
options.pattern = _options.pattern || options.pattern
|
284
|
+
options.template = _options.template || options.template
|
285
|
+
if (typeof _options.middleware === 'function') {
|
286
|
+
options.middleware = _options.middleware
|
287
|
+
}
|
288
|
+
}
|
289
|
+
|
290
|
+
function compile(data) {
|
291
|
+
return options.template.replace(options.pattern, function(match, prop) {
|
292
|
+
var value = options.middleware(prop, data[prop], options.template)
|
293
|
+
// jadams: resultsOutput hardcoded
|
294
|
+
var resultsOutput = document.getElementById('jss-panel')
|
295
|
+
resultsOutput.style.display = 'none'; // to hide
|
296
|
+
if (value !== undefined) {
|
297
|
+
return value
|
298
|
+
}
|
299
|
+
// jadams
|
300
|
+
resultsOutput.style.display = 'block'; // to show
|
301
|
+
return data[prop] || match
|
302
|
+
})
|
303
|
+
}
|
304
|
+
|
305
|
+
}, {}],
|
306
|
+
7: [function(require, module, exports) {;
|
307
|
+
(function(window, document, undefined) {
|
308
|
+
'use strict'
|
309
|
+
// ToDo: resultsOutput
|
310
|
+
var options = {
|
311
|
+
searchInput: null,
|
312
|
+
resultsOutput: null,
|
313
|
+
resultsContainer: null,
|
314
|
+
json: [],
|
315
|
+
searchResultTemplate: '<li><a href="{url}" title="{desc}">{title}</a></li>',
|
316
|
+
templateMiddleware: function() {},
|
317
|
+
noResultsText: 'No results found',
|
318
|
+
limit: 10,
|
319
|
+
minSearchItemLen: 3,
|
320
|
+
fuzzy: false,
|
321
|
+
exclude: []
|
322
|
+
}
|
323
|
+
|
324
|
+
var requiredOptions = ['searchInput', 'resultsContainer', 'json']
|
325
|
+
|
326
|
+
var templater = require('./Templater')
|
327
|
+
var repository = require('./Repository')
|
328
|
+
var jsonLoader = require('./JSONLoader')
|
329
|
+
var optionsValidator = require('./OptionsValidator')({
|
330
|
+
required: requiredOptions
|
331
|
+
})
|
332
|
+
var utils = require('./utils')
|
333
|
+
|
334
|
+
/*
|
335
|
+
Public API
|
336
|
+
*/
|
337
|
+
window.SimpleJekyllSearch = function SimpleJekyllSearch(_options) {
|
338
|
+
var errors = optionsValidator.validate(_options)
|
339
|
+
if (errors.length > 0) {
|
340
|
+
throwError('You must specify the following required options: ' + requiredOptions)
|
341
|
+
}
|
342
|
+
|
343
|
+
options = utils.merge(options, _options)
|
344
|
+
|
345
|
+
templater.setOptions({
|
346
|
+
template: options.searchResultTemplate,
|
347
|
+
middleware: options.templateMiddleware,
|
348
|
+
})
|
349
|
+
|
350
|
+
repository.setOptions({
|
351
|
+
fuzzy: options.fuzzy,
|
352
|
+
limit: options.limit,
|
353
|
+
})
|
354
|
+
|
355
|
+
if (utils.isJSON(options.json)) {
|
356
|
+
initWithJSON(options.json)
|
357
|
+
} else {
|
358
|
+
initWithURL(options.json)
|
359
|
+
}
|
360
|
+
}
|
361
|
+
|
362
|
+
// for backwards compatibility
|
363
|
+
window.SimpleJekyllSearch.init = window.SimpleJekyllSearch
|
364
|
+
|
365
|
+
if (typeof window.SimpleJekyllSearchInit === 'function') {
|
366
|
+
window.SimpleJekyllSearchInit.call(this, window.SimpleJekyllSearch);
|
367
|
+
}
|
368
|
+
|
369
|
+
function initWithJSON(json) {
|
370
|
+
repository.put(json)
|
371
|
+
registerInput()
|
372
|
+
}
|
373
|
+
|
374
|
+
function initWithURL(url) {
|
375
|
+
jsonLoader.load(url, function(err, json) {
|
376
|
+
if (err) {
|
377
|
+
var start = moment();
|
378
|
+
var log_text = "[" +start.format("HH:mm:ss.SSS")+ "] JekyllSearch: " +err;
|
379
|
+
console.log( log_text );
|
380
|
+
throwError('failed to get JSON (' + url + ')');
|
381
|
+
}
|
382
|
+
initWithJSON(json)
|
383
|
+
})
|
384
|
+
}
|
385
|
+
|
386
|
+
function emptyResultsContainer() {
|
387
|
+
options.resultsContainer.innerHTML = ''
|
388
|
+
}
|
389
|
+
|
390
|
+
function appendToResultsContainer(text) {
|
391
|
+
options.resultsContainer.innerHTML += text
|
392
|
+
}
|
393
|
+
|
394
|
+
function registerInput() {
|
395
|
+
options.searchInput.addEventListener('keyup', function(e) {
|
396
|
+
var key = e.which
|
397
|
+
var query = e.target.value
|
398
|
+
if (isWhitelistedKey(key) && isValidQuery(query)) {
|
399
|
+
emptyResultsContainer();
|
400
|
+
render(repository.search(query));
|
401
|
+
}
|
402
|
+
})
|
403
|
+
}
|
404
|
+
|
405
|
+
function render(results) {
|
406
|
+
if (results.length === 0) {
|
407
|
+
// jadams: resultsOutput hardcoded
|
408
|
+
var resultsOutput = document.getElementById('jss-panel')
|
409
|
+
resultsOutput.style.display = 'none'; // to hide
|
410
|
+
return appendToResultsContainer(options.noResultsText)
|
411
|
+
}
|
412
|
+
for (var i = 0; i < results.length; i++) {
|
413
|
+
appendToResultsContainer(templater.compile(results[i]))
|
414
|
+
}
|
415
|
+
}
|
416
|
+
|
417
|
+
function isValidQuery(query) {
|
418
|
+
return query && query.length > 0
|
419
|
+
}
|
420
|
+
|
421
|
+
function isWhitelistedKey(key) {
|
422
|
+
return [13, 16, 20, 37, 38, 39, 40, 91].indexOf(key) === -1
|
423
|
+
}
|
424
|
+
|
425
|
+
function throwError(message) {
|
426
|
+
throw new Error('SimpleJekyllSearch --- ' + message)
|
427
|
+
}
|
428
|
+
})(window, document);
|
429
|
+
|
430
|
+
}, {
|
431
|
+
"./JSONLoader": 1,
|
432
|
+
"./OptionsValidator": 2,
|
433
|
+
"./Repository": 3,
|
434
|
+
"./Templater": 6,
|
435
|
+
"./utils": 8
|
436
|
+
}],
|
437
|
+
8: [function(require, module, exports) {
|
438
|
+
'use strict'
|
439
|
+
module.exports = {
|
440
|
+
merge: merge,
|
441
|
+
isJSON: isJSON,
|
442
|
+
}
|
443
|
+
|
444
|
+
function merge(defaultParams, mergeParams) {
|
445
|
+
var mergedOptions = {}
|
446
|
+
for (var option in defaultParams) {
|
447
|
+
mergedOptions[option] = defaultParams[option]
|
448
|
+
if (mergeParams[option] !== undefined) {
|
449
|
+
mergedOptions[option] = mergeParams[option]
|
450
|
+
}
|
451
|
+
}
|
452
|
+
return mergedOptions
|
453
|
+
}
|
454
|
+
|
455
|
+
function isJSON(json) {
|
456
|
+
try {
|
457
|
+
if (json instanceof Object && JSON.parse(JSON.stringify(json))) {
|
458
|
+
return true
|
459
|
+
}
|
460
|
+
return false
|
461
|
+
} catch (e) {
|
462
|
+
return false
|
463
|
+
}
|
464
|
+
}
|
465
|
+
|
466
|
+
}, {}]
|
467
|
+
}, {}, [7])
|
@@ -0,0 +1,25 @@
|
|
1
|
+
/*
|
2
|
+
# -----------------------------------------------------------------------------
|
3
|
+
# J1: ~/assets/themes/j1/simple-jekyll-search/js/jekyll-search.min.js
|
4
|
+
# Provides all JavaScript functions for J1 Simple-Jekyll-Search
|
5
|
+
#
|
6
|
+
# Product/Info:
|
7
|
+
# http://jekyll.one
|
8
|
+
# https://github.com/christian-fei/Simple-Jekyll-Search
|
9
|
+
#
|
10
|
+
# Copyright (C) 2015 Christian Fei
|
11
|
+
# Copyright (C) 2016 Juergen Adams
|
12
|
+
#
|
13
|
+
# J1 licensed under the Creative Commons Attribution 3.0 Unported License.
|
14
|
+
# For details, see http://creativecommons.org/licenses/by/3.0
|
15
|
+
# Simple-Jekyll-Search licensed under MIT License (MIT).
|
16
|
+
# For details, see https://opensource.org/licenses/MIT
|
17
|
+
#
|
18
|
+
# -----------------------------------------------------------------------------
|
19
|
+
# $LastChangedDate: 2016-12-04 19:37:21 +0100 (So, 04 Dez 2016) $
|
20
|
+
# $LastChangedRevision: 13 $
|
21
|
+
# $LastChangedBy: jadams $
|
22
|
+
# -----------------------------------------------------------------------------
|
23
|
+
*/
|
24
|
+
|
25
|
+
(function e(b,g,d){function c(k,i){if(!g[k]){if(!b[k]){var h=typeof require=="function"&&require;if(!i&&h){return h(k,!0)}if(a){return a(k,!0)}throw new Error("Cannot find module '"+k+"'")}var j=g[k]={exports:{}};b[k][0].call(j.exports,function(l){var m=b[k][1][l];return c(m?m:l)},j,j.exports,e,b,g,d)}return g[k].exports}var a=typeof require=="function"&&require;for(var f=0;f<d.length;f++){c(d[f])}return c})({1:[function(b,d,a){d.exports={load:f};function f(h,j){var i=g();i.open("GET",h,true);i.onreadystatechange=c(i,j);i.send()}function c(h,i){return function(){if(h.readyState===4&&h.status===200){try{i(null,JSON.parse(h.responseText))}catch(j){i(j,null)}}}}function g(){return(window.XMLHttpRequest)?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP")}},{}],2:[function(b,c,a){c.exports=function d(h){if(!f(h)){throw new Error("-- OptionsValidator: required options missing")}if(!(this instanceof d)){return new d(h)}var g=h.required;this.getRequiredOptions=function(){return g};this.validate=function(i){var j=[];g.forEach(function(k){if(i[k]===undefined){j.push(k)}});return j};function f(i){if(!i){return false}return i.required!==undefined&&i.required instanceof Array}}},{}],3:[function(h,c,t){c.exports={put:g,clear:o,get:r,search:i,setOptions:q};var p=h("./SearchStrategies/FuzzySearchStrategy");var l=h("./SearchStrategies/LiteralSearchStrategy");var s=[];var b={};b.fuzzy=false;b.limit=10;b.searchStrategy=b.fuzzy?p:l;b.minSearchItemLen=4;b.resultsOutput=document.getElementById("jss-panel");function g(u){if(j(u)){return m(u)}if(k(u)){return f(u)}return undefined}function o(){s.length=0;return s}function r(){return s}function j(u){return !!u&&Object.prototype.toString.call(u)==="[object Object]"}function k(u){return !!u&&Object.prototype.toString.call(u)==="[object Array]"}function m(u){s.push(u);return s}function f(w){var v=[];for(var u=0;u<w.length;u++){if(j(w[u])){v.push(m(w[u]))}}return v}function i(u){var v=u.length;if(v<b.minSearchItemLen){return[]}if(!u){return[]}return n(s,u,b.searchStrategy,b)}function q(u){b=u||{};b.fuzzy=u.fuzzy||false;b.limit=u.limit||10;b.minSearchItemLen=u.minSearchItemLen||3;b.searchStrategy=u.fuzzy?p:l;b.resultsOutput=u.resultsOutput||"jss-panel"}function n(z,u,A,x){var y=[];for(var w=0;w<z.length&&y.length<x.limit;w++){var v=a(z[w],u,A,x);if(v){y.push(v)}}return y}function a(x,u,y,w){for(var v in x){if(!d(x[v],w.exclude)&&y.matches(x[v],u)){return x}}}function d(y,v){var w=false;v=v||[];for(var x=0;x<v.length;x++){var u=v[x];if(!w&&new RegExp(y).test(u)){w=true}}return w}},{"./SearchStrategies/FuzzySearchStrategy":4,"./SearchStrategies/LiteralSearchStrategy":5}],4:[function(b,c,a){c.exports=new d();function d(){this.matches=function(g,f){if(typeof g!=="string"||typeof f!=="string"){return false}var h=f.split("").reduce(function(j,i){return j+"[^"+i+"]*"+i});h=new RegExp(h,"gi");return !!h.test(g)}}},{}],5:[function(b,c,a){c.exports=new d();function d(){this.matches=function(g,f){if(typeof g!=="string"){return false}g=g.trim();return g.toLowerCase().indexOf(f.toLowerCase())>=0}}},{}],6:[function(d,f,a){f.exports={compile:g,setOptions:b};var c={};c.pattern=/\{(.*?)\}/g;c.template="";c.middleware=function(){};function b(h){c.pattern=h.pattern||c.pattern;c.template=h.template||c.template;if(typeof h.middleware==="function"){c.middleware=h.middleware}}function g(h){return c.template.replace(c.pattern,function(i,l){var j=c.middleware(l,h[l],c.template);var k=document.getElementById("jss-panel");k.style.display="none";if(j!==undefined){return j}k.style.display="block";return h[l]||i})}},{}],7:[function(b,c,a){(function(k,n,i){var g={searchInput:null,resultsOutput:null,resultsContainer:null,json:[],searchResultTemplate:'<li><a href="{url}" title="{desc}">{title}</a></li>',templateMiddleware:function(){},noResultsText:"No results found",limit:10,minSearchItemLen:3,fuzzy:false,exclude:[]};var m=["searchInput","resultsContainer","json"];var f=b("./Templater");var t=b("./Repository");var w=b("./JSONLoader");var l=b("./OptionsValidator")({required:m});var v=b("./utils");k.SimpleJekyllSearch=function q(y){var z=l.validate(y);if(z.length>0){u("You must specify the following required options: "+m)}g=v.merge(g,y);f.setOptions({template:g.searchResultTemplate,middleware:g.templateMiddleware,});t.setOptions({fuzzy:g.fuzzy,limit:g.limit,});if(v.isJSON(g.json)){o(g.json)}else{h(g.json)}};k.SimpleJekyllSearch.init=k.SimpleJekyllSearch;if(typeof k.SimpleJekyllSearchInit==="function"){k.SimpleJekyllSearchInit.call(this,k.SimpleJekyllSearch)}function o(y){t.put(y);j()}function h(y){w.load(y,function(A,z){if(A){u("failed to get JSON ("+y+")")}o(z)})}function r(){g.resultsContainer.innerHTML=""}function d(y){g.resultsContainer.innerHTML+=y}function j(){g.searchInput.addEventListener("keyup",function(A){var y=A.which;var z=A.target.value;if(p(y)&&s(z)){r();x(t.search(z))}})}function x(z){if(z.length===0){var A=n.getElementById("jss-panel");A.style.display="none";return d(g.noResultsText)}for(var y=0;y<z.length;y++){d(f.compile(z[y]))}}function s(y){return y&&y.length>0}function p(y){return[13,16,20,37,38,39,40,91].indexOf(y)===-1}function u(y){throw new Error("SimpleJekyllSearch --- "+y)}})(window,document)},{"./JSONLoader":1,"./OptionsValidator":2,"./Repository":3,"./Templater":6,"./utils":8}],8:[function(c,d,b){d.exports={merge:f,isJSON:a,};function f(i,h){var j={};for(var g in i){j[g]=i[g];if(h[g]!==undefined){j[g]=h[g]}}return j}function a(g){try{if(g instanceof Object&&JSON.parse(JSON.stringify(g))){return true}return false}catch(h){return false}}},{}]},{},[7]);
|
@@ -0,0 +1,39 @@
|
|
1
|
+
/*
|
2
|
+
# -----------------------------------------------------------------------------
|
3
|
+
# J1: ~/assets/themes/j1/simple_jekyll_search/js/jekyll_view_results.js
|
4
|
+
# Provides JavaScript functions displaying results for SimpleJekyllSearch
|
5
|
+
#
|
6
|
+
# Product/Info:
|
7
|
+
# https://jekyll.one
|
8
|
+
# https://github.com/christian-fei/Simple-Jekyll-Search
|
9
|
+
#
|
10
|
+
# Copyright (C) 2017 Juergen Adams
|
11
|
+
# Copyright (C) 2015 Christian Fei
|
12
|
+
#
|
13
|
+
# J1 Template is licensed under the MIT License.
|
14
|
+
# For details, see https://jekyll.one
|
15
|
+
# SimpleJekyllSearch is licensed under the MIT License.
|
16
|
+
# For details, see https://github.com/christian-fei/Simple-Jekyll-Search
|
17
|
+
#
|
18
|
+
# -----------------------------------------------------------------------------
|
19
|
+
*/
|
20
|
+
|
21
|
+
function toggle_result_block(result_block) {
|
22
|
+
result_block.prev().toggleClass('stacked');
|
23
|
+
result_block.toggle();
|
24
|
+
}
|
25
|
+
|
26
|
+
function insert_result_links() {
|
27
|
+
$('.result').each(function(idx, node) {
|
28
|
+
var result_block = $(node);
|
29
|
+
var title_div = result_block.prev().find('.title');
|
30
|
+
var view_result_link = $('<a class="view-result" href="#">view result</a>');
|
31
|
+
title_div.append(view_result_link);
|
32
|
+
view_result_link.on('click', function(event) {
|
33
|
+
event.preventDefault();
|
34
|
+
toggle_result_block(result_block);
|
35
|
+
});
|
36
|
+
});
|
37
|
+
}
|
38
|
+
|
39
|
+
$(insert_result_links);
|
@@ -0,0 +1,63 @@
|
|
1
|
+
{% comment%}
|
2
|
+
---
|
3
|
+
regenerate: false
|
4
|
+
---
|
5
|
+
Note: Remove comment for production
|
6
|
+
{% endcomment%}
|
7
|
+
|
8
|
+
{% comment%}
|
9
|
+
|
10
|
+
The liquid template search.json is used by SimpleJekyllSearch, a JavaScript
|
11
|
+
library to add search functionality to any Jekyll Site or Blog. the template
|
12
|
+
is a helper to generate the corresponding search index data file search.json
|
13
|
+
within the site generated by Jekyll.
|
14
|
+
|
15
|
+
The Liquid generates a JSON file as an array that contains objects for all
|
16
|
+
posts and pages included for indexing. See below the fields taken from the
|
17
|
+
source files.
|
18
|
+
|
19
|
+
NOTE:
|
20
|
+
Be carefull change the Liquid code. If the code is changed, check the
|
21
|
+
interity of the JSON data created. Corrupted JSON data will make the
|
22
|
+
Javascript portion of SimpleJekyllSearch to fail and search functionality
|
23
|
+
willl be available.
|
24
|
+
|
25
|
+
{% endcomment%}
|
26
|
+
|
27
|
+
{% capture jbx_cache %}
|
28
|
+
|
29
|
+
{% for post in site.posts %}
|
30
|
+
{% unless post.noindex %}
|
31
|
+
{
|
32
|
+
"title" : "{{ post.title | escape }}",
|
33
|
+
"category" : "{{ post.category }}",
|
34
|
+
"tagline" : "{{ post.tagline }}",
|
35
|
+
"tags" : "{{ post.tags | join: ', ' }}",
|
36
|
+
"index" : "{{ site.source_root | append: '/' | append: post.path | regex_replace: '\\', '/' }}",
|
37
|
+
"url" : "{{ site.baseurl }}{{ post.url }}.html",
|
38
|
+
"date" : "{{ post.date }}"
|
39
|
+
}, {% endunless %}
|
40
|
+
{% endfor %}
|
41
|
+
|
42
|
+
{% for page in site.pages %}
|
43
|
+
{% unless page.noindex %}
|
44
|
+
{% unless page.url contains 'assets' or page.url contains '.json' or page.url contains '.txt' %}
|
45
|
+
{
|
46
|
+
"title" : "{{ page.title | escape }}",
|
47
|
+
"group" : "{{ page.group }}",
|
48
|
+
"tagline" : "{{ page.tagline }}",
|
49
|
+
"tags" : "{{ page.tags | join: ', ' }}",
|
50
|
+
"index" : "{{ site.source_root | append: '/' | append: page.path | regex_replace: '\\', '/' }}",
|
51
|
+
"url" : "{{ site.baseurl }}{{ page.url }}"
|
52
|
+
}, {% endunless %} {% endunless %}
|
53
|
+
{% endfor %}
|
54
|
+
|
55
|
+
{}
|
56
|
+
|
57
|
+
{% endcapture %}
|
58
|
+
|
59
|
+
[
|
60
|
+
{{ jbx_cache | strip_empty_lines }}
|
61
|
+
]
|
62
|
+
|
63
|
+
{% assign jbx_cache = nil %}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module CharFilter
|
3
|
+
def remove_chars(input)
|
4
|
+
input.gsub! '\\','\'
|
5
|
+
input.gsub! /\t/, ' '
|
6
|
+
input.strip_control_and_extended_characters
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
Liquid::Template.register_filter(Jekyll::CharFilter)
|
12
|
+
|
13
|
+
class String
|
14
|
+
def strip_control_and_extended_characters()
|
15
|
+
chars.each_with_object("") do |char, str|
|
16
|
+
str << char if char.ascii_only? and char.ord.between?(32,126)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/exe/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "j1m_nav"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/exe/setup
ADDED
data/lib/j1m_search.rb
ADDED
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: j1m_search
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Juergen Adams
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-19 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.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.2'
|
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.14'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.14'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: J1 SEARCH Module is a gem-based module for J1 Template to provide a search
|
56
|
+
engine based on JekyllSimpleSearch.
|
57
|
+
email:
|
58
|
+
- juergen@jekyll-one.com
|
59
|
+
executables:
|
60
|
+
- console
|
61
|
+
- setup
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- LICENSE.md
|
66
|
+
- README.md
|
67
|
+
- _data/modules/default/j1_search-0.0.1/j1_jekyll_search.yml
|
68
|
+
- _data/resources/default/j1_search-0.0.1/resource.yml
|
69
|
+
- _plugins/simple_search_filter.rb
|
70
|
+
- assets/data/search.json
|
71
|
+
- assets/themes/j1/j1/js/adapters/simple_jekyll_search.js
|
72
|
+
- assets/themes/j1/simple_jekyll_search/css/search.css
|
73
|
+
- assets/themes/j1/simple_jekyll_search/js/jekyll_search.js
|
74
|
+
- assets/themes/j1/simple_jekyll_search/js/jekyll_search.min.js
|
75
|
+
- assets/themes/j1/simple_jekyll_search/js/jekyll_view_results.js
|
76
|
+
- assets/themes/j1/simple_jekyll_search/json/search.json
|
77
|
+
- assets/themes/j1/simple_jekyll_search/plugins/simple_search_filter.rb
|
78
|
+
- exe/console
|
79
|
+
- exe/setup
|
80
|
+
- lib/j1m_search.rb
|
81
|
+
- lib/j1m_search/version.rb
|
82
|
+
homepage: https://jekyll-one.com
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata:
|
86
|
+
allowed_push_host: https://rubygems.org
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.6.11
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: J1 SEARCH Module
|
107
|
+
test_files: []
|