From 04bfaa9b35103e40a77400aba4422035347bd80f Mon Sep 17 00:00:00 2001 From: MoHKale Date: Sat, 8 Feb 2020 08:02:59 +0000 Subject: [PATCH 1/3] autoPages.rb (restructure): logging to minimise output --- lib/jekyll-paginate-v2/autopages/autoPages.rb | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/jekyll-paginate-v2/autopages/autoPages.rb b/lib/jekyll-paginate-v2/autopages/autoPages.rb index a6b7c84..4df5101 100644 --- a/lib/jekyll-paginate-v2/autopages/autoPages.rb +++ b/lib/jekyll-paginate-v2/autopages/autoPages.rb @@ -16,6 +16,8 @@ def self.create_autopages(site) return end + autopages_log(autopage_config, 'tags', 'categories', 'collections') + # TODO: Should I detect here and disable if we're running the legacy paginate code???! # Simply gather all documents across all pages/posts/collections that we have @@ -55,8 +57,6 @@ def self.autopage_create(autopage_config, pagination_config, posts_to_use, confi if !autopage_config[configkey_name].nil? ap_sub_config = autopage_config[configkey_name] if ap_sub_config ['enabled'] - Jekyll.logger.info "AutoPages:","Generating #{configkey_name} pages" - # Roll through all documents in the posts collection and extract the tags index_keys = Utils.ap_index_posts_by(posts_to_use, indexkey_name) # Cannot use just the posts here, must use all things.. posts, collections... @@ -67,11 +67,31 @@ def self.autopage_create(autopage_config, pagination_config, posts_to_use, confi createpage_lambda.call(ap_sub_config, pagination_config, layout_name, index_key, value[-1]) # the last item in the value array will be the display name end end - else - Jekyll.logger.info "AutoPages:","#{configkey_name} pages are disabled/not configured in site.config." end end end + def self.autopages_log(config, *config_keys) + enabled, disabled = [], [] + config_keys.each do |key| + key_config = config[key] # config for key + next if config.nil? + + (key_config['enabled'] ? enabled : disabled) << key + end + + Jekyll.logger.info("AutoPages:","Generating pages for #{_to_sentence(enabled)}") unless enabled.empty? + Jekyll.logger.info("AutoPages:","#{_to_sentence(disabled)} pages are disabled/not configured in site.config") unless disabled.empty? + end + + def self._to_sentence(array) + if array.empty? + "" + elsif array.length == 1 + array[0].to_s + else + array[0..-2].join(", ") + " & " + array.last + end + end end # module PaginateV2 end # module Jekyll From 4fc3db39ab60c2753991eaca79fc86261859b09e Mon Sep 17 00:00:00 2001 From: MoHKale Date: Sat, 8 Feb 2020 08:04:02 +0000 Subject: [PATCH 2/3] autoPages.rb (config): add option to silence logging if users don't want to autopage generate tags, then don't keep telling them it hasn't been configured :P --- lib/jekyll-paginate-v2/autopages/autoPages.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll-paginate-v2/autopages/autoPages.rb b/lib/jekyll-paginate-v2/autopages/autoPages.rb index 4df5101..e957302 100644 --- a/lib/jekyll-paginate-v2/autopages/autoPages.rb +++ b/lib/jekyll-paginate-v2/autopages/autoPages.rb @@ -75,7 +75,7 @@ def self.autopages_log(config, *config_keys) enabled, disabled = [], [] config_keys.each do |key| key_config = config[key] # config for key - next if config.nil? + next if config.nil? || key_config['silent'] (key_config['enabled'] ? enabled : disabled) << key end From 47c26d7c35174fd229bceafe39d8a890bb678c68 Mon Sep 17 00:00:00 2001 From: MoHKale Date: Sat, 8 Feb 2020 09:48:43 +0000 Subject: [PATCH 3/3] autopages.md (update): add example for the 'silent' option --- README-AUTOPAGES.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README-AUTOPAGES.md b/README-AUTOPAGES.md index ab52fec..f1a498e 100644 --- a/README-AUTOPAGES.md +++ b/README-AUTOPAGES.md @@ -42,6 +42,8 @@ autopages: # Optional, the permalink for the pagination page (:cat is replaced), # the pagination permalink path is then appended to this permalink structure permalink: '/category/:cat' + # Optional, when true logging related to category pages will be supressed. + silent: false # Collection pages, omit to disable collections: @@ -49,6 +51,7 @@ autopages: - 'autopage_collection.html' title: 'Posts in collection :coll' # :coll is replaced by the collection name permalink: '/collection/:coll' + silent: false # Tag pages, omit to disable tags: @@ -56,6 +59,7 @@ autopages: - 'autopage_tags.html' title: 'Posts tagged with :tag' # :tag is replaced by the tag name permalink: '/tag/:tag' + silent: false ``` ## Simple configuration @@ -101,4 +105,4 @@ An example of this can be found in [examples/03-tags/_layouts/autopage_collectio There is no need to include the pagination title macros `:num`, `:max` or `:title` in the title configuration. The autopages will use the title configuration from the pagination configuration itself. ## Common issues -_None reported so far_ \ No newline at end of file +_None reported so far_