jekyll-listme 0.4.1

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: 1afa2d6bfd820a02e9abc713944cb7096dd26b68fe11d30c328778413316f06c
4
+ data.tar.gz: 26cc6ad800c29e885ca89168f087236ffb7a3886ae31e16949deb1811aaa03cc
5
+ SHA512:
6
+ metadata.gz: f455264505b1a2642309c86298ce92ce18ab18cc51c182885237fa16e5b641aa690402d16683f193e4844639911be2a1b2db9124fc2b52b33099e5b3e257c7ac
7
+ data.tar.gz: aa987f366f055e5f6105fea809170118f0144ea132bab395258d9fa2a008a7bec4db7d7b43bb001b8d4dc86cea9de9dec897add1c763800a1dc8c7c1027e5f09
@@ -0,0 +1,5 @@
1
+ .dockerignore
2
+ devcontainer.json
3
+ docker-compose.yml
4
+ Dockerfile
5
+ README.md
@@ -0,0 +1,63 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
+ // README at: https://github.com/devcontainers/templates/tree/main/src/rust
3
+ {
4
+ "name": "Jekyll",
5
+ // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6
+ // info about this base image: https://github.com/devcontainers/images/tree/main/src/jekyll
7
+ "image": "mcr.microsoft.com/devcontainers/jekyll:2.0.5-bookworm",
8
+ // Features to add to the dev container. More info: https://containers.dev/features.
9
+ "features": {
10
+ "ghcr.io/devcontainers/features/sshd:1": {
11
+ "version": "latest"
12
+ },
13
+ "ghcr.io/devcontainers/features/github-cli:1": {},
14
+ "ghcr.io/devcontainers/features/node:1": {
15
+ "version": "18" // has to match the one in .nvmrc
16
+ }
17
+ },
18
+ // Configure tool-specific properties.
19
+ "customizations": {
20
+ // Configure properties specific to VS Code.
21
+ "vscode": {
22
+ "settings": {
23
+ "terminal.integrated.defaultProfile.linux": "zsh",
24
+ "terminal.integrated.defaultProfile.osx": "zsh",
25
+ "terminal.integrated.defaultProfile.windows": "PowerShell"
26
+ },
27
+ "extensions": [
28
+ // ruby dev
29
+ "Shopify.ruby-extensions-pack", // ruby extensions pack
30
+ // bash
31
+ "mads-hartmann.bash-ide-vscode", // bash ide
32
+ // editor styling
33
+ "vscode-icons-team.vscode-icons", // better vs code icons
34
+ "will-stone.plastic", // my fav theme
35
+ // ide extensions
36
+ "EditorConfig.EditorConfig", // editorconfig support
37
+ "eamodio.gitlens", // git++
38
+ "codezombiech.gitignore", // gitignore assistant
39
+ "redhat.vscode-yaml", // yaml support
40
+ "streetsidesoftware.code-spell-checker", // spell checks
41
+ "wayou.vscode-todo-highlight", // to-do highlighting
42
+ "mrmlnc.vscode-duplicate", // option to duplicate files/folders
43
+ "tamasfe.even-better-toml", // toml support
44
+ "dunstontc.viml", // vim syntax support
45
+ "malmaud.tmux", // tmux syntax support
46
+ "hangxingliu.vscode-nginx-conf-hint", // nginx syntax support
47
+ // gh related
48
+ "GitHub.vscode-pull-request-github", // gh pr support
49
+ "github.vscode-github-actions", // gh actions support
50
+ "GitHub.copilot", // gh copilot
51
+ "GitHub.copilot-chat" // gh copilot chat
52
+ ]
53
+ }
54
+ },
55
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
56
+ // "forwardPorts": [],
57
+ // Use 'postCreateCommand' to run commands after the container is created.
58
+ // "postCreateCommand": "rustc --version",
59
+ // NOTE: gh cli is installed by the 'features' property above.
60
+ "postCreateCommand": "gh extension install github/gh-copilot"
61
+ // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
62
+ // "remoteUser": "root"
63
+ }
data/.editorconfig ADDED
@@ -0,0 +1,24 @@
1
+ # EditorConfig is awesome: https://EditorConfig.org
2
+
3
+ # top-most EditorConfig file
4
+ root = true
5
+
6
+ [*]
7
+ indent_style = space
8
+ indent_size = 2
9
+ end_of_line = lf
10
+ charset = utf-8
11
+ trim_trailing_whitespace = true
12
+ insert_final_newline = true
13
+
14
+ [*.rb]
15
+ indent_size = 2
16
+
17
+ [*.py]
18
+ indent_size = 4
19
+
20
+ [*.sh]
21
+ indent_size = 4
22
+
23
+ [*.js]
24
+ indent_size = 2
@@ -0,0 +1,31 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*.*.*'
7
+
8
+ permissions:
9
+ contents: write
10
+
11
+ jobs:
12
+ release:
13
+ name: Release
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - name: Create release and upload assets
17
+ uses: softprops/action-gh-release@v2
18
+ with:
19
+ name: ${{ github.ref_name }}
20
+ tag_name: ${{ github.ref_name }}
21
+ body: |
22
+ Release notes for `${{ github.ref_name }}` are available here: https://github.com/pirafrank/jekyll-listme/blob/main/CHANGELOG.md
23
+ generate_release_notes: false
24
+ draft: false
25
+ prerelease: false
26
+ # Note: drafts and prereleases cannot be set as latest.
27
+ make_latest: true
28
+ fail_on_unmatched_files: true
29
+ # no need to specify GITHUB_TOKEN here, it is automatically provided by GitHub Actions
30
+ # https://github.com/softprops/action-gh-release#-customizing
31
+ # https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,24 @@
1
+ require: rubocop-jekyll
2
+
3
+ inherit_gem:
4
+ rubocop-jekyll: .rubocop.yml
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 3.0
8
+ Exclude:
9
+ - vendor/**/*
10
+
11
+ Jekyll/NoPutsAllowed:
12
+ Enabled: false
13
+
14
+ Metrics/LineLength:
15
+ Max: 154
16
+
17
+ Metrics/MethodLength:
18
+ Max: 40
19
+
20
+ Style/StringLiterals:
21
+ EnforcedStyle: double_quotes
22
+
23
+ Style/StringLiteralsInInterpolation:
24
+ EnforcedStyle: double_quotes
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,67 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [0.4.1] - 2025-02-15
6
+
7
+ ### 🚜 Refactor
8
+
9
+ - Use @site class instance variable
10
+ - Remove rubocop warnings
11
+
12
+ ### ⚙️ Miscellaneous Tasks
13
+
14
+ - Better project setup
15
+ - Removed unneeded files
16
+ - Update readme
17
+
18
+ ## [0.4.0] - 2024-04-23
19
+
20
+ ### 🚀 Features
21
+
22
+ - Count support
23
+ - Count all
24
+
25
+ ### 💼 Other
26
+
27
+ - Easier syntax
28
+ - Bump to 0.4.0 and readme update
29
+
30
+ ## [0.3.0] - 2024-04-22
31
+
32
+ ### 🚀 Features
33
+
34
+ - Add listing of drafts and posts
35
+ - Add listing of pages
36
+ - Added base58 id support and removed toml for good
37
+
38
+ ### 🐛 Bug Fixes
39
+
40
+ - Fixed nasty typo
41
+
42
+ ### 💼 Other
43
+
44
+ - Bump to 0.3.0
45
+
46
+ ## [0.2.0] - 2024-03-21
47
+
48
+ ### 🚀 Features
49
+
50
+ - First commit
51
+ - First working version
52
+ - Added ruby-version file
53
+ - Add option to print as csv or tsv
54
+ - Add option to print as psv or toml
55
+ - Case-insensitive input + validation
56
+
57
+ ### 💼 Other
58
+
59
+ - Devcontainer
60
+ - Readme update
61
+ - Bump to 0.2.0
62
+
63
+ ### ⚙️ Miscellaneous Tasks
64
+
65
+ - Chores
66
+
67
+ <!-- generated by git-cliff -->
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in jekyll-listme.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,55 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ jekyll-listme (0.4.1)
5
+ json (~> 2.7)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ json (2.7.1)
12
+ language_server-protocol (3.17.0.4)
13
+ parallel (1.26.3)
14
+ parser (3.3.7.1)
15
+ ast (~> 2.4.1)
16
+ racc
17
+ racc (1.8.1)
18
+ rainbow (3.1.1)
19
+ rake (13.1.0)
20
+ regexp_parser (2.10.0)
21
+ rexml (3.4.0)
22
+ rubocop (1.57.2)
23
+ json (~> 2.3)
24
+ language_server-protocol (>= 3.17.0)
25
+ parallel (~> 1.10)
26
+ parser (>= 3.2.2.4)
27
+ rainbow (>= 2.2.2, < 4.0)
28
+ regexp_parser (>= 1.8, < 3.0)
29
+ rexml (>= 3.2.5, < 4.0)
30
+ rubocop-ast (>= 1.28.1, < 2.0)
31
+ ruby-progressbar (~> 1.7)
32
+ unicode-display_width (>= 2.4.0, < 3.0)
33
+ rubocop-ast (1.38.0)
34
+ parser (>= 3.3.1.0)
35
+ rubocop-jekyll (0.14.0)
36
+ rubocop (~> 1.57.0)
37
+ rubocop-performance (~> 1.2)
38
+ rubocop-performance (1.23.1)
39
+ rubocop (>= 1.48.1, < 2.0)
40
+ rubocop-ast (>= 1.31.1, < 2.0)
41
+ ruby-progressbar (1.13.0)
42
+ unicode-display_width (2.6.0)
43
+
44
+ PLATFORMS
45
+ ruby
46
+ x86_64-linux
47
+
48
+ DEPENDENCIES
49
+ bundler (~> 2.5)
50
+ jekyll-listme!
51
+ rake (~> 13.0)
52
+ rubocop-jekyll (~> 0.14)
53
+
54
+ BUNDLED WITH
55
+ 2.5.6
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Francesco Pira
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # Jekyll ListMe
2
+
3
+ A [Jekyll](https://jekyllrb.com/) [command](https://jekyllrb.com/docs/plugins/commands/) plugin to list and count data in your Jekyll website. List tags, categories, and more, and count their occurrencies. Choose among various output formats.
4
+
5
+ ## Installation
6
+
7
+ ```Gemfile
8
+ gem 'jekyll-listme', git: 'https://github.com/pirafrank/jekyll-listme', branch: 'main'
9
+ ```
10
+
11
+ ## Update
12
+
13
+ ```sh
14
+ bundle update jekyll-listme
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ Plain text is the default output format:
20
+
21
+ ```sh
22
+ bundle exec jekyll list tags
23
+ bundle exec jekyll list categories
24
+ ```
25
+
26
+ You can choose an output format like this:
27
+
28
+ ```sh
29
+ bundle exec jekyll list tags --output FORMAT
30
+ bundle exec jekyll list categories --output FORMAT
31
+ ```
32
+
33
+ You can also count items, instead of listing them:
34
+
35
+ ```sh
36
+ bundle exec jekyll list --count tags --output FORMAT
37
+ bundle exec jekyll list --all --output FORMAT
38
+ ```
39
+
40
+ Supported formats are:
41
+
42
+ - `plain`
43
+ - `json`
44
+ - `yaml`
45
+ - `csv`
46
+ - `tsv`
47
+ - `psv`
48
+
49
+ ## Development
50
+
51
+ Clone and run `bundle install` to get started.
52
+
53
+ Code lives in `lib/jekyll/commands` and is referenced with `require` in `lib/jekyll/listme.rb`. To experiment with that code, run `bundle exec jekyll list` from a Jekyll site with this gem added as plugin. Read more on [Jekyll's Commands documentation](https://jekyllrb.com/docs/plugins/commands/).
54
+
55
+ I got the first steps to create the template from [here](https://maxchadwick.xyz/blog/building-a-custom-jekyll-command-plugin).
56
+
57
+ ## Contributing
58
+
59
+ [Bug reports](https://github.com/pirafrank/jekyll-listme/issues) and [pull requests](https://github.com/pirafrank/jekyll-listme/pulls) are welcome on GitHub.
60
+
61
+ ## Guarantee
62
+
63
+ This plugin is provided as is, without any guarantee. Use at your own risk.
64
+
65
+ ## License
66
+
67
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
data/cliff.toml ADDED
@@ -0,0 +1,91 @@
1
+ # git-cliff ~ default configuration file
2
+ # https://git-cliff.org/docs/configuration
3
+ #
4
+ # Lines starting with "#" are comments.
5
+ # Configuration options are organized into tables and keys.
6
+ # See documentation for more information on available options.
7
+
8
+ [changelog]
9
+ # template for the changelog header
10
+ header = """
11
+ # Changelog\n
12
+ All notable changes to this project will be documented in this file.\n
13
+ """
14
+ # template for the changelog body
15
+ # https://keats.github.io/tera/docs/#introduction
16
+ body = """
17
+ {% if version %}\
18
+ ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
19
+ {% else %}\
20
+ ## [unreleased]
21
+ {% endif %}\
22
+ {% for group, commits in commits | group_by(attribute="group") %}
23
+ ### {{ group | striptags | trim | upper_first }}
24
+ {% for commit in commits %}
25
+ - {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
26
+ {% if commit.breaking %}[**breaking**] {% endif %}\
27
+ {{ commit.message | upper_first }}\
28
+ {% endfor %}
29
+ {% endfor %}\n
30
+ """
31
+ # template for the changelog footer
32
+ footer = """
33
+ <!-- generated by git-cliff -->
34
+ """
35
+ # remove the leading and trailing s
36
+ trim = true
37
+ # postprocessors
38
+ postprocessors = [
39
+ # { pattern = '<REPO>', replace = "https://github.com/orhun/git-cliff" }, # replace repository URL
40
+ ]
41
+ # render body even when there are no releases to process
42
+ # render_always = true
43
+ # output file path
44
+ # output = "test.md"
45
+
46
+ [git]
47
+ # parse the commits based on https://www.conventionalcommits.org
48
+ conventional_commits = true
49
+ # filter out the commits that are not conventional
50
+ filter_unconventional = false
51
+ # process each line of a commit as an individual commit
52
+ split_commits = false
53
+ # regex for preprocessing the commit messages
54
+ commit_preprocessors = [
55
+ # because of old commits -- start
56
+ { pattern = "^add(.*)", replace = "feat: Add$1"},
57
+ { pattern = "^first(.*)", replace = "feat: first$1"},
58
+ { pattern = "^count(.*)", replace = "feat: count$1"},
59
+ { pattern = "^case-(.*)", replace = "feat: case-$1"},
60
+ # because of old commits -- end
61
+ #
62
+ # Replace issue numbers
63
+ #{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))"},
64
+ # Check spelling of the commit with https://github.com/crate-ci/typos
65
+ # If the spelling is incorrect, it will be automatically fixed.
66
+ #{ pattern = '.*', replace_command = 'typos --write-changes -' },
67
+ ]
68
+ # regex for parsing and grouping commits
69
+ commit_parsers = [
70
+ { message = "^feat", group = "<!-- 0 -->🚀 Features" },
71
+ { message = "^fix", group = "<!-- 1 -->🐛 Bug Fixes" },
72
+ { message = "^doc", group = "<!-- 3 -->📚 Documentation" },
73
+ { message = "^perf", group = "<!-- 4 -->⚡ Performance" },
74
+ { message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
75
+ { message = "^style", group = "<!-- 5 -->🎨 Styling" },
76
+ { message = "^test", group = "<!-- 6 -->🧪 Testing" },
77
+ { message = "^chore\\(release\\): prepare for", skip = true },
78
+ { message = "^chore\\(deps.*\\)", skip = true },
79
+ { message = "^chore\\(pr\\)", skip = true },
80
+ { message = "^chore\\(pull\\)", skip = true },
81
+ { message = "^chore|^ci", group = "<!-- 7 -->⚙️ Miscellaneous Tasks" },
82
+ { body = ".*security", group = "<!-- 8 -->🛡️ Security" },
83
+ { message = "^revert", group = "<!-- 9 -->◀️ Revert" },
84
+ { message = ".*", group = "<!-- 10 -->💼 Other" },
85
+ ]
86
+ # filter out the commits that are not matched by commit parsers
87
+ filter_commits = false
88
+ # sort the tags topologically
89
+ topo_order = false
90
+ # sort the commits inside sections by oldest/newest order
91
+ sort_commits = "oldest"
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/jekyll/listme/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "jekyll-listme"
7
+ spec.version = Jekyll::Listme::VERSION
8
+ spec.authors = ["Francesco Pira"]
9
+ spec.email = ["dev@fpira.com"]
10
+
11
+ spec.summary = "List tags and categories for your Jekyll website."
12
+ spec.description = "Jekyll command plugin to list tags and categories for your Jekyll website and number of their occurrencies. Choose between a JSON, YAML, or plain text output."
13
+ spec.homepage = "https://github.com/pirafrank/jekyll-listme"
14
+
15
+ spec.license = "MIT"
16
+ spec.required_ruby_version = ">= 3.0.0"
17
+
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.executables = spec.files.grep(%r!^bin/!) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
23
+
24
+ spec.metadata["homepage_uri"] = spec.homepage
25
+ spec.metadata["changelog_uri"] = "https://github.com/pirafrank/jekyll-listme/blob/main/CHANGELOG.md"
26
+ spec.metadata["bug_tracker_uri"] = "https://github.com/pirafrank/jekyll-listme/issues"
27
+
28
+ spec.add_dependency "json", "~> 2.7"
29
+
30
+ spec.add_development_dependency "bundler", "~> 2.5"
31
+ spec.add_development_dependency "rake", "~> 13.0"
32
+ spec.add_development_dependency "rubocop-jekyll", "~> 0.14"
33
+ end
@@ -0,0 +1,220 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module Jekyll
6
+ module Commands
7
+ class ListMe < Command
8
+ class << self
9
+ def init_with_program(prog)
10
+ prog.command(:list) do |c|
11
+ c.description "List tags and categories used in the site."
12
+ c.syntax "list [items] [options]"
13
+
14
+ # nb. check the short option because it may be used elsewhere.
15
+ # run --help to see the full list of options.
16
+ c.option "output", "-o", "--output FORMAT", "Output format"
17
+ c.option "count", "-c", "--count", "Count the number of items"
18
+ c.option "all", "-a", "--all", "Count all items"
19
+
20
+ c.action do |args, options|
21
+ options["serving"] = false
22
+ Jekyll::Commands::ListMe.process(args, options)
23
+ end
24
+ end
25
+ end
26
+
27
+ def normalize_output_format(output)
28
+ if output.nil?
29
+ "plain"
30
+ else
31
+ output.downcase
32
+ end
33
+ end
34
+
35
+ def init_site(opts)
36
+ Jekyll.logger.adjust_verbosity(opts)
37
+ options = configuration_from_options(opts)
38
+ options["show_drafts"] = true
39
+ site = Jekyll::Site.new(options)
40
+ site.reset
41
+ site.read
42
+ @site = site
43
+ end
44
+
45
+ def populate_results(choice)
46
+ results = Hash.new(0)
47
+ case choice
48
+ when "tags"
49
+ results["tags"] = tags
50
+ when "categories"
51
+ results["categories"] = categories
52
+ when "drafts"
53
+ results["drafts"] = posts(true)
54
+ when "posts"
55
+ results["posts"] = posts(false)
56
+ when "pages"
57
+ results["pages"] = pages
58
+ else
59
+ Jekyll.logger.error "Invalid option. You must specify a known option. Check --help."
60
+ return
61
+ end
62
+ results
63
+ end
64
+
65
+ def process(args, opts)
66
+ supported_items = %w(tags categories drafts posts pages)
67
+ choice = opts["all"] ? "all" : args[0]
68
+ if choice.nil?
69
+ Jekyll.logger.error "You must specify items to list.\nSupported items are: #{supported_items.join(", ")}"
70
+ return
71
+ end
72
+ # normalize to lowercase
73
+ choice = choice.downcase
74
+ unless supported_items.include?(choice) || opts["all"]
75
+ Jekyll.logger.error "Invalid argument. Supported items are: #{supported_items.join(", ")}"
76
+ return
77
+ end
78
+
79
+ opts["output"] = normalize_output_format(opts["output"])
80
+ supported_formats = %w(plain yaml json csv tsv psv)
81
+ unless supported_formats.include?(opts["output"])
82
+ Jekyll.logger.error "Invalid output format. Supported formats are: #{supported_formats.join(", ")}"
83
+ return
84
+ end
85
+
86
+ # Generate the website
87
+ init_site(opts)
88
+ # Populate the results based on the choice
89
+ to_print = Hash.new(0)
90
+ if choice == "all"
91
+ supported_items.each do |item|
92
+ results = populate_results(item)
93
+ to_print[item] = count_items(results[item])
94
+ end
95
+ else
96
+ results = populate_results(choice)
97
+ if opts["count"]
98
+ to_print[choice] = count_items(results[choice])
99
+ else
100
+ to_print = results[choice]
101
+ end
102
+ end
103
+
104
+ # finally print the data
105
+ print_data(to_print, opts)
106
+ end
107
+
108
+ def print_data(data, opts)
109
+ print_list_text(data) if opts["output"] == "plain"
110
+ print_list_yaml(data) if opts["output"] == "yaml"
111
+ print_list_json(data) if opts["output"] == "json"
112
+ print_list_text(data, ",") if opts["output"] == "csv"
113
+ print_list_text(data, "\t") if opts["output"] == "tsv"
114
+ print_list_text(data, "|") if opts["output"] == "psv"
115
+ end
116
+
117
+ def count_items(list)
118
+ count = 0
119
+ if list.instance_of?(Hash)
120
+ count = list.keys.length
121
+ elsif list.instance_of?(Array)
122
+ count = list.length
123
+ end
124
+ count
125
+ end
126
+
127
+ def categories
128
+ @site.categories.keys
129
+ end
130
+
131
+ def tags
132
+ tags = Hash.new(0)
133
+ # Loop through all the posts
134
+ @site.posts.docs.each do |post|
135
+ # Loop through each tag of the post
136
+ post.data["tags"].each do |tag|
137
+ # If the tag already exists in the map, increment the count
138
+ if tags.key?(tag)
139
+ tags[tag] += 1
140
+ else
141
+ # Otherwise initialize the count to 1
142
+ tags[tag] = 1
143
+ end
144
+ end
145
+ end
146
+
147
+ # Sort the tags alphabetically (case-insensitive)
148
+ tags.sort_by { |tag, _| tag.downcase }.to_h
149
+ end
150
+
151
+ def posts(is_draft)
152
+ list = []
153
+ @site.posts.docs.sort_by { |post| post.data["date"] }.each do |post|
154
+ next unless post.data["draft"] == is_draft
155
+
156
+ iso_date = post.data["date"].iso8601
157
+ post_id = generate_base58_from_string(post.data["slug"])
158
+ title = post.data["title"]
159
+ list << { "date" => iso_date, "id" => post_id, "title" => title }
160
+ end
161
+ list
162
+ end
163
+
164
+ def pages
165
+ pages = Hash.new(0)
166
+ @site.pages.each do |page|
167
+ pages[page.url] = page.data["title"]
168
+ end
169
+ pages
170
+ end
171
+
172
+ def generate_base58_from_string(str)
173
+ # Generate a base58 string from the input string
174
+ alphabet = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
175
+ base = alphabet.length
176
+ base58 = ""
177
+ num_hex = Digest::SHA1.hexdigest(str)
178
+ num = num_hex.to_i(16)
179
+ while num > 0 # rubocop:disable Style/NumericPredicate
180
+ num, remainder = num.divmod(base)
181
+ base58 = alphabet[remainder] + base58
182
+ end
183
+ base58
184
+ end
185
+
186
+ def print_list_text(list, separator = " ")
187
+ if list.instance_of?(Hash)
188
+ list.each do |key, value|
189
+ puts "#{key}#{separator}#{value}"
190
+ end
191
+ elsif list.instance_of?(Array)
192
+ list.each do |item|
193
+ if item.instance_of?(String)
194
+ puts item
195
+ elsif item.instance_of?(Hash)
196
+ puts item.values.join(separator)
197
+ elsif item.instance_of?(Array)
198
+ puts item.join(separator)
199
+ else
200
+ puts "Invalid data type"
201
+ end
202
+ end
203
+ else
204
+ puts "Invalid data type"
205
+ end
206
+ end
207
+
208
+ def print_list_json(list)
209
+ # Print the output in JSON format
210
+ puts JSON.pretty_generate(list)
211
+ end
212
+
213
+ def print_list_yaml(list)
214
+ # Print the output in YAML format
215
+ puts list.to_yaml
216
+ end
217
+ end
218
+ end
219
+ end
220
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Listme
5
+ VERSION = "0.4.1"
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "listme/version"
4
+ require_relative "commands/listme"
5
+
6
+ module Jekyll
7
+ module Listme
8
+ class Error < StandardError; end
9
+ # Your code goes here...
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ module Jekyll
2
+ module Listme
3
+ VERSION: String
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-listme
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.1
5
+ platform: ruby
6
+ authors:
7
+ - Francesco Pira
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-02-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '13.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '13.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-jekyll
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.14'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.14'
69
+ description: Jekyll command plugin to list tags and categories for your Jekyll website
70
+ and number of their occurrencies. Choose between a JSON, YAML, or plain text output.
71
+ email:
72
+ - dev@fpira.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".devcontainer/.dockerignore"
78
+ - ".devcontainer/devcontainer.json"
79
+ - ".editorconfig"
80
+ - ".github/workflows/release.yml"
81
+ - ".gitignore"
82
+ - ".rubocop.yml"
83
+ - ".ruby-version"
84
+ - CHANGELOG.md
85
+ - Gemfile
86
+ - Gemfile.lock
87
+ - LICENSE.txt
88
+ - README.md
89
+ - Rakefile
90
+ - cliff.toml
91
+ - jekyll-listme.gemspec
92
+ - lib/jekyll/commands/listme.rb
93
+ - lib/jekyll/listme.rb
94
+ - lib/jekyll/listme/version.rb
95
+ - sig/jekyll/listme.rbs
96
+ homepage: https://github.com/pirafrank/jekyll-listme
97
+ licenses:
98
+ - MIT
99
+ metadata:
100
+ allowed_push_host: https://rubygems.org
101
+ homepage_uri: https://github.com/pirafrank/jekyll-listme
102
+ changelog_uri: https://github.com/pirafrank/jekyll-listme/blob/main/CHANGELOG.md
103
+ bug_tracker_uri: https://github.com/pirafrank/jekyll-listme/issues
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 3.0.0
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubygems_version: 3.5.18
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: List tags and categories for your Jekyll website.
123
+ test_files: []