rails_admin_sitemap 0.2.0 → 0.3.0
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/app/views/rails_admin/main/sitemap.slim +10 -0
- data/config/locales/sitemap.en.yml +13 -1
- data/config/locales/sitemap.ru.yml +13 -1
- data/lib/rails_admin_sitemap/action.rb +76 -49
- data/lib/rails_admin_sitemap/version.rb +1 -1
- metadata +3 -3
- data/app/views/layouts/rails_admin/_secondary_navigation.html.slim +0 -19
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 14429f48407222916b4d9f49c5f6360108aad2fe
|
|
4
|
+
data.tar.gz: 58a4c31371ee088e82437e895ce81c8e0d2737c7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5883cb01fe2b960f9e57ad03f8ab5bcfc144c64c5336d59b45c3e031354b2116245cd62d21d2db8108505f27d4c7a9f2c860eaf95fff8b26306adda949f5e86f
|
|
7
|
+
data.tar.gz: f7e29dacbdae615f40e06e5510eb90d20c8ce1bd9eda627142e772f820ef1a1c9e0f7b7bd9ddbf98c445886fb0ca0b3ee8915ba19b7344396edf788968e3e0ee
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#rails_admin_sitemap_wrapper
|
|
2
|
+
#rails_admin_sitemap
|
|
3
|
+
.controls
|
|
4
|
+
= form_for "sitemap", url: sitemap_path(model_name: @abstract_model), method: :post do |f|
|
|
5
|
+
p= f.submit "Перегенирить карту сайта"
|
|
6
|
+
|
|
7
|
+
= link_to "Проверить", "/sitemap.xml.gz", target: :_blank, title: "Проверить сожержимое sitemap.xml там и сейчас"
|
|
8
|
+
'
|
|
9
|
+
= link_to "Проверить тут", sitemap_path(model_name: @abstract_model, get_xml: true), title: "Проверить сожержимое sitemap.xml здесь и сейчас", onclick: "$('#file_contents').load(this.href, function(){$('#file_contents').text($('#file_contents').html())}); return false;"
|
|
10
|
+
pre#file_contents{style='margin-bottom: 20px;'}
|
|
@@ -12,4 +12,16 @@ en:
|
|
|
12
12
|
confirm: "Are you sure, you want to regenerate Sitemap?"
|
|
13
13
|
|
|
14
14
|
incorrect_generator: "Incorrect Sitemap generator"
|
|
15
|
-
unknown_error: "Unknown error"
|
|
15
|
+
unknown_error: "Unknown error"
|
|
16
|
+
|
|
17
|
+
sitemap_for_model:
|
|
18
|
+
title: "Sitemap"
|
|
19
|
+
menu: "Sitemap for %{model_label} '%{object_label}'"
|
|
20
|
+
breadcrumb: "Sitemap"
|
|
21
|
+
link: "Sitemap"
|
|
22
|
+
bulk_link: "Sitemap selected %{model_label_plural}"
|
|
23
|
+
done: "Sitemaped"
|
|
24
|
+
confirm: "Are you sure, you want to regenerate Sitemap?"
|
|
25
|
+
|
|
26
|
+
incorrect_generator: "Incorrect Sitemap generator"
|
|
27
|
+
unknown_error: "Unknown error"
|
|
@@ -11,4 +11,16 @@ ru:
|
|
|
11
11
|
confirm: "Вы уверены, что хотите перегенерить Sitemap?"
|
|
12
12
|
|
|
13
13
|
incorrect_generator: "Неверно указан генератор Sitemap"
|
|
14
|
-
unknown_error: "Неизвестная ошибка"
|
|
14
|
+
unknown_error: "Неизвестная ошибка"
|
|
15
|
+
|
|
16
|
+
sitemap_for_model:
|
|
17
|
+
title: "Перегенерить Sitemap"
|
|
18
|
+
menu: "Перегенерить Sitemap"
|
|
19
|
+
breadcrumb: "Sitemap"
|
|
20
|
+
link: "Перегенерить Sitemap"
|
|
21
|
+
bulk_link: "Перегенерить Sitemap"
|
|
22
|
+
done: "Sitemap сгенерен"
|
|
23
|
+
confirm: "Вы уверены, что хотите перегенерить Sitemap?"
|
|
24
|
+
|
|
25
|
+
incorrect_generator: "Неверно указан генератор Sitemap"
|
|
26
|
+
unknown_error: "Неизвестная ошибка"
|
|
@@ -11,74 +11,101 @@ module RailsAdmin
|
|
|
11
11
|
true
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
# register_instance_option :breadcrumb_parent do
|
|
15
|
-
# nil
|
|
16
|
-
# end
|
|
17
14
|
|
|
18
15
|
register_instance_option :controller do
|
|
19
16
|
Proc.new do
|
|
17
|
+
if request.get?
|
|
18
|
+
if params[:get_xml] and request.xhr?
|
|
19
|
+
content = `gzip -cd #{Rails.root.join("public", "sitemap.xml.gz")}`
|
|
20
|
+
content = Nokogiri::XML::DocumentFragment.parse(content).to_xml if defined?(Nokogiri)
|
|
21
|
+
render plain: content
|
|
22
|
+
else
|
|
23
|
+
render action: @action.template_name
|
|
24
|
+
end
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
26
|
+
else
|
|
27
|
+
error = nil
|
|
28
|
+
begin
|
|
29
|
+
|
|
30
|
+
case RailsAdminSitemap.configuration.generator
|
|
31
|
+
|
|
32
|
+
#https://github.com/kjvarga/sitemap_generator
|
|
33
|
+
when :sitemap_generator then
|
|
34
|
+
::SitemapGenerator::Interpreter.run(:config_file => RailsAdminSitemap.configuration.config_file)
|
|
35
|
+
|
|
36
|
+
#https://github.com/lassebunk/dynamic_sitemaps
|
|
37
|
+
when :dynamic_sitemaps
|
|
38
|
+
require 'dynamic_sitemaps'
|
|
39
|
+
DynamicSitemaps.configure do |config|
|
|
40
|
+
config.path = RailsAdminSitemap.configuration.dynamic_sitemaps_conf[:path]
|
|
41
|
+
config.folder = RailsAdminSitemap.configuration.dynamic_sitemaps_conf[:folder]
|
|
42
|
+
config.index_file_name = RailsAdminSitemap.configuration.dynamic_sitemaps_conf[:index_file_name]
|
|
43
|
+
|
|
44
|
+
config.config_path = RailsAdminSitemap.configuration.config_file
|
|
45
|
+
end
|
|
46
|
+
DynamicSitemaps.generate_sitemap
|
|
47
|
+
|
|
48
|
+
#https://github.com/viseztrance/rails-sitemap
|
|
49
|
+
when :rails_sitemap
|
|
50
|
+
require "sitemap"
|
|
51
|
+
require RailsAdminSitemap.configuration.config_file
|
|
52
|
+
path = RailsAdminSitemap.configuration.output_file
|
|
53
|
+
::Sitemap::Generator.instance.build!
|
|
54
|
+
::Sitemap::Generator.instance.save path
|
|
55
|
+
|
|
56
|
+
else
|
|
57
|
+
error = t("admin.actions.sitemap.incorrect_generator")
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
rescue Exception => ex
|
|
61
|
+
error = ex.message
|
|
62
|
+
error ||= t("admin.actions.sitemap.unknown_error")
|
|
53
63
|
end
|
|
54
64
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
if error.blank?
|
|
66
|
+
flash[:notice] = t("admin.actions.sitemap.done")
|
|
67
|
+
else
|
|
68
|
+
flash[:error] = error
|
|
69
|
+
end
|
|
59
70
|
|
|
60
|
-
|
|
61
|
-
flash[:notice] = t("admin.actions.sitemap.done")
|
|
62
|
-
else
|
|
63
|
-
flash[:error] = error
|
|
71
|
+
redirect_to sitemap_path(model_name: @abstract_model)
|
|
64
72
|
end
|
|
65
|
-
|
|
66
|
-
redirect_to dashboard_path
|
|
67
73
|
end
|
|
68
74
|
end
|
|
69
75
|
|
|
76
|
+
register_instance_option :link_icon do
|
|
77
|
+
'fa fa-sitemap'
|
|
78
|
+
end
|
|
79
|
+
|
|
70
80
|
register_instance_option :statistics? do
|
|
71
81
|
false
|
|
72
82
|
end
|
|
73
83
|
|
|
74
|
-
register_instance_option :
|
|
84
|
+
register_instance_option :http_methods do
|
|
85
|
+
[:get, :post]
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
module RailsAdmin
|
|
94
|
+
module Config
|
|
95
|
+
module Actions
|
|
96
|
+
class SitemapForModel < Sitemap
|
|
97
|
+
RailsAdmin::Config::Actions.register(self)
|
|
98
|
+
|
|
99
|
+
# Is the action acting on the root level (Example: /admin/contact)
|
|
100
|
+
register_instance_option :root? do
|
|
75
101
|
false
|
|
76
102
|
end
|
|
77
103
|
|
|
78
|
-
register_instance_option :
|
|
79
|
-
|
|
104
|
+
register_instance_option :collection? do
|
|
105
|
+
true
|
|
80
106
|
end
|
|
107
|
+
|
|
81
108
|
end
|
|
82
109
|
end
|
|
83
110
|
end
|
|
84
|
-
end
|
|
111
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails_admin_sitemap
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexander Kiseliev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2017-03-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails_admin
|
|
@@ -33,7 +33,7 @@ extra_rdoc_files: []
|
|
|
33
33
|
files:
|
|
34
34
|
- MIT-LICENSE
|
|
35
35
|
- Rakefile
|
|
36
|
-
- app/views/
|
|
36
|
+
- app/views/rails_admin/main/sitemap.slim
|
|
37
37
|
- config/locales/sitemap.en.yml
|
|
38
38
|
- config/locales/sitemap.ru.yml
|
|
39
39
|
- lib/rails_admin_sitemap.rb
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
ul.nav.pull-right.root_links
|
|
2
|
-
- actions(:root).each do |action|
|
|
3
|
-
- data_method = nil if action.http_methods.include?(:get)
|
|
4
|
-
- data_method = "post" if action.http_methods.include?(:post)
|
|
5
|
-
- data_method = "put" if action.http_methods.include?(:put)
|
|
6
|
-
- data_method = "delete" if action.http_methods.include?(:delete)
|
|
7
|
-
|
|
8
|
-
li{class="#{action.action_name}_root_link"}
|
|
9
|
-
= link_to wording_for(:menu, action), { action: action.action_name, controller: 'rails_admin/main' }, class: (action.pjax? ? "pjax" : ""), data: data_method ? {method: data_method, confirm: t("admin.actions.#{action.action_name}.confirm")} : nil
|
|
10
|
-
|
|
11
|
-
- if main_app_root_path = (main_app.root_path rescue false)
|
|
12
|
-
li= link_to t('admin.home.name').capitalize, main_app_root_path
|
|
13
|
-
- if _current_user
|
|
14
|
-
- if user_link = edit_user_link
|
|
15
|
-
li= user_link
|
|
16
|
-
- if logout_path.present?
|
|
17
|
-
li= link_to content_tag('span', t('admin.misc.log_out'), class: 'label label-important'), logout_path, method: logout_method
|
|
18
|
-
- if _current_user.respond_to?(:email) && _current_user.email.present?
|
|
19
|
-
li= image_tag "#{(request.ssl? ? 'https://secure' : 'http://www')}.gravatar.com/avatar/#{Digest::MD5.hexdigest _current_user.email}?s=30", style: 'padding-top:5px'
|