trestle-search 0.2.1 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.browserlistrc +1 -0
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/.travis.yml +20 -3
- data/Gemfile +8 -0
- data/app/assets/bundle/trestle/search.css +1 -0
- data/app/views/trestle/search/_search.html.erb +10 -9
- data/config/initializers/trestle.rb +2 -2
- data/config/{locale → locales}/en.yml +0 -0
- data/config/locales/es.yml +5 -0
- data/config/locales/fr.yml +5 -0
- data/config/{locale → locales}/pl.yml +0 -0
- data/config/{locale → locales}/pt-BR.yml +0 -0
- data/config/locales/ru.yml +5 -0
- data/frontend/index.scss +42 -0
- data/gemfiles/rails-4.2.gemfile +14 -0
- data/gemfiles/rails-5.0.gemfile +14 -0
- data/gemfiles/rails-5.1.gemfile +14 -0
- data/gemfiles/rails-5.2.gemfile +14 -0
- data/gemfiles/rails-6.0.gemfile +14 -0
- data/lib/trestle/search.rb +5 -5
- data/lib/trestle/search/adapters/chewy_adapter.rb +4 -0
- data/lib/trestle/search/builder.rb +1 -1
- data/lib/trestle/search/controller.rb +2 -2
- data/lib/trestle/search/engine.rb +5 -2
- data/lib/trestle/search/resource.rb +24 -11
- data/lib/trestle/search/version.rb +1 -1
- data/package.json +30 -0
- data/trestle-search.gemspec +12 -10
- data/webpack.config.js +48 -0
- data/yarn.lock +4765 -0
- metadata +33 -47
- data/app/assets/stylesheets/trestle/search.scss +0 -55
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c44c519d3870778dc31c5eec549290d197ea2bb09eb3db856c4208a64e3be20c
|
4
|
+
data.tar.gz: 712100fba45ffa35814854889da4f5e94be4e0f479a0863a73a2d3286f45bd04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7791222516cebd2bea8d941279d7c71c6e120976cbebd229564925220e2e8fac794f240fcb25f8ba570b32acdf4fd5084bf202dd0abef7920525ea0d1f75b42e
|
7
|
+
data.tar.gz: 76cb2f9208c783b2fe3ace5ed8bf8f36a0bb9a6e31f5fd5a89c9c43cf797306e38f3785217571e9fcad2cca773d3b1e969485c0ac32dc7ffbd6e342b46d5f35e
|
data/.browserlistrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
> 0.25%
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.travis.yml
CHANGED
@@ -1,5 +1,22 @@
|
|
1
|
-
sudo: false
|
2
1
|
language: ruby
|
2
|
+
|
3
|
+
cache: bundler
|
4
|
+
|
5
|
+
before_install:
|
6
|
+
- gem update --system
|
7
|
+
- gem install bundler
|
8
|
+
|
3
9
|
rvm:
|
4
|
-
- 2.
|
5
|
-
|
10
|
+
- 2.6.5
|
11
|
+
|
12
|
+
gemfile:
|
13
|
+
- gemfiles/rails-5.0.gemfile
|
14
|
+
- gemfiles/rails-5.1.gemfile
|
15
|
+
- gemfiles/rails-5.2.gemfile
|
16
|
+
- gemfiles/rails-6.0.gemfile
|
17
|
+
|
18
|
+
jobs:
|
19
|
+
include:
|
20
|
+
gemfile: gemfiles/rails-4.2.gemfile
|
21
|
+
before_install:
|
22
|
+
- gem install bundler -v '< 2'
|
data/Gemfile
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
.searchbox{width:100%;max-width:30em;margin-right:auto}.searchbox .input-group{background:#fff;border:1px solid #ccc;border-radius:50rem}.searchbox .form-control,.searchbox .input-group-text{background:transparent;border:0}.searchbox .form-control{padding-left:0;box-shadow:none}.searchbox .form-control::-webkit-search-cancel-button{display:none}.searchbox .clear-search{position:absolute;right:.75rem;z-index:5;color:#555;font-size:1.2rem;padding:.35rem}.searchbox .clear-search:focus,.searchbox .clear-search:hover{color:#333}
|
@@ -1,10 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
<div class="input-group">
|
5
|
-
<span class="input-group-
|
6
|
-
<%= text_field_tag :q, params[:q], class: "form-control", placeholder: t("admin.search.placeholder", default: "Search") %>
|
1
|
+
<div class="searchbox">
|
2
|
+
<%= form_tag admin.path, method: :get do %>
|
3
|
+
<div class="input-group">
|
4
|
+
<div class="input-group-prepend">
|
5
|
+
<span class="input-group-text"><icon class="fa fa-search"></icon></span>
|
7
6
|
</div>
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
<%= link_to icon("fa fa-times"), admin.path, class: "clear-search" if params[:q].present? %>
|
8
|
+
<%= search_field_tag :q, params[:q], class: "form-control", autocomplete: "off", placeholder: admin.t("search.placeholder", default: "Search") %>
|
9
|
+
</div>
|
10
|
+
<% end %>
|
11
|
+
</div>
|
@@ -1,11 +1,11 @@
|
|
1
1
|
Trestle.configure do |config|
|
2
2
|
config.persistent_params << :q
|
3
|
-
|
3
|
+
|
4
4
|
config.hook("stylesheets") do
|
5
5
|
stylesheet_link_tag "trestle/search"
|
6
6
|
end
|
7
7
|
|
8
|
-
config.hook("
|
8
|
+
config.hook("resource.index.header", if: -> { admin.searchable? }) do
|
9
9
|
render "trestle/search/search"
|
10
10
|
end
|
11
11
|
end
|
File without changes
|
File without changes
|
File without changes
|
data/frontend/index.scss
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
.searchbox {
|
2
|
+
width: 100%;
|
3
|
+
max-width: 30em;
|
4
|
+
margin-right: auto;
|
5
|
+
|
6
|
+
.input-group {
|
7
|
+
background: white;
|
8
|
+
border: 1px solid #ccc;
|
9
|
+
border-radius: 50rem;
|
10
|
+
}
|
11
|
+
|
12
|
+
.input-group-text {
|
13
|
+
background: transparent;
|
14
|
+
border: 0;
|
15
|
+
}
|
16
|
+
|
17
|
+
.form-control {
|
18
|
+
padding-left: 0;
|
19
|
+
|
20
|
+
background: transparent;
|
21
|
+
box-shadow: none;
|
22
|
+
|
23
|
+
border: 0;
|
24
|
+
|
25
|
+
&::-webkit-search-cancel-button {
|
26
|
+
display: none;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
.clear-search {
|
31
|
+
position: absolute;
|
32
|
+
right: 0.75rem;
|
33
|
+
z-index: 5;
|
34
|
+
color: #555;
|
35
|
+
font-size: 1.2rem;
|
36
|
+
padding: 0.35rem;
|
37
|
+
|
38
|
+
&:hover, &:focus {
|
39
|
+
color: #333;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
data/lib/trestle/search.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative "search/version"
|
2
2
|
|
3
3
|
require "trestle"
|
4
4
|
|
@@ -6,9 +6,9 @@ module Trestle
|
|
6
6
|
module Search
|
7
7
|
extend ActiveSupport::Autoload
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
require_relative "search/builder"
|
10
|
+
require_relative "search/controller"
|
11
|
+
require_relative "search/resource"
|
12
12
|
|
13
13
|
autoload_under "adapters" do
|
14
14
|
autoload :ChewyAdapter
|
@@ -17,4 +17,4 @@ module Trestle
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
require_relative "search/engine" if defined?(Rails)
|
@@ -3,10 +3,13 @@ module Trestle
|
|
3
3
|
class Engine < ::Rails::Engine
|
4
4
|
config.assets.precompile << "trestle/search.css"
|
5
5
|
|
6
|
+
config.to_prepare do
|
7
|
+
Trestle::ResourceController.send(:prepend, Trestle::Search::Controller)
|
8
|
+
end
|
9
|
+
|
6
10
|
initializer :extensions do
|
7
|
-
Trestle::Resource.
|
11
|
+
Trestle::Resource.send(:include, Trestle::Search::Resource)
|
8
12
|
Trestle::Resource::Builder.send(:include, Trestle::Search::Builder)
|
9
|
-
Trestle::Resource::Controller.send(:prepend, Trestle::Search::Controller)
|
10
13
|
end
|
11
14
|
end
|
12
15
|
end
|
@@ -1,22 +1,35 @@
|
|
1
1
|
module Trestle
|
2
2
|
module Search
|
3
3
|
module Resource
|
4
|
-
|
4
|
+
extend ActiveSupport::Concern
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
included do
|
7
|
+
# Include custom #collection method on Resource instance
|
8
|
+
prepend Collection
|
9
|
+
|
10
|
+
# Include custom #collection method on Resource class
|
11
|
+
singleton_class.send(:prepend, Collection)
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
module Collection
|
15
|
+
def collection(params={})
|
16
|
+
if searchable?
|
17
|
+
query = params[:q].presence
|
18
|
+
search(query, params) || super
|
19
|
+
else
|
20
|
+
super
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def search(query, params={})
|
25
|
+
adapter.search(query, params)
|
26
|
+
end
|
16
27
|
end
|
17
28
|
|
18
|
-
|
19
|
-
|
29
|
+
module ClassMethods
|
30
|
+
def searchable?
|
31
|
+
adapter.respond_to?(:search)
|
32
|
+
end
|
20
33
|
end
|
21
34
|
end
|
22
35
|
end
|
data/package.json
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"name": "trestle-search",
|
3
|
+
"version": "0.4.0",
|
4
|
+
"description": "Search plugin for the Trestle admin framework",
|
5
|
+
"main": "index.scss",
|
6
|
+
"repository": "https://github.com/TrestleAdmin/trestle-search.git",
|
7
|
+
"author": "Sam Pohlenz <sam@sampohlenz.com>",
|
8
|
+
"license": "LGPL-3.0",
|
9
|
+
"private": true,
|
10
|
+
"scripts": {
|
11
|
+
"dev": "webpack --mode development",
|
12
|
+
"build": "webpack --mode production",
|
13
|
+
"watch": "webpack --mode development --watch"
|
14
|
+
},
|
15
|
+
"devDependencies": {
|
16
|
+
"autoprefixer": "^9.6.1",
|
17
|
+
"css-loader": "^3.2.0",
|
18
|
+
"mini-css-extract-plugin": "^0.8.0",
|
19
|
+
"node-sass": "^4.12.0",
|
20
|
+
"optimize-css-assets-webpack-plugin": "^5.0.3",
|
21
|
+
"postcss-loader": "^3.0.0",
|
22
|
+
"sass-loader": "^8.0.0",
|
23
|
+
"webpack": "^4.40.2",
|
24
|
+
"webpack-cli": "^3.3.9",
|
25
|
+
"webpack-fix-style-only-entries": "^0.4.0"
|
26
|
+
},
|
27
|
+
"dependencies": {
|
28
|
+
"trestle": "https://github.com/TrestleAdmin/trestle.git"
|
29
|
+
}
|
30
|
+
}
|
data/trestle-search.gemspec
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'trestle/search/version'
|
1
|
+
require_relative 'lib/trestle/search/version'
|
5
2
|
|
6
3
|
Gem::Specification.new do |spec|
|
7
4
|
spec.name = "trestle-search"
|
@@ -11,16 +8,21 @@ Gem::Specification.new do |spec|
|
|
11
8
|
spec.email = ["sam@sampohlenz.com"]
|
12
9
|
|
13
10
|
spec.summary = "Search plugin for the Trestle admin framework"
|
14
|
-
spec.description = "Search plugin for the Trestle admin framework."
|
15
11
|
spec.homepage = "https://www.trestle.io"
|
16
12
|
spec.license = "LGPL-3.0"
|
17
13
|
|
18
|
-
spec.files =
|
14
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
15
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
|
16
|
+
end
|
17
|
+
|
19
18
|
spec.require_paths = ["lib"]
|
20
19
|
|
21
|
-
spec.
|
20
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
21
|
+
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/TrestleAdmin/trestle-search"
|
24
|
+
|
25
|
+
spec.add_dependency "trestle", "~> 0.9.0", ">= 0.9.3"
|
22
26
|
|
23
|
-
spec.add_development_dependency "
|
24
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
spec.add_development_dependency "rspec-rails", "~> 3.0"
|
26
28
|
end
|