rocket_cms 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/app/models/page.rb +0 -1
- data/app/views/search/index.html.haml +19 -5
- data/lib/rails_admin/custom_show_in_app.rb +1 -13
- data/lib/rocket_cms.rb +19 -2
- data/lib/rocket_cms/controller.rb +6 -1
- data/lib/rocket_cms/controllers/search.rb +20 -16
- data/lib/rocket_cms/models/news.rb +2 -3
- data/lib/rocket_cms/models/page.rb +3 -3
- data/lib/rocket_cms/search.rb +38 -0
- data/lib/rocket_cms/version.rb +1 -1
- data/rocket_cms.gemspec +2 -2
- data/template.rb +1 -2
- metadata +3 -3
- data/lib/rocket_cms/elastic_search.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c561a9c54c086e5e2c2841a5bda68989ac749a54
|
4
|
+
data.tar.gz: 9dadffa15b78de9ad6b319e1da5cca44b204a8cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 390a696a45e6c1020d6ac16f3554218b7d112f954f1ec801c16d10058b6fdaa57e31e48ef7db0977eb28da9cb00f22b568e8e29d148128b6094b1c82b803d748
|
7
|
+
data.tar.gz: a24fb04e148f58f00af442464cc50cf47aa5ac5d5983bc3fe3c5555930de9dcaece10a86df8d8f4e8986157a48df3dbb097deefe56b52a8978c0b6750df36f14
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rocket_cms (0.9.
|
4
|
+
rocket_cms (0.9.2)
|
5
5
|
addressable
|
6
6
|
coffee-rails
|
7
7
|
devise
|
@@ -113,7 +113,7 @@ GEM
|
|
113
113
|
mail (2.6.3)
|
114
114
|
mime-types (>= 1.16, < 3)
|
115
115
|
mime-types (2.6.2)
|
116
|
-
mini_magick (4.3.
|
116
|
+
mini_magick (4.3.6)
|
117
117
|
mini_portile (0.6.2)
|
118
118
|
minitest (5.8.1)
|
119
119
|
nested_form (0.3.2)
|
@@ -174,7 +174,7 @@ GEM
|
|
174
174
|
responders (2.1.0)
|
175
175
|
railties (>= 4.2.0, < 5)
|
176
176
|
safe_yaml (1.0.4)
|
177
|
-
sass (3.4.
|
177
|
+
sass (3.4.19)
|
178
178
|
sass-rails (5.0.4)
|
179
179
|
railties (>= 4.0.0, < 5.0)
|
180
180
|
sass (~> 3.1)
|
@@ -191,7 +191,7 @@ GEM
|
|
191
191
|
smart_excerpt (0.1.5)
|
192
192
|
activesupport
|
193
193
|
htmlentities
|
194
|
-
sprockets (3.
|
194
|
+
sprockets (3.4.0)
|
195
195
|
rack (> 1, < 3)
|
196
196
|
sprockets-rails (2.3.3)
|
197
197
|
actionpack (>= 3.0)
|
data/app/models/page.rb
CHANGED
@@ -8,11 +8,25 @@
|
|
8
8
|
- @results.each do |r|
|
9
9
|
- any = true
|
10
10
|
%li
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
-if RocketCMS.mongoid?
|
12
|
+
.title= link_to (r._highlight.nil? || r._highlight['name'].nil?) ? r.name : r._highlight['name'].join(' ... ').html_safe, url_for(r)
|
13
|
+
.text
|
14
|
+
= raw (r._highlight.nil? || r._highlight['content'].nil?) ? (r.content.blank? ? '' : SmartExcerpt.truncate(r.content)) : r._highlight['content'].join(' ... ')
|
15
|
+
%span.more= link_to '', url_for(r)
|
16
|
+
- else
|
17
|
+
- u = app_url(result.searchable)
|
18
|
+
- next if u.nil?
|
19
|
+
- next if result.searchable.respond_to?(:enabled) && !result.searchable.enabled
|
20
|
+
- any = true
|
21
|
+
%a{href: u}
|
22
|
+
%span
|
23
|
+
%strong= highlight(result.searchable.name, params[:query], highlighter: '<em>\1</em>')
|
24
|
+
| (#{result.searchable.class.model_name.human})
|
25
|
+
- ex = excerpt(strip_tags(result.searchable.content), params[:query], radius: 150)
|
26
|
+
- if ex.nil?
|
27
|
+
== strip_tags(SmartExcerpt.h.smart_truncate(result.searchable.content, words: 20))
|
28
|
+
- else
|
29
|
+
== highlight(ex, params[:query], highlighter: '<em>\1</em>')
|
16
30
|
- unless any
|
17
31
|
.rs-search-no-results К сожалению, ничего не найдено
|
18
32
|
|
@@ -14,19 +14,7 @@ module RailsAdmin
|
|
14
14
|
|
15
15
|
register_instance_option :controller do
|
16
16
|
Proc.new do
|
17
|
-
|
18
|
-
if @object.fullpath.blank?
|
19
|
-
redirect_to main_app.page_url(@object)
|
20
|
-
else
|
21
|
-
redirect_to @object.fullpath
|
22
|
-
end
|
23
|
-
elsif @object.class.name == 'News'
|
24
|
-
redirect_to main_app.news_url(@object)
|
25
|
-
elsif @object.class.name == 'Obj'
|
26
|
-
redirect_to main_app.object_url(@object.category, @object)
|
27
|
-
else
|
28
|
-
redirect_to main_app.url_for(@object)
|
29
|
-
end
|
17
|
+
RocketCMS.app_url(@object)
|
30
18
|
end
|
31
19
|
end
|
32
20
|
|
data/lib/rocket_cms.rb
CHANGED
@@ -28,7 +28,7 @@ require 'rocket_cms/seo_helpers'
|
|
28
28
|
require 'rocket_cms/configuration'
|
29
29
|
require 'rocket_cms/patch'
|
30
30
|
require 'rocket_cms/admin'
|
31
|
-
require 'rocket_cms/
|
31
|
+
require 'rocket_cms/search'
|
32
32
|
require 'rocket_cms/model'
|
33
33
|
require 'rocket_cms/rails_admin_menu'
|
34
34
|
require 'rocket_cms/engine'
|
@@ -48,6 +48,24 @@ module RocketCMS
|
|
48
48
|
def orm_specific(name)
|
49
49
|
"#{model_namespace}::#{name}".constantize
|
50
50
|
end
|
51
|
+
|
52
|
+
def custom_app_url(object)
|
53
|
+
redirect_to Rails.application.routes.url_helpers.url_for(object)
|
54
|
+
end
|
55
|
+
|
56
|
+
def app_url(object)
|
57
|
+
if object.class.name == 'Page'
|
58
|
+
if object.fullpath.blank?
|
59
|
+
redirect_to Rails.application.routes.url_helpers.page_url(object)
|
60
|
+
else
|
61
|
+
redirect_to object.fullpath
|
62
|
+
end
|
63
|
+
elsif object.class.name == 'News'
|
64
|
+
redirect_to Rails.application.routes.url_helpers.news_url(object)
|
65
|
+
else
|
66
|
+
RocketCMS.custom_app_url(object)
|
67
|
+
end
|
68
|
+
end
|
51
69
|
end
|
52
70
|
|
53
71
|
autoload :Migration, 'rocket_cms/migration'
|
@@ -85,4 +103,3 @@ module RocketCMS
|
|
85
103
|
end
|
86
104
|
|
87
105
|
require 'manual_slug'
|
88
|
-
|
@@ -6,10 +6,11 @@ module RocketCMS::Controller
|
|
6
6
|
include RsMenu
|
7
7
|
protect_from_forgery with: :exception
|
8
8
|
helper_method :page_title
|
9
|
+
helper_method :app_url
|
9
10
|
end
|
10
11
|
|
11
12
|
protected
|
12
|
-
|
13
|
+
|
13
14
|
def page_title
|
14
15
|
if @seo_page.nil?
|
15
16
|
Settings.default_title
|
@@ -21,4 +22,8 @@ module RocketCMS::Controller
|
|
21
22
|
def ckeditor_authenticate
|
22
23
|
redirect_to '/' unless user_signed_in? && current_user.has_role?('admin')
|
23
24
|
end
|
25
|
+
|
26
|
+
def app_url(object)
|
27
|
+
RocketCMS.app_url(object)
|
28
|
+
end
|
24
29
|
end
|
@@ -6,23 +6,27 @@ module RocketCMS
|
|
6
6
|
if params[:query].blank?
|
7
7
|
@results = []
|
8
8
|
else
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
if RocketCMS.mongoid?
|
10
|
+
@results = Mongoid::Search.search({
|
11
|
+
body: {
|
12
|
+
query: {
|
13
|
+
query_string: {
|
14
|
+
query: Mongoid::Search::Utils.clean(params[:query])
|
15
|
+
}
|
16
|
+
},
|
17
|
+
highlight: {
|
18
|
+
fields: {
|
19
|
+
name: {},
|
20
|
+
content: {}
|
21
|
+
}
|
14
22
|
}
|
15
|
-
},
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
}},
|
23
|
-
page: params[:page],
|
24
|
-
per_page: RocketCMS.config.search_per_page,
|
25
|
-
)
|
23
|
+
}},
|
24
|
+
page: params[:page],
|
25
|
+
per_page: RocketCMS.config.search_per_page,
|
26
|
+
)
|
27
|
+
else
|
28
|
+
@results = PgSearch.multisearch(params[:q])
|
29
|
+
end
|
26
30
|
end
|
27
31
|
end
|
28
32
|
end
|
@@ -9,14 +9,14 @@ module RocketCMS
|
|
9
9
|
include ManualSlug
|
10
10
|
|
11
11
|
if RocketCMS.config.search_enabled
|
12
|
-
include RocketCMS::
|
12
|
+
include RocketCMS::Search
|
13
13
|
end
|
14
14
|
|
15
15
|
included do
|
16
16
|
unless RocketCMS.config.news_image_styles.nil?
|
17
17
|
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/, if: :image?
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
validates_presence_of :name
|
21
21
|
if RocketCMS.config.news_content_required
|
22
22
|
validates_presence_of :content
|
@@ -52,4 +52,3 @@ module RocketCMS
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
55
|
-
|
@@ -10,9 +10,9 @@ module RocketCMS
|
|
10
10
|
include RocketCMS.orm_specific('Page')
|
11
11
|
|
12
12
|
if RocketCMS.config.search_enabled
|
13
|
-
include RocketCMS::
|
13
|
+
include RocketCMS::Search
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
included do
|
17
17
|
has_and_belongs_to_many :menus, inverse_of: :pages
|
18
18
|
validates_uniqueness_of :fullpath
|
@@ -70,7 +70,7 @@ module RocketCMS
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
def nav_options
|
75
75
|
{highlights_on: clean_regexp}
|
76
76
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module RocketCMS::Search
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
included do
|
4
|
+
if RocketCMS.mongoid?
|
5
|
+
include Mongoid::Elasticsearch
|
6
|
+
elasticsearch!({
|
7
|
+
index_options: {
|
8
|
+
settings: {
|
9
|
+
index: {
|
10
|
+
analysis: {
|
11
|
+
analyzer: {
|
12
|
+
my_analyzer: {
|
13
|
+
type: "snowball",
|
14
|
+
language: "Russian"
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
},
|
21
|
+
index_mapings: {
|
22
|
+
name: {type: 'string', boost: 10, analyzer: 'my_analyzer'},
|
23
|
+
content: {type: 'string', boost: 1, analyzer: 'my_analyzer'},
|
24
|
+
}
|
25
|
+
})
|
26
|
+
else
|
27
|
+
include PgSearch
|
28
|
+
multisearchable against: [:name, :content]
|
29
|
+
end
|
30
|
+
|
31
|
+
def es_index?
|
32
|
+
enabled
|
33
|
+
end
|
34
|
+
def as_indexed_json
|
35
|
+
{name: name, content: SmartExcerpt.strip_tags(content)}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/rocket_cms/version.rb
CHANGED
data/rocket_cms.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.add_development_dependency 'bundler'
|
21
21
|
spec.add_development_dependency 'rake'
|
22
|
-
|
22
|
+
|
23
23
|
spec.add_dependency 'rails', '>= 4.1.0', '< 5.0'
|
24
24
|
|
25
25
|
spec.add_dependency 'jquery-rails'
|
@@ -42,5 +42,5 @@ Gem::Specification.new do |spec|
|
|
42
42
|
spec.add_dependency 'stringex'
|
43
43
|
spec.add_dependency 'thor'
|
44
44
|
spec.add_dependency 'smart_excerpt'
|
45
|
-
end
|
46
45
|
|
46
|
+
end
|
data/template.rb
CHANGED
@@ -422,7 +422,7 @@ end
|
|
422
422
|
FileUtils.cp(Pathname.new(destination_root).join('config', 'secrets.yml').to_s, Pathname.new(destination_root).join('config', 'secrets.yml.example').to_s)
|
423
423
|
|
424
424
|
unless mongoid
|
425
|
-
generate "paper_trail:install"
|
425
|
+
generate "paper_trail:install", "--with-associations"
|
426
426
|
generate "friendly_id"
|
427
427
|
rake "db:migrate"
|
428
428
|
end
|
@@ -430,4 +430,3 @@ end
|
|
430
430
|
git :init
|
431
431
|
git add: "."
|
432
432
|
git commit: %Q{ -m 'Initial commit' }
|
433
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rocket_cms
|
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
|
- glebtv
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -452,7 +452,6 @@ files:
|
|
452
452
|
- lib/rocket_cms/controllers/news.rb
|
453
453
|
- lib/rocket_cms/controllers/pages.rb
|
454
454
|
- lib/rocket_cms/controllers/search.rb
|
455
|
-
- lib/rocket_cms/elastic_search.rb
|
456
455
|
- lib/rocket_cms/engine.rb
|
457
456
|
- lib/rocket_cms/migration.rb
|
458
457
|
- lib/rocket_cms/model.rb
|
@@ -473,6 +472,7 @@ files:
|
|
473
472
|
- lib/rocket_cms/models/seo.rb
|
474
473
|
- lib/rocket_cms/patch.rb
|
475
474
|
- lib/rocket_cms/rails_admin_menu.rb
|
475
|
+
- lib/rocket_cms/search.rb
|
476
476
|
- lib/rocket_cms/seo_helpers.rb
|
477
477
|
- lib/rocket_cms/simple_form_patch.rb
|
478
478
|
- lib/rocket_cms/tasks.rb
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module RocketCMS::ElasticSearch
|
2
|
-
extend ActiveSupport::Concern
|
3
|
-
included do
|
4
|
-
include Mongoid::Elasticsearch
|
5
|
-
elasticsearch!({
|
6
|
-
index_options: {
|
7
|
-
settings: {
|
8
|
-
index: {
|
9
|
-
analysis: {
|
10
|
-
analyzer: {
|
11
|
-
my_analyzer: {
|
12
|
-
type: "snowball",
|
13
|
-
language: "Russian"
|
14
|
-
}
|
15
|
-
}
|
16
|
-
}
|
17
|
-
}
|
18
|
-
}
|
19
|
-
},
|
20
|
-
index_mapings: {
|
21
|
-
name: {type: 'string', boost: 10, analyzer: 'my_analyzer'},
|
22
|
-
content: {type: 'string', boost: 1, analyzer: 'my_analyzer'},
|
23
|
-
}
|
24
|
-
})
|
25
|
-
def es_index?
|
26
|
-
enabled
|
27
|
-
end
|
28
|
-
def as_indexed_json
|
29
|
-
{name: name, content: SmartExcerpt.strip_tags(content)}
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|