camaleon_sitemap_customizer 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c811fdeb76df68e0ff79dc06991a947c325442d5d4eaae6703af3ae3016aa4cd
4
+ data.tar.gz: 8735cfdde7084d4473f1eca60110e1af927e400260c87f66adb9b2465f64b740
5
+ SHA512:
6
+ metadata.gz: 38fc9000151254d987360df212d56f7b5dacb438186c97d0fd16652a9a6dfa8b5bc61fa6eb1a32b61d7eebcdbae8268d735d639ca2be37766739b2c92c4d2645
7
+ data.tar.gz: e4bd85c065982624d9aa3256c97539614521c46d4eb41cd9d2e8b681828739283cadd5f825a008e7b5aa2a6af58267e7d6dcf73878f47350fdb63fe7bccc359f
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2017 Brian Kephart
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
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.
3
+
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.
12
+
13
+ ## Installation
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'camaleon_sitemap_customizer', git: 'https://github.com/brian-kephart/camaleon_sitemap_customizer.git'
18
+ ```
19
+
20
+ And then execute:
21
+ ```bash
22
+ $ bundle
23
+ ```
24
+
25
+ Or install it yourself as:
26
+ ```bash
27
+ $ gem install camaleon_sitemap_customizer
28
+ ```
29
+
30
+ ## 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)
36
+
37
+ ## License
38
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,36 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'CamaleonSitemapCustomizer'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ require 'bundler/gem_tasks'
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'test'
31
+ t.pattern = 'test/**/*_test.rb'
32
+ t.verbose = false
33
+ end
34
+
35
+
36
+ task default: :test
@@ -0,0 +1,24 @@
1
+ class Plugins::CamaleonSitemapCustomizer::AdminController < CamaleonCms::Apps::PluginsAdminController
2
+ include Plugins::CamaleonSitemapCustomizer::MainHelper
3
+ def index
4
+ end
5
+
6
+ # show settings form
7
+ def settings
8
+ end
9
+
10
+ # save values from settings form
11
+ 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
20
+ @plugin.set_metas(params[:metas]) if params[:metas].present? # save meta values
21
+ @plugin.set_field_values(params[:field_options]) if params[:field_options].present? # save custom field values
22
+ redirect_to url_for(action: :settings), notice: 'Settings Saved Successfully'
23
+ end
24
+ end
@@ -0,0 +1,71 @@
1
+ module Plugins::CamaleonSitemapCustomizer::MainHelper
2
+ def self.included(klass)
3
+ # klass.helper_method [:my_helper_method] rescue "" # here your methods accessible from views
4
+ end
5
+
6
+ def camaleon_sitemap_customizer_on_active(plugin)
7
+ set_skip_posts plugin
8
+ end
9
+
10
+ def camaleon_sitemap_customizer_on_inactive(plugin)
11
+ end
12
+
13
+ def camaleon_sitemap_customizer_on_upgrade(plugin)
14
+ set_skip_posts plugin
15
+ end
16
+
17
+ def camaleon_sitemap_customizer_on_plugin_options(args)
18
+ args[:links] << link_to('Settings', admin_plugins_camaleon_sitemap_customizer_settings_path)
19
+ end
20
+
21
+ def customize_sitemap(r)
22
+
23
+ # 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|
26
+ # 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
30
+ # 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
34
+ end
35
+
36
+ # 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 || []
42
+ end
43
+
44
+ def camaleon_sitemap_customizer_form(args)
45
+ args[:extra_settings] << "
46
+ <div class='form-group'>
47
+ <label for='options_hide_in_sitemap' class='control-label'>
48
+ <input type='checkbox' name='options[hide_in_sitemap]' id='options_hide_in_sitemap' value='true' #{'checked' if args[:post].get_option('hide_in_sitemap').present?}>
49
+ &nbsp;&nbsp;#{cama_t('hide_in_sitemap')}?
50
+ </label>
51
+ </div>
52
+ "
53
+ end
54
+
55
+ 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
58
+ end
59
+
60
+ def set_skip_posts(plugin)
61
+ plugin.set_option 'skip_posts', current_site.the_posts.eager_load(:metas).select { |post| post.get_option('hide_in_sitemap').present? } .map(&:id)
62
+ end
63
+
64
+ 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
+ []
70
+ end
71
+ end
@@ -0,0 +1,67 @@
1
+ <script>
2
+ jQuery(function($){
3
+ var form = $("#cache_front_form");
4
+ form.find("#btn-add-path").click(function(){
5
+ var a = '<div class="input-group"> <input name="cache[paths][]" type="text" class="form-control" value=""> <span class="input-group-addon border_trans"><i class="round_icon fa fa-times text-danger del_path "></i></span> </div>';
6
+ form.find("#paths").append(a);
7
+ return false;
8
+ });
9
+ form.on("click", ".del_path", function(){
10
+ $(this).closest(".input-group").remove();
11
+ });
12
+ $('#camaleon_sitemap_customizer_form select').selectpicker();
13
+ });
14
+ </script>
15
+
16
+ <div class="panel panel-default">
17
+ <div class="panel-heading">
18
+ <h4><%= cama_t 'sitemap_settings' %></h4>
19
+ </div>
20
+
21
+ <div class="panel-body">
22
+
23
+ <div class="alert alert-info">
24
+ <%== cama_t 'instructions' %>
25
+ </div>
26
+
27
+ <%= form_tag url_for(action: :save_settings), id: 'camaleon_sitemap_customizer_form', class: 'validate' do %>
28
+
29
+ <div class="form-group">
30
+ <label><%= cama_t 'content_types_complete' %></label>
31
+ <%= select_tag "options[skip_post_types]", options_from_collection_for_select(current_site.post_types.decorate, "id", "the_title", @plugin.get_option('skip_post_types')), class: "form-control select", multiple: true, "data-live-search" => true %>
32
+ </div>
33
+
34
+ <div class="form-group">
35
+ <label><%= cama_t 'content_types_list' %></label>
36
+ <%= select_tag "options[skip_post_list_types]", options_from_collection_for_select(current_site.post_types.decorate, "id", "the_title", @plugin.get_option('skip_post_list_types')), class: "form-control select", multiple: true, "data-live-search" => true %>
37
+ </div>
38
+
39
+ <div class="form-group">
40
+ <label><%= cama_t 'categories_list' %></label>
41
+ <%= select_tag "options[skip_category_list_types]", options_from_collection_for_select(current_site.the_full_categories.decorate, "id", "the_title", @plugin.get_option('skip_category_list_types')), class: "form-control select", multiple: true, "data-live-search" => true %>
42
+ </div>
43
+
44
+ <div class="form-group">
45
+ <label><%= cama_t 'categories_all' %>?</label>
46
+ <%= check_box_tag "options[skip_all_categories]", 1, @plugin.get_option('skip_all_categories'), style: 'display: block;' %>
47
+ </div>
48
+
49
+ <div class="form-group">
50
+ <label><%= cama_t 'tags' %>?</label>
51
+ <%= check_box_tag "options[skip_tags]", 1, @plugin.get_option('skip_tags'), style: 'display: block;' %>
52
+ </div>
53
+
54
+ <div class="form-group">
55
+ <label><%= cama_t 'homepage' %></label>
56
+ <%= check_box_tag "options[skip_home]", 1, @plugin.get_option('skip_home'), style: 'display: block;' %>
57
+ </div>
58
+
59
+
60
+ <div class="form-group text-right">
61
+ <%= link_to 'View Sitemap', '/sitemap', target: 'blank' %>&nbsp;&nbsp;&nbsp;&nbsp;
62
+ <%= submit_tag 'Save Settings', class: 'btn btn-primary' %>
63
+ </div>
64
+
65
+ <% end %>
66
+ </div>
67
+ </div>
@@ -0,0 +1,17 @@
1
+ {
2
+ "title": "Camaleon Sitemap Customizer",
3
+ "descr": "Alter the auto-generated sitemap in Camaleon CMS",
4
+ "key": "camaleon_sitemap_customizer",
5
+ "helpers": [
6
+ "Plugins::CamaleonSitemapCustomizer::MainHelper"
7
+ ],
8
+ "hooks": {
9
+ "new_post":["camaleon_sitemap_customizer_form"],
10
+ "edit_post":["camaleon_sitemap_customizer_form"],
11
+ "updated_post": ["camaleon_sitemap_customizer_save"],
12
+ "on_active": ["camaleon_sitemap_customizer_on_active"],
13
+ "on_inactive": ["camaleon_sitemap_customizer_on_inactive"],
14
+ "plugin_options": ["camaleon_sitemap_customizer_on_plugin_options"],
15
+ "on_render_sitemap": ["customize_sitemap"]
16
+ }
17
+ }
@@ -0,0 +1,10 @@
1
+ en:
2
+ sitemap_settings: "Sitemap Settings"
3
+ hide_in_sitemap: "Hide in Sitemap"
4
+ instructions: "Camaleon CMS automatically generates a sitemap. Select the content types you wish to <b>exclude</b> from this sitemap. You can also exclude individual posts by using the post editor."
5
+ content_types_complete: "Content Types to exclude completely"
6
+ content_types_list: "Content Types to exclude (list pages only)"
7
+ categories_list: "Categories to exclude (list pages only)"
8
+ categories_all: "Exclude ALL Categories (overrides above setting)"
9
+ tags: "Exclude Tags"
10
+ homepage: "Exclude duplicate home page url? (ex. – remove www.mysite.com/home if this renders the same post as www.mysite.com)"
data/config/routes.rb ADDED
@@ -0,0 +1,17 @@
1
+ Rails.application.routes.draw do
2
+
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
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,4 @@
1
+ module CamaleonSitemapCustomizer
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module CamaleonSitemapCustomizer
2
+ VERSION = '0.4.0'
3
+ end
@@ -0,0 +1,4 @@
1
+ require "camaleon_sitemap_customizer/engine"
2
+
3
+ module CamaleonSitemapCustomizer
4
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: camaleon_sitemap_customizer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
+ platform: ruby
6
+ authors:
7
+ - Brian Kephart
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-03-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: camaleon_cms
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Customize auto-generated sitemap in Camaleon CMS
28
+ email:
29
+ - briantkephart@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - MIT-LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - app/controllers/plugins/camaleon_sitemap_customizer/admin_controller.rb
38
+ - app/helpers/plugins/camaleon_sitemap_customizer/main_helper.rb
39
+ - app/views/plugins/camaleon_sitemap_customizer/admin/settings.html.erb
40
+ - config/camaleon_plugin.json
41
+ - config/locales/en.yml
42
+ - config/routes.rb
43
+ - lib/camaleon_sitemap_customizer.rb
44
+ - lib/camaleon_sitemap_customizer/engine.rb
45
+ - lib/camaleon_sitemap_customizer/version.rb
46
+ homepage: ''
47
+ licenses:
48
+ - MIT
49
+ metadata: {}
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 2.7.5
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: Customize auto-generated sitemap in Camaleon CMS
70
+ test_files: []