jekyll_plugin_template 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 589cb215e8458e084b40967bd4b4360c457bb65a3fd01c9830af52a17d5c3bab
4
+ data.tar.gz: 323ea35b37a006144ccb10227bff0f49a048a098670f79ee51dda4df4787fb4b
5
+ SHA512:
6
+ metadata.gz: 3d0850c46f853f9925e99e92f423e1918303f4ae253b5f45bad8711e614d3cfc76824b7f369d0d6b7a82282440647fd1a9c6d4d5ac66b3605f56ca2d4f62cf41
7
+ data.tar.gz: 59fdefd6d4baff1526db8065f2691b01c86a0d889d3aaed5f81ff75adb2ea83da5982b23198fa90a3e167815ff8285d8879841078ebac374ae673cc30f8fba37
data/.rubocop.yml ADDED
@@ -0,0 +1,35 @@
1
+ # require: rubocop-jekyll
2
+ # inherit_gem:
3
+ # rubocop-jekyll: .rubocop.yml
4
+
5
+ AllCops:
6
+ Exclude:
7
+ - vendor/**/*
8
+ - Gemfile*
9
+ - '*.gemspec' # This does nothing. Why?
10
+ NewCops: enable
11
+ TargetRubyVersion: 2.6
12
+
13
+ # Gemspec/RequireMFA:
14
+ # Enabled: false
15
+
16
+ # Jekyll/NoPutsAllowed:
17
+ # Enabled: false
18
+
19
+ Layout/HashAlignment:
20
+ EnforcedHashRocketStyle: table
21
+
22
+ Layout/LineLength:
23
+ Max: 150
24
+
25
+ Metrics/BlockLength:
26
+ Max: 50
27
+
28
+ Metrics/MethodLength:
29
+ Max: 40
30
+
31
+ Metrics/ModuleLength:
32
+ Enabled: false
33
+
34
+ Style/StringLiterals:
35
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ ## 0.1.3 / 2022-04-15
2
+ * Renamed `lib/jekyll_tag_plugins.rb` to `lib/jekyll_block_tag_plugin.rb`
3
+ * Added `lib/jekyll_tag_plugin.rb`
4
+ ## 0.1.2 / 2022-04-05
5
+ * Initial version published
6
+ * `bin/run_this_first` is unfinished but plugins work
data/LICENSE.txt ADDED
@@ -0,0 +1,121 @@
1
+ Creative Commons Legal Code
2
+
3
+ CC0 1.0 Universal
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
data/PLUGIN_README.md ADDED
@@ -0,0 +1,178 @@
1
+ `jekyll_plugin_template`
2
+ [![Gem Version](https://badge.fury.io/rb/jekyll_plugin_template.svg)](https://badge.fury.io/rb/jekyll_plugin_template)
3
+ ===========
4
+
5
+ `jekyll_plugin_template` is a Jekyll plugin that provides a new Liquid tag called `new_tag_name` and a new tag block called `new_tag_block_name`.
6
+ The plugin is packaged as a Ruby gem.
7
+
8
+ * A `new_tag_block_name` block tag that can do magic with its eyes closed.
9
+ ```
10
+ {% new_tag_name [arguments] %}
11
+ Contents of new_tag_block_name
12
+ {% endnew_tag_name %}
13
+ ```
14
+ * A `new_tag_name` tag that can turn on a dime and leave 15 cents change.
15
+ ```
16
+ {% new_tag_name Contents of new_tag_name tag%}
17
+ ```
18
+
19
+
20
+ ## Demo
21
+ The `demo` directory contains a small Jekyll website pre-configured for instant gratification.
22
+ Run the demo by typing:
23
+ ```shell
24
+ $ bin/attach demo
25
+ ```
26
+
27
+ The `bin/attach` script builds the plugin locally and installs it locally,
28
+ then launches the demo Jekyll website under control of the Ruby Fast Debugger.
29
+
30
+ As described in [Debugging Jekyll Plugins with an IDE](https://www.mslinn.com/blog/2022/02/21/jekyll-debugging.html),
31
+ attach to the process using `ruby-debug-ide` by selecting the **Run / Debug** configuration called **Attach rdebug-ide**.
32
+
33
+ ![Demo screen shot](demo.png)
34
+
35
+ ### Control Log Verbosity
36
+ `demo/_config.yml` contains a block of YAML that looks something like:
37
+ ```yaml
38
+ plugin_loggers:
39
+ PluginMetaLogger: info
40
+ CleanHook: info
41
+ DocumentHooks: info
42
+ MyBlock: info
43
+ PageHooks: info
44
+ PostHooks: info
45
+ SiteHooks: warn
46
+ ```
47
+ The above sets the verbosity for each of the loggers.
48
+ Possible values are: `debug`, `info`, `warn` and `error`.
49
+
50
+
51
+ ## Debugging
52
+ Run `bin/attach` and pass it the directory name of a Jekyll website that has a suitable script called `_bin/debug`.
53
+ The `demo` subdirectory fits this description.
54
+ ```script
55
+ $ bin/attach demo
56
+ Successfully uninstalled jekyll_plugin_template-0.1.2
57
+ jekyll_plugin_template 0.1.2 built to pkg/jekyll_plugin_template-0.1.2.gem.
58
+ jekyll_plugin_template (0.1.2) installed.
59
+ Fast Debugger (ruby-debug-ide 0.7.3, debase 0.2.4.1, file filtering is supported) listens on 0.0.0.0:1234
60
+ ```
61
+ Now attach to the debugger process.
62
+ This git repo includes a Visual Studio Code launcher for this purpose labeled `Attach rdebug-ide`.
63
+
64
+
65
+ ## Additional Information
66
+ More information is available on Mike Slinn's web site about
67
+ [Jekyll plugins](https://www.mslinn.com/blog/index.html#Jekyll).
68
+
69
+
70
+ ## Installation
71
+ This has already been done for the demo; these instructions are for incorporating the plugin(s) into other Jekyll websites.
72
+ Add this line to your application's Gemfile:
73
+
74
+ ```ruby
75
+ group :jekyll_plugins do
76
+ gem 'jekyll_plugin_template'
77
+ end
78
+ ```
79
+
80
+ And then execute:
81
+
82
+ $ bundle install
83
+
84
+ Or install it yourself as:
85
+
86
+ $ gem install jekyll_plugin_template
87
+
88
+
89
+ ## Usage
90
+
91
+ Given this markup in an HTML file:
92
+
93
+ ```
94
+ {% block_tag_template param1="Today is a wonderful day!" %}
95
+ Hello, world!
96
+ {% endblock_tag_template %}
97
+ The rendered HTML from the block tag looks like this:
98
+ ```
99
+
100
+ <p style="color: green; background-color: yellow; padding: 1em; border: solid thin grey;">Hello, world! Today is a wonderful day!</p>
101
+
102
+ Console output looks like this, when the plugin's log level is set to `debug`:
103
+ ```
104
+ DEBUG MyBlock: tag_name = 'block_tag_template'
105
+ argument_string = 'param1="Today is a wonderful day!" '
106
+ @param1 = 'Today is a wonderful day!'
107
+ @param_x = ''
108
+ params =
109
+ param1 = Today is a wonderful day!
110
+ param2 =
111
+ param3 =
112
+
113
+ DEBUG MyBlock: mode=""
114
+ page.path="_posts/2022-03-28-jekyll-plugin-template-collection.html"
115
+ page.url="/blog/2022/03/28/jekyll-plugin-template-collection.html"
116
+ ```
117
+
118
+
119
+ ## Development
120
+
121
+ After checking out the repo, run `bin/setup` to install dependencies.
122
+
123
+ You can also run `bin/console` for an interactive prompt that will allow you to experiment.
124
+
125
+
126
+ ### Build and Install Locally
127
+ To build and install this gem onto your local machine, run:
128
+ ```shell
129
+ $ rake install:local
130
+ ```
131
+
132
+ The following also does the same thing:
133
+ ```shell
134
+ $ bundle exec rake install
135
+ jekyll_plugin_template 0.1.0 built to pkg/jekyll_plugin_template-0.1.0.gem.
136
+ jekyll_plugin_template (0.1.0) installed.
137
+ ```
138
+
139
+ Examine the newly built gem:
140
+ ```shell
141
+ $ gem info jekyll_plugin_template
142
+
143
+ *** LOCAL GEMS ***
144
+
145
+ jekyll_plugin_template (0.1.0)
146
+ Author: Firstname Lastname
147
+ Homepage:
148
+ https://github.com/username/jekyll_plugin_template
149
+ License: MIT
150
+ Installed at: /home/mslinn/.gems
151
+
152
+ Write a short summary; RubyGems requires one.
153
+ ```
154
+
155
+
156
+ ### Build and Push to RubyGems
157
+ To release a new version,
158
+ 1. Update the version number in `version.rb`.
159
+ 2. Commit all changes to git; if you don't the next step might fail with an unexplainable error message.
160
+ 3. Run the following:
161
+ ```shell
162
+ $ bundle exec rake release
163
+ ```
164
+ The above creates a git tag for the version, commits the created tag,
165
+ and pushes the new `.gem` file to [RubyGems.org](https://rubygems.org).
166
+
167
+
168
+ ## Contributing
169
+
170
+ 1. Fork the project
171
+ 2. Create a descriptively named feature branch
172
+ 3. Add your feature
173
+ 4. Submit a pull request
174
+
175
+
176
+ ## License
177
+
178
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # Jekyll Plugin Gem Customization
2
+
3
+ The [`bin/run_this_first`](bin/run_this_first) script customizes your new Jekyll plugin gem.
4
+ It does the following:
5
+ 1) Renames the Jekyll template, including directories, files and contents.
6
+ 2) Deletes itself, its tests and its test data.
7
+ 3) Does not delete tests for the Jekyll plugin.
8
+ 4) Deletes this README.md and renames [`PLUGIN_README.md`](PLUGIN_README.md) to `README.md`.
9
+ 5) Initializes a new local git repository and optionally creates a public or private project on GitHub.
10
+ 6) Provides scripts for building and testing your new Jekyll plugin gem locally.
11
+ 7) Provides settings for Visual Studio Code, Rake, Rubocop and RSpec.
12
+
13
+ The customized gem is ready to be pushed to `RubyGems.org`, or any other Ruby gem repository, whenever your feel ready.
14
+
15
+
16
+ ## About Developing Jekyll Plugins and Ruby Gems
17
+ * [Setting Up a Ruby Development Environment](https://www.mslinn.com/blog/2022/02/12/ruby-setup.html)
18
+ * [Working with Jekyll Plugins as Ruby Gems](https://www.mslinn.com/blog/2022/02/13/jekyll-gem.html)
19
+ * [Making a Jekyll Plugin as a Ruby Gem](https://www.mslinn.com/blog/2022/02/13/jekyll-gem2.html)
20
+ * [Debugging Jekyll Plugins with an IDE](https://www.mslinn.com/blog/2022/02/21/jekyll-debugging.html)
21
+ * [Installing Rubocop As a Development Dependency](https://www.mslinn.com/blog/2022/03/06/rubocop-install.html)
22
+ * [Jekyll Plugin Template Collection](https://www.mslinn.com/blog/2022/03/28/jekyll-plugin-template-collection.html)
23
+
24
+
25
+ ## Usage
26
+ 1) Clone this repo into a directory called `my_plugin`, or whatever you want to call your plugin.
27
+ ```shell
28
+ $ git clone https://github.com/mslinn/jekyll_plugin_template.git my_plugin
29
+ ```
30
+ Or, if you have forked the project, replace `mslinn` below with your GitHub user id:
31
+ ```shell
32
+ $ git clone git@github.com:mslinn/jekyll_plugin_template.git my_plugin
33
+ ```
34
+ 2) Change directory to the new plugin project:
35
+ ```shell
36
+ $ cd my_plugin
37
+ ```
38
+ 3) Run the customization script and answer the prompts.
39
+ ```shell
40
+ $ bin/run_this_first
41
+ ```
42
+ 4) Open the project in Visual Studio Code and explore the project:
43
+ ```shell
44
+ $ code .
45
+ ```
46
+ 5) Build the plugins provided with this template.
47
+ ```shell
48
+ $ rake install:local
49
+ ```
50
+ 6) You can now use your new Jekyll plugins in a Jekyll website.
51
+
52
+ a) Add the following to your Jekyll website's `Gemfile`.
53
+ The installation script had you rename the plugin template from `jekyll_plugin_template` to a name of your choosing.
54
+ Use that name instead below:
55
+ ```ruby
56
+ group :jekyll_plugins do
57
+ gem 'jekyll_plugin_template'
58
+ end
59
+ ```
60
+ b) Add the following you your Jekyll website's `_config.yml` to set log levels for each type of plugin from the template.
61
+ Customize the log levels as desired:
62
+ ```yaml
63
+ plugin_loggers:
64
+ CleanHook: info
65
+ DocumentHooks: warn
66
+ MyBlock: info
67
+ PageHooks: warn
68
+ PostHooks: warn
69
+ PluginMetaLogger: info
70
+ SiteHooks: info
71
+ ```
72
+ 7) Delete the portions of the template that you do not need.
73
+ 8) [Debug the Jekyll plugin](https://www.mslinn.com/blog/2022/02/21/jekyll-debugging.html) if required.
74
+ 8) [Publish the gem](https://www.mslinn.com/blog/2022/02/13/jekyll-gem2.html#publish) when ready:
75
+ ```shell
76
+ $ bundle exec rake release
77
+ ```
78
+
79
+
80
+ ## For More Information
81
+ Please see the blog post about this {% href https://mslinn.com/blog/2022/03/28/jekyll-plugin-template-collection.html Jekyll plugin gem template %}.
82
+
83
+
84
+ ## Hook Call Order
85
+ The Jekyll documentation does not indicate the exact order that each of the 45 hooks gets called.
86
+ However, the log output from this template makes that clear.
87
+ Following is elided output; I removed duplicate log entries.
88
+ All loggers were set to level `info`.
89
+ Output will vary, depending on the Jekyll site that is processed and the log levels you set.
90
+ `:post_init`, in particular, gets called many times.
91
+ ```
92
+ INFO Module: Jekyll::Hooks.register(:site, :after_reset) invoked.
93
+ INFO Module: Jekyll::Hooks.register(:pages, :post_init) invoked.
94
+ INFO Module: Jekyll::Hooks.register(:documents, :post_init) invoked.
95
+ INFO Module: Jekyll::Hooks.register(:posts, :post_init) invoked.
96
+ INFO Module: Jekyll::Hooks.register(:site, :post_read) invoked.
97
+ INFO Module: Jekyll::Hooks.register(:pages, :post_init) invoked.
98
+ INFO Module: Jekyll::Hooks.register(:site, :pre_render) invoked.
99
+ INFO Module: Jekyll::Hooks.register(:pages, :pre_render) invoked.
100
+ INFO Module: Jekyll::Hooks.register(:pages, :post_convert) invoked.
101
+ INFO Module: Jekyll::Hooks.register(:pages, :post_render) invoked.
102
+ INFO Module: Jekyll::Hooks.register(:site, :post_render) invoked.
103
+ INFO Module: Jekyll::Hooks.register(:clean, :on_obsolete) invoked for [].
104
+ INFO Module: Jekyll::Hooks.register(:pages, :post_write) invoked.
105
+ ```
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+ task :default => :spec
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/jekyll_plugin_template/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ github = "https://github.com/mslinn/jekyll_plugin_template"
7
+
8
+ spec.authors = ["Firstname Lastname"]
9
+ spec.bindir = "bin"
10
+ spec.description = <<~END_OF_DESC
11
+ Expand on what spec.summary says.
12
+ END_OF_DESC
13
+ spec.email = ["email@email.com"]
14
+ spec.executables = []
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ spec.files = Dir[".rubocop.yml", "LICENSE.*", "Rakefile", "{lib,spec}/**/*", "*.gemspec", "*.md"]
18
+
19
+ spec.homepage = "https://www.mslinn.com/blog/2020/12/30/jekyll-plugin-template-collection.html"
20
+ spec.license = "CC0-1.0"
21
+ spec.metadata = {
22
+ "allowed_push_host" => "https://rubygems.org",
23
+ "bug_tracker_uri" => "#{github}/issues",
24
+ "changelog_uri" => "#{github}/CHANGELOG.md",
25
+ "homepage_uri" => spec.homepage,
26
+ "source_code_uri" => github,
27
+ }
28
+ spec.name = "jekyll_plugin_template"
29
+ spec.require_paths = ["lib"]
30
+ spec.required_ruby_version = ">= 2.6.0"
31
+ spec.summary = "Write a short summary; RubyGems requires one."
32
+ spec.version = JekyllPluginTemplateVersion::VERSION
33
+
34
+ spec.add_dependency "jekyll", ">= 3.5.0"
35
+ spec.add_dependency "jekyll_plugin_logger"
36
+ spec.add_dependency "key-value-parser"
37
+ spec.add_dependency "git"
38
+ spec.add_dependency "nokogiri"
39
+ spec.add_dependency "os"
40
+ spec.add_dependency "shellwords"
41
+ spec.add_dependency "talk_like_a_pirate", ">= 0.2.2"
42
+ spec.add_dependency "tty-prompt"
43
+
44
+ # spec.add_development_dependency "debase"
45
+ # spec.add_development_dependency "ruby-debug-ide"
46
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Testing...
4
+ module CategoryCombiner
5
+ # For each catagory, makes a combined page from the collection pages, saves into _site/combined/#{collection.label}.html.
6
+ def combine
7
+ proc do |site, _payload|
8
+ site.collections.each do |_name, collection|
9
+ collection_page = Jekyll::PageWithoutAFile.new(site, site.source, "combined", "#{collection.label}.html")
10
+ collection_page.output = collection.docs.map(&:content).join("\f")
11
+ site.pages << collection_page
12
+ end
13
+ end
14
+ end
15
+
16
+ module_function :combine
17
+
18
+ Jekyll::Hooks.register(:site, :post_render, &combine)
19
+
20
+ PluginMetaLogger.instance.logger.info { "Loaded CategoryCombiner v#{JekyllPluginTemplateVersion::VERSION} plugin." }
21
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Inspired by the badly broken example on https://jekyllrb.com/docs/plugins/generators/, and completely redone so it works.
4
+ module CategoryIndexGenerator
5
+ # Creates an index page for each catagory, plus a main index, all within a directory called _site/categories.
6
+ class CategoryGenerator < Jekyll::Generator
7
+ safe true
8
+
9
+ # Only generates content in development mode
10
+ # rubocop:disable Style/StringConcatenation, Metrics/AbcSize
11
+ def generate(site)
12
+ # This plugin is disabled unless _config.yml contains an entry for category_generator_enable and the value is not false
13
+ return if site.config['category_generator_enable']
14
+
15
+ return if site.config['env']['JEKYLL_ENV'] == "production"
16
+
17
+ index = Jekyll::PageWithoutAFile.new(site, site.source, 'categories', "index.html")
18
+ index.data['layout'] = "default"
19
+ index.data['title'] = "Post Categories"
20
+ index.content = "<p>"
21
+
22
+ site.categories.each do |category, posts|
23
+ new_page = Jekyll::PageWithoutAFile.new(site, site.source, 'categories', "#{category}.html")
24
+ new_page.data['layout'] = "default"
25
+ new_page.data['title'] = "Category #{category} Posts"
26
+ new_page.content = "<p>" + posts.map do |post|
27
+ "<a href='#{post.url}'>#{post.data['title']}</a><br>"
28
+ end.join("\n") + "</p>\n"
29
+ site.pages << new_page
30
+ index.content += "<a href='#{category}.html'>#{category}</a><br>\n"
31
+ end
32
+ index.content += "</p>"
33
+ site.pages << index
34
+ end
35
+ # rubocop:enable Style/StringConcatenation, Metrics/AbcSize
36
+ end
37
+
38
+ PluginMetaLogger.instance.logger.info { "Loaded CategoryGenerator v#{JekyllPluginTemplateVersion::VERSION} plugin." }
39
+ end