camaleon_sitemap_customizer 0.5.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 044b819320b8c634f74f959e3efc63992fd462b0e3d9ae9843f6f5c98e3b34cb
4
- data.tar.gz: 92ec9e59355e9dd61e7b24e610a328937d1d418c88bc6d111ab021f4f4ba6edc
3
+ metadata.gz: 1e3b2de62c6a36766e25f4a1e66779e40dbed80fda1956abf2b39196b2b4c30b
4
+ data.tar.gz: 274372e1b11f769b706b2d9a2e5c37687dd7563587246c5b6bf28fcdb395647b
5
5
  SHA512:
6
- metadata.gz: 9f68a337bcb208a34d1b9871c3eecd679c79528344810dccc352cf70d18f757294f52fc97846b0976b1e7ee57cf274770a50ab2faa573fb5bd128d59c133fcbf
7
- data.tar.gz: db02eccb4dc720e528009c6baae6c49b036dbbb5014bb09bad2bca44aafb23d298aa041c9eeb43d91bf6975baac5a89069bc2e65b274c266e8dade18e8e536d3
6
+ metadata.gz: e8ab214a2b7c6bde032d58fbb43dade4f1fcaccb45f0c014029e27caca070a2ed4e9e51a65869576d655abd78d3e9dfadb2b32c5d8db5cee1712d84cc7e92c11
7
+ data.tar.gz: 1dcce635a28669151d5055b3ba02ad98155e597ca2bb40e0198f9a8e9aace780515db293a3a95ad6cd447ba4e84f6b3851b5174acedee3a12bff469c296eb93d
data/README.md CHANGED
@@ -1,11 +1,15 @@
1
+ ![](https://img.shields.io/badge/ruby-2.3%2B-red.svg)
2
+ ![Gem Version](https://img.shields.io/gem/v/camaleon_sitemap_customizer.svg?colorB=blue)
1
3
  [![Build Status](https://travis-ci.com/brian-kephart/camaleon_sitemap_customizer.svg?branch=master)](https://travis-ci.com/brian-kephart/camaleon_sitemap_customizer)
2
4
 
3
- # Sitemap Customizer
5
+ # Camaleon Sitemap Customizer
4
6
  Camaleon CMS automatically generates sitemaps for all content of your site. This plugin allows you to select content to omit from the sitemap. You may wish to do this for a variety of reasons:
5
7
  - Keep search engines from indexing pages that are not relevant to the general public.
6
8
  - Keep search engines from indexing summary pages that only contain duplicate content.
7
9
  - Remove redundant entries. (ex. – 'https://yoursite.com', 'https://yoursite.com/index')
8
10
 
11
+ This plugin also comes with an optional sitemap template that includes caching to speed up rendering.
12
+
9
13
  ## Installation
10
14
  Add this line to your application's Gemfile:
11
15
 
@@ -30,9 +34,19 @@ Use the site settings (/admin/plugins/camaleon_sitemap_customizer/settings) to:
30
34
  - Select **categories** for which to exclude list pages, same as above.
31
35
  - Exclude all **tag** list pages.
32
36
  - Exclude post url for page designated as the homepage. For example, if you have a page called '/index' that you have set as your homepage in the site settings, the sitemap will list the same page at 'http://yoursite.com/' and 'http://yoursite.com/index'. This option allows you to avoid the duplicate listing.
37
+ - Choose whether to use the included sitemap template, which includes caching to speed up rendering.
33
38
 
34
39
  This plugin also adds an option to each post for exclusion from the sitemap. This is accessible via the regular post editor, rather than in the plugin settings.
35
40
 
41
+ ### About sitemap caching
42
+ The default sitemaps in Camaleon render very slowly due to the many database queries required for them to be accurate. This may not be noticeable on small sites, but large ones can sometimes take several seconds to render. This can be sped up with caching, but Camaleon's Front Cache plugin does not render XML.
43
+
44
+ This plugin offers an XML builder template that uses Russian doll caching to speed up rendering. It can be enabled on the settings page.
45
+
46
+ If you wish to make changes to the included template:
47
+ 1. **Disable** the caching option in the plugin settings.
48
+ 2. Copy the included `app/views/themes/default/views/sitemap_with_caching.xml.builder` into your app's `app/apps/themes/your_theme/views/sitemap.xml.builder` and make your changes. Camaleon will use the `sitemap.xml.builder` file in your theme directory by default.
49
+
36
50
  ## Contributing
37
51
  See CONTRIBUTING.md
38
52
 
@@ -5,7 +5,8 @@ class Plugins::CamaleonSitemapCustomizer::AdminController < CamaleonCms::Apps::P
5
5
  'skip_category_list_types' => [],
6
6
  'skip_all_categories' => false,
7
7
  'skip_tags' => false,
8
- 'skip_home' => false
8
+ 'skip_home' => false,
9
+ 'cache' => Rails.env.test? ? true : false
9
10
  }.freeze
10
11
 
11
12
  include Plugins::CamaleonSitemapCustomizer::MainHelper
@@ -31,8 +31,15 @@ module Plugins::CamaleonSitemapCustomizer::MainHelper
31
31
  args[:skip_posttype_ids] += current_plugin.get_option('skip_post_list_types')&.map(&:to_i).presence || []
32
32
  args[:skip_cat_ids] += select_categories
33
33
  args[:skip_tag_ids] += current_site.the_tags.map(&:id) if current_plugin.get_option('skip_tags')
34
+
35
+ # exclude individual posts via post editor option
34
36
  args[:skip_post_ids] += current_plugin.get_option('skip_posts').presence || []
37
+
38
+ # exclude redundant home page url
35
39
  args[:skip_post_ids] << current_site.options.dig(:home_page).to_i if current_plugin.get_option('skip_home') && current_site.options.dig(:home_page).present?
40
+
41
+ # use caching in sitemap
42
+ args[:render] = cached_sitemap_template if current_plugin.get_option('cache').present?
36
43
  end
37
44
 
38
45
  def camaleon_sitemap_customizer_form(args)
@@ -51,6 +58,8 @@ module Plugins::CamaleonSitemapCustomizer::MainHelper
51
58
  skip_posts current_plugin
52
59
  end
53
60
 
61
+ private
62
+
54
63
  def skip_posts(plugin)
55
64
  plugin.set_option 'skip_posts', current_site.the_posts.eager_load(:metas).select { |post| post.get_option('hide_in_sitemap').present? } .map(&:id)
56
65
  end
@@ -62,4 +71,8 @@ module Plugins::CamaleonSitemapCustomizer::MainHelper
62
71
  current_plugin.get_option('skip_category_list_types')&.map(&:to_i).presence || []
63
72
  end
64
73
  end
74
+
75
+ def cached_sitemap_template
76
+ 'sitemap_with_caching'
77
+ end
65
78
  end
@@ -0,0 +1,81 @@
1
+ xml.instruct! :xml, version: '1.0'
2
+ xml.urlset xmlns: 'http://www.sitemaps.org/schemas/sitemap/0.9' do
3
+ current_site.get_languages.each_with_index do |lang, index|
4
+ lang = (index.zero? ? nil : lang)
5
+ xml.url do
6
+ xml.loc current_site.the_url(locale: lang)
7
+ xml.lastmod current_site.updated_at.to_date
8
+ xml.changefreq 'daily'
9
+ xml.priority '1.0'
10
+ end
11
+
12
+ cache ["xml_sitemap/posts/#{current_site.the_posts.maximum :updated_at}", @r[:skip_post_ids]] do
13
+ current_site.the_posts.decorate.each do |post|
14
+ next if @r[:skip_post_ids].include? post.id
15
+ cache post do
16
+ xml.url do
17
+ xml.loc post.the_url(locale: lang)
18
+ xml.lastmod post.updated_at.to_date
19
+ xml.changefreq 'monthly'
20
+ xml.priority '0.5'
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ cache ["xml_sitemap/categories/#{current_site.full_categories.maximum :updated_at}", @r[:skip_cat_ids]] do
27
+ current_site.full_categories.no_empty.decorate.each do |cat|
28
+ next if @r[:skip_cat_ids].include? cat.id
29
+ cache cat do
30
+ xml.url do
31
+ xml.loc cat.the_url(locale: lang)
32
+ xml.lastmod cat.updated_at.to_date
33
+ xml.changefreq 'monthly'
34
+ xml.priority '0.5'
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ cache ["xml_sitemap/post_types/#{current_site.post_types.maximum :updated_at}", @r[:skip_posttype_ids]] do
41
+ current_site.post_types.decorate.each do |ptype|
42
+ next if @r[:skip_posttype_ids].include? ptype.id
43
+ cache ptype do
44
+ xml.url do
45
+ xml.loc ptype.the_url(locale: lang)
46
+ xml.lastmod ptype.updated_at.to_date
47
+ xml.changefreq 'monthly'
48
+ xml.priority '0.5'
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ cache ["xml_sitemap/post_tags/#{current_site.post_types.maximum :updated_at}", @r[:skip_tag_ids]] do
55
+ current_site.post_tags.decorate.each do |tag|
56
+ next if @r[:skip_tag_ids].include? tag.id
57
+ cache tag do
58
+ xml.url do
59
+ xml.loc tag.the_url(locale: lang)
60
+ xml.lastmod tag.updated_at.to_date
61
+ xml.changefreq 'monthly'
62
+ xml.priority '0.5'
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+
69
+ cache @r[:custom] do
70
+ @r[:custom].each do |_key, item|
71
+ cache item do
72
+ xml.url do
73
+ xml.loc item[:url]
74
+ xml.lastmod item[:lastmod] || Date.today.to_s
75
+ xml.changefreq item[:changefreq] || 'monthly'
76
+ xml.priority item[:priority] || '0.5'
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -56,6 +56,10 @@
56
56
  <%= check_box_tag "options[skip_home]", 1, @plugin.get_option('skip_home'), style: 'display: block;' %>
57
57
  </div>
58
58
 
59
+ <div class="form-group">
60
+ <label><%= cama_t 'cache' %></label>
61
+ <%= check_box_tag "options[cache]", 1, @plugin.get_option('cache'), style: 'display: block;' %>
62
+ </div>
59
63
 
60
64
  <div class="form-group text-right">
61
65
  <%= link_to 'View Sitemap', '/sitemap', target: 'blank' %>&nbsp;&nbsp;&nbsp;&nbsp;
@@ -8,3 +8,4 @@ en:
8
8
  categories_all: "Exclude ALL Categories (overrides above setting)"
9
9
  tags: "Exclude Tags"
10
10
  homepage: "Exclude duplicate home page url? (ex. – remove www.mysite.com/home if this renders the same post as www.mysite.com)"
11
+ cache: "Use caching to speed up sitemap rendering?"
@@ -1,3 +1,3 @@
1
1
  module CamaleonSitemapCustomizer
2
- VERSION = '0.5.2'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: camaleon_sitemap_customizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Kephart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-27 00:00:00.000000000 Z
11
+ date: 2018-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: camaleon_cms
@@ -65,6 +65,7 @@ files:
65
65
  - Rakefile
66
66
  - app/controllers/plugins/camaleon_sitemap_customizer/admin_controller.rb
67
67
  - app/helpers/plugins/camaleon_sitemap_customizer/main_helper.rb
68
+ - app/views/camaleon_cms/default_theme/sitemap_with_caching.xml.builder
68
69
  - app/views/plugins/camaleon_sitemap_customizer/admin/settings.html.erb
69
70
  - config/camaleon_plugin.json
70
71
  - config/locales/en.yml