camaleon_sitemap_customizer 0.5.1 → 0.5.2

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: 6be96407242f8ed63430807b32391796d6f23b879611546f3447e35d3ebedf5a
4
- data.tar.gz: f50b123ba4d294c33745153fdeea8325c7ef1c2dcc512e75bd20b510281a084e
3
+ metadata.gz: 044b819320b8c634f74f959e3efc63992fd462b0e3d9ae9843f6f5c98e3b34cb
4
+ data.tar.gz: 92ec9e59355e9dd61e7b24e610a328937d1d418c88bc6d111ab021f4f4ba6edc
5
5
  SHA512:
6
- metadata.gz: 3e5398a02f510d9aae7260322ffe922fa11b91d0e13cf086661851c70bd662d722871475c5648698c56aa49051ef9ddcbd9b37d0d8661eebefb7cd3ac78f86ab
7
- data.tar.gz: b2f98783bcf07fc91623bb2ea0c3a2c5ed8a0b9d32377ff96e3d1333978f56314a5cfac8ce967f10d93c1bf7058ab28920b9adcb39f2faaf6deeeb01491f0f76
6
+ metadata.gz: 9f68a337bcb208a34d1b9871c3eecd679c79528344810dccc352cf70d18f757294f52fc97846b0976b1e7ee57cf274770a50ab2faa573fb5bd128d59c133fcbf
7
+ data.tar.gz: db02eccb4dc720e528009c6baae6c49b036dbbb5014bb09bad2bca44aafb23d298aa041c9eeb43d91bf6975baac5a89069bc2e65b274c266e8dade18e8e536d3
data/README.md CHANGED
@@ -1,14 +1,10 @@
1
- # Sitemap Customizer
2
- Camaleon CMS automatically generates sitemaps for all content of your site. This plugin allows you to select content to omit from the sitemap.
1
+ [![Build Status](https://travis-ci.com/brian-kephart/camaleon_sitemap_customizer.svg?branch=master)](https://travis-ci.com/brian-kephart/camaleon_sitemap_customizer)
3
2
 
4
- Use the site settings (/admin/plugins/camaleon_sitemap_customizer/settings) to:
5
- - Select **content types** to exclude **completely** (individual posts and list pages).
6
- - Select **content types** for which to exclude **list pages only**. For example, if you have a content type called 'Podcast', this option would allow you to exclude 'http://yoursite.com/podcast' (the page listing all posts of type 'Podcast') without excluding the pages for each individual post.
7
- - Select **categories** for which to exclude list pages, same as above.
8
- - Exclude all **tag** list pages.
9
- - 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.
10
-
11
- This plugin (as of version 0.3.0) 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.
3
+ # Sitemap Customizer
4
+ 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
+ - Keep search engines from indexing pages that are not relevant to the general public.
6
+ - Keep search engines from indexing summary pages that only contain duplicate content.
7
+ - Remove redundant entries. (ex. – 'https://yoursite.com', 'https://yoursite.com/index')
12
8
 
13
9
  ## Installation
14
10
  Add this line to your application's Gemfile:
@@ -27,12 +23,18 @@ Or install it yourself as:
27
23
  $ gem install camaleon_sitemap_customizer
28
24
  ```
29
25
 
26
+ ## Usage
27
+ Use the site settings (/admin/plugins/camaleon_sitemap_customizer/settings) to:
28
+ - Select **content types** to exclude **completely** (individual posts and list pages).
29
+ - Select **content types** for which to exclude **list pages only**. For example, if you have a content type called 'Podcast', this option would allow you to exclude 'http://yoursite.com/podcast' (the page listing all posts of type 'Podcast') without excluding the pages for each individual post.
30
+ - Select **categories** for which to exclude list pages, same as above.
31
+ - Exclude all **tag** list pages.
32
+ - 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.
33
+
34
+ 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
+
30
36
  ## Contributing
31
- - Fork it.
32
- - Create a branch (git checkout -b my_feature_branch)
33
- - Commit your changes (git commit -am "Added a sweet feature")
34
- - Push to the branch (git push origin my_feature_branch)
35
- - Create a pull request from your branch into master (Please be sure to provide enough detail for us to cipher what this change is doing)
37
+ See CONTRIBUTING.md
36
38
 
37
39
  ## License
38
40
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -14,14 +14,11 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
14
  rdoc.rdoc_files.include('lib/**/*.rb')
15
15
  end
16
16
 
17
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
17
+ APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
18
18
  load 'rails/tasks/engine.rake'
19
19
 
20
-
21
20
  load 'rails/tasks/statistics.rake'
22
21
 
23
-
24
-
25
22
  require 'bundler/gem_tasks'
26
23
 
27
24
  require 'rake/testtask'
@@ -32,5 +29,4 @@ Rake::TestTask.new(:test) do |t|
32
29
  t.verbose = false
33
30
  end
34
31
 
35
-
36
32
  task default: :test
@@ -1,22 +1,23 @@
1
1
  class Plugins::CamaleonSitemapCustomizer::AdminController < CamaleonCms::Apps::PluginsAdminController
2
+ DEFAULT_OPTIONS = {
3
+ 'skip_post_types' => [],
4
+ 'skip_post_list_types' => [],
5
+ 'skip_category_list_types' => [],
6
+ 'skip_all_categories' => false,
7
+ 'skip_tags' => false,
8
+ 'skip_home' => false
9
+ }.freeze
10
+
2
11
  include Plugins::CamaleonSitemapCustomizer::MainHelper
3
- def index
4
- end
12
+ def index; end
5
13
 
6
14
  # show settings form
7
- def settings
8
- end
15
+ def settings; end
9
16
 
10
17
  # save values from settings form
11
18
  def save_settings
12
- params[:options] ||= {}
13
- params[:options]['skip_post_types'] ||= []
14
- params[:options]['skip_post_list_types'] ||= []
15
- params[:options]['skip_category_list_types'] ||= []
16
- params[:options]['skip_all_categories'] ||= false
17
- params[:options]['skip_tags'] ||= false
18
- params[:options]['skip_home'] ||= false
19
- @plugin.set_options(params[:options]) # save option values
19
+ options = DEFAULT_OPTIONS.merge(params[:options]&.to_unsafe_h.presence || {})
20
+ @plugin.set_options(options) # save option values
20
21
  @plugin.set_metas(params[:metas]) if params[:metas].present? # save meta values
21
22
  @plugin.set_field_values(params[:field_options]) if params[:field_options].present? # save custom field values
22
23
  redirect_to url_for(action: :settings), notice: 'Settings Saved Successfully'
@@ -4,41 +4,35 @@ module Plugins::CamaleonSitemapCustomizer::MainHelper
4
4
  end
5
5
 
6
6
  def camaleon_sitemap_customizer_on_active(plugin)
7
- set_skip_posts plugin
7
+ skip_posts plugin
8
8
  end
9
9
 
10
- def camaleon_sitemap_customizer_on_inactive(plugin)
11
- end
10
+ def camaleon_sitemap_customizer_on_inactive(plugin); end
12
11
 
13
12
  def camaleon_sitemap_customizer_on_upgrade(plugin)
14
- set_skip_posts plugin
13
+ skip_posts plugin
15
14
  end
16
15
 
17
16
  def camaleon_sitemap_customizer_on_plugin_options(args)
18
17
  args[:links] << [link_to('Settings', admin_plugins_camaleon_sitemap_customizer_settings_path), link_to('View Sitemap', '/sitemap', target: :blank)]
19
18
  end
20
19
 
21
- def customize_sitemap(r)
22
-
20
+ def customize_sitemap(args)
23
21
  # completely excluded content types
24
- r[:skip_posttype_ids] += current_plugin.get_option('skip_post_types').map(&:to_i) rescue nil
25
- r[:skip_posttype_ids].each do |ptype|
22
+ args[:skip_posttype_ids] += current_plugin.get_option('skip_post_types')&.map(&:to_i).presence || []
23
+ args[:skip_posttype_ids].each do |ptype|
26
24
  # leave out post pages within content type
27
- current_site.the_posts(ptype).each do |post|
28
- r[:skip_post_ids] += [post.id]
29
- end
25
+ args[:skip_post_ids] += current_site.the_posts(ptype).map(&:id)
30
26
  # leave out category pages within content type
31
- current_site.the_categories(ptype).each do |cat|
32
- r[:skip_cat_ids] += [cat.id]
33
- end
27
+ args[:skip_cat_ids] += current_site.the_categories(ptype).map(&:id)
34
28
  end
35
29
 
36
30
  # excluded list pages
37
- r[:skip_posttype_ids] += current_plugin.get_option('skip_post_list_types').map(&:to_i) rescue []
38
- r[:skip_cat_ids] += select_categories
39
- r[:skip_tag_ids] += current_site.the_tags.map(&:id) if current_plugin.get_option('skip_tags')
40
- r[:skip_post_ids] += [@_site_options[:home_page].to_i] if current_plugin.get_option('skip_home')
41
- r[:skip_post_ids] += current_plugin.get_option('skip_posts').presence || []
31
+ args[:skip_posttype_ids] += current_plugin.get_option('skip_post_list_types')&.map(&:to_i).presence || []
32
+ args[:skip_cat_ids] += select_categories
33
+ args[:skip_tag_ids] += current_site.the_tags.map(&:id) if current_plugin.get_option('skip_tags')
34
+ args[:skip_post_ids] += current_plugin.get_option('skip_posts').presence || []
35
+ 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?
42
36
  end
43
37
 
44
38
  def camaleon_sitemap_customizer_form(args)
@@ -53,19 +47,19 @@ module Plugins::CamaleonSitemapCustomizer::MainHelper
53
47
  end
54
48
 
55
49
  def camaleon_sitemap_customizer_save(args)
56
- args[:post].set_option 'hide_in_sitemap', nil unless params.dig(:options, 'hide_in_sitemap').present?
57
- set_skip_posts current_plugin
50
+ args[:post].set_option 'hide_in_sitemap', false unless params.dig(:options, 'hide_in_sitemap').present?
51
+ skip_posts current_plugin
58
52
  end
59
53
 
60
- def set_skip_posts(plugin)
54
+ def skip_posts(plugin)
61
55
  plugin.set_option 'skip_posts', current_site.the_posts.eager_load(:metas).select { |post| post.get_option('hide_in_sitemap').present? } .map(&:id)
62
56
  end
63
57
 
64
58
  def select_categories
65
- current_plugin.get_option('skip_all_categories').present? ?
66
- current_site.the_full_categories.pluck(:id) :
67
- current_plugin.get_option('skip_category_list_types').map(&:to_i)
68
- rescue
69
- []
59
+ if current_plugin.get_option('skip_all_categories').present?
60
+ current_site.the_full_categories.pluck(:id)
61
+ else
62
+ current_plugin.get_option('skip_category_list_types')&.map(&:to_i).presence || []
63
+ end
70
64
  end
71
65
  end
data/config/routes.rb CHANGED
@@ -1,17 +1,19 @@
1
- Rails.application.routes.draw do
1
+ require 'plugin_routes'
2
+ require 'camaleon_cms/engine'
2
3
 
3
- scope PluginRoutes.system_info["relative_url_root"] do
4
- #Admin Panel
5
- scope :admin, as: 'admin', path: PluginRoutes.system_info['admin_path_name'] do
6
- namespace 'plugins' do
7
- namespace 'camaleon_sitemap_customizer' do
8
- controller :admin do
9
- get :index
10
- get :settings
11
- post :save_settings
12
- end
4
+ Rails.application.routes.draw do
5
+ scope PluginRoutes.system_info['relative_url_root'] do
6
+ # Admin Panel
7
+ scope :admin, as: 'admin', path: PluginRoutes.system_info['admin_path_name'] do
8
+ namespace 'plugins' do
9
+ namespace 'camaleon_sitemap_customizer' do
10
+ controller :admin do
11
+ get :index
12
+ get :settings
13
+ post :save_settings
13
14
  end
14
15
  end
15
16
  end
16
17
  end
17
18
  end
19
+ end
@@ -1,4 +1,4 @@
1
- require "camaleon_sitemap_customizer/engine"
1
+ require 'camaleon_sitemap_customizer/engine'
2
2
 
3
3
  module CamaleonSitemapCustomizer
4
4
  end
@@ -1,3 +1,3 @@
1
1
  module CamaleonSitemapCustomizer
2
- VERSION = '0.5.1'
2
+ VERSION = '0.5.2'.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.1
4
+ version: 0.5.2
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-04-01 00:00:00.000000000 Z
11
+ date: 2018-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: camaleon_cms
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.56'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.56'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sqlite3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.3.13
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.3.13
27
55
  description: Customize auto-generated sitemap in Camaleon CMS. Eliminate duplicate
28
56
  content and list pages.
29
57
  email:
@@ -57,9 +85,9 @@ require_paths:
57
85
  - lib
58
86
  required_ruby_version: !ruby/object:Gem::Requirement
59
87
  requirements:
60
- - - ">="
88
+ - - "~>"
61
89
  - !ruby/object:Gem::Version
62
- version: '0'
90
+ version: '2.3'
63
91
  required_rubygems_version: !ruby/object:Gem::Requirement
64
92
  requirements:
65
93
  - - ">="
@@ -67,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
95
  version: '0'
68
96
  requirements: []
69
97
  rubyforge_project:
70
- rubygems_version: 2.7.5
98
+ rubygems_version: 2.7.6
71
99
  signing_key:
72
100
  specification_version: 4
73
101
  summary: Customize auto-generated sitemap in Camaleon CMS