7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
53
54
55
56
57
|
# File 'app/controller/sitemap_controller.rb', line 7
def sitemap
FiSeo::create_sitemap_seo_records
class_names = ActiveRecord::Base.connection.tables.map do |model|
model
end
domain = 'www.domain.com'
domain = FiSeo.initialized_config.sitemap_host_url if FiSeo.initialized_config.sitemap_host_url.present?
@map = XmlSitemap::Map.new(domain) do |m|
SitemapSeo.where(status: true).each do |site_map_seo|
action = site_map_seo.sitemap_action
controller = site_map_seo.sitemap_controller
priority = site_map_seo.priority
period = site_map_seo.period
static = site_map_seo.static
if SitemapSeo.periods[period.to_sym] == 0
period_string = 'none'
period_sym = period_string.to_sym
else
period_sym = period.to_sym
end
if class_names.include? controller.pluralize
p = controller.capitalize.singularize.camelize
if Object.const_defined?(p) && (%w[destroy update create index new].exclude? action) && p.constantize.any? && !static
p.constantize.all.each do |record|
if (%w[new create index].include? action)
m.add(url_for(controller: controller, action: action, only_path: true),
priority: priority, updated: Date.today, period: period_sym)
else
m.add(url_for(controller: controller, action: action, id: record.id, only_path: true),
priority: priority, updated: Date.today, period: period_sym)
end
end
elsif %w[destroy update create].exclude? action
m.add(url_for(controller: controller, action: action, only_path: true),
priority: priority, updated: Date.today, period: period_sym)
end
elsif %w[destroy update create].exclude? action
m.add(url_for(controller: controller, action: action, only_path: true),
priority: priority, updated: Date.today, period: period_sym)
end
end
end
respond_to do |format|
format.xml
end
end
|